Bug 1265055 - move a bunch of tests to the urlbar directory, r=adw

MozReview-Commit-ID: 67eb9v4blas

--HG--
rename : browser/base/content/test/general/authenticate.sjs => browser/base/content/test/urlbar/authenticate.sjs
rename : browser/base/content/test/general/browser_URLBarSetURI.js => browser/base/content/test/urlbar/browser_URLBarSetURI.js
rename : browser/base/content/test/general/browser_action_keyword.js => browser/base/content/test/urlbar/browser_action_keyword.js
rename : browser/base/content/test/general/browser_action_keyword_override.js => browser/base/content/test/urlbar/browser_action_keyword_override.js
rename : browser/base/content/test/general/browser_action_searchengine.js => browser/base/content/test/urlbar/browser_action_searchengine.js
rename : browser/base/content/test/general/browser_action_searchengine_alias.js => browser/base/content/test/urlbar/browser_action_searchengine_alias.js
rename : browser/base/content/test/general/browser_autocomplete_a11y_label.js => browser/base/content/test/urlbar/browser_autocomplete_a11y_label.js
rename : browser/base/content/test/general/browser_autocomplete_autoselect.js => browser/base/content/test/urlbar/browser_autocomplete_autoselect.js
rename : browser/base/content/test/general/browser_autocomplete_cursor.js => browser/base/content/test/urlbar/browser_autocomplete_cursor.js
rename : browser/base/content/test/general/browser_autocomplete_edit_completed.js => browser/base/content/test/urlbar/browser_autocomplete_edit_completed.js
rename : browser/base/content/test/general/browser_autocomplete_enter_race.js => browser/base/content/test/urlbar/browser_autocomplete_enter_race.js
rename : browser/base/content/test/general/browser_autocomplete_no_title.js => browser/base/content/test/urlbar/browser_autocomplete_no_title.js
rename : browser/base/content/test/general/browser_autocomplete_oldschool_wrap.js => browser/base/content/test/urlbar/browser_autocomplete_oldschool_wrap.js
rename : browser/base/content/test/general/browser_autocomplete_tag_star_visibility.js => browser/base/content/test/urlbar/browser_autocomplete_tag_star_visibility.js
rename : browser/base/content/test/general/browser_bug1003461-switchtab-override.js => browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js
rename : browser/base/content/test/general/browser_bug1024133-switchtab-override-keynav.js => browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js
rename : browser/base/content/test/general/browser_bug1025195_switchToTabHavingURI_aOpenParams.js => browser/base/content/test/urlbar/browser_bug1025195_switchToTabHavingURI_aOpenParams.js
rename : browser/base/content/test/general/browser_bug1070778.js => browser/base/content/test/urlbar/browser_bug1070778.js
rename : browser/base/content/test/general/browser_bug1104165-switchtab-decodeuri.js => browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js
rename : browser/base/content/test/general/browser_bug1225194-remotetab.js => browser/base/content/test/urlbar/browser_bug1225194-remotetab.js
rename : browser/base/content/test/general/browser_bug304198.js => browser/base/content/test/urlbar/browser_bug304198.js
rename : browser/base/content/test/general/browser_bug556061.js => browser/base/content/test/urlbar/browser_bug556061.js
rename : browser/base/content/test/general/browser_bug562649.js => browser/base/content/test/urlbar/browser_bug562649.js
rename : browser/base/content/test/general/browser_bug623155.js => browser/base/content/test/urlbar/browser_bug623155.js
rename : browser/base/content/test/general/browser_bug783614.js => browser/base/content/test/urlbar/browser_bug783614.js
rename : browser/base/content/test/general/browser_canonizeURL.js => browser/base/content/test/urlbar/browser_canonizeURL.js
rename : browser/base/content/test/general/browser_locationBarCommand.js => browser/base/content/test/urlbar/browser_locationBarCommand.js
rename : browser/base/content/test/general/browser_locationBarExternalLoad.js => browser/base/content/test/urlbar/browser_locationBarExternalLoad.js
rename : browser/base/content/test/general/browser_removeUnsafeProtocolsFromURLBarPaste.js => browser/base/content/test/urlbar/browser_removeUnsafeProtocolsFromURLBarPaste.js
rename : browser/base/content/test/general/browser_search_favicon.js => browser/base/content/test/urlbar/browser_search_favicon.js
rename : browser/base/content/test/general/browser_tabMatchesInAwesomebar.js => browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js
rename : browser/base/content/test/general/browser_tabMatchesInAwesomebar_perwindowpb.js => browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar_perwindowpb.js
rename : browser/base/content/test/general/browser_urlHighlight.js => browser/base/content/test/urlbar/browser_urlHighlight.js
rename : browser/base/content/test/general/browser_urlbarAutoFillTrimURLs.js => browser/base/content/test/urlbar/browser_urlbarAutoFillTrimURLs.js
rename : browser/base/content/test/general/browser_urlbarCopying.js => browser/base/content/test/urlbar/browser_urlbarCopying.js
rename : browser/base/content/test/general/browser_urlbarDecode.js => browser/base/content/test/urlbar/browser_urlbarDecode.js
rename : browser/base/content/test/general/browser_urlbarDelete.js => browser/base/content/test/urlbar/browser_urlbarDelete.js
rename : browser/base/content/test/general/browser_urlbarEnter.js => browser/base/content/test/urlbar/browser_urlbarEnter.js
rename : browser/base/content/test/general/browser_urlbarEnterAfterMouseOver.js => browser/base/content/test/urlbar/browser_urlbarEnterAfterMouseOver.js
rename : browser/base/content/test/general/browser_urlbarRevert.js => browser/base/content/test/urlbar/browser_urlbarRevert.js
rename : browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js => browser/base/content/test/urlbar/browser_urlbarSearchSingleWordNotification.js
rename : browser/base/content/test/general/browser_urlbarSearchSuggestions.js => browser/base/content/test/urlbar/browser_urlbarSearchSuggestions.js
rename : browser/base/content/test/general/browser_urlbarSearchSuggestionsNotification.js => browser/base/content/test/urlbar/browser_urlbarSearchSuggestionsNotification.js
rename : browser/base/content/test/general/browser_urlbarSearchTelemetry.js => browser/base/content/test/urlbar/browser_urlbarSearchTelemetry.js
rename : browser/base/content/test/general/browser_urlbarStop.js => browser/base/content/test/urlbar/browser_urlbarStop.js
rename : browser/base/content/test/general/browser_urlbarTrimURLs.js => browser/base/content/test/urlbar/browser_urlbarTrimURLs.js
rename : browser/base/content/test/general/browser_urlbar_autoFill_backspaced.js => browser/base/content/test/urlbar/browser_urlbar_autoFill_backspaced.js
rename : browser/base/content/test/general/browser_urlbar_searchsettings.js => browser/base/content/test/urlbar/browser_urlbar_searchsettings.js
rename : browser/base/content/test/general/browser_wyciwyg_urlbarCopying.js => browser/base/content/test/urlbar/browser_wyciwyg_urlbarCopying.js
rename : browser/base/content/test/general/dummy_page.html => browser/base/content/test/urlbar/dummy_page.html
rename : browser/base/content/test/general/head.js => browser/base/content/test/urlbar/head.js
rename : browser/base/content/test/general/moz.png => browser/base/content/test/urlbar/moz.png
rename : browser/base/content/test/general/redirect_bug623155.sjs => browser/base/content/test/urlbar/redirect_bug623155.sjs
rename : browser/base/content/test/general/searchSuggestionEngine.sjs => browser/base/content/test/urlbar/searchSuggestionEngine.sjs
rename : browser/base/content/test/general/searchSuggestionEngine.xml => browser/base/content/test/urlbar/searchSuggestionEngine.xml
rename : browser/base/content/test/general/test_wyciwyg_copying.html => browser/base/content/test/urlbar/test_wyciwyg_copying.html
rename : browser/base/content/test/general/authenticate.sjs => toolkit/components/thumbnails/test/authenticate.sjs
extra : rebase_source : 3c83a311373930cb962816cf61d84a8ee7c44c07
extra : amend_source : 9ed9e18817c591afb9b4d10fda724bb71dd80b26
This commit is contained in:
Gijs Kruitbosch 2016-04-15 21:11:15 +01:00
parent 38b061900f
commit 03c4d690a3
62 changed files with 733 additions and 139 deletions

View File

@ -6,7 +6,6 @@ support-files =
alltabslistener.html
app_bug575561.html
app_subframe_bug575561.html
authenticate.sjs
aboutHome_content_script.js
audio.ogg
browser_bug479408_sample.html
@ -86,7 +85,6 @@ support-files =
ssl_error_reports.sjs
popup_blocker.html
print_postdata.sjs
redirect_bug623155.sjs
searchSuggestionEngine.sjs
searchSuggestionEngine.xml
searchSuggestionEngine2.xml
@ -99,7 +97,6 @@ support-files =
test_bug839103.html
test_bug959531.html
test_process_flags_chrome.html
test_wyciwyg_copying.html
title_test.svg
unknownContentType_file.pif
unknownContentType_file.pif^headers^
@ -137,8 +134,6 @@ support-files =
!/toolkit/mozapps/extensions/test/xpinstall/restartless.xpi
!/toolkit/mozapps/extensions/test/xpinstall/theme.xpi
[browser_URLBarSetURI.js]
skip-if = (os == "linux" || os == "mac") && debug # bug 970052, bug 970053
[browser_aboutAccounts.js]
skip-if = os == "linux" # Bug 958026
support-files =
@ -149,22 +144,9 @@ support-files =
skip-if = os == "linux" # Bug 924307
[browser_aboutHome.js]
[browser_aboutHome_wrapsCorrectly.js]
[browser_action_keyword.js]
[browser_action_keyword_override.js]
[browser_action_searchengine.js]
[browser_action_searchengine_alias.js]
[browser_addKeywordSearch.js]
[browser_search_favicon.js]
[browser_alltabslistener.js]
[browser_audioTabIcon.js]
[browser_autocomplete_a11y_label.js]
[browser_autocomplete_cursor.js]
[browser_autocomplete_edit_completed.js]
[browser_autocomplete_enter_race.js]
[browser_autocomplete_no_title.js]
[browser_autocomplete_autoselect.js]
[browser_autocomplete_oldschool_wrap.js]
[browser_autocomplete_tag_star_visibility.js]
[browser_backButtonFitts.js]
skip-if = os == "mac" # The Fitt's Law back button is not supported on OS X
[browser_beforeunload_duplicate_dialogs.js]
@ -173,7 +155,6 @@ skip-if = os == "mac" # The Fitt's Law back button is not supported on OS X
skip-if = (os == "linux" && debug) # mouseover not reliable on linux debug builds
[browser_bookmark_titles.js]
skip-if = buildapp == 'mulet' || toolkit == "windows" # Disabled on Windows due to frequent failures (bugs 825739, 841341)
[browser_bug304198.js]
[browser_bug321000.js]
skip-if = true # browser_bug321000.js is disabled because newline handling is shaky (bug 592528)
[browser_bug356571.js]
@ -226,10 +207,8 @@ skip-if = buildapp == 'mulet' || e10s # Bug 1134458 - Find bar doesn't work corr
skip-if = buildapp == 'mulet' # Bug 1066070 - I don't think either popup notifications nor addon install stuff works on mulet?
[browser_bug555224.js]
[browser_bug555767.js]
[browser_bug556061.js]
[browser_bug559991.js]
[browser_bug561636.js]
[browser_bug562649.js]
[browser_bug563588.js]
[browser_bug565575.js]
[browser_bug565667.js]
@ -254,7 +233,6 @@ skip-if = toolkit != "cocoa"
[browser_bug596687.js]
[browser_bug597218.js]
[browser_bug609700.js]
[browser_bug623155.js]
[browser_bug623893.js]
[browser_bug624734.js]
[browser_bug633691.js]
@ -274,7 +252,6 @@ skip-if = os == "mac" # Bug 1102331 - does focus things on the content window wh
[browser_bug749738.js]
[browser_bug763468_perwindowpb.js]
[browser_bug767836_perwindowpb.js]
[browser_bug783614.js]
[browser_bug817947.js]
[browser_bug822367.js]
tags = mcb
@ -295,9 +272,7 @@ tags = mcb
[browser_bug1015721.js]
skip-if = os == 'win'
[browser_bug1064280_changeUrlInPinnedTab.js]
[browser_bug1070778.js]
[browser_accesskeys.js]
[browser_canonizeURL.js]
[browser_clipboard.js]
[browser_contentAreaClick.js]
[browser_contextmenu.js]
@ -346,9 +321,6 @@ skip-if = buildapp == 'mulet'
[browser_keywordSearch_postData.js]
[browser_lastAccessedTab.js]
skip-if = toolkit == "windows" # Disabled on Windows due to frequent failures (bug 969405)
[browser_locationBarCommand.js]
skip-if = os == "linux" # Linux: Intermittent failures, bug 917535
[browser_locationBarExternalLoad.js]
[browser_menuButtonFitts.js]
skip-if = os != "win" # The Fitts Law menu button is only supported on Windows (bug 969376)
[browser_middleMouse_noJSPaste.js]
@ -400,7 +372,6 @@ support-files =
test_remoteTroubleshoot.html
[browser_remoteWebNavigation_postdata.js]
[browser_removeTabsToTheEnd.js]
[browser_removeUnsafeProtocolsFromURLBarPaste.js]
[browser_restore_isAppTab.js]
[browser_sanitize-passwordDisabledHosts.js]
[browser_sanitize-sitepermissions.js]
@ -434,9 +405,6 @@ run-if = e10s
skip-if = buildapp == 'mulet'
[browser_tabReorder.js]
skip-if = buildapp == 'mulet'
[browser_tabMatchesInAwesomebar.js]
[browser_tabMatchesInAwesomebar_perwindowpb.js]
skip-if = os == 'linux' # Bug 1104755
[browser_tab_detach_restore.js]
[browser_tab_drag_drop_perwindow.js]
skip-if = buildapp == 'mulet'
@ -494,23 +462,6 @@ support-files =
skip-if = buildapp == 'mulet'
[browser_unknownContentType_title.js]
[browser_unloaddialogs.js]
[browser_urlHighlight.js]
[browser_urlbarAutoFillTrimURLs.js]
[browser_urlbarCopying.js]
[browser_urlbarDecode.js]
[browser_urlbarDelete.js]
[browser_urlbarEnter.js]
[browser_urlbarEnterAfterMouseOver.js]
skip-if = os == "linux" # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_urlbarRevert.js]
[browser_urlbarSearchSingleWordNotification.js]
[browser_urlbarSearchSuggestions.js]
[browser_urlbarSearchSuggestionsNotification.js]
[browser_urlbarSearchTelemetry.js]
[browser_urlbarStop.js]
[browser_urlbarTrimURLs.js]
[browser_urlbar_autoFill_backspaced.js]
[browser_urlbar_searchsettings.js]
[browser_utilityOverlay.js]
[browser_viewSourceInTabOnViewSource.js]
[browser_visibleFindSelection.js]
@ -524,20 +475,14 @@ skip-if = (os == "win" && !debug)
[browser_web_channel.js]
[browser_windowopen_reflows.js]
skip-if = buildapp == 'mulet'
[browser_wyciwyg_urlbarCopying.js]
[browser_zbug569342.js]
skip-if = e10s # Bug 1094240 - has findbar-related failures
[browser_registerProtocolHandler_notification.js]
[browser_no_mcb_on_http_site.js]
tags = mcb
[browser_bug1104165-switchtab-decodeuri.js]
[browser_bug1003461-switchtab-override.js]
[browser_bug1024133-switchtab-override-keynav.js]
[browser_bug1025195_switchToTabHavingURI_aOpenParams.js]
[browser_addCertException.js]
[browser_bug1045809.js]
tags = mcb
[browser_bug1225194-remotetab.js]
[browser_e10s_switchbrowser.js]
[browser_e10s_about_process.js]
[browser_e10s_chrome_process.js]

View File

@ -936,15 +936,6 @@ function assertMixedContentBlockingState(tabbrowser, states = {}) {
return new Promise(resolve => executeSoon(resolve));
}
function makeActionURI(action, params) {
let encodedParams = {};
for (let key in params) {
encodedParams[key] = encodeURIComponent(params[key]);
}
let url = "moz-action:" + action + "," + JSON.stringify(encodedParams);
return NetUtil.newURI(url);
}
function is_hidden(element) {
var style = element.ownerDocument.defaultView.getComputedStyle(element, "");
if (style.display == "none")
@ -1021,28 +1012,6 @@ function promiseNotificationShown(notification) {
return panelPromise;
}
function promiseSearchComplete(win = window) {
return promisePopupShown(win.gURLBar.popup).then(() => {
function searchIsComplete() {
return win.gURLBar.controller.searchStatus >=
Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
}
// Wait until there are at least two matches.
return new Promise(resolve => waitForCondition(searchIsComplete, resolve));
});
}
function promiseAutocompleteResultPopup(inputText, win = window) {
waitForFocus(() => {
win.gURLBar.focus();
win.gURLBar.value = inputText;
win.gURLBar.controller.startSearch(inputText);
}, win);
return promiseSearchComplete(win);
}
/**
* Allows waiting for an observer notification once.
*

View File

@ -1,13 +1,86 @@
[DEFAULT]
support-files =
dummy_page.html
head.js
[browser_URLBarSetURI.js]
skip-if = (os == "linux" || os == "mac") && debug # bug 970052, bug 970053
[browser_action_keyword.js]
[browser_action_keyword_override.js]
[browser_action_searchengine.js]
[browser_action_searchengine_alias.js]
[browser_autocomplete_a11y_label.js]
[browser_autocomplete_autoselect.js]
[browser_autocomplete_cursor.js]
[browser_autocomplete_edit_completed.js]
[browser_autocomplete_enter_race.js]
[browser_autocomplete_no_title.js]
[browser_autocomplete_oldschool_wrap.js]
[browser_autocomplete_tag_star_visibility.js]
[browser_bug1104165-switchtab-decodeuri.js]
[browser_bug1003461-switchtab-override.js]
[browser_bug1024133-switchtab-override-keynav.js]
[browser_bug1025195_switchToTabHavingURI_aOpenParams.js]
[browser_bug1070778.js]
[browser_bug1225194-remotetab.js]
[browser_bug304198.js]
[browser_bug556061.js]
[browser_bug562649.js]
[browser_bug623155.js]
support-files =
redirect_bug623155.sjs
[browser_bug783614.js]
[browser_canonizeURL.js]
[browser_locationBarCommand.js]
skip-if = os == "linux" # Linux: Intermittent failures, bug 917535
[browser_locationBarExternalLoad.js]
[browser_moz_action_link.js]
[browser_removeUnsafeProtocolsFromURLBarPaste.js]
[browser_search_favicon.js]
[browser_tabMatchesInAwesomebar.js]
support-files =
moz.png
[browser_tabMatchesInAwesomebar_perwindowpb.js]
skip-if = os == 'linux' # Bug 1104755
[browser_urlbarAutoFillTrimURLs.js]
[browser_urlbarCopying.js]
support-files =
authenticate.sjs
[browser_urlbarDecode.js]
[browser_urlbarDelete.js]
[browser_urlbarEnter.js]
[browser_urlbarEnterAfterMouseOver.js]
skip-if = os == "linux" # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_urlbarRevert.js]
[browser_urlbarSearchSingleWordNotification.js]
[browser_urlbarSearchSuggestions.js]
support-files =
searchSuggestionEngine.xml
searchSuggestionEngine.sjs
[browser_urlbarSearchSuggestionsNotification.js]
support-files =
searchSuggestionEngine.xml
searchSuggestionEngine.sjs
[browser_urlbarSearchTelemetry.js]
support-files =
searchSuggestionEngine.xml
searchSuggestionEngine.sjs
[browser_urlbarStop.js]
[browser_urlbarTrimURLs.js]
[browser_urlbar_autoFill_backspaced.js]
[browser_urlbar_blanking.js]
support-files =
file_blank_but_not_blank.html
[browser_urlbar_locationchange_urlbar_edit_dos.js]
support-files =
file_urlbar_edit_dos.html
[browser_urlbar_searchsettings.js]
[browser_urlbar_stop_pending.js]
support-files =
slow-page.sjs
[browser_urlbar_remoteness_switch.js]
run-if = e10s
[browser_urlHighlight.js]
[browser_wyciwyg_urlbarCopying.js]
support-files =
test_wyciwyg_copying.html

View File

@ -37,19 +37,17 @@ var tests = [
});
},
function customize(next) {
whenNewWindowLoaded(undefined, function (win) {
// Need to wait for delayedStartup for the customization part of the test,
// since that's where BrowserToolboxCustomizeDone is set.
whenDelayedStartupFinished(win, function () {
loadTabInWindow(win, function () {
openToolbarCustomizationUI(function () {
closeToolbarCustomizationUI(function () {
is(win.gURLBar.textValue, "example.com", "URL bar had user/pass stripped after customize");
win.close();
next();
}, win);
// Need to wait for delayedStartup for the customization part of the test,
// since that's where BrowserToolboxCustomizeDone is set.
BrowserTestUtils.openNewBrowserWindow().then(function(win) {
loadTabInWindow(win, function () {
openToolbarCustomizationUI(function () {
closeToolbarCustomizationUI(function () {
is(win.gURLBar.textValue, "example.com", "URL bar had user/pass stripped after customize");
win.close();
next();
}, win);
});
}, win);
});
});
},
@ -76,3 +74,27 @@ function loadTabInWindow(win, callback) {
callback(tab);
}, true);
}
function openToolbarCustomizationUI(aCallback, aBrowserWin) {
if (!aBrowserWin)
aBrowserWin = window;
aBrowserWin.gCustomizeMode.enter();
aBrowserWin.gNavToolbox.addEventListener("customizationready", function UI_loaded() {
aBrowserWin.gNavToolbox.removeEventListener("customizationready", UI_loaded);
executeSoon(function() {
aCallback(aBrowserWin)
});
});
}
function closeToolbarCustomizationUI(aCallback, aBrowserWin) {
aBrowserWin.gNavToolbox.addEventListener("aftercustomization", function unloaded() {
aBrowserWin.gNavToolbox.removeEventListener("aftercustomization", unloaded);
executeSoon(aCallback);
});
aBrowserWin.gCustomizeMode.exit();
}

View File

@ -78,7 +78,7 @@ add_task(function*() {
uri = NetUtil.newURI(result.getAttribute("url"));
is(uri.spec, makeActionURI("keyword", {url: "http://example.com/?q=somethingmore", input: "keyword somethingmore"}).spec, "Expect correct url");
tabPromise = promiseWaitForEvent(gBrowser.tabContainer, "TabOpen");
tabPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen");
EventUtils.synthesizeMouseAtCenter(result, {button: 1});
let tabOpenEvent = yield tabPromise;
let newTab = tabOpenEvent.target;

View File

@ -10,7 +10,7 @@ add_task(function* test_switchtab_override() {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
let testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
info("Opening first tab");
let tab = gBrowser.addTab(testURL);

View File

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
add_task(function* test_switchtab_override_keynav() {
let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
let testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
info("Opening first tab");
let tab = gBrowser.addTab(testURL);

View File

@ -1,6 +1,6 @@
add_task(function* test_switchtab_decodeuri() {
info("Opening first tab");
let tab = gBrowser.addTab("http://example.org/browser/browser/base/content/test/general/dummy_page.html#test%7C1");
let tab = gBrowser.addTab("http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html#test%7C1");
yield promiseTabLoadEvent(tab);
info("Opening and selecting second tab");

View File

@ -1,5 +1,5 @@
add_task(function* test_remotetab_opens() {
const url = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
const url = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
yield BrowserTestUtils.withNewTab({url: "about:robots", gBrowser}, function* () {
// Set the urlbar to include the moz-action
gURLBar.value = "moz-action:remotetab," + JSON.stringify({ url });

View File

@ -9,7 +9,7 @@ add_task(function* () {
deletedURLTab = gBrowser.addTab();
fullURLTab = gBrowser.addTab();
partialURLTab = gBrowser.addTab();
testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
let loaded1 = BrowserTestUtils.browserLoaded(deletedURLTab.linkedBrowser, testURL);
let loaded2 = BrowserTestUtils.browserLoaded(fullURLTab.linkedBrowser, testURL);

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
var testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
var testActionURL = "moz-action:switchtab," + JSON.stringify({url: testURL});
testURL = gURLBar.trimValue(testURL);
var testTab;

View File

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const REDIRECT_FROM = "https://example.com/browser/browser/base/content/test/general/" +
const REDIRECT_FROM = "https://example.com/browser/browser/base/content/test/urlbar/" +
"redirect_bug623155.sjs";
const REDIRECT_TO = "https://www.bank1.com/"; // Bad-cert host.
@ -20,7 +20,7 @@ function isRedirectedURI(aURI) {
Test.
1. Load
https://example.com/browser/browser/base/content/test/general/redirect_bug623155.sjs#BG
https://example.com/browser/browser/base/content/test/urlbar/redirect_bug623155.sjs#BG
in a background tab.
2. The redirected URI is <https://www.bank1.com/#BG>, which displayes a cert
@ -31,7 +31,7 @@ https://example.com/browser/browser/base/content/test/general/redirect_bug623155
4. Check the URLbar's value, expecting <https://www.bank1.com/#BG>
5. Load
https://example.com/browser/browser/base/content/test/general/redirect_bug623155.sjs#FG
https://example.com/browser/browser/base/content/test/urlbar/redirect_bug623155.sjs#FG
in the foreground tab.
6. The redirected URI is <https://www.bank1.com/#FG>. And this is also

View File

@ -35,7 +35,7 @@ add_task(function* alt_left_click_test() {
add_task(function* shift_left_click_test() {
info("Running test: Shift left click");
let newWindowPromise = promiseWaitForNewWindow();
let newWindowPromise = BrowserTestUtils.waitForNewWindow();
triggerCommand(true, {shiftKey: true});
let win = yield newWindowPromise;
@ -199,25 +199,6 @@ function promiseNewTabSwitched() {
});
}
function promiseWaitForNewWindow() {
return new Promise(resolve => {
let listener = {
onOpenWindow(xulWindow) {
let win = xulWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
Services.wm.removeListener(listener);
whenDelayedStartupFinished(win, () => resolve(win));
},
onCloseWindow() {},
onWindowTitleChange() {}
};
Services.wm.addListener(listener);
});
}
function promiseCheckChildNoFocusedElement(browser)
{
if (!gMultiProcessBrowser) {

View File

@ -7,8 +7,8 @@
requestLongerTimeout(2);
const TEST_URL_BASES = [
"http://example.org/browser/browser/base/content/test/general/dummy_page.html#tabmatch",
"http://example.org/browser/browser/base/content/test/general/moz.png#tabmatch"
"http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html#tabmatch",
"http://example.org/browser/browser/base/content/test/urlbar/moz.png#tabmatch"
];
var gController = Cc["@mozilla.org/autocomplete/controller;1"].

View File

@ -1,4 +1,4 @@
let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
let testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
add_task(function*() {
let normalWindow = yield BrowserTestUtils.openNewBrowserWindow();
@ -27,7 +27,7 @@ function* runTest(aSourceWindow, aDestWindow, aExpectSwitch, aCallback) {
let testTab = yield BrowserTestUtils.openNewForegroundTab(aDestWindow.gBrowser);
info("waiting for focus on the window");
yield promiseWaitForFocus(aDestWindow);
yield SimpleTest.promiseFocus(aDestWindow);
info("got focus on the window");
// Select the testTab

View File

@ -70,9 +70,9 @@ var tests = [
// Test that userPass is stripped out
{
loadURL: "http://user:pass@mochi.test:8888/browser/browser/base/content/test/general/authenticate.sjs?user=user&pass=pass",
expectedURL: "mochi.test:8888/browser/browser/base/content/test/general/authenticate.sjs?user=user&pass=pass",
copyExpected: "http://mochi.test:8888/browser/browser/base/content/test/general/authenticate.sjs?user=user&pass=pass"
loadURL: "http://user:pass@mochi.test:8888/browser/browser/base/content/test/urlbar/authenticate.sjs?user=user&pass=pass",
expectedURL: "mochi.test:8888/browser/browser/base/content/test/urlbar/authenticate.sjs?user=user&pass=pass",
copyExpected: "http://mochi.test:8888/browser/browser/base/content/test/urlbar/authenticate.sjs?user=user&pass=pass"
},
// Test escaping

View File

@ -17,7 +17,7 @@ function testURLBarCopy(targetValue) {
}
add_task(function* () {
const url = "http://mochi.test:8888/browser/browser/base/content/test/general/test_wyciwyg_copying.html";
const url = "http://mochi.test:8888/browser/browser/base/content/test/urlbar/test_wyciwyg_copying.html";
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, url);
yield BrowserTestUtils.synthesizeMouseAtCenter("#btn", {}, tab.linkedBrowser);

View File

@ -0,0 +1,9 @@
<html>
<head>
<title>Dummy test page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"></meta>
</head>
<body>
<p>Dummy test page</p>
</body>
</html>

View File

@ -0,0 +1,357 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
"resource://testing-common/PlacesTestUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TabCrashHandler",
"resource:///modules/ContentCrashHandlers.jsm");
function waitForCondition(condition, nextTest, errorMsg, retryTimes) {
retryTimes = typeof retryTimes !== 'undefined' ? retryTimes : 30;
var tries = 0;
var interval = setInterval(function() {
if (tries >= retryTimes) {
ok(false, errorMsg);
moveOn();
}
var conditionPassed;
try {
conditionPassed = condition();
} catch (e) {
ok(false, e + "\n" + e.stack);
conditionPassed = false;
}
if (conditionPassed) {
moveOn();
}
tries++;
}, 100);
var moveOn = function() { clearInterval(interval); nextTest(); };
}
function promiseWaitForCondition(aConditionFn) {
let deferred = Promise.defer();
waitForCondition(aConditionFn, deferred.resolve, "Condition didn't pass.");
return deferred.promise;
}
function promiseWaitForEvent(object, eventName, capturing = false, chrome = false) {
return new Promise((resolve) => {
function listener(event) {
info("Saw " + eventName);
object.removeEventListener(eventName, listener, capturing, chrome);
resolve(event);
}
info("Waiting for " + eventName);
object.addEventListener(eventName, listener, capturing, chrome);
});
}
function promiseWindowWillBeClosed(win) {
return new Promise((resolve, reject) => {
Services.obs.addObserver(function observe(subject, topic) {
if (subject == win) {
Services.obs.removeObserver(observe, topic);
resolve();
}
}, "domwindowclosed", false);
});
}
function promiseWindowClosed(win) {
let promise = promiseWindowWillBeClosed(win);
win.close();
return promise;
}
function promiseOpenAndLoadWindow(aOptions, aWaitForDelayedStartup=false) {
let deferred = Promise.defer();
let win = OpenBrowserWindow(aOptions);
if (aWaitForDelayedStartup) {
Services.obs.addObserver(function onDS(aSubject, aTopic, aData) {
if (aSubject != win) {
return;
}
Services.obs.removeObserver(onDS, "browser-delayed-startup-finished");
deferred.resolve(win);
}, "browser-delayed-startup-finished", false);
} else {
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad);
deferred.resolve(win);
});
}
return deferred.promise;
}
function whenNewTabLoaded(aWindow, aCallback) {
aWindow.BrowserOpenTab();
let browser = aWindow.gBrowser.selectedBrowser;
if (browser.contentDocument.readyState === "complete") {
aCallback();
return;
}
whenTabLoaded(aWindow.gBrowser.selectedTab, aCallback);
}
function whenTabLoaded(aTab, aCallback) {
promiseTabLoadEvent(aTab).then(aCallback);
}
function promiseTabLoaded(aTab) {
let deferred = Promise.defer();
whenTabLoaded(aTab, deferred.resolve);
return deferred.promise;
}
/**
* Waits for the next top-level document load in the current browser. The URI
* of the document is compared against aExpectedURL. The load is then stopped
* before it actually starts.
*
* @param aExpectedURL
* The URL of the document that is expected to load.
* @param aStopFromProgressListener
* Whether to cancel the load directly from the progress listener. Defaults to true.
* If you're using this method to avoid hitting the network, you want the default (true).
* However, the browser UI will behave differently for loads stopped directly from
* the progress listener (effectively in the middle of a call to loadURI) and so there
* are cases where you may want to avoid stopping the load directly from within the
* progress listener callback.
* @return promise
*/
function waitForDocLoadAndStopIt(aExpectedURL, aBrowser=gBrowser.selectedBrowser, aStopFromProgressListener=true) {
function content_script(aStopFromProgressListener) {
let { interfaces: Ci, utils: Cu } = Components;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
let wp = docShell.QueryInterface(Ci.nsIWebProgress);
function stopContent(now, uri) {
if (now) {
/* Hammer time. */
content.stop();
/* Let the parent know we're done. */
sendAsyncMessage("Test:WaitForDocLoadAndStopIt", { uri });
} else {
setTimeout(stopContent.bind(null, true, uri), 0);
}
}
let progressListener = {
onStateChange: function (webProgress, req, flags, status) {
dump("waitForDocLoadAndStopIt: onStateChange " + flags.toString(16) + ": " + req.name + "\n");
if (webProgress.isTopLevel &&
flags & Ci.nsIWebProgressListener.STATE_START) {
wp.removeProgressListener(progressListener);
let chan = req.QueryInterface(Ci.nsIChannel);
dump(`waitForDocLoadAndStopIt: Document start: ${chan.URI.spec}\n`);
stopContent(aStopFromProgressListener, chan.originalURI.spec);
}
},
QueryInterface: XPCOMUtils.generateQI(["nsISupportsWeakReference"])
};
wp.addProgressListener(progressListener, wp.NOTIFY_STATE_WINDOW);
/**
* As |this| is undefined and we can't extend |docShell|, adding an unload
* event handler is the easiest way to ensure the weakly referenced
* progress listener is kept alive as long as necessary.
*/
addEventListener("unload", function () {
try {
wp.removeProgressListener(progressListener);
} catch (e) { /* Will most likely fail. */ }
});
}
return new Promise((resolve, reject) => {
function complete({ data }) {
is(data.uri, aExpectedURL, "waitForDocLoadAndStopIt: The expected URL was loaded");
mm.removeMessageListener("Test:WaitForDocLoadAndStopIt", complete);
resolve();
}
let mm = aBrowser.messageManager;
mm.loadFrameScript("data:,(" + content_script.toString() + ")(" + aStopFromProgressListener + ");", true);
mm.addMessageListener("Test:WaitForDocLoadAndStopIt", complete);
info("waitForDocLoadAndStopIt: Waiting for URL: " + aExpectedURL);
});
}
/**
* Waits for a load (or custom) event to finish in a given tab. If provided
* load an uri into the tab.
*
* @param tab
* The tab to load into.
* @param [optional] url
* The url to load, or the current url.
* @return {Promise} resolved when the event is handled.
* @resolves to the received event
* @rejects if a valid load event is not received within a meaningful interval
*/
function promiseTabLoadEvent(tab, url)
{
let deferred = Promise.defer();
info("Wait tab event: load");
function handle(loadedUrl) {
if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) {
info(`Skipping spurious load event for ${loadedUrl}`);
return false;
}
info("Tab event received: load");
return true;
}
// Create two promises: one resolved from the content process when the page
// loads and one that is rejected if we take too long to load the url.
let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
let timeout = setTimeout(() => {
deferred.reject(new Error("Timed out while waiting for a 'load' event"));
}, 30000);
loaded.then(() => {
clearTimeout(timeout);
deferred.resolve()
});
if (url)
BrowserTestUtils.loadURI(tab.linkedBrowser, url);
// Promise.all rejects if either promise rejects (i.e. if we time out) and
// if our loaded promise resolves before the timeout, then we resolve the
// timeout promise as well, causing the all promise to resolve.
return Promise.all([deferred.promise, loaded]);
}
function makeActionURI(action, params) {
let encodedParams = {};
for (let key in params) {
encodedParams[key] = encodeURIComponent(params[key]);
}
let url = "moz-action:" + action + "," + JSON.stringify(encodedParams);
return NetUtil.newURI(url);
}
function is_hidden(element) {
var style = element.ownerDocument.defaultView.getComputedStyle(element, "");
if (style.display == "none")
return true;
if (style.visibility != "visible")
return true;
if (style.display == "-moz-popup")
return ["hiding","closed"].indexOf(element.state) != -1;
// Hiding a parent element will hide all its children
if (element.parentNode != element.ownerDocument)
return is_hidden(element.parentNode);
return false;
}
function is_visible(element) {
var style = element.ownerDocument.defaultView.getComputedStyle(element, "");
if (style.display == "none")
return false;
if (style.visibility != "visible")
return false;
if (style.display == "-moz-popup" && element.state != "open")
return false;
// Hiding a parent element will hide all its children
if (element.parentNode != element.ownerDocument)
return is_visible(element.parentNode);
return true;
}
function is_element_visible(element, msg) {
isnot(element, null, "Element should not be null, when checking visibility");
ok(is_visible(element), msg || "Element should be visible");
}
function is_element_hidden(element, msg) {
isnot(element, null, "Element should not be null, when checking visibility");
ok(is_hidden(element), msg || "Element should be hidden");
}
function promisePopupEvent(popup, eventSuffix) {
let endState = {shown: "open", hidden: "closed"}[eventSuffix];
if (popup.state == endState)
return Promise.resolve();
let eventType = "popup" + eventSuffix;
let deferred = Promise.defer();
popup.addEventListener(eventType, function onPopupShown(event) {
popup.removeEventListener(eventType, onPopupShown);
deferred.resolve();
});
return deferred.promise;
}
function promisePopupShown(popup) {
return promisePopupEvent(popup, "shown");
}
function promisePopupHidden(popup) {
return promisePopupEvent(popup, "hidden");
}
function promiseSearchComplete(win = window) {
return promisePopupShown(win.gURLBar.popup).then(() => {
function searchIsComplete() {
return win.gURLBar.controller.searchStatus >=
Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
}
// Wait until there are at least two matches.
return new Promise(resolve => waitForCondition(searchIsComplete, resolve));
});
}
function promiseAutocompleteResultPopup(inputText, win = window) {
waitForFocus(() => {
win.gURLBar.focus();
win.gURLBar.value = inputText;
win.gURLBar.controller.startSearch(inputText);
}, win);
return promiseSearchComplete(win);
}
function promiseNewSearchEngine(basename) {
return new Promise((resolve, reject) => {
info("Waiting for engine to be added: " + basename);
let url = getRootDirectory(gTestPath) + basename;
Services.search.addEngine(url, null, "", false, {
onSuccess: function (engine) {
info("Search engine added: " + basename);
registerCleanupFunction(() => Services.search.removeEngine(engine));
resolve(engine);
},
onError: function (errCode) {
Assert.ok(false, "addEngine failed with error code " + errCode);
reject();
},
});
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

View File

@ -0,0 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function handleRequest(req, resp) {
let suffixes = ["foo", "bar"];
let data = [req.queryString, suffixes.map(s => req.queryString + s)];
resp.setHeader("Content-Type", "application/json", false);
resp.write(JSON.stringify(data));
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>browser_searchSuggestionEngine searchSuggestionEngine.xml</ShortName>
<Url type="application/x-suggestions+json" method="GET" template="http://mochi.test:8888/browser/browser/base/content/test/urlbar/searchSuggestionEngine.sjs?{searchTerms}"/>
<Url type="text/html" method="GET" template="http://mochi.test:8888/" rel="searchform"/>
</SearchPlugin>

View File

@ -0,0 +1,220 @@
function handleRequest(request, response)
{
try {
reallyHandleRequest(request, response);
} catch (e) {
response.setStatusLine("1.0", 200, "AlmostOK");
response.write("Error handling request: " + e);
}
}
function reallyHandleRequest(request, response) {
var match;
var requestAuth = true, requestProxyAuth = true;
// Allow the caller to drive how authentication is processed via the query.
// Eg, http://localhost:8888/authenticate.sjs?user=foo&realm=bar
// The extra ? allows the user/pass/realm checks to succeed if the name is
// at the beginning of the query string.
var query = "?" + request.queryString;
var expected_user = "", expected_pass = "", realm = "mochitest";
var proxy_expected_user = "", proxy_expected_pass = "", proxy_realm = "mochi-proxy";
var huge = false, plugin = false, anonymous = false;
var authHeaderCount = 1;
// user=xxx
match = /[^_]user=([^&]*)/.exec(query);
if (match)
expected_user = match[1];
// pass=xxx
match = /[^_]pass=([^&]*)/.exec(query);
if (match)
expected_pass = match[1];
// realm=xxx
match = /[^_]realm=([^&]*)/.exec(query);
if (match)
realm = match[1];
// proxy_user=xxx
match = /proxy_user=([^&]*)/.exec(query);
if (match)
proxy_expected_user = match[1];
// proxy_pass=xxx
match = /proxy_pass=([^&]*)/.exec(query);
if (match)
proxy_expected_pass = match[1];
// proxy_realm=xxx
match = /proxy_realm=([^&]*)/.exec(query);
if (match)
proxy_realm = match[1];
// huge=1
match = /huge=1/.exec(query);
if (match)
huge = true;
// plugin=1
match = /plugin=1/.exec(query);
if (match)
plugin = true;
// multiple=1
match = /multiple=([^&]*)/.exec(query);
if (match)
authHeaderCount = match[1]+0;
// anonymous=1
match = /anonymous=1/.exec(query);
if (match)
anonymous = true;
// Look for an authentication header, if any, in the request.
//
// EG: Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
//
// This test only supports Basic auth. The value sent by the client is
// "username:password", obscured with base64 encoding.
var actual_user = "", actual_pass = "", authHeader, authPresent = false;
if (request.hasHeader("Authorization")) {
authPresent = true;
authHeader = request.getHeader("Authorization");
match = /Basic (.+)/.exec(authHeader);
if (match.length != 2)
throw "Couldn't parse auth header: " + authHeader;
var userpass = base64ToString(match[1]); // no atob() :-(
match = /(.*):(.*)/.exec(userpass);
if (match.length != 3)
throw "Couldn't decode auth header: " + userpass;
actual_user = match[1];
actual_pass = match[2];
}
var proxy_actual_user = "", proxy_actual_pass = "";
if (request.hasHeader("Proxy-Authorization")) {
authHeader = request.getHeader("Proxy-Authorization");
match = /Basic (.+)/.exec(authHeader);
if (match.length != 2)
throw "Couldn't parse auth header: " + authHeader;
var userpass = base64ToString(match[1]); // no atob() :-(
match = /(.*):(.*)/.exec(userpass);
if (match.length != 3)
throw "Couldn't decode auth header: " + userpass;
proxy_actual_user = match[1];
proxy_actual_pass = match[2];
}
// Don't request authentication if the credentials we got were what we
// expected.
if (expected_user == actual_user &&
expected_pass == actual_pass) {
requestAuth = false;
}
if (proxy_expected_user == proxy_actual_user &&
proxy_expected_pass == proxy_actual_pass) {
requestProxyAuth = false;
}
if (anonymous) {
if (authPresent) {
response.setStatusLine("1.0", 400, "Unexpected authorization header found");
} else {
response.setStatusLine("1.0", 200, "Authorization header not found");
}
} else {
if (requestProxyAuth) {
response.setStatusLine("1.0", 407, "Proxy authentication required");
for (i = 0; i < authHeaderCount; ++i)
response.setHeader("Proxy-Authenticate", "basic realm=\"" + proxy_realm + "\"", true);
} else if (requestAuth) {
response.setStatusLine("1.0", 401, "Authentication required");
for (i = 0; i < authHeaderCount; ++i)
response.setHeader("WWW-Authenticate", "basic realm=\"" + realm + "\"", true);
} else {
response.setStatusLine("1.0", 200, "OK");
}
}
response.setHeader("Content-Type", "application/xhtml+xml", false);
response.write("<html xmlns='http://www.w3.org/1999/xhtml'>");
response.write("<p>Login: <span id='ok'>" + (requestAuth ? "FAIL" : "PASS") + "</span></p>\n");
response.write("<p>Proxy: <span id='proxy'>" + (requestProxyAuth ? "FAIL" : "PASS") + "</span></p>\n");
response.write("<p>Auth: <span id='auth'>" + authHeader + "</span></p>\n");
response.write("<p>User: <span id='user'>" + actual_user + "</span></p>\n");
response.write("<p>Pass: <span id='pass'>" + actual_pass + "</span></p>\n");
if (huge) {
response.write("<div style='display: none'>");
for (i = 0; i < 100000; i++) {
response.write("123456789\n");
}
response.write("</div>");
response.write("<span id='footnote'>This is a footnote after the huge content fill</span>");
}
if (plugin) {
response.write("<embed id='embedtest' style='width: 400px; height: 100px;' " +
"type='application/x-test'></embed>\n");
}
response.write("</html>");
}
// base64 decoder
//
// Yoinked from extensions/xml-rpc/src/nsXmlRpcClient.js because btoa()
// doesn't seem to exist. :-(
/* Convert Base64 data to a string */
const toBinaryTable = [
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1, 0,-1,-1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
-1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
];
const base64Pad = '=';
function base64ToString(data) {
var result = '';
var leftbits = 0; // number of bits decoded, but yet to be appended
var leftdata = 0; // bits decoded, but yet to be appended
// Convert one by one.
for (var i = 0; i < data.length; i++) {
var c = toBinaryTable[data.charCodeAt(i) & 0x7f];
var padding = (data[i] == base64Pad);
// Skip illegal characters and whitespace
if (c == -1) continue;
// Collect data into leftdata, update bitcount
leftdata = (leftdata << 6) | c;
leftbits += 6;
// If we have 8 or more bits, append 8 bits to the result
if (leftbits >= 8) {
leftbits -= 8;
// Append if not padding.
if (!padding)
result += String.fromCharCode((leftdata >> leftbits) & 0xff);
leftdata &= (1 << leftbits) - 1;
}
}
// If there are any bits left, the base64 string was corrupted
if (leftbits)
throw Components.Exception('Corrupted base64 string');
return result;
}

View File

@ -1,5 +1,6 @@
[DEFAULT]
support-files =
authenticate.sjs
background_red.html
background_red_redirect.sjs
background_red_scroll.html
@ -8,7 +9,6 @@ support-files =
thumbnails_background.sjs
thumbnails_crash_content_helper.js
thumbnails_update.sjs
!/browser/base/content/test/general/authenticate.sjs
[browser_thumbnails_bg_bad_url.js]
[browser_thumbnails_bg_crash_during_capture.js]

View File

@ -10,7 +10,7 @@
// appear - how long should the watcher be active before assuming it's not
// going to appear?)
function* runTests() {
let url = "http://mochi.test:8888/browser/browser/base/content/test/general/authenticate.sjs?user=anyone";
let url = "http://mochi.test:8888/browser/toolkit/components/thumbnails/test/authenticate.sjs?user=anyone";
ok(!thumbnailExists(url), "Thumbnail file should not already exist.");
let capturedURL = yield bgCapture(url);