diff options
Diffstat (limited to 'browser/base/content/test/general')
411 files changed, 0 insertions, 35369 deletions
diff --git a/browser/base/content/test/general/.eslintrc.js b/browser/base/content/test/general/.eslintrc.js deleted file mode 100644 index 11abd6140..000000000 --- a/browser/base/content/test/general/.eslintrc.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; - -module.exports = { - "extends": [ - "../../../../../testing/mochitest/browser.eslintrc.js", - "../../../../../testing/mochitest/mochitest.eslintrc.js", - ] -}; diff --git a/browser/base/content/test/general/POSTSearchEngine.xml b/browser/base/content/test/general/POSTSearchEngine.xml deleted file mode 100644 index 30567d92f..000000000 --- a/browser/base/content/test/general/POSTSearchEngine.xml +++ /dev/null @@ -1,6 +0,0 @@ -<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> - <ShortName>POST Search</ShortName> - <Url type="text/html" method="POST" template="http://mochi.test:8888/browser/browser/base/content/test/general/print_postdata.sjs"> - <Param name="searchterms" value="{searchTerms}"/> - </Url> -</OpenSearchDescription> diff --git a/browser/base/content/test/general/aboutHome_content_script.js b/browser/base/content/test/general/aboutHome_content_script.js deleted file mode 100644 index 28d0e617e..000000000 --- a/browser/base/content/test/general/aboutHome_content_script.js +++ /dev/null @@ -1,6 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -addMessageListener("AboutHome:SearchTriggered", function (msg) { - sendAsyncMessage("AboutHomeTest:CheckRecordedSearch", msg.data); -}); diff --git a/browser/base/content/test/general/accounts_testRemoteCommands.html b/browser/base/content/test/general/accounts_testRemoteCommands.html deleted file mode 100644 index 517317aff..000000000 --- a/browser/base/content/test/general/accounts_testRemoteCommands.html +++ /dev/null @@ -1,83 +0,0 @@ -<html>
- <head>
- <meta charset="utf-8">
-
-<script type="text/javascript;version=1.8">
-
-function init() {
- window.addEventListener("message", function process(e) {doTest(e)}, false);
- // unless we relinquish the eventloop,
- // tests will run before the chrome event handlers are ready
- setTimeout(doTest, 0);
-}
-
-function checkStatusValue(payload, expectedValue) {
- return payload.status == expectedValue;
-}
-
-let tests = [
-{
- info: "Check account log in",
- event: "login",
- data: {
- email: "foo@example.com",
- uid: "1234@lcip.org",
- assertion: "foobar",
- sessionToken: "dead",
- kA: "beef",
- kB: "cafe",
- verified: true
- },
- payloadType: "message",
- validateResponse: function(payload) {
- return checkStatusValue(payload, "login");
- },
-},
-];
-
-let currentTest = -1;
-function doTest(evt) {
- if (evt) {
- if (currentTest < 0 || !evt.data.content)
- return; // not yet testing
-
- let test = tests[currentTest];
- if (evt.data.type != test.payloadType)
- return; // skip unrequested events
-
- let error = JSON.stringify(evt.data.content);
- let pass = false;
- try {
- pass = test.validateResponse(evt.data.content)
- } catch (e) {}
- reportResult(test.info, pass, error);
- }
- // start the next test if there are any left
- if (tests[++currentTest])
- sendToBrowser(tests[currentTest].event, tests[currentTest].data);
- else
- reportFinished();
-}
-
-function reportResult(info, pass, error) {
- let data = {type: "testResult", info: info, pass: pass, error: error};
- let event = new CustomEvent("FirefoxAccountsTestResponse", {detail: {data: data}, bubbles: true});
- document.dispatchEvent(event);
-}
-
-function reportFinished(cmd) {
- let data = {type: "testsComplete", count: tests.length};
- let event = new CustomEvent("FirefoxAccountsTestResponse", {detail: {data: data}, bubbles: true});
- document.dispatchEvent(event);
-}
-
-function sendToBrowser(type, data) {
- let event = new CustomEvent("FirefoxAccountsCommand", {detail: {command: type, data: data}, bubbles: true});
- document.dispatchEvent(event);
-}
-
-</script>
- </head>
- <body onload="init()">
- </body>
-</html>
diff --git a/browser/base/content/test/general/alltabslistener.html b/browser/base/content/test/general/alltabslistener.html deleted file mode 100644 index 166c31037..000000000 --- a/browser/base/content/test/general/alltabslistener.html +++ /dev/null @@ -1,8 +0,0 @@ -<html> -<head> -<title>Test page for bug 463387</title> -</head> -<body> -<p>Test page for bug 463387</p> -</body> -</html> diff --git a/browser/base/content/test/general/app_bug575561.html b/browser/base/content/test/general/app_bug575561.html deleted file mode 100644 index a60c7c87e..000000000 --- a/browser/base/content/test/general/app_bug575561.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=575561
--->
- <head>
- <title>Test for links in app tabs</title>
- </head>
- <body>
- <a href="http://example.com/browser/browser/base/content/test/general/dummy_page.html">same domain</a>
- <a href="http://test1.example.com/browser/browser/base/content/test/general/dummy_page.html">same domain (different subdomain)</a>
- <a href="http://example.org/browser/browser/base/content/test/general/dummy_page.html">different domain</a>
- <a href="http://example.org/browser/browser/base/content/test/general/dummy_page.html" target="foo">different domain (with target)</a>
- <a href="http://www.example.com/browser/browser/base/content/test/general/dummy_page.html">same domain (www prefix)</a>
- <a href="data:text/html,<!DOCTYPE html><html><body>Another Page</body></html>">data: URI</a>
- <iframe src="app_subframe_bug575561.html"></iframe>
- </body>
-</html>
diff --git a/browser/base/content/test/general/app_subframe_bug575561.html b/browser/base/content/test/general/app_subframe_bug575561.html deleted file mode 100644 index 8690497ff..000000000 --- a/browser/base/content/test/general/app_subframe_bug575561.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=575561 ---> - <head> - <title>Test for links in app tab subframes</title> - </head> - <body> - <a href="http://example.org/browser/browser/base/content/test/general/dummy_page.html">different domain</a> - </body> -</html> diff --git a/browser/base/content/test/general/audio.ogg b/browser/base/content/test/general/audio.ogg Binary files differdeleted file mode 100644 index 477544875..000000000 --- a/browser/base/content/test/general/audio.ogg +++ /dev/null diff --git a/browser/base/content/test/general/benignPage.html b/browser/base/content/test/general/benignPage.html deleted file mode 100644 index 8e9429acd..000000000 --- a/browser/base/content/test/general/benignPage.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE HTML> -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - 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/. --> -<html dir="ltr" xml:lang="en-US" lang="en-US"> - <head> - <meta charset="utf8"> - </head> - <body> - <iframe src="http://not-tracking.example.com/"></iframe> - </body> -</html> diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini deleted file mode 100644 index 96e591ffe..000000000 --- a/browser/base/content/test/general/browser.ini +++ /dev/null @@ -1,494 +0,0 @@ -[DEFAULT] -support-files = - POSTSearchEngine.xml - accounts_testRemoteCommands.html - alltabslistener.html - app_bug575561.html - app_subframe_bug575561.html - aboutHome_content_script.js - audio.ogg - browser_bug479408_sample.html - browser_bug678392-1.html - browser_bug678392-2.html - browser_bug970746.xhtml - browser_fxa_oauth.html - browser_fxa_oauth_with_keys.html - browser_fxa_web_channel.html - browser_registerProtocolHandler_notification.html - browser_star_hsts.sjs - browser_tab_dragdrop2_frame1.xul - browser_web_channel.html - browser_web_channel_iframe.html - bug1262648_string_with_newlines.dtd - bug592338.html - bug792517-2.html - bug792517.html - bug792517.sjs - bug839103.css - clipboard_pastefile.html - contextmenu_common.js - ctxmenu-image.png - discovery.html - download_page.html - dummy_page.html - feed_tab.html - file_generic_favicon.ico - file_with_favicon.html - file_bug822367_1.html - file_bug822367_1.js - file_bug822367_2.html - file_bug822367_3.html - file_bug822367_4.html - file_bug822367_4.js - file_bug822367_4B.html - file_bug822367_5.html - file_bug822367_6.html - file_bug902156.js - file_bug902156_1.html - file_bug902156_2.html - file_bug902156_3.html - file_bug906190_1.html - file_bug906190_2.html - file_bug906190_3_4.html - file_bug906190_redirected.html - file_bug906190.js - file_bug906190.sjs - file_mediaPlayback.html - file_mixedContentFromOnunload.html - file_mixedContentFromOnunload_test1.html - file_mixedContentFromOnunload_test2.html - file_mixedContentFramesOnHttp.html - file_mixedPassiveContent.html - file_bug970276_popup1.html - file_bug970276_popup2.html - file_bug970276_favicon1.ico - file_bug970276_favicon2.ico - file_documentnavigation_frameset.html - file_double_close_tab.html - file_favicon_change.html - file_favicon_change_not_in_document.html - file_fullscreen-window-open.html - head.js - healthreport_pingData.js - healthreport_testRemoteCommands.html - moz.png - navigating_window_with_download.html - offlineQuotaNotification.cacheManifest - offlineQuotaNotification.html - page_style_sample.html - parsingTestHelpers.jsm - pinning_headers.sjs - ssl_error_reports.sjs - print_postdata.sjs - searchSuggestionEngine.sjs - searchSuggestionEngine.xml - searchSuggestionEngine2.xml - subtst_contextmenu.html - subtst_contextmenu_input.html - subtst_contextmenu_xul.xul - test-mixedcontent-securityerrors.html - test_bug435035.html - test_bug462673.html - test_bug628179.html - test_bug839103.html - test_bug959531.html - test_process_flags_chrome.html - title_test.svg - unknownContentType_file.pif - unknownContentType_file.pif^headers^ - video.ogg - web_video.html - web_video1.ogv - web_video1.ogv^headers^ - zoom_test.html - test_no_mcb_on_http_site_img.html - test_no_mcb_on_http_site_img.css - test_no_mcb_on_http_site_font.html - test_no_mcb_on_http_site_font.css - test_no_mcb_on_http_site_font2.html - test_no_mcb_on_http_site_font2.css - test_mcb_redirect.html - test_mcb_redirect_image.html - test_mcb_double_redirect_image.html - test_mcb_redirect.js - test_mcb_redirect.sjs - file_bug1045809_1.html - file_bug1045809_2.html - file_csp_block_all_mixedcontent.html - file_csp_block_all_mixedcontent.js - !/image/test/mochitest/blue.png - !/toolkit/components/passwordmgr/test/browser/form_basic.html - !/toolkit/components/passwordmgr/test/browser/insecure_test.html - !/toolkit/components/passwordmgr/test/browser/insecure_test_subframe.html - !/toolkit/content/tests/browser/common/mockTransfer.js - !/toolkit/modules/tests/browser/metadata_*.html - !/toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi - !/toolkit/mozapps/extensions/test/xpinstall/corrupt.xpi - !/toolkit/mozapps/extensions/test/xpinstall/incompatible.xpi - !/toolkit/mozapps/extensions/test/xpinstall/installtrigger.html - !/toolkit/mozapps/extensions/test/xpinstall/redirect.sjs - !/toolkit/mozapps/extensions/test/xpinstall/restartless-unsigned.xpi - !/toolkit/mozapps/extensions/test/xpinstall/restartless.xpi - !/toolkit/mozapps/extensions/test/xpinstall/theme.xpi - !/toolkit/mozapps/extensions/test/xpinstall/slowinstall.sjs - -[browser_aboutAccounts.js] -skip-if = os == "linux" # Bug 958026 -support-files = - content_aboutAccounts.js -[browser_aboutCertError.js] -[browser_aboutNetError.js] -[browser_aboutSupport_newtab_security_state.js] -[browser_aboutHealthReport.js] -skip-if = os == "linux" # Bug 924307 -[browser_aboutHome.js] -[browser_aboutHome_wrapsCorrectly.js] -[browser_addKeywordSearch.js] -[browser_alltabslistener.js] -[browser_audioTabIcon.js] -tags = audiochannel -[browser_backButtonFitts.js] -skip-if = os == "mac" # The Fitt's Law back button is not supported on OS X -[browser_beforeunload_duplicate_dialogs.js] -[browser_blob-channelname.js] -[browser_bookmark_popup.js] -skip-if = (os == "linux" && debug) # mouseover not reliable on linux debug builds -[browser_bookmark_titles.js] -skip-if = toolkit == "windows" # Disabled on Windows due to frequent failures (bugs 825739, 841341) -[browser_bug321000.js] -subsuite = clipboard -skip-if = true # browser_bug321000.js is disabled because newline handling is shaky (bug 592528) -[browser_bug356571.js] -[browser_bug380960.js] -[browser_bug386835.js] -[browser_bug406216.js] -[browser_bug408415.js] -[browser_bug409481.js] -[browser_bug409624.js] -[browser_bug413915.js] -[browser_bug416661.js] -[browser_bug417483.js] -[browser_bug419612.js] -[browser_bug422590.js] -[browser_bug423833.js] -skip-if = true # bug 428712 -[browser_bug424101.js] -[browser_bug427559.js] -[browser_bug431826.js] -[browser_bug432599.js] -[browser_bug435035.js] -[browser_bug435325.js] -[browser_bug441778.js] -[browser_bug455852.js] -[browser_bug460146.js] -[browser_bug462289.js] -skip-if = toolkit == "cocoa" -[browser_bug462673.js] -[browser_bug477014.js] -[browser_bug479408.js] -[browser_bug481560.js] -[browser_bug484315.js] -[browser_bug491431.js] -[browser_bug495058.js] -[browser_bug517902.js] -skip-if = (os == 'linux' && e10s) # bug 1161699 -[browser_bug519216.js] -[browser_bug520538.js] -[browser_bug521216.js] -[browser_bug533232.js] -[browser_bug537013.js] -subsuite = clipboard -skip-if = e10s # Bug 1134458 - Find bar doesn't work correctly in a detached tab -[browser_bug537474.js] -[browser_bug550565.js] -[browser_bug553455.js] -[browser_bug555224.js] -[browser_bug555767.js] -[browser_bug559991.js] -[browser_bug561636.js] -skip-if = true # bug 1057615 -[browser_bug563588.js] -[browser_bug565575.js] -[browser_bug567306.js] -subsuite = clipboard -[browser_bug1261299.js] -subsuite = clipboard -skip-if = toolkit != "cocoa" # Because of tests for supporting Service Menu of macOS, bug 1261299 -[browser_bug1297539.js] -skip-if = toolkit != "cocoa" # Because of tests for supporting pasting from Service Menu of macOS, bug 1297539 -[browser_bug575561.js] -[browser_bug575830.js] -[browser_bug577121.js] -[browser_bug578534.js] -[browser_bug579872.js] -[browser_bug580638.js] -[browser_bug580956.js] -[browser_bug581242.js] -[browser_bug581253.js] -[browser_bug585558.js] -[browser_bug585785.js] -[browser_bug585830.js] -[browser_bug590206.js] -[browser_bug592338.js] -[browser_bug594131.js] -[browser_bug595507.js] -skip-if = true # bug 1057615 -[browser_bug596687.js] -[browser_bug597218.js] -[browser_bug609700.js] -[browser_bug623893.js] -[browser_bug624734.js] -[browser_bug633691.js] -[browser_bug647886.js] -[browser_bug655584.js] -[browser_bug664672.js] -[browser_bug676619.js] -skip-if = os == "mac" # mac: Intermittent failures, bug 925225 -[browser_bug678392.js] -skip-if = os == "mac" # Bug 1102331 - does focus things on the content window which break in e10s mode (still causes orange on Mac 10.10) -[browser_bug710878.js] -[browser_bug719271.js] -[browser_bug724239.js] -[browser_bug734076.js] -[browser_bug735471.js] -[browser_bug749738.js] -[browser_bug763468_perwindowpb.js] -[browser_bug767836_perwindowpb.js] -[browser_bug817947.js] -[browser_bug822367.js] -tags = mcb -[browser_bug832435.js] -[browser_bug839103.js] -[browser_bug882977.js] -[browser_bug902156.js] -tags = mcb -[browser_bug906190.js] -tags = mcb -[browser_mixedContentFromOnunload.js] -tags = mcb -[browser_mixedContentFramesOnHttp.js] -tags = mcb -[browser_bug970746.js] -[browser_bug1015721.js] -skip-if = os == 'win' -[browser_bug1064280_changeUrlInPinnedTab.js] -[browser_accesskeys.js] -[browser_clipboard.js] -subsuite = clipboard -[browser_clipboard_pastefile.js] -skip-if = true # Disabled due to the clipboard not supporting real file types yet (bug 1288773) -[browser_contentAreaClick.js] -skip-if = e10s # Clicks in content don't go through contentAreaClick with e10s. -[browser_contentAltClick.js] -[browser_contextmenu.js] -subsuite = clipboard -tags = fullscreen -skip-if = toolkit == "gtk2" || toolkit == "gtk3" # disabled on Linux due to bug 513558 -[browser_contextmenu_input.js] -skip-if = toolkit == "gtk2" || toolkit == "gtk3" # disabled on Linux due to bug 513558 -[browser_ctrlTab.js] -[browser_datachoices_notification.js] -skip-if = !datareporting -[browser_decoderDoctor.js] -skip-if = os == "mac" # decoder doctor isn't implemented on osx -[browser_devedition.js] -[browser_discovery.js] -[browser_double_close_tab.js] -[browser_documentnavigation.js] -[browser_duplicateIDs.js] -[browser_drag.js] -skip-if = true # browser_drag.js is disabled, as it needs to be updated for the new behavior from bug 320638. -[browser_favicon_change.js] -[browser_favicon_change_not_in_document.js] -[browser_findbarClose.js] -[browser_focusonkeydown.js] -[browser_fullscreen-window-open.js] -tags = fullscreen -skip-if = os == "linux" # Linux: Intermittent failures - bug 941575. -[browser_fxaccounts.js] -support-files = fxa_profile_handler.sjs -[browser_fxa_migrate.js] -[browser_fxa_oauth.js] -[browser_fxa_web_channel.js] -[browser_gestureSupport.js] -skip-if = e10s # Bug 863514 - no gesture support. -[browser_getshortcutoruri.js] -[browser_hide_removing.js] -[browser_homeDrop.js] -[browser_identity_UI.js] -[browser_insecureLoginForms.js] -support-files = insecure_opener.html -[browser_invalid_uri_back_forward_manipulation.js] -[browser_keywordBookmarklets.js] -[browser_keywordSearch.js] -[browser_keywordSearch_postData.js] -[browser_lastAccessedTab.js] -skip-if = toolkit == "windows" # Disabled on Windows due to frequent failures (bug 969405) -[browser_menuButtonFitts.js] -skip-if = os != "win" # The Fitts Law menu button is only supported on Windows (bug 969376) -[browser_middleMouse_noJSPaste.js] -subsuite = clipboard -[browser_minimize.js] -[browser_misused_characters_in_strings.js] -[browser_mixed_content_cert_override.js] -[browser_mixedcontent_securityflags.js] -tags = mcb -[browser_modifiedclick_inherit_principal.js] -[browser_offlineQuotaNotification.js] -skip-if = os == "linux" && !debug # bug 1304273 -[browser_feed_discovery.js] -support-files = feed_discovery.html -[browser_gZipOfflineChild.js] -support-files = test_offline_gzip.html gZipOfflineChild.cacheManifest gZipOfflineChild.cacheManifest^headers^ gZipOfflineChild.html gZipOfflineChild.html^headers^ -[browser_overflowScroll.js] -[browser_pageInfo.js] -[browser_pageinfo_svg_image.js] -support-files = - svg_image.html -[browser_page_style_menu.js] -[browser_page_style_menu_update.js] -[browser_parsable_css.js] -skip-if = (debug || asan) # no point in running on both opt and debug, and will likely intermittently timeout on debug -[browser_parsable_script.js] -skip-if = asan || (os == 'linux' && !debug && (bits == 32)) # disabled on asan because of timeouts, and bug 1172468 for the linux 32-bit pgo issue. -[browser_permissions.js] -support-files = - permissions.html -[browser_pinnedTabs.js] -[browser_plainTextLinks.js] -[browser_printpreview.js] -[browser_private_browsing_window.js] -[browser_private_no_prompt.js] -[browser_purgehistory_clears_sh.js] -[browser_PageMetaData_pushstate.js] -[browser_refreshBlocker.js] -support-files = - refresh_header.sjs - refresh_meta.sjs -[browser_relatedTabs.js] -[browser_remoteTroubleshoot.js] -support-files = - test_remoteTroubleshoot.html -[browser_remoteWebNavigation_postdata.js] -[browser_removeTabsToTheEnd.js] -[browser_restore_isAppTab.js] -[browser_sanitize-passwordDisabledHosts.js] -[browser_sanitize-sitepermissions.js] -[browser_sanitize-timespans.js] -[browser_sanitizeDialog.js] -[browser_save_link-perwindowpb.js] -skip-if = e10s && debug && os == "win" # Bug 1280505 -[browser_save_private_link_perwindowpb.js] -[browser_save_link_when_window_navigates.js] -[browser_save_video.js] -[browser_save_video_frame.js] -[browser_scope.js] -[browser_contentSearchUI.js] -support-files = - contentSearchUI.html - contentSearchUI.js -[browser_selectpopup.js] -run-if = e10s -[browser_selectTabAtIndex.js] -[browser_ssl_error_reports.js] -[browser_star_hsts.js] -[browser_subframe_favicons_not_used.js] -[browser_syncui.js] -[browser_tab_close_dependent_window.js] -[browser_tabDrop.js] -[browser_tabReorder.js] -[browser_tab_detach_restore.js] -[browser_tab_drag_drop_perwindow.js] -[browser_tab_dragdrop.js] -skip-if = buildapp == 'mulet' || (e10s && (debug || os == 'linux')) # Bug 1312436 -[browser_tab_dragdrop2.js] -[browser_tabbar_big_widgets.js] -skip-if = os == "linux" || os == "mac" # No tabs in titlebar on linux - # Disabled on OS X because of bug 967917 -[browser_tabfocus.js] -[browser_tabkeynavigation.js] -skip-if = (os == "mac" && !e10s) # Bug 1237713 - OSX eats keypresses for some reason -[browser_tabopen_reflows.js] -[browser_tabs_close_beforeunload.js] -support-files = - close_beforeunload_opens_second_tab.html - close_beforeunload.html -[browser_tabs_isActive.js] -[browser_tabs_owner.js] -[browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js] -run-if = e10s -[browser_trackingUI_1.js] -tags = trackingprotection -support-files = - trackingPage.html - benignPage.html -[browser_trackingUI_2.js] -tags = trackingprotection -support-files = - trackingPage.html - benignPage.html -[browser_trackingUI_3.js] -tags = trackingprotection -[browser_trackingUI_4.js] -tags = trackingprotection -support-files = - trackingPage.html - benignPage.html -[browser_trackingUI_5.js] -tags = trackingprotection -support-files = - trackingPage.html -[browser_trackingUI_6.js] -tags = trackingprotection -support-files = - file_trackingUI_6.html - file_trackingUI_6.js - file_trackingUI_6.js^headers^ -[browser_trackingUI_telemetry.js] -tags = trackingprotection -support-files = - trackingPage.html -[browser_typeAheadFind.js] -[browser_unknownContentType_title.js] -[browser_unloaddialogs.js] -[browser_utilityOverlay.js] -[browser_viewSourceInTabOnViewSource.js] -[browser_visibleFindSelection.js] -[browser_visibleTabs.js] -[browser_visibleTabs_bookmarkAllPages.js] -skip-if = true # Bug 1005420 - fails intermittently. also with e10s enabled: bizarre problem with hidden tab having _mouseenter called, via _setPositionalAttributes, and tab not being found resulting in 'candidate is undefined' -[browser_visibleTabs_bookmarkAllTabs.js] -[browser_visibleTabs_contextMenu.js] -[browser_visibleTabs_tabPreview.js] -skip-if = (os == "win" && !debug) -[browser_web_channel.js] -[browser_windowopen_reflows.js] -[browser_zbug569342.js] -skip-if = e10s || debug # Bug 1094240 - has findbar-related failures -[browser_registerProtocolHandler_notification.js] -[browser_no_mcb_on_http_site.js] -tags = mcb -[browser_addCertException.js] -[browser_bug1045809.js] -tags = mcb -[browser_e10s_switchbrowser.js] -[browser_e10s_about_process.js] -[browser_e10s_chrome_process.js] -[browser_e10s_javascript.js] -[browser_blockHPKP.js] -tags = psm -[browser_mcb_redirect.js] -tags = mcb -[browser_windowactivation.js] -[browser_contextmenu_childprocess.js] -[browser_bug963945.js] -[browser_domFullscreen_fullscreenMode.js] -tags = fullscreen -[browser_menuButtonBadgeManager.js] -[browser_newTabDrop.js] -[browser_newWindowDrop.js] -[browser_csp_block_all_mixedcontent.js] -tags = mcb -[browser_newwindow_focus.js] -skip-if = (os == "linux" && !e10s) # Bug 1263254 - Perma fails on Linux without e10s for some reason. -[browser_bug1299667.js] diff --git a/browser/base/content/test/general/browser_PageMetaData_pushstate.js b/browser/base/content/test/general/browser_PageMetaData_pushstate.js deleted file mode 100644 index 6f71c57a3..000000000 --- a/browser/base/content/test/general/browser_PageMetaData_pushstate.js +++ /dev/null @@ -1,29 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -add_task(function* () { - let rooturi = "https://example.com/browser/toolkit/modules/tests/browser/"; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, rooturi + "metadata_simple.html"); - yield ContentTask.spawn(gBrowser.selectedBrowser, { rooturi }, function* (args) { - let result = PageMetadata.getData(content.document); - // Result should have description. - Assert.equal(result.url, args.rooturi + "metadata_simple.html", "metadata url is correct"); - Assert.equal(result.title, "Test Title", "metadata title is correct"); - Assert.equal(result.description, "A very simple test page", "description is correct"); - - content.history.pushState({}, "2", "2.html"); - result = PageMetadata.getData(content.document); - // Result should not have description. - Assert.equal(result.url, args.rooturi + "2.html", "metadata url is correct"); - Assert.equal(result.title, "Test Title", "metadata title is correct"); - Assert.ok(!result.description, "description is undefined"); - - Assert.equal(content.document.documentURI, args.rooturi + "2.html", - "content.document has correct url"); - }); - - is(gBrowser.currentURI.spec, rooturi + "2.html", "gBrowser has correct url"); - - gBrowser.removeTab(gBrowser.selectedTab); -}); diff --git a/browser/base/content/test/general/browser_aboutAccounts.js b/browser/base/content/test/general/browser_aboutAccounts.js deleted file mode 100644 index fd72a1608..000000000 --- a/browser/base/content/test/general/browser_aboutAccounts.js +++ /dev/null @@ -1,499 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: window.location is null"); - -XPCOMUtils.defineLazyModuleGetter(this, "Promise", - "resource://gre/modules/Promise.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Task", - "resource://gre/modules/Task.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "fxAccounts", - "resource://gre/modules/FxAccounts.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", - "resource://gre/modules/FileUtils.jsm"); - -const CHROME_BASE = "chrome://mochitests/content/browser/browser/base/content/test/general/"; -// Preference helpers. -var changedPrefs = new Set(); - -function setPref(name, value) { - changedPrefs.add(name); - Services.prefs.setCharPref(name, value); -} - -registerCleanupFunction(function() { - // Ensure we don't pollute prefs for next tests. - for (let name of changedPrefs) { - Services.prefs.clearUserPref(name); - } -}); - -var gTests = [ -{ - desc: "Test the remote commands", - teardown: function* () { - gBrowser.removeCurrentTab(); - yield signOut(); - }, - run: function* () - { - setPref("identity.fxaccounts.remote.signup.uri", - "https://example.com/browser/browser/base/content/test/general/accounts_testRemoteCommands.html"); - let tab = yield promiseNewTabLoadEvent("about:accounts"); - let mm = tab.linkedBrowser.messageManager; - - let deferred = Promise.defer(); - - // We'll get a message when openPrefs() is called, which this test should - // arrange. - let promisePrefsOpened = promiseOneMessage(tab, "test:openPrefsCalled"); - let results = 0; - try { - mm.addMessageListener("test:response", function responseHandler(msg) { - let data = msg.data.data; - if (data.type == "testResult") { - ok(data.pass, data.info); - results++; - } else if (data.type == "testsComplete") { - is(results, data.count, "Checking number of results received matches the number of tests that should have run"); - mm.removeMessageListener("test:response", responseHandler); - deferred.resolve(); - } - }); - } catch (e) { - ok(false, "Failed to get all commands"); - deferred.reject(); - } - yield deferred.promise; - yield promisePrefsOpened; - } -}, -{ - desc: "Test action=signin - no user logged in", - teardown: () => gBrowser.removeCurrentTab(), - run: function* () - { - // When this loads with no user logged-in, we expect the "normal" URL - const expected_url = "https://example.com/?is_sign_in"; - setPref("identity.fxaccounts.remote.signin.uri", expected_url); - let [tab, url] = yield promiseNewTabWithIframeLoadEvent("about:accounts?action=signin"); - is(url, expected_url, "action=signin got the expected URL"); - // we expect the remote iframe to be shown. - yield checkVisibilities(tab, { - stage: false, // parent of 'manage' and 'intro' - manage: false, - intro: false, // this is "get started" - remote: true, - networkError: false - }); - } -}, -{ - desc: "Test action=signin - user logged in", - teardown: function* () { - gBrowser.removeCurrentTab(); - yield signOut(); - }, - run: function* () - { - // When this loads with a user logged-in, we expect the normal URL to - // have been ignored and the "manage" page to be shown. - const expected_url = "https://example.com/?is_sign_in"; - setPref("identity.fxaccounts.remote.signin.uri", expected_url); - yield setSignedInUser(); - let tab = yield promiseNewTabLoadEvent("about:accounts?action=signin"); - // about:accounts initializes after fetching the current user from Fxa - - // so we also request it - by the time we get it we know it should have - // done its thing. - yield fxAccounts.getSignedInUser(); - // we expect "manage" to be shown. - yield checkVisibilities(tab, { - stage: true, // parent of 'manage' and 'intro' - manage: true, - intro: false, // this is "get started" - remote: false, - networkError: false - }); - } -}, -{ - desc: "Test action=signin - captive portal", - teardown: () => gBrowser.removeCurrentTab(), - run: function* () - { - const signinUrl = "https://redirproxy.example.com/test"; - setPref("identity.fxaccounts.remote.signin.uri", signinUrl); - let [tab, ] = yield promiseNewTabWithIframeLoadEvent("about:accounts?action=signin"); - yield checkVisibilities(tab, { - stage: true, // parent of 'manage' and 'intro' - manage: false, - intro: false, // this is "get started" - remote: false, - networkError: true - }); - } -}, -{ - desc: "Test action=signin - offline", - teardown: () => { - gBrowser.removeCurrentTab(); - BrowserOffline.toggleOfflineStatus(); - }, - run: function* () - { - BrowserOffline.toggleOfflineStatus(); - Services.cache2.clear(); - - const signinUrl = "https://unknowndomain.cow"; - setPref("identity.fxaccounts.remote.signin.uri", signinUrl); - let [tab, ] = yield promiseNewTabWithIframeLoadEvent("about:accounts?action=signin"); - yield checkVisibilities(tab, { - stage: true, // parent of 'manage' and 'intro' - manage: false, - intro: false, // this is "get started" - remote: false, - networkError: true - }); - } -}, -{ - desc: "Test action=signup - no user logged in", - teardown: () => gBrowser.removeCurrentTab(), - run: function* () - { - const expected_url = "https://example.com/?is_sign_up"; - setPref("identity.fxaccounts.remote.signup.uri", expected_url); - let [tab, url] = yield promiseNewTabWithIframeLoadEvent("about:accounts?action=signup"); - is(url, expected_url, "action=signup got the expected URL"); - // we expect the remote iframe to be shown. - yield checkVisibilities(tab, { - stage: false, // parent of 'manage' and 'intro' - manage: false, - intro: false, // this is "get started" - remote: true, - networkError: false - }); - }, -}, -{ - desc: "Test action=signup - user logged in", - teardown: () => gBrowser.removeCurrentTab(), - run: function* () - { - const expected_url = "https://example.com/?is_sign_up"; - setPref("identity.fxaccounts.remote.signup.uri", expected_url); - yield setSignedInUser(); - let tab = yield promiseNewTabLoadEvent("about:accounts?action=signup"); - yield fxAccounts.getSignedInUser(); - // we expect "manage" to be shown. - yield checkVisibilities(tab, { - stage: true, // parent of 'manage' and 'intro' - manage: true, - intro: false, // this is "get started" - remote: false, - networkError: false - }); - }, -}, -{ - desc: "Test action=reauth", - teardown: function* () { - gBrowser.removeCurrentTab(); - yield signOut(); - }, - run: function* () - { - const expected_url = "https://example.com/?is_force_auth"; - setPref("identity.fxaccounts.remote.force_auth.uri", expected_url); - - yield setSignedInUser(); - let [, url] = yield promiseNewTabWithIframeLoadEvent("about:accounts?action=reauth"); - // The current user will be appended to the url - let expected = expected_url + "&email=foo%40example.com"; - is(url, expected, "action=reauth got the expected URL"); - }, -}, -{ - desc: "Test with migrateToDevEdition enabled (success)", - teardown: function* () { - gBrowser.removeCurrentTab(); - yield signOut(); - }, - run: function* () - { - let fxAccountsCommon = {}; - Cu.import("resource://gre/modules/FxAccountsCommon.js", fxAccountsCommon); - const pref = "identity.fxaccounts.migrateToDevEdition"; - changedPrefs.add(pref); - Services.prefs.setBoolPref(pref, true); - - // Create the signedInUser.json file that will be used as the source of - // migrated user data. - let signedInUser = { - version: 1, - accountData: { - email: "foo@example.com", - uid: "1234@lcip.org", - sessionToken: "dead", - verified: true - } - }; - // We use a sub-dir of the real profile dir as the "pretend" profile dir - // for this test. - let profD = Services.dirsvc.get("ProfD", Ci.nsIFile); - let mockDir = profD.clone(); - mockDir.append("about-accounts-mock-profd"); - mockDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); - let fxAccountsStorage = OS.Path.join(mockDir.path, fxAccountsCommon.DEFAULT_STORAGE_FILENAME); - yield OS.File.writeAtomic(fxAccountsStorage, JSON.stringify(signedInUser)); - info("Wrote file " + fxAccountsStorage); - - // this is a little subtle - we load about:robots so we get a non-remote - // tab, then we send a message which does both (a) load the URL we want and - // (b) mocks the default profile path used by about:accounts. - let tab = yield promiseNewTabLoadEvent("about:robots"); - let readyPromise = promiseOneMessage(tab, "test:load-with-mocked-profile-path-response"); - - let mm = tab.linkedBrowser.messageManager; - mm.sendAsyncMessage("test:load-with-mocked-profile-path", { - url: "about:accounts", - profilePath: mockDir.path, - }); - - let response = yield readyPromise; - // We are expecting the iframe to be on the "force reauth" URL - let expected = yield fxAccounts.promiseAccountsForceSigninURI(); - is(response.data.url, expected); - - let userData = yield fxAccounts.getSignedInUser(); - SimpleTest.isDeeply(userData, signedInUser.accountData, "All account data were migrated"); - // The migration pref will have been switched off by now. - is(Services.prefs.getBoolPref(pref), false, pref + " got the expected value"); - - yield OS.File.remove(fxAccountsStorage); - yield OS.File.removeEmptyDir(mockDir.path); - }, -}, -{ - desc: "Test with migrateToDevEdition enabled (no user to migrate)", - teardown: function* () { - gBrowser.removeCurrentTab(); - yield signOut(); - }, - run: function* () - { - const pref = "identity.fxaccounts.migrateToDevEdition"; - changedPrefs.add(pref); - Services.prefs.setBoolPref(pref, true); - - let profD = Services.dirsvc.get("ProfD", Ci.nsIFile); - let mockDir = profD.clone(); - mockDir.append("about-accounts-mock-profd"); - mockDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); - // but leave it empty, so we don't think a user is logged in. - - let tab = yield promiseNewTabLoadEvent("about:robots"); - let readyPromise = promiseOneMessage(tab, "test:load-with-mocked-profile-path-response"); - - let mm = tab.linkedBrowser.messageManager; - mm.sendAsyncMessage("test:load-with-mocked-profile-path", { - url: "about:accounts", - profilePath: mockDir.path, - }); - - let response = yield readyPromise; - // We are expecting the iframe to be on the "signup" URL - let expected = yield fxAccounts.promiseAccountsSignUpURI(); - is(response.data.url, expected); - - // and expect no signed in user. - let userData = yield fxAccounts.getSignedInUser(); - is(userData, null); - // The migration pref should have still been switched off. - is(Services.prefs.getBoolPref(pref), false, pref + " got the expected value"); - yield OS.File.removeEmptyDir(mockDir.path); - }, -}, -{ - desc: "Test observers about:accounts", - teardown: function() { - gBrowser.removeCurrentTab(); - }, - run: function* () { - setPref("identity.fxaccounts.remote.signup.uri", "https://example.com/"); - yield setSignedInUser(); - let tab = yield promiseNewTabLoadEvent("about:accounts"); - // sign the user out - the tab should have action=signin - yield signOut(); - // wait for the new load. - yield promiseOneMessage(tab, "test:document:load"); - is(tab.linkedBrowser.contentDocument.location.href, "about:accounts?action=signin"); - } -}, -{ - desc: "Test entrypoint query string, no action, no user logged in", - teardown: () => gBrowser.removeCurrentTab(), - run: function* () { - // When this loads with no user logged-in, we expect the "normal" URL - setPref("identity.fxaccounts.remote.signup.uri", "https://example.com/"); - let [, url] = yield promiseNewTabWithIframeLoadEvent("about:accounts?entrypoint=abouthome"); - is(url, "https://example.com/?entrypoint=abouthome", "entrypoint=abouthome got the expected URL"); - }, -}, -{ - desc: "Test entrypoint query string for signin", - teardown: () => gBrowser.removeCurrentTab(), - run: function* () { - // When this loads with no user logged-in, we expect the "normal" URL - const expected_url = "https://example.com/?is_sign_in"; - setPref("identity.fxaccounts.remote.signin.uri", expected_url); - let [, url] = yield promiseNewTabWithIframeLoadEvent("about:accounts?action=signin&entrypoint=abouthome"); - is(url, expected_url + "&entrypoint=abouthome", "entrypoint=abouthome got the expected URL"); - }, -}, -{ - desc: "Test entrypoint query string for signup", - teardown: () => gBrowser.removeCurrentTab(), - run: function* () { - // When this loads with no user logged-in, we expect the "normal" URL - const sign_up_url = "https://example.com/?is_sign_up"; - setPref("identity.fxaccounts.remote.signup.uri", sign_up_url); - let [, url] = yield promiseNewTabWithIframeLoadEvent("about:accounts?entrypoint=abouthome&action=signup"); - is(url, sign_up_url + "&entrypoint=abouthome", "entrypoint=abouthome got the expected URL"); - }, -}, -{ - desc: "about:accounts URL params should be copied to remote URL params " + - "when remote URL has no URL params, except for 'action'", - teardown() { - gBrowser.removeCurrentTab(); - }, - run: function* () { - let signupURL = "https://example.com/"; - setPref("identity.fxaccounts.remote.signup.uri", signupURL); - let queryStr = "email=foo%40example.com&foo=bar&baz=quux"; - let [, url] = - yield promiseNewTabWithIframeLoadEvent("about:accounts?" + queryStr + - "&action=action"); - is(url, signupURL + "?" + queryStr, "URL params are copied to signup URL"); - }, -}, -{ - desc: "about:accounts URL params should be copied to remote URL params " + - "when remote URL already has some URL params, except for 'action'", - teardown() { - gBrowser.removeCurrentTab(); - }, - run: function* () { - let signupURL = "https://example.com/?param"; - setPref("identity.fxaccounts.remote.signup.uri", signupURL); - let queryStr = "email=foo%40example.com&foo=bar&baz=quux"; - let [, url] = - yield promiseNewTabWithIframeLoadEvent("about:accounts?" + queryStr + - "&action=action"); - is(url, signupURL + "&" + queryStr, "URL params are copied to signup URL"); - }, -}, -]; // gTests - -function test() -{ - waitForExplicitFinish(); - - Task.spawn(function* () { - for (let testCase of gTests) { - info(testCase.desc); - try { - yield testCase.run(); - } finally { - yield testCase.teardown(); - } - } - - finish(); - }); -} - -function promiseOneMessage(tab, messageName) { - let mm = tab.linkedBrowser.messageManager; - let deferred = Promise.defer(); - mm.addMessageListener(messageName, function onmessage(message) { - mm.removeMessageListener(messageName, onmessage); - deferred.resolve(message); - }); - return deferred.promise; -} - -function promiseNewTabLoadEvent(aUrl) -{ - let tab = gBrowser.selectedTab = gBrowser.addTab(aUrl); - let browser = tab.linkedBrowser; - let mm = browser.messageManager; - - // give it an e10s-friendly content script to help with our tests. - mm.loadFrameScript(CHROME_BASE + "content_aboutAccounts.js", true); - // and wait for it to tell us about the load. - return promiseOneMessage(tab, "test:document:load").then( - () => tab - ); -} - -// Returns a promise which is resolved with the iframe's URL after a new -// tab is created and the iframe in that tab loads. -function promiseNewTabWithIframeLoadEvent(aUrl) { - let deferred = Promise.defer(); - let tab = gBrowser.selectedTab = gBrowser.addTab(aUrl); - let browser = tab.linkedBrowser; - let mm = browser.messageManager; - - // give it an e10s-friendly content script to help with our tests. - mm.loadFrameScript(CHROME_BASE + "content_aboutAccounts.js", true); - // and wait for it to tell us about the iframe load. - mm.addMessageListener("test:iframe:load", function onFrameLoad(message) { - mm.removeMessageListener("test:iframe:load", onFrameLoad); - deferred.resolve([tab, message.data.url]); - }); - return deferred.promise; -} - -function checkVisibilities(tab, data) { - let ids = Object.keys(data); - let mm = tab.linkedBrowser.messageManager; - let deferred = Promise.defer(); - mm.addMessageListener("test:check-visibilities-response", function onResponse(message) { - mm.removeMessageListener("test:check-visibilities-response", onResponse); - for (let id of ids) { - is(message.data[id], data[id], "Element '" + id + "' has correct visibility"); - } - deferred.resolve(); - }); - mm.sendAsyncMessage("test:check-visibilities", {ids: ids}); - return deferred.promise; -} - -// watch out - these will fire observers which if you aren't careful, may -// interfere with the tests. -function setSignedInUser(data) { - if (!data) { - data = { - email: "foo@example.com", - uid: "1234@lcip.org", - assertion: "foobar", - sessionToken: "dead", - kA: "beef", - kB: "cafe", - verified: true - } - } - return fxAccounts.setSignedInUser(data); -} - -function signOut() { - // we always want a "localOnly" signout here... - return fxAccounts.signOut(true); -} diff --git a/browser/base/content/test/general/browser_aboutCertError.js b/browser/base/content/test/general/browser_aboutCertError.js deleted file mode 100644 index 0e335066c..000000000 --- a/browser/base/content/test/general/browser_aboutCertError.js +++ /dev/null @@ -1,409 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -// This is testing the aboutCertError page (Bug 1207107). - -const GOOD_PAGE = "https://example.com/"; -const BAD_CERT = "https://expired.example.com/"; -const UNKNOWN_ISSUER = "https://self-signed.example.com "; -const BAD_STS_CERT = "https://badchain.include-subdomains.pinning.example.com:443"; -const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); -const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - -add_task(function* checkReturnToAboutHome() { - info("Loading a bad cert page directly and making sure 'return to previous page' goes to about:home"); - let browser; - let certErrorLoaded; - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => { - gBrowser.selectedTab = gBrowser.addTab(BAD_CERT); - browser = gBrowser.selectedBrowser; - certErrorLoaded = waitForCertErrorLoad(browser); - }, false); - - info("Loading and waiting for the cert error"); - yield certErrorLoaded; - - is(browser.webNavigation.canGoBack, false, "!webNavigation.canGoBack"); - is(browser.webNavigation.canGoForward, false, "!webNavigation.canGoForward"); - - // Populate the shistory entries manually, since it happens asynchronously - // and the following tests will be too soon otherwise. - yield TabStateFlusher.flush(browser); - let {entries} = JSON.parse(ss.getTabState(tab)); - is(entries.length, 1, "there is one shistory entry"); - - info("Clicking the go back button on about:certerror"); - yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - let returnButton = doc.getElementById("returnButton"); - is(returnButton.getAttribute("autofocus"), "true", "returnButton has autofocus"); - returnButton.click(); - - yield ContentTaskUtils.waitForEvent(this, "pageshow", true); - }); - - is(browser.webNavigation.canGoBack, true, "webNavigation.canGoBack"); - is(browser.webNavigation.canGoForward, false, "!webNavigation.canGoForward"); - is(gBrowser.currentURI.spec, "about:home", "Went back"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -add_task(function* checkReturnToPreviousPage() { - info("Loading a bad cert page and making sure 'return to previous page' goes back"); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, GOOD_PAGE); - let browser = gBrowser.selectedBrowser; - - info("Loading and waiting for the cert error"); - let certErrorLoaded = waitForCertErrorLoad(browser); - BrowserTestUtils.loadURI(browser, BAD_CERT); - yield certErrorLoaded; - - is(browser.webNavigation.canGoBack, true, "webNavigation.canGoBack"); - is(browser.webNavigation.canGoForward, false, "!webNavigation.canGoForward"); - - // Populate the shistory entries manually, since it happens asynchronously - // and the following tests will be too soon otherwise. - yield TabStateFlusher.flush(browser); - let {entries} = JSON.parse(ss.getTabState(tab)); - is(entries.length, 2, "there are two shistory entries"); - - info("Clicking the go back button on about:certerror"); - yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - let returnButton = doc.getElementById("returnButton"); - returnButton.click(); - - yield ContentTaskUtils.waitForEvent(this, "pageshow", true); - }); - - is(browser.webNavigation.canGoBack, false, "!webNavigation.canGoBack"); - is(browser.webNavigation.canGoForward, true, "webNavigation.canGoForward"); - is(gBrowser.currentURI.spec, GOOD_PAGE, "Went back"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -add_task(function* checkBadStsCert() { - info("Loading a badStsCert and making sure exception button doesn't show up"); - yield BrowserTestUtils.openNewForegroundTab(gBrowser, GOOD_PAGE); - let browser = gBrowser.selectedBrowser; - - info("Loading and waiting for the cert error"); - let certErrorLoaded = waitForCertErrorLoad(browser); - BrowserTestUtils.loadURI(browser, BAD_STS_CERT); - yield certErrorLoaded; - - let exceptionButtonHidden = yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - let exceptionButton = doc.getElementById("exceptionDialogButton"); - return exceptionButton.hidden; - }); - ok(exceptionButtonHidden, "Exception button is hidden"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -const PREF_BLOCKLIST_CLOCK_SKEW_SECONDS = "services.blocklist.clock_skew_seconds"; - -add_task(function* checkWrongSystemTimeWarning() { - function* setUpPage() { - let browser; - let certErrorLoaded; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => { - gBrowser.selectedTab = gBrowser.addTab(BAD_CERT); - browser = gBrowser.selectedBrowser; - certErrorLoaded = waitForCertErrorLoad(browser); - }, false); - - info("Loading and waiting for the cert error"); - yield certErrorLoaded; - - return yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - let div = doc.getElementById("wrongSystemTimePanel"); - let systemDateDiv = doc.getElementById("wrongSystemTime_systemDate"); - let actualDateDiv = doc.getElementById("wrongSystemTime_actualDate"); - let learnMoreLink = doc.getElementById("learnMoreLink"); - - return { - divDisplay: content.getComputedStyle(div).display, - text: div.textContent, - systemDate: systemDateDiv.textContent, - actualDate: actualDateDiv.textContent, - learnMoreLink: learnMoreLink.href - }; - }); - } - - let formatter = new Intl.DateTimeFormat(); - - // pretend we have a positively skewed (ahead) system time - let serverDate = new Date("2015/10/27"); - let serverDateFmt = formatter.format(serverDate); - let localDateFmt = formatter.format(new Date()); - - let skew = Math.floor((Date.now() - serverDate.getTime()) / 1000); - yield new Promise(r => SpecialPowers.pushPrefEnv({set: - [[PREF_BLOCKLIST_CLOCK_SKEW_SECONDS, skew]]}, r)); - - info("Loading a bad cert page with a skewed clock"); - let message = yield Task.spawn(setUpPage); - - isnot(message.divDisplay, "none", "Wrong time message information is visible"); - ok(message.text.includes("because your clock appears to show the wrong time"), - "Correct error message found"); - ok(message.text.includes("expired.example.com"), "URL found in error message"); - ok(message.systemDate.includes(localDateFmt), "correct local date displayed"); - ok(message.actualDate.includes(serverDateFmt), "correct server date displayed"); - ok(message.learnMoreLink.includes("time-errors"), "time-errors in the Learn More URL"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - - // pretend we have a negatively skewed (behind) system time - serverDate = new Date(); - serverDate.setYear(serverDate.getFullYear() + 1); - serverDateFmt = formatter.format(serverDate); - - skew = Math.floor((Date.now() - serverDate.getTime()) / 1000); - yield new Promise(r => SpecialPowers.pushPrefEnv({set: - [[PREF_BLOCKLIST_CLOCK_SKEW_SECONDS, skew]]}, r)); - - info("Loading a bad cert page with a skewed clock"); - message = yield Task.spawn(setUpPage); - - isnot(message.divDisplay, "none", "Wrong time message information is visible"); - ok(message.text.includes("because your clock appears to show the wrong time"), - "Correct error message found"); - ok(message.text.includes("expired.example.com"), "URL found in error message"); - ok(message.systemDate.includes(localDateFmt), "correct local date displayed"); - ok(message.actualDate.includes(serverDateFmt), "correct server date displayed"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - - // pretend we only have a slightly skewed system time, four hours - skew = 60 * 60 * 4; - yield new Promise(r => SpecialPowers.pushPrefEnv({set: - [[PREF_BLOCKLIST_CLOCK_SKEW_SECONDS, skew]]}, r)); - - info("Loading a bad cert page with an only slightly skewed clock"); - message = yield Task.spawn(setUpPage); - - is(message.divDisplay, "none", "Wrong time message information is not visible"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - - // now pretend we have no skewed system time - skew = 0; - yield new Promise(r => SpecialPowers.pushPrefEnv({set: - [[PREF_BLOCKLIST_CLOCK_SKEW_SECONDS, skew]]}, r)); - - info("Loading a bad cert page with no skewed clock"); - message = yield Task.spawn(setUpPage); - - is(message.divDisplay, "none", "Wrong time message information is not visible"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -add_task(function* checkAdvancedDetails() { - info("Loading a bad cert page and verifying the main error and advanced details section"); - let browser; - let certErrorLoaded; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => { - gBrowser.selectedTab = gBrowser.addTab(BAD_CERT); - browser = gBrowser.selectedBrowser; - certErrorLoaded = waitForCertErrorLoad(browser); - }, false); - - info("Loading and waiting for the cert error"); - yield certErrorLoaded; - - let message = yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - let shortDescText = doc.getElementById("errorShortDescText"); - info("Main error text: " + shortDescText.textContent); - ok(shortDescText.textContent.includes("expired.example.com"), - "Should list hostname in error message."); - - let advancedButton = doc.getElementById("advancedButton"); - advancedButton.click(); - let el = doc.getElementById("errorCode"); - return { textContent: el.textContent, tagName: el.tagName }; - }); - is(message.textContent, "SEC_ERROR_EXPIRED_CERTIFICATE", - "Correct error message found"); - is(message.tagName, "a", "Error message is a link"); - - message = yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - let errorCode = doc.getElementById("errorCode"); - errorCode.click(); - let div = doc.getElementById("certificateErrorDebugInformation"); - let text = doc.getElementById("certificateErrorText"); - - let serhelper = Cc["@mozilla.org/network/serialization-helper;1"] - .getService(Ci.nsISerializationHelper); - let serializable = docShell.failedChannel.securityInfo - .QueryInterface(Ci.nsITransportSecurityInfo) - .QueryInterface(Ci.nsISerializable); - let serializedSecurityInfo = serhelper.serializeToString(serializable); - return { - divDisplay: content.getComputedStyle(div).display, - text: text.textContent, - securityInfoAsString: serializedSecurityInfo - }; - }); - isnot(message.divDisplay, "none", "Debug information is visible"); - ok(message.text.includes(BAD_CERT), "Correct URL found"); - ok(message.text.includes("Certificate has expired"), - "Correct error message found"); - ok(message.text.includes("HTTP Strict Transport Security: false"), - "Correct HSTS value found"); - ok(message.text.includes("HTTP Public Key Pinning: false"), - "Correct HPKP value found"); - let certChain = getCertChain(message.securityInfoAsString); - ok(message.text.includes(certChain), "Found certificate chain"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -add_task(function* checkAdvancedDetailsForHSTS() { - info("Loading a bad STS cert page and verifying the advanced details section"); - let browser; - let certErrorLoaded; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => { - gBrowser.selectedTab = gBrowser.addTab(BAD_STS_CERT); - browser = gBrowser.selectedBrowser; - certErrorLoaded = waitForCertErrorLoad(browser); - }, false); - - info("Loading and waiting for the cert error"); - yield certErrorLoaded; - - let message = yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - let advancedButton = doc.getElementById("advancedButton"); - advancedButton.click(); - let ec = doc.getElementById("errorCode"); - let cdl = doc.getElementById("cert_domain_link"); - return { - ecTextContent: ec.textContent, - ecTagName: ec.tagName, - cdlTextContent: cdl.textContent, - cdlTagName: cdl.tagName - }; - }); - - const badStsUri = Services.io.newURI(BAD_STS_CERT, null, null); - is(message.ecTextContent, "SSL_ERROR_BAD_CERT_DOMAIN", - "Correct error message found"); - is(message.ecTagName, "a", "Error message is a link"); - const url = badStsUri.prePath.slice(badStsUri.prePath.indexOf(".") + 1); - is(message.cdlTextContent, url, - "Correct cert_domain_link contents found"); - is(message.cdlTagName, "a", "cert_domain_link is a link"); - - message = yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - let errorCode = doc.getElementById("errorCode"); - errorCode.click(); - let div = doc.getElementById("certificateErrorDebugInformation"); - let text = doc.getElementById("certificateErrorText"); - - let serhelper = Cc["@mozilla.org/network/serialization-helper;1"] - .getService(Ci.nsISerializationHelper); - let serializable = docShell.failedChannel.securityInfo - .QueryInterface(Ci.nsITransportSecurityInfo) - .QueryInterface(Ci.nsISerializable); - let serializedSecurityInfo = serhelper.serializeToString(serializable); - return { - divDisplay: content.getComputedStyle(div).display, - text: text.textContent, - securityInfoAsString: serializedSecurityInfo - }; - }); - isnot(message.divDisplay, "none", "Debug information is visible"); - ok(message.text.includes(badStsUri.spec), "Correct URL found"); - ok(message.text.includes("requested domain name does not match the server\u2019s certificate"), - "Correct error message found"); - ok(message.text.includes("HTTP Strict Transport Security: false"), - "Correct HSTS value found"); - ok(message.text.includes("HTTP Public Key Pinning: true"), - "Correct HPKP value found"); - let certChain = getCertChain(message.securityInfoAsString); - ok(message.text.includes(certChain), "Found certificate chain"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -add_task(function* checkUnknownIssuerLearnMoreLink() { - info("Loading a cert error for self-signed pages and checking the correct link is shown"); - let browser; - let certErrorLoaded; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => { - gBrowser.selectedTab = gBrowser.addTab(UNKNOWN_ISSUER); - browser = gBrowser.selectedBrowser; - certErrorLoaded = waitForCertErrorLoad(browser); - }, false); - - info("Loading and waiting for the cert error"); - yield certErrorLoaded; - - let href = yield ContentTask.spawn(browser, null, function* () { - let learnMoreLink = content.document.getElementById("learnMoreLink"); - return learnMoreLink.href; - }); - ok(href.endsWith("security-error"), "security-error in the Learn More URL"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -function waitForCertErrorLoad(browser) { - return new Promise(resolve => { - info("Waiting for DOMContentLoaded event"); - browser.addEventListener("DOMContentLoaded", function load() { - browser.removeEventListener("DOMContentLoaded", load, false, true); - resolve(); - }, false, true); - }); -} - -function getCertChain(securityInfoAsString) { - let certChain = ""; - const serhelper = Cc["@mozilla.org/network/serialization-helper;1"] - .getService(Ci.nsISerializationHelper); - let securityInfo = serhelper.deserializeObject(securityInfoAsString); - securityInfo.QueryInterface(Ci.nsITransportSecurityInfo); - let certs = securityInfo.failedCertChain.getEnumerator(); - while (certs.hasMoreElements()) { - let cert = certs.getNext(); - cert.QueryInterface(Ci.nsIX509Cert); - certChain += getPEMString(cert); - } - return certChain; -} - -function getDERString(cert) -{ - var length = {}; - var derArray = cert.getRawDER(length); - var derString = ''; - for (var i = 0; i < derArray.length; i++) { - derString += String.fromCharCode(derArray[i]); - } - return derString; -} - -function getPEMString(cert) -{ - var derb64 = btoa(getDERString(cert)); - // Wrap the Base64 string into lines of 64 characters, - // with CRLF line breaks (as specified in RFC 1421). - var wrapped = derb64.replace(/(\S{64}(?!$))/g, "$1\r\n"); - return "-----BEGIN CERTIFICATE-----\r\n" - + wrapped - + "\r\n-----END CERTIFICATE-----\r\n"; -} diff --git a/browser/base/content/test/general/browser_aboutHealthReport.js b/browser/base/content/test/general/browser_aboutHealthReport.js deleted file mode 100644 index 0be184fb8..000000000 --- a/browser/base/content/test/general/browser_aboutHealthReport.js +++ /dev/null @@ -1,139 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -XPCOMUtils.defineLazyModuleGetter(this, "Promise", - "resource://gre/modules/Promise.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Task", - "resource://gre/modules/Task.jsm"); - -const CHROME_BASE = "chrome://mochitests/content/browser/browser/base/content/test/general/"; -const HTTPS_BASE = "https://example.com/browser/browser/base/content/test/general/"; - -const TELEMETRY_LOG_PREF = "toolkit.telemetry.log.level"; -const telemetryOriginalLogPref = Preferences.get(TELEMETRY_LOG_PREF, null); - -const originalReportUrl = Services.prefs.getCharPref("datareporting.healthreport.about.reportUrl"); - -registerCleanupFunction(function() { - // Ensure we don't pollute prefs for next tests. - if (telemetryOriginalLogPref) { - Preferences.set(TELEMETRY_LOG_PREF, telemetryOriginalLogPref); - } else { - Preferences.reset(TELEMETRY_LOG_PREF); - } - - try { - Services.prefs.setCharPref("datareporting.healthreport.about.reportUrl", originalReportUrl); - Services.prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true); - } catch (ex) {} -}); - -function fakeTelemetryNow(...args) { - let date = new Date(...args); - let scope = {}; - const modules = [ - Cu.import("resource://gre/modules/TelemetrySession.jsm", scope), - Cu.import("resource://gre/modules/TelemetryEnvironment.jsm", scope), - Cu.import("resource://gre/modules/TelemetryController.jsm", scope), - ]; - - for (let m of modules) { - m.Policy.now = () => new Date(date); - } - - return date; -} - -function* setupPingArchive() { - let scope = {}; - Cu.import("resource://gre/modules/TelemetryController.jsm", scope); - Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader) - .loadSubScript(CHROME_BASE + "healthreport_pingData.js", scope); - - for (let p of scope.TEST_PINGS) { - fakeTelemetryNow(p.date); - p.id = yield scope.TelemetryController.submitExternalPing(p.type, p.payload); - } -} - -var gTests = [ - -{ - desc: "Test the remote commands", - setup: Task.async(function*() - { - Preferences.set(TELEMETRY_LOG_PREF, "Trace"); - yield setupPingArchive(); - Preferences.set("datareporting.healthreport.about.reportUrl", - HTTPS_BASE + "healthreport_testRemoteCommands.html"); - }), - run: function (iframe) - { - let deferred = Promise.defer(); - let results = 0; - try { - iframe.contentWindow.addEventListener("FirefoxHealthReportTestResponse", function evtHandler(event) { - let data = event.detail.data; - if (data.type == "testResult") { - ok(data.pass, data.info); - results++; - } - else if (data.type == "testsComplete") { - is(results, data.count, "Checking number of results received matches the number of tests that should have run"); - iframe.contentWindow.removeEventListener("FirefoxHealthReportTestResponse", evtHandler, true); - deferred.resolve(); - } - }, true); - - } catch (e) { - ok(false, "Failed to get all commands"); - deferred.reject(); - } - return deferred.promise; - } -}, - -]; // gTests - -function test() -{ - waitForExplicitFinish(); - - // xxxmpc leaving this here until we resolve bug 854038 and bug 854060 - requestLongerTimeout(10); - - Task.spawn(function* () { - for (let testCase of gTests) { - info(testCase.desc); - yield testCase.setup(); - - let iframe = yield promiseNewTabLoadEvent("about:healthreport"); - - yield testCase.run(iframe); - - gBrowser.removeCurrentTab(); - } - - finish(); - }); -} - -function promiseNewTabLoadEvent(aUrl, aEventType="load") -{ - let deferred = Promise.defer(); - let tab = gBrowser.selectedTab = gBrowser.addTab(aUrl); - tab.linkedBrowser.addEventListener(aEventType, function load(event) { - tab.linkedBrowser.removeEventListener(aEventType, load, true); - let iframe = tab.linkedBrowser.contentDocument.getElementById("remote-report"); - iframe.addEventListener("load", function frameLoad(e) { - if (iframe.contentWindow.location.href == "about:blank" || - e.target != iframe) { - return; - } - iframe.removeEventListener("load", frameLoad, false); - deferred.resolve(iframe); - }, false); - }, true); - return deferred.promise; -} diff --git a/browser/base/content/test/general/browser_aboutHome.js b/browser/base/content/test/general/browser_aboutHome.js deleted file mode 100644 index f0e19e852..000000000 --- a/browser/base/content/test/general/browser_aboutHome.js +++ /dev/null @@ -1,668 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// This test needs to be split up. See bug 1258717. -requestLongerTimeout(4); -ignoreAllUncaughtExceptions(); - -XPCOMUtils.defineLazyModuleGetter(this, "AboutHomeUtils", - "resource:///modules/AboutHome.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "AppConstants", - "resource://gre/modules/AppConstants.jsm"); - -const TEST_CONTENT_HELPER = "chrome://mochitests/content/browser/browser/base/" + - "content/test/general/aboutHome_content_script.js"; -var gRightsVersion = Services.prefs.getIntPref("browser.rights.version"); - -registerCleanupFunction(function() { - // Ensure we don't pollute prefs for next tests. - Services.prefs.clearUserPref("network.cookies.cookieBehavior"); - Services.prefs.clearUserPref("network.cookie.lifetimePolicy"); - Services.prefs.clearUserPref("browser.rights.override"); - Services.prefs.clearUserPref("browser.rights." + gRightsVersion + ".shown"); -}); - -add_task(function* () { - info("Check that clearing cookies does not clear storage"); - - yield withSnippetsMap( - () => { - Cc["@mozilla.org/observer-service;1"] - .getService(Ci.nsIObserverService) - .notifyObservers(null, "cookie-changed", "cleared"); - }, - function* () { - isnot(content.gSnippetsMap.get("snippets-last-update"), null, - "snippets-last-update should have a value"); - }); -}); - -add_task(function* () { - info("Check default snippets are shown"); - - yield withSnippetsMap(null, function* () { - let doc = content.document; - let snippetsElt = doc.getElementById("snippets"); - ok(snippetsElt, "Found snippets element") - is(snippetsElt.getElementsByTagName("span").length, 1, - "A default snippet is present."); - }); -}); - -add_task(function* () { - info("Check default snippets are shown if snippets are invalid xml"); - - yield withSnippetsMap( - // This must set some incorrect xhtml code. - snippetsMap => snippetsMap.set("snippets", "<p><b></p></b>"), - function* () { - let doc = content.document; - let snippetsElt = doc.getElementById("snippets"); - ok(snippetsElt, "Found snippets element"); - is(snippetsElt.getElementsByTagName("span").length, 1, - "A default snippet is present."); - - content.gSnippetsMap.delete("snippets"); - }); -}); - -add_task(function* () { - info("Check that performing a search fires a search event and records to Telemetry."); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) { - let currEngine = Services.search.currentEngine; - let engine = yield promiseNewEngine("searchSuggestionEngine.xml"); - // Make this actually work in healthreport by giving it an ID: - Object.defineProperty(engine.wrappedJSObject, "identifier", - { value: "org.mozilla.testsearchsuggestions" }); - - let p = promiseContentSearchChange(browser, engine.name); - Services.search.currentEngine = engine; - yield p; - - yield ContentTask.spawn(browser, { expectedName: engine.name }, function* (args) { - let engineName = content.wrappedJSObject.gContentSearchController.defaultEngine.name; - is(engineName, args.expectedName, "Engine name in DOM should match engine we just added"); - }); - - let numSearchesBefore = 0; - // Get the current number of recorded searches. - let histogramKey = engine.identifier + ".abouthome"; - try { - let hs = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS").snapshot(); - if (histogramKey in hs) { - numSearchesBefore = hs[histogramKey].sum; - } - } catch (ex) { - // No searches performed yet, not a problem, |numSearchesBefore| is 0. - } - - let searchStr = "a search"; - - let expectedURL = Services.search.currentEngine - .getSubmission(searchStr, null, "homepage").uri.spec; - let promise = waitForDocLoadAndStopIt(expectedURL, browser); - - // Perform a search to increase the SEARCH_COUNT histogram. - yield ContentTask.spawn(browser, { searchStr }, function* (args) { - let doc = content.document; - info("Perform a search."); - doc.getElementById("searchText").value = args.searchStr; - doc.getElementById("searchSubmit").click(); - }); - - yield promise; - - // Make sure the SEARCH_COUNTS histogram has the right key and count. - let hs = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS").snapshot(); - Assert.ok(histogramKey in hs, "histogram with key should be recorded"); - Assert.equal(hs[histogramKey].sum, numSearchesBefore + 1, - "histogram sum should be incremented"); - - Services.search.currentEngine = currEngine; - try { - Services.search.removeEngine(engine); - } catch (ex) {} - }); -}); - -add_task(function* () { - info("Check snippets map is cleared if cached version is old"); - - yield withSnippetsMap( - snippetsMap => { - snippetsMap.set("snippets", "test"); - snippetsMap.set("snippets-cached-version", 0); - }, - function* () { - let snippetsMap = content.gSnippetsMap; - ok(!snippetsMap.has("snippets"), "snippets have been properly cleared"); - ok(!snippetsMap.has("snippets-cached-version"), - "cached-version has been properly cleared"); - }); -}); - -add_task(function* () { - info("Check cached snippets are shown if cached version is current"); - - yield withSnippetsMap( - snippetsMap => snippetsMap.set("snippets", "test"), - function* (args) { - let doc = content.document; - let snippetsMap = content.gSnippetsMap - - let snippetsElt = doc.getElementById("snippets"); - ok(snippetsElt, "Found snippets element"); - is(snippetsElt.innerHTML, "test", "Cached snippet is present."); - - is(snippetsMap.get("snippets"), "test", "snippets still cached"); - is(snippetsMap.get("snippets-cached-version"), - args.expectedVersion, - "cached-version is correct"); - ok(snippetsMap.has("snippets-last-update"), "last-update still exists"); - }, { expectedVersion: AboutHomeUtils.snippetsVersion }); -}); - -add_task(function* () { - info("Check if the 'Know Your Rights' default snippet is shown when " + - "'browser.rights.override' pref is set and that its link works"); - - Services.prefs.setBoolPref("browser.rights.override", false); - - ok(AboutHomeUtils.showKnowYourRights, "AboutHomeUtils.showKnowYourRights should be TRUE"); - - yield withSnippetsMap(null, function* () { - let doc = content.document; - let snippetsElt = doc.getElementById("snippets"); - ok(snippetsElt, "Found snippets element"); - let linkEl = snippetsElt.querySelector("a"); - is(linkEl.href, "about:rights", "Snippet link is present."); - }, null, function* () { - let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, "about:rights"); - yield BrowserTestUtils.synthesizeMouseAtCenter("a[href='about:rights']", { - button: 0 - }, gBrowser.selectedBrowser); - yield loadPromise; - is(gBrowser.currentURI.spec, "about:rights", "about:rights should have opened."); - }); - - - Services.prefs.clearUserPref("browser.rights.override"); -}); - -add_task(function* () { - info("Check if the 'Know Your Rights' default snippet is NOT shown when " + - "'browser.rights.override' pref is NOT set"); - - Services.prefs.setBoolPref("browser.rights.override", true); - - let rightsData = AboutHomeUtils.knowYourRightsData; - ok(!rightsData, "AboutHomeUtils.knowYourRightsData should be FALSE"); - - yield withSnippetsMap(null, function*() { - let doc = content.document; - let snippetsElt = doc.getElementById("snippets"); - ok(snippetsElt, "Found snippets element"); - ok(snippetsElt.getElementsByTagName("a")[0].href != "about:rights", - "Snippet link should not point to about:rights."); - }); - - Services.prefs.clearUserPref("browser.rights.override"); -}); - -add_task(function* () { - info("Check POST search engine support"); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) { - return new Promise(resolve => { - let searchObserver = Task.async(function* search_observer(subject, topic, data) { - let currEngine = Services.search.defaultEngine; - let engine = subject.QueryInterface(Ci.nsISearchEngine); - info("Observer: " + data + " for " + engine.name); - - if (data != "engine-added") - return; - - if (engine.name != "POST Search") - return; - - Services.obs.removeObserver(searchObserver, "browser-search-engine-modified"); - - // Ready to execute the tests! - let needle = "Search for something awesome."; - - let p = promiseContentSearchChange(browser, engine.name); - Services.search.defaultEngine = engine; - yield p; - - let promise = BrowserTestUtils.browserLoaded(browser); - - yield ContentTask.spawn(browser, { needle }, function* (args) { - let doc = content.document; - doc.getElementById("searchText").value = args.needle; - doc.getElementById("searchSubmit").click(); - }); - - yield promise; - - // When the search results load, check them for correctness. - yield ContentTask.spawn(browser, { needle }, function* (args) { - let loadedText = content.document.body.textContent; - ok(loadedText, "search page loaded"); - is(loadedText, "searchterms=" + escape(args.needle.replace(/\s/g, "+")), - "Search text should arrive correctly"); - }); - - Services.search.defaultEngine = currEngine; - try { - Services.search.removeEngine(engine); - } catch (ex) {} - resolve(); - }); - Services.obs.addObserver(searchObserver, "browser-search-engine-modified", false); - Services.search.addEngine("http://test:80/browser/browser/base/content/test/general/POSTSearchEngine.xml", - null, null, false); - }); - }); -}); - -add_task(function* () { - info("Make sure that a page can't imitate about:home"); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) { - let promise = BrowserTestUtils.browserLoaded(browser); - browser.loadURI("https://example.com/browser/browser/base/content/test/general/test_bug959531.html"); - yield promise; - - yield ContentTask.spawn(browser, null, function* () { - let button = content.document.getElementById("settings"); - ok(button, "Found settings button in test page"); - button.click(); - }); - - yield new Promise(resolve => { - // It may take a few turns of the event loop before the window - // is displayed, so we wait. - function check(n) { - let win = Services.wm.getMostRecentWindow("Browser:Preferences"); - ok(!win, "Preferences window not showing"); - if (win) { - win.close(); - } - - if (n > 0) { - executeSoon(() => check(n-1)); - } else { - resolve(); - } - } - - check(5); - }); - }); -}); - -add_task(function* () { - // See browser_contentSearchUI.js for comprehensive content search UI tests. - info("Search suggestion smoke test"); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) { - // Add a test engine that provides suggestions and switch to it. - let currEngine = Services.search.currentEngine; - let engine = yield promiseNewEngine("searchSuggestionEngine.xml"); - let p = promiseContentSearchChange(browser, engine.name); - Services.search.currentEngine = engine; - yield p; - - yield ContentTask.spawn(browser, null, function* () { - // Avoid intermittent failures. - content.wrappedJSObject.gContentSearchController.remoteTimeout = 5000; - - // Type an X in the search input. - let input = content.document.getElementById("searchText"); - input.focus(); - }); - - yield BrowserTestUtils.synthesizeKey("x", {}, browser); - - yield ContentTask.spawn(browser, null, function* () { - // Wait for the search suggestions to become visible. - let table = content.document.getElementById("searchSuggestionTable"); - let input = content.document.getElementById("searchText"); - - yield new Promise(resolve => { - let observer = new content.MutationObserver(() => { - if (input.getAttribute("aria-expanded") == "true") { - observer.disconnect(); - ok(!table.hidden, "Search suggestion table unhidden"); - resolve(); - } - }); - observer.observe(input, { - attributes: true, - attributeFilter: ["aria-expanded"], - }); - }); - }); - - // Empty the search input, causing the suggestions to be hidden. - yield BrowserTestUtils.synthesizeKey("a", { accelKey: true }, browser); - yield BrowserTestUtils.synthesizeKey("VK_DELETE", {}, browser); - - yield ContentTask.spawn(browser, null, function* () { - let table = content.document.getElementById("searchSuggestionTable"); - yield ContentTaskUtils.waitForCondition(() => table.hidden, - "Search suggestion table hidden"); - }); - - Services.search.currentEngine = currEngine; - try { - Services.search.removeEngine(engine); - } catch (ex) { } - }); -}); - -add_task(function* () { - info("Clicking suggestion list while composing"); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) { - // Add a test engine that provides suggestions and switch to it. - let currEngine = Services.search.currentEngine; - let engine = yield promiseNewEngine("searchSuggestionEngine.xml"); - let p = promiseContentSearchChange(browser, engine.name); - Services.search.currentEngine = engine; - yield p; - - yield ContentTask.spawn(browser, null, function* () { - // Start composition and type "x" - let input = content.document.getElementById("searchText"); - input.focus(); - }); - - yield BrowserTestUtils.synthesizeComposition({ - type: "compositionstart", - data: "" - }, browser); - yield BrowserTestUtils.synthesizeCompositionChange({ - composition: { - string: "x", - clauses: [ - { length: 1, attr: Ci.nsITextInputProcessor.ATTR_RAW_CLAUSE } - ] - }, - caret: { start: 1, length: 0 } - }, browser); - - yield ContentTask.spawn(browser, null, function* () { - let searchController = content.wrappedJSObject.gContentSearchController; - - // Wait for the search suggestions to become visible. - let table = searchController._suggestionsList; - let input = content.document.getElementById("searchText"); - - yield new Promise(resolve => { - let observer = new content.MutationObserver(() => { - if (input.getAttribute("aria-expanded") == "true") { - observer.disconnect(); - ok(!table.hidden, "Search suggestion table unhidden"); - resolve(); - } - }); - observer.observe(input, { - attributes: true, - attributeFilter: ["aria-expanded"], - }); - }); - - let row = table.children[1]; - row.setAttribute("id", "TEMPID"); - - // ContentSearchUIController looks at the current selectedIndex when - // performing a search. Synthesizing the mouse event on the suggestion - // doesn't actually mouseover the suggestion and trigger it to be flagged - // as selected, so we manually select it first. - searchController.selectedIndex = 1; - }); - - // Click the second suggestion. - let expectedURL = Services.search.currentEngine - .getSubmission("xbar", null, "homepage").uri.spec; - let loadPromise = waitForDocLoadAndStopIt(expectedURL); - yield BrowserTestUtils.synthesizeMouseAtCenter("#TEMPID", { - button: 0 - }, browser); - yield loadPromise; - - yield ContentTask.spawn(browser, null, function* () { - let input = content.document.getElementById("searchText"); - ok(input.value == "x", "Input value did not change"); - - let row = content.document.getElementById("TEMPID"); - if (row) { - row.removeAttribute("id"); - } - }); - - Services.search.currentEngine = currEngine; - try { - Services.search.removeEngine(engine); - } catch (ex) { } - }); -}); - -add_task(function* () { - info("Pressing any key should focus the search box in the page, and send the key to it"); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) { - yield BrowserTestUtils.synthesizeMouseAtCenter("#brandLogo", {}, browser); - - yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - isnot(doc.getElementById("searchText"), doc.activeElement, - "Search input should not be the active element."); - }); - - yield BrowserTestUtils.synthesizeKey("a", {}, browser); - - yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - let searchInput = doc.getElementById("searchText"); - yield ContentTaskUtils.waitForCondition(() => doc.activeElement === searchInput, - "Search input should be the active element."); - is(searchInput.value, "a", "Search input should be 'a'."); - }); - }); -}); - -add_task(function* () { - info("Cmd+k should focus the search box in the toolbar when it's present"); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) { - yield BrowserTestUtils.synthesizeMouseAtCenter("#brandLogo", {}, browser); - - let doc = window.document; - let searchInput = doc.getElementById("searchbar").textbox.inputField; - isnot(searchInput, doc.activeElement, "Search bar should not be the active element."); - - EventUtils.synthesizeKey("k", { accelKey: true }); - yield promiseWaitForCondition(() => doc.activeElement === searchInput); - is(searchInput, doc.activeElement, "Search bar should be the active element."); - }); -}); - -add_task(function* () { - info("Sync button should open about:preferences#sync"); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) { - let oldOpenPrefs = window.openPreferences; - let openPrefsPromise = new Promise(resolve => { - window.openPreferences = function (pane, params) { - resolve({ pane: pane, params: params }); - }; - }); - - yield BrowserTestUtils.synthesizeMouseAtCenter("#sync", {}, browser); - - let result = yield openPrefsPromise; - window.openPreferences = oldOpenPrefs; - - is(result.pane, "paneSync", "openPreferences should be called with paneSync"); - is(result.params.urlParams.entrypoint, "abouthome", - "openPreferences should be called with abouthome entrypoint"); - }); -}); - -add_task(function* () { - info("Pressing Space while the Addons button is focused should activate it"); - - // Skip this test on Mac, because Space doesn't activate the button there. - if (AppConstants.platform == "macosx") { - return; - } - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) { - info("Waiting for about:addons tab to open..."); - let promiseTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, "about:addons"); - - yield ContentTask.spawn(browser, null, function* () { - let addOnsButton = content.document.getElementById("addons"); - addOnsButton.focus(); - }); - yield BrowserTestUtils.synthesizeKey(" ", {}, browser); - - let tab = yield promiseTabOpened; - is(tab.linkedBrowser.currentURI.spec, "about:addons", - "Should have seen the about:addons tab"); - yield BrowserTestUtils.removeTab(tab); - }); -}); - -/** - * Cleans up snippets and ensures that by default we don't try to check for - * remote snippets since that may cause network bustage or slowness. - * - * @param aSetupFn - * The setup function to be run. - * @param testFn - * the content task to run - * @param testArgs (optional) - * the parameters to pass to the content task - * @param parentFn (optional) - * the function to run in the parent after the content task has completed. - * @return {Promise} resolved when the snippets are ready. Gets the snippets map. - */ -function* withSnippetsMap(setupFn, testFn, testArgs = null, parentFn = null) { - let setupFnSource; - if (setupFn) { - setupFnSource = setupFn.toSource(); - } - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (browser) { - let promiseAfterLocationChange = () => { - return ContentTask.spawn(browser, { - setupFnSource, - version: AboutHomeUtils.snippetsVersion, - }, function* (args) { - return new Promise(resolve => { - let document = content.document; - // We're not using Promise-based listeners, because they resolve asynchronously. - // The snippets test setup code relies on synchronous behaviour here. - document.addEventListener("AboutHomeLoadSnippets", function loadSnippets() { - document.removeEventListener("AboutHomeLoadSnippets", loadSnippets); - - let updateSnippets; - if (args.setupFnSource) { - updateSnippets = eval(`(() => (${args.setupFnSource}))()`); - } - - content.wrappedJSObject.ensureSnippetsMapThen(snippetsMap => { - snippetsMap = Cu.waiveXrays(snippetsMap); - info("Got snippets map: " + - "{ last-update: " + snippetsMap.get("snippets-last-update") + - ", cached-version: " + snippetsMap.get("snippets-cached-version") + - " }"); - // Don't try to update. - snippetsMap.set("snippets-last-update", Date.now()); - snippetsMap.set("snippets-cached-version", args.version); - // Clear snippets. - snippetsMap.delete("snippets"); - - if (updateSnippets) { - updateSnippets(snippetsMap); - } - - // Tack it to the global object - content.gSnippetsMap = snippetsMap; - - resolve(); - }); - }); - }); - }); - }; - - // We'd like to listen to the 'AboutHomeLoadSnippets' event on a fresh - // document as soon as technically possible, so we use webProgress. - let promise = new Promise(resolve => { - let wpl = { - onLocationChange() { - gBrowser.removeProgressListener(wpl); - // Phase 2: retrieving the snippets map is the next promise on our agenda. - promiseAfterLocationChange().then(resolve); - }, - onProgressChange() {}, - onStatusChange() {}, - onSecurityChange() {} - }; - gBrowser.addProgressListener(wpl); - }); - - // Set the URL to 'about:home' here to allow capturing the 'AboutHomeLoadSnippets' - // event. - browser.loadURI("about:home"); - // Wait for LocationChange. - yield promise; - - yield ContentTask.spawn(browser, testArgs, testFn); - if (parentFn) { - yield parentFn(); - } - }); -} - -function promiseContentSearchChange(browser, newEngineName) { - return ContentTask.spawn(browser, { newEngineName }, function* (args) { - return new Promise(resolve => { - content.addEventListener("ContentSearchService", function listener(aEvent) { - if (aEvent.detail.type == "CurrentState" && - content.wrappedJSObject.gContentSearchController.defaultEngine.name == args.newEngineName) { - content.removeEventListener("ContentSearchService", listener); - resolve(); - } - }); - }); - }); -} - -function promiseNewEngine(basename) { - info("Waiting for engine to be added: " + basename); - return new Promise((resolve, reject) => { - let url = getRootDirectory(gTestPath) + basename; - Services.search.addEngine(url, null, "", false, { - onSuccess: function (engine) { - info("Search engine added: " + basename); - registerCleanupFunction(() => { - try { - Services.search.removeEngine(engine); - } catch (ex) { /* Can't remove the engine more than once */ } - }); - resolve(engine); - }, - onError: function (errCode) { - ok(false, "addEngine failed with error code " + errCode); - reject(); - }, - }); - }); -} diff --git a/browser/base/content/test/general/browser_aboutHome_wrapsCorrectly.js b/browser/base/content/test/general/browser_aboutHome_wrapsCorrectly.js deleted file mode 100644 index bfe0fe9c8..000000000 --- a/browser/base/content/test/general/browser_aboutHome_wrapsCorrectly.js +++ /dev/null @@ -1,28 +0,0 @@ -add_task(function* () { - let newWindow = yield BrowserTestUtils.openNewBrowserWindow(); - - let resizedPromise = BrowserTestUtils.waitForEvent(newWindow, "resize"); - newWindow.resizeTo(300, 300); - yield resizedPromise; - - yield BrowserTestUtils.openNewForegroundTab(newWindow.gBrowser, "about:home"); - - yield ContentTask.spawn(newWindow.gBrowser.selectedBrowser, {}, function* () { - Assert.equal(content.document.body.getAttribute("narrow"), "true", "narrow mode"); - }); - - resizedPromise = BrowserTestUtils.waitForContentEvent(newWindow.gBrowser.selectedBrowser, "resize"); - - - yield ContentTask.spawn(newWindow.gBrowser.selectedBrowser, {}, function* () { - content.window.resizeTo(800, 800); - }); - - yield resizedPromise; - - yield ContentTask.spawn(newWindow.gBrowser.selectedBrowser, {}, function* () { - Assert.equal(content.document.body.hasAttribute("narrow"), false, "non-narrow mode"); - }); - - yield BrowserTestUtils.closeWindow(newWindow); -}); diff --git a/browser/base/content/test/general/browser_aboutNetError.js b/browser/base/content/test/general/browser_aboutNetError.js deleted file mode 100644 index 5185cbcaa..000000000 --- a/browser/base/content/test/general/browser_aboutNetError.js +++ /dev/null @@ -1,47 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -// Set ourselves up for TLS error -Services.prefs.setIntPref("security.tls.version.max", 3); -Services.prefs.setIntPref("security.tls.version.min", 3); - -const LOW_TLS_VERSION = "https://tls1.example.com/"; -const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); -const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - -add_task(function* checkReturnToPreviousPage() { - info("Loading a TLS page that isn't supported, ensure we have a fix button and clicking it then loads the page"); - let browser; - let pageLoaded; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => { - gBrowser.selectedTab = gBrowser.addTab(LOW_TLS_VERSION); - browser = gBrowser.selectedBrowser; - pageLoaded = BrowserTestUtils.waitForErrorPage(browser); - }, false); - - info("Loading and waiting for the net error"); - yield pageLoaded; - - // NB: This code assumes that the error page and the test page load in the - // same process. If this test starts to fail, it could be because they load - // in different processes. - yield ContentTask.spawn(browser, LOW_TLS_VERSION, function* (LOW_TLS_VERSION_) { - ok(content.document.getElementById("prefResetButton").getBoundingClientRect().left >= 0, - "Should have a visible button"); - - ok(content.document.documentURI.startsWith("about:neterror"), "Should be showing error page"); - - let doc = content.document; - let prefResetButton = doc.getElementById("prefResetButton"); - is(prefResetButton.getAttribute("autofocus"), "true", "prefResetButton has autofocus"); - prefResetButton.click(); - - yield ContentTaskUtils.waitForEvent(this, "pageshow", true); - - is(content.document.documentURI, LOW_TLS_VERSION_, "Should not be showing page"); - }); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); diff --git a/browser/base/content/test/general/browser_aboutSupport_newtab_security_state.js b/browser/base/content/test/general/browser_aboutSupport_newtab_security_state.js deleted file mode 100644 index e574ba978..000000000 --- a/browser/base/content/test/general/browser_aboutSupport_newtab_security_state.js +++ /dev/null @@ -1,26 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: window.location is null"); - - -add_task(function* checkIdentityOfAboutSupport() { - let tab = gBrowser.loadOneTab("about:support", { - referrerURI: null, - inBackground: false, - allowThirdPartyFixup: false, - relatedToCurrent: false, - skipAnimation: true, - allowMixedContent: false - }); - - yield promiseTabLoaded(tab); - let identityBox = document.getElementById("identity-box"); - is(identityBox.className, "chromeUI", "Should know that we're chrome."); - gBrowser.removeTab(tab); -}); - diff --git a/browser/base/content/test/general/browser_accesskeys.js b/browser/base/content/test/general/browser_accesskeys.js deleted file mode 100644 index 56fe3995f..000000000 --- a/browser/base/content/test/general/browser_accesskeys.js +++ /dev/null @@ -1,82 +0,0 @@ -add_task(function *() { - yield pushPrefs(["ui.key.contentAccess", 5], ["ui.key.chromeAccess", 5]); - - const gPageURL1 = "data:text/html,<body><p>" + - "<button id='button' accesskey='y'>Button</button>" + - "<input id='checkbox' type='checkbox' accesskey='z'>Checkbox" + - "</p></body>"; - let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gPageURL1); - tab1.linkedBrowser.messageManager.loadFrameScript("data:,(" + childHandleFocus.toString() + ")();", false); - - Services.focus.clearFocus(window); - - // Press an accesskey in the child document while the chrome is focused. - let focusedId = yield performAccessKey("y"); - is(focusedId, "button", "button accesskey"); - - // Press an accesskey in the child document while the content document is focused. - focusedId = yield performAccessKey("z"); - is(focusedId, "checkbox", "checkbox accesskey"); - - // Add an element with an accesskey to the chrome and press its accesskey while the chrome is focused. - let newButton = document.createElement("button"); - newButton.id = "chromebutton"; - newButton.setAttribute("accesskey", "z"); - document.documentElement.appendChild(newButton); - - Services.focus.clearFocus(window); - - focusedId = yield performAccessKeyForChrome("z"); - is(focusedId, "chromebutton", "chromebutton accesskey"); - - // Add a second tab and ensure that accesskey from the first tab is not used. - const gPageURL2 = "data:text/html,<body>" + - "<button id='tab2button' accesskey='y'>Button in Tab 2</button>" + - "</body>"; - let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gPageURL2); - tab2.linkedBrowser.messageManager.loadFrameScript("data:,(" + childHandleFocus.toString() + ")();", false); - - Services.focus.clearFocus(window); - - focusedId = yield performAccessKey("y"); - is(focusedId, "tab2button", "button accesskey in tab2"); - - // Press the accesskey for the chrome element while the content document is focused. - focusedId = yield performAccessKeyForChrome("z"); - is(focusedId, "chromebutton", "chromebutton accesskey"); - - newButton.parentNode.removeChild(newButton); - - gBrowser.removeTab(tab1); - gBrowser.removeTab(tab2); -}); - -function childHandleFocus() { - content.document.body.firstChild.addEventListener("focus", function focused(event) { - let focusedElement = content.document.activeElement; - focusedElement.blur(); - sendAsyncMessage("Test:FocusFromAccessKey", { focus: focusedElement.id }) - }, true); -} - -function performAccessKey(key) -{ - return new Promise(resolve => { - let mm = gBrowser.selectedBrowser.messageManager; - mm.addMessageListener("Test:FocusFromAccessKey", function listenForFocus(msg) { - mm.removeMessageListener("Test:FocusFromAccessKey", listenForFocus); - resolve(msg.data.focus); - }); - - EventUtils.synthesizeKey(key, { altKey: true, shiftKey: true }); - }); -} - -// This version is used when a chrome elemnt is expected to be found for an accesskey. -function* performAccessKeyForChrome(key, inChild) -{ - let waitFocusChangePromise = BrowserTestUtils.waitForEvent(document, "focus", true); - EventUtils.synthesizeKey(key, { altKey: true, shiftKey: true }); - yield waitFocusChangePromise; - return document.activeElement.id; -} diff --git a/browser/base/content/test/general/browser_addCertException.js b/browser/base/content/test/general/browser_addCertException.js deleted file mode 100644 index e2cf34b47..000000000 --- a/browser/base/content/test/general/browser_addCertException.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -// Test adding a certificate exception by attempting to browse to a site with -// a bad certificate, being redirected to the internal about:certerror page, -// using the button contained therein to load the certificate exception -// dialog, using that to add an exception, and finally successfully visiting -// the site, including showing the right identity box and control center icons. -add_task(function* () { - yield BrowserTestUtils.openNewForegroundTab(gBrowser); - yield loadBadCertPage("https://expired.example.com"); - checkControlPanelIcons(); - let certOverrideService = Cc["@mozilla.org/security/certoverride;1"] - .getService(Ci.nsICertOverrideService); - certOverrideService.clearValidityOverride("expired.example.com", -1); - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -// Check for the correct icons in the identity box and control center. -function checkControlPanelIcons() { - let { gIdentityHandler } = gBrowser.ownerGlobal; - gIdentityHandler._identityBox.click(); - document.getElementById("identity-popup-security-expander").click(); - - is_element_visible(document.getElementById("connection-icon"), "Should see connection icon"); - let connectionIconImage = gBrowser.ownerGlobal - .getComputedStyle(document.getElementById("connection-icon"), "") - .getPropertyValue("list-style-image"); - let securityViewBG = gBrowser.ownerGlobal - .getComputedStyle(document.getElementById("identity-popup-securityView"), "") - .getPropertyValue("background-image"); - let securityContentBG = gBrowser.ownerGlobal - .getComputedStyle(document.getElementById("identity-popup-security-content"), "") - .getPropertyValue("background-image"); - is(connectionIconImage, - "url(\"chrome://browser/skin/connection-mixed-passive-loaded.svg#icon\")", - "Using expected icon image in the identity block"); - is(securityViewBG, - "url(\"chrome://browser/skin/connection-mixed-passive-loaded.svg#icon\")", - "Using expected icon image in the Control Center main view"); - is(securityContentBG, - "url(\"chrome://browser/skin/connection-mixed-passive-loaded.svg#icon\")", - "Using expected icon image in the Control Center subview"); - - gIdentityHandler._identityPopup.hidden = true; -} - diff --git a/browser/base/content/test/general/browser_addKeywordSearch.js b/browser/base/content/test/general/browser_addKeywordSearch.js deleted file mode 100644 index f38050b43..000000000 --- a/browser/base/content/test/general/browser_addKeywordSearch.js +++ /dev/null @@ -1,81 +0,0 @@ -var testData = [ - { desc: "No path", - action: "http://example.com/", - param: "q", - }, - { desc: "With path", - action: "http://example.com/new-path-here/", - param: "q", - }, - { desc: "No action", - action: "", - param: "q", - }, - { desc: "With Query String", - action: "http://example.com/search?oe=utf-8", - param: "q", - }, -]; - -add_task(function*() { - const TEST_URL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL); - - let count = 0; - for (let method of ["GET", "POST"]) { - for (let {desc, action, param } of testData) { - info(`Running ${method} keyword test '${desc}'`); - let id = `keyword-form-${count++}`; - let contextMenu = document.getElementById("contentAreaContextMenu"); - let contextMenuPromise = - BrowserTestUtils.waitForEvent(contextMenu, "popupshown") - .then(() => gContextMenuContentData.popupNode); - - yield ContentTask.spawn(tab.linkedBrowser, - { action, param, method, id }, function* (args) { - let doc = content.document; - let form = doc.createElement("form"); - form.id = args.id; - form.method = args.method; - form.action = args.action; - let element = doc.createElement("input"); - element.setAttribute("type", "text"); - element.setAttribute("name", args.param); - form.appendChild(element); - doc.body.appendChild(form); - }); - - yield BrowserTestUtils.synthesizeMouseAtCenter(`#${id} > input`, - { type : "contextmenu", button : 2 }, - tab.linkedBrowser); - let target = yield contextMenuPromise; - - yield new Promise(resolve => { - let url = action || tab.linkedBrowser.currentURI.spec; - let mm = tab.linkedBrowser.messageManager; - let onMessage = (message) => { - mm.removeMessageListener("ContextMenu:SearchFieldBookmarkData:Result", onMessage); - if (method == "GET") { - ok(message.data.spec.endsWith(`${param}=%s`), - `Check expected url for field named ${param} and action ${action}`); - } else { - is(message.data.spec, url, - `Check expected url for field named ${param} and action ${action}`); - is(message.data.postData, `${param}%3D%25s`, - `Check expected POST data for field named ${param} and action ${action}`); - } - resolve(); - }; - mm.addMessageListener("ContextMenu:SearchFieldBookmarkData:Result", onMessage); - - mm.sendAsyncMessage("ContextMenu:SearchFieldBookmarkData", null, { target }); - }); - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden"); - contextMenu.hidePopup(); - yield popupHiddenPromise; - } - } - - yield BrowserTestUtils.removeTab(tab); -}); diff --git a/browser/base/content/test/general/browser_alltabslistener.js b/browser/base/content/test/general/browser_alltabslistener.js deleted file mode 100644 index a56473ec9..000000000 --- a/browser/base/content/test/general/browser_alltabslistener.js +++ /dev/null @@ -1,206 +0,0 @@ -var Ci = Components.interfaces; - -const gCompleteState = Ci.nsIWebProgressListener.STATE_STOP + - Ci.nsIWebProgressListener.STATE_IS_NETWORK; - -var gFrontProgressListener = { - onProgressChange: function (aWebProgress, aRequest, - aCurSelfProgress, aMaxSelfProgress, - aCurTotalProgress, aMaxTotalProgress) { - }, - - onStateChange: function (aWebProgress, aRequest, aStateFlags, aStatus) { - var state = "onStateChange"; - info("FrontProgress: " + state + " 0x" + aStateFlags.toString(16)); - ok(gFrontNotificationsPos < gFrontNotifications.length, "Got an expected notification for the front notifications listener"); - is(state, gFrontNotifications[gFrontNotificationsPos], "Got a notification for the front notifications listener"); - gFrontNotificationsPos++; - }, - - onLocationChange: function (aWebProgress, aRequest, aLocationURI, aFlags) { - var state = "onLocationChange"; - info("FrontProgress: " + state + " " + aLocationURI.spec); - ok(gFrontNotificationsPos < gFrontNotifications.length, "Got an expected notification for the front notifications listener"); - is(state, gFrontNotifications[gFrontNotificationsPos], "Got a notification for the front notifications listener"); - gFrontNotificationsPos++; - }, - - onStatusChange: function (aWebProgress, aRequest, aStatus, aMessage) { - }, - - onSecurityChange: function (aWebProgress, aRequest, aState) { - var state = "onSecurityChange"; - info("FrontProgress: " + state + " 0x" + aState.toString(16)); - ok(gFrontNotificationsPos < gFrontNotifications.length, "Got an expected notification for the front notifications listener"); - is(state, gFrontNotifications[gFrontNotificationsPos], "Got a notification for the front notifications listener"); - gFrontNotificationsPos++; - } -} - -var gAllProgressListener = { - onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) { - var state = "onStateChange"; - info("AllProgress: " + state + " 0x" + aStateFlags.toString(16)); - ok(aBrowser == gTestBrowser, state + " notification came from the correct browser"); - ok(gAllNotificationsPos < gAllNotifications.length, "Got an expected notification for the all notifications listener"); - is(state, gAllNotifications[gAllNotificationsPos], "Got a notification for the all notifications listener"); - gAllNotificationsPos++; - - if ((aStateFlags & gCompleteState) == gCompleteState) { - ok(gAllNotificationsPos == gAllNotifications.length, "Saw the expected number of notifications"); - ok(gFrontNotificationsPos == gFrontNotifications.length, "Saw the expected number of frontnotifications"); - executeSoon(gNextTest); - } - }, - - onLocationChange: function (aBrowser, aWebProgress, aRequest, aLocationURI, - aFlags) { - var state = "onLocationChange"; - info("AllProgress: " + state + " " + aLocationURI.spec); - ok(aBrowser == gTestBrowser, state + " notification came from the correct browser"); - ok(gAllNotificationsPos < gAllNotifications.length, "Got an expected notification for the all notifications listener"); - is(state, gAllNotifications[gAllNotificationsPos], "Got a notification for the all notifications listener"); - gAllNotificationsPos++; - }, - - onStatusChange: function (aBrowser, aWebProgress, aRequest, aStatus, aMessage) { - var state = "onStatusChange"; - ok(aBrowser == gTestBrowser, state + " notification came from the correct browser"); - }, - - onSecurityChange: function (aBrowser, aWebProgress, aRequest, aState) { - var state = "onSecurityChange"; - info("AllProgress: " + state + " 0x" + aState.toString(16)); - ok(aBrowser == gTestBrowser, state + " notification came from the correct browser"); - ok(gAllNotificationsPos < gAllNotifications.length, "Got an expected notification for the all notifications listener"); - is(state, gAllNotifications[gAllNotificationsPos], "Got a notification for the all notifications listener"); - gAllNotificationsPos++; - } -} - -var gFrontNotifications, gAllNotifications, gFrontNotificationsPos, gAllNotificationsPos; -var gBackgroundTab, gForegroundTab, gBackgroundBrowser, gForegroundBrowser, gTestBrowser; -var gTestPage = "/browser/browser/base/content/test/general/alltabslistener.html"; -const kBasePage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; -var gNextTest; - -function test() { - waitForExplicitFinish(); - - gBackgroundTab = gBrowser.addTab(); - gForegroundTab = gBrowser.addTab(); - gBackgroundBrowser = gBrowser.getBrowserForTab(gBackgroundTab); - gForegroundBrowser = gBrowser.getBrowserForTab(gForegroundTab); - gBrowser.selectedTab = gForegroundTab; - - // We must wait until a page has completed loading before - // starting tests or we get notifications from that - let promises = [ - waitForDocLoadComplete(gBackgroundBrowser), - waitForDocLoadComplete(gForegroundBrowser) - ]; - gBackgroundBrowser.loadURI(kBasePage); - gForegroundBrowser.loadURI(kBasePage); - Promise.all(promises).then(startTest1); -} - -function runTest(browser, url, next) { - gFrontNotificationsPos = 0; - gAllNotificationsPos = 0; - gNextTest = next; - gTestBrowser = browser; - browser.loadURI(url); -} - -function startTest1() { - info("\nTest 1"); - gBrowser.addProgressListener(gFrontProgressListener); - gBrowser.addTabsProgressListener(gAllProgressListener); - - gAllNotifications = [ - "onStateChange", - "onLocationChange", - "onSecurityChange", - "onStateChange" - ]; - gFrontNotifications = gAllNotifications; - runTest(gForegroundBrowser, "http://example.org" + gTestPage, startTest2); -} - -function startTest2() { - info("\nTest 2"); - gAllNotifications = [ - "onStateChange", - "onLocationChange", - "onSecurityChange", - "onSecurityChange", - "onStateChange" - ]; - gFrontNotifications = gAllNotifications; - runTest(gForegroundBrowser, "https://example.com" + gTestPage, startTest3); -} - -function startTest3() { - info("\nTest 3"); - gAllNotifications = [ - "onStateChange", - "onLocationChange", - "onSecurityChange", - "onStateChange" - ]; - gFrontNotifications = []; - runTest(gBackgroundBrowser, "http://example.org" + gTestPage, startTest4); -} - -function startTest4() { - info("\nTest 4"); - gAllNotifications = [ - "onStateChange", - "onLocationChange", - "onSecurityChange", - "onSecurityChange", - "onStateChange" - ]; - gFrontNotifications = []; - runTest(gBackgroundBrowser, "https://example.com" + gTestPage, startTest5); -} - -function startTest5() { - info("\nTest 5"); - // Switch the foreground browser - [gForegroundBrowser, gBackgroundBrowser] = [gBackgroundBrowser, gForegroundBrowser]; - [gForegroundTab, gBackgroundTab] = [gBackgroundTab, gForegroundTab]; - // Avoid the onLocationChange this will fire - gBrowser.removeProgressListener(gFrontProgressListener); - gBrowser.selectedTab = gForegroundTab; - gBrowser.addProgressListener(gFrontProgressListener); - - gAllNotifications = [ - "onStateChange", - "onLocationChange", - "onSecurityChange", - "onStateChange" - ]; - gFrontNotifications = gAllNotifications; - runTest(gForegroundBrowser, "http://example.org" + gTestPage, startTest6); -} - -function startTest6() { - info("\nTest 6"); - gAllNotifications = [ - "onStateChange", - "onLocationChange", - "onSecurityChange", - "onStateChange" - ]; - gFrontNotifications = []; - runTest(gBackgroundBrowser, "http://example.org" + gTestPage, finishTest); -} - -function finishTest() { - gBrowser.removeProgressListener(gFrontProgressListener); - gBrowser.removeTabsProgressListener(gAllProgressListener); - gBrowser.removeTab(gBackgroundTab); - gBrowser.removeTab(gForegroundTab); - finish(); -} diff --git a/browser/base/content/test/general/browser_audioTabIcon.js b/browser/base/content/test/general/browser_audioTabIcon.js deleted file mode 100644 index 4d7a7bbd8..000000000 --- a/browser/base/content/test/general/browser_audioTabIcon.js +++ /dev/null @@ -1,504 +0,0 @@ -const PAGE = "https://example.com/browser/browser/base/content/test/general/file_mediaPlayback.html"; -const TABATTR_REMOVAL_PREFNAME = "browser.tabs.delayHidingAudioPlayingIconMS"; -const INITIAL_TABATTR_REMOVAL_DELAY_MS = Services.prefs.getIntPref(TABATTR_REMOVAL_PREFNAME); - -function* wait_for_tab_playing_event(tab, expectPlaying) { - if (tab.soundPlaying == expectPlaying) { - ok(true, "The tab should " + (expectPlaying ? "" : "not ") + "be playing"); - return true; - } - return yield BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => { - if (event.detail.changed.includes("soundplaying")) { - is(tab.hasAttribute("soundplaying"), expectPlaying, "The tab should " + (expectPlaying ? "" : "not ") + "be playing"); - is(tab.soundPlaying, expectPlaying, "The tab should " + (expectPlaying ? "" : "not ") + "be playing"); - return true; - } - return false; - }); -} - -function* play(tab) { - let browser = tab.linkedBrowser; - yield ContentTask.spawn(browser, {}, function* () { - let audio = content.document.querySelector("audio"); - audio.play(); - }); - - yield wait_for_tab_playing_event(tab, true); -} - -function* pause(tab, options) { - ok(tab.hasAttribute("soundplaying"), "The tab should have the soundplaying attribute when pause() is called"); - - let extendedDelay = options && options.extendedDelay; - if (extendedDelay) { - // Use 10s to remove possibility of race condition with attr removal. - Services.prefs.setIntPref(TABATTR_REMOVAL_PREFNAME, 10000); - } - - try { - let browser = tab.linkedBrowser; - let awaitDOMAudioPlaybackStopped = - BrowserTestUtils.waitForEvent(browser, "DOMAudioPlaybackStopped", "DOMAudioPlaybackStopped event should get fired after pause"); - let awaitTabPausedAttrModified = - wait_for_tab_playing_event(tab, false); - yield ContentTask.spawn(browser, {}, function* () { - let audio = content.document.querySelector("audio"); - audio.pause(); - }); - - if (extendedDelay) { - ok(tab.hasAttribute("soundplaying"), "The tab should still have the soundplaying attribute immediately after pausing"); - - yield awaitDOMAudioPlaybackStopped; - ok(tab.hasAttribute("soundplaying"), "The tab should still have the soundplaying attribute immediately after DOMAudioPlaybackStopped"); - } - - yield awaitTabPausedAttrModified; - ok(!tab.hasAttribute("soundplaying"), "The tab should not have the soundplaying attribute after the timeout has resolved"); - } finally { - // Make sure other tests don't timeout if an exception gets thrown above. - // Need to use setIntPref instead of clearUserPref because prefs_general.js - // overrides the default value to help this and other tests run faster. - Services.prefs.setIntPref(TABATTR_REMOVAL_PREFNAME, INITIAL_TABATTR_REMOVAL_DELAY_MS); - } -} - -function disable_non_test_mouse(disable) { - let utils = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils); - utils.disableNonTestMouseEvents(disable); -} - -function* hover_icon(icon, tooltip) { - disable_non_test_mouse(true); - - let popupShownPromise = BrowserTestUtils.waitForEvent(tooltip, "popupshown"); - EventUtils.synthesizeMouse(icon, 1, 1, {type: "mouseover"}); - EventUtils.synthesizeMouse(icon, 2, 2, {type: "mousemove"}); - EventUtils.synthesizeMouse(icon, 3, 3, {type: "mousemove"}); - EventUtils.synthesizeMouse(icon, 4, 4, {type: "mousemove"}); - return popupShownPromise; -} - -function leave_icon(icon) { - EventUtils.synthesizeMouse(icon, 0, 0, {type: "mouseout"}); - EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"}); - EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"}); - EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"}); - - disable_non_test_mouse(false); -} - -function* test_tooltip(icon, expectedTooltip, isActiveTab) { - let tooltip = document.getElementById("tabbrowser-tab-tooltip"); - - yield hover_icon(icon, tooltip); - if (isActiveTab) { - // The active tab should have the keybinding shortcut in the tooltip. - // We check this by ensuring that the strings are not equal but the expected - // message appears in the beginning. - isnot(tooltip.getAttribute("label"), expectedTooltip, "Tooltips should not be equal"); - is(tooltip.getAttribute("label").indexOf(expectedTooltip), 0, "Correct tooltip expected"); - } else { - is(tooltip.getAttribute("label"), expectedTooltip, "Tooltips should not be equal"); - } - leave_icon(icon); -} - -// The set of tabs which have ever had their mute state changed. -// Used to determine whether the tab should have a muteReason value. -let everMutedTabs = new WeakSet(); - -function get_wait_for_mute_promise(tab, expectMuted) { - return BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, event => { - if (event.detail.changed.includes("muted")) { - is(tab.hasAttribute("muted"), expectMuted, "The tab should " + (expectMuted ? "" : "not ") + "be muted"); - is(tab.muted, expectMuted, "The tab muted property " + (expectMuted ? "" : "not ") + "be true"); - - if (expectMuted || everMutedTabs.has(tab)) { - everMutedTabs.add(tab); - is(tab.muteReason, null, "The tab should have a null muteReason value"); - } else { - is(tab.muteReason, undefined, "The tab should have an undefined muteReason value"); - } - return true; - } - return false; - }); -} - -function* test_mute_tab(tab, icon, expectMuted) { - let mutedPromise = test_mute_keybinding(tab, expectMuted); - - let activeTab = gBrowser.selectedTab; - - let tooltip = document.getElementById("tabbrowser-tab-tooltip"); - - yield hover_icon(icon, tooltip); - EventUtils.synthesizeMouseAtCenter(icon, {button: 0}); - leave_icon(icon); - - is(gBrowser.selectedTab, activeTab, "Clicking on mute should not change the currently selected tab"); - - return mutedPromise; -} - -function get_tab_state(tab) { - const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - return JSON.parse(ss.getTabState(tab)); -} - -function* test_muting_using_menu(tab, expectMuted) { - // Show the popup menu - let contextMenu = document.getElementById("tabContextMenu"); - let popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown"); - EventUtils.synthesizeMouseAtCenter(tab, {type: "contextmenu", button: 2}); - yield popupShownPromise; - - // Check the menu - let expectedLabel = expectMuted ? "Unmute Tab" : "Mute Tab"; - let toggleMute = document.getElementById("context_toggleMuteTab"); - is(toggleMute.label, expectedLabel, "Correct label expected"); - is(toggleMute.accessKey, "M", "Correct accessKey expected"); - - is(toggleMute.hasAttribute("muted"), expectMuted, "Should have the correct state for the muted attribute"); - ok(!toggleMute.hasAttribute("soundplaying"), "Should not have the soundplaying attribute"); - - yield play(tab); - - is(toggleMute.hasAttribute("muted"), expectMuted, "Should have the correct state for the muted attribute"); - ok(toggleMute.hasAttribute("soundplaying"), "Should have the soundplaying attribute"); - - yield pause(tab); - - is(toggleMute.hasAttribute("muted"), expectMuted, "Should have the correct state for the muted attribute"); - ok(!toggleMute.hasAttribute("soundplaying"), "Should not have the soundplaying attribute"); - - // Click on the menu and wait for the tab to be muted. - let mutedPromise = get_wait_for_mute_promise(tab, !expectMuted); - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden"); - EventUtils.synthesizeMouseAtCenter(toggleMute, {}); - yield popupHiddenPromise; - yield mutedPromise; -} - -function* test_playing_icon_on_tab(tab, browser, isPinned) { - let icon = document.getAnonymousElementByAttribute(tab, "anonid", - isPinned ? "overlay-icon" : "soundplaying-icon"); - let isActiveTab = tab === gBrowser.selectedTab; - - yield play(tab); - - yield test_tooltip(icon, "Mute tab", isActiveTab); - - ok(!("muted" in get_tab_state(tab)), "No muted attribute should be persisted"); - ok(!("muteReason" in get_tab_state(tab)), "No muteReason property should be persisted"); - - yield test_mute_tab(tab, icon, true); - - ok("muted" in get_tab_state(tab), "Muted attribute should be persisted"); - ok("muteReason" in get_tab_state(tab), "muteReason property should be persisted"); - - yield test_tooltip(icon, "Unmute tab", isActiveTab); - - yield test_mute_tab(tab, icon, false); - - ok(!("muted" in get_tab_state(tab)), "No muted attribute should be persisted"); - ok(!("muteReason" in get_tab_state(tab)), "No muteReason property should be persisted"); - - yield test_tooltip(icon, "Mute tab", isActiveTab); - - yield test_mute_tab(tab, icon, true); - - yield pause(tab); - - ok(tab.hasAttribute("muted") && - !tab.hasAttribute("soundplaying"), "Tab should still be muted but not playing"); - ok(tab.muted && !tab.soundPlaying, "Tab should still be muted but not playing"); - - yield test_tooltip(icon, "Unmute tab", isActiveTab); - - yield test_mute_tab(tab, icon, false); - - ok(!tab.hasAttribute("muted") && - !tab.hasAttribute("soundplaying"), "Tab should not be be muted or playing"); - ok(!tab.muted && !tab.soundPlaying, "Tab should not be be muted or playing"); - - // Make sure it's possible to mute using the context menu. - yield test_muting_using_menu(tab, false); - - // Make sure it's possible to unmute using the context menu. - yield test_muting_using_menu(tab, true); -} - -function* test_swapped_browser_while_playing(oldTab, newBrowser) { - ok(oldTab.hasAttribute("muted"), "Expected the correct muted attribute on the old tab"); - is(oldTab.muteReason, null, "Expected the correct muteReason attribute on the old tab"); - ok(oldTab.hasAttribute("soundplaying"), "Expected the correct soundplaying attribute on the old tab"); - - let newTab = gBrowser.getTabForBrowser(newBrowser); - let AttrChangePromise = BrowserTestUtils.waitForEvent(newTab, "TabAttrModified", false, event => { - return event.detail.changed.includes("soundplaying") && - event.detail.changed.includes("muted"); - }); - - gBrowser.swapBrowsersAndCloseOther(newTab, oldTab); - yield AttrChangePromise; - - ok(newTab.hasAttribute("muted"), "Expected the correct muted attribute on the new tab"); - is(newTab.muteReason, null, "Expected the correct muteReason property on the new tab"); - ok(newTab.hasAttribute("soundplaying"), "Expected the correct soundplaying attribute on the new tab"); - - let icon = document.getAnonymousElementByAttribute(newTab, "anonid", - "soundplaying-icon"); - yield test_tooltip(icon, "Unmute tab", true); -} - -function* test_swapped_browser_while_not_playing(oldTab, newBrowser) { - ok(oldTab.hasAttribute("muted"), "Expected the correct muted attribute on the old tab"); - is(oldTab.muteReason, null, "Expected the correct muteReason property on the old tab"); - ok(!oldTab.hasAttribute("soundplaying"), "Expected the correct soundplaying attribute on the old tab"); - - let newTab = gBrowser.getTabForBrowser(newBrowser); - let AttrChangePromise = BrowserTestUtils.waitForEvent(newTab, "TabAttrModified", false, event => { - return event.detail.changed.includes("muted"); - }); - - let AudioPlaybackPromise = new Promise(resolve => { - let observer = (subject, topic, data) => { - ok(false, "Should not see an audio-playback notification"); - }; - Services.obs.addObserver(observer, "audiochannel-activity-normal", false); - setTimeout(() => { - Services.obs.removeObserver(observer, "audiochannel-activity-normal"); - resolve(); - }, 100); - }); - - gBrowser.swapBrowsersAndCloseOther(newTab, oldTab); - yield AttrChangePromise; - - ok(newTab.hasAttribute("muted"), "Expected the correct muted attribute on the new tab"); - is(newTab.muteReason, null, "Expected the correct muteReason property on the new tab"); - ok(!newTab.hasAttribute("soundplaying"), "Expected the correct soundplaying attribute on the new tab"); - - // Wait to see if an audio-playback event is dispatched. - yield AudioPlaybackPromise; - - ok(newTab.hasAttribute("muted"), "Expected the correct muted attribute on the new tab"); - is(newTab.muteReason, null, "Expected the correct muteReason property on the new tab"); - ok(!newTab.hasAttribute("soundplaying"), "Expected the correct soundplaying attribute on the new tab"); - - let icon = document.getAnonymousElementByAttribute(newTab, "anonid", - "soundplaying-icon"); - yield test_tooltip(icon, "Unmute tab", true); -} - -function* test_browser_swapping(tab, browser) { - // First, test swapping with a playing but muted tab. - yield play(tab); - - let icon = document.getAnonymousElementByAttribute(tab, "anonid", - "soundplaying-icon"); - yield test_mute_tab(tab, icon, true); - - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: "about:blank", - }, function*(newBrowser) { - yield test_swapped_browser_while_playing(tab, newBrowser) - - // Now, test swapping with a muted but not playing tab. - // Note that the tab remains muted, so we only need to pause playback. - tab = gBrowser.getTabForBrowser(newBrowser); - yield pause(tab); - - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: "about:blank", - }, secondAboutBlankBrowser => test_swapped_browser_while_not_playing(tab, secondAboutBlankBrowser)); - }); -} - -function* test_click_on_pinned_tab_after_mute() { - function* taskFn(browser) { - let tab = gBrowser.getTabForBrowser(browser); - - gBrowser.selectedTab = originallySelectedTab; - isnot(tab, gBrowser.selectedTab, "Sanity check, the tab should not be selected!"); - - // Steps to reproduce the bug: - // Pin the tab. - gBrowser.pinTab(tab); - - // Start playback and wait for it to finish. - yield play(tab); - - // Mute the tab. - let icon = document.getAnonymousElementByAttribute(tab, "anonid", "overlay-icon"); - yield test_mute_tab(tab, icon, true); - - // Pause playback and wait for it to finish. - yield pause(tab); - - // Unmute tab. - yield test_mute_tab(tab, icon, false); - - // Now click on the tab. - let image = document.getAnonymousElementByAttribute(tab, "anonid", "tab-icon-image"); - EventUtils.synthesizeMouseAtCenter(image, {button: 0}); - - is(tab, gBrowser.selectedTab, "Tab switch should be successful"); - - // Cleanup. - gBrowser.unpinTab(tab); - gBrowser.selectedTab = originallySelectedTab; - } - - let originallySelectedTab = gBrowser.selectedTab; - - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: PAGE - }, taskFn); -} - -// This test only does something useful in e10s! -function* test_cross_process_load() { - function* taskFn(browser) { - let tab = gBrowser.getTabForBrowser(browser); - - // Start playback and wait for it to finish. - yield play(tab); - - let soundPlayingStoppedPromise = BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, - event => event.detail.changed.includes("soundplaying") - ); - - // Go to a different process. - browser.loadURI("about:"); - yield BrowserTestUtils.browserLoaded(browser); - - yield soundPlayingStoppedPromise; - - ok(!tab.hasAttribute("soundplaying"), "Tab should not be playing sound any more"); - ok(!tab.soundPlaying, "Tab should not be playing sound any more"); - } - - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: PAGE - }, taskFn); -} - -function* test_mute_keybinding() { - function* test_muting_using_keyboard(tab) { - let mutedPromise = get_wait_for_mute_promise(tab, true); - EventUtils.synthesizeKey("m", {ctrlKey: true}); - yield mutedPromise; - mutedPromise = get_wait_for_mute_promise(tab, false); - EventUtils.synthesizeKey("m", {ctrlKey: true}); - yield mutedPromise; - } - function* taskFn(browser) { - let tab = gBrowser.getTabForBrowser(browser); - - // Make sure it's possible to mute before the tab is playing. - yield test_muting_using_keyboard(tab); - - // Start playback and wait for it to finish. - yield play(tab); - - // Make sure it's possible to mute after the tab is playing. - yield test_muting_using_keyboard(tab); - - // Pause playback and wait for it to finish. - yield pause(tab); - - // Make sure things work if the tab is pinned. - gBrowser.pinTab(tab); - - // Make sure it's possible to mute before the tab is playing. - yield test_muting_using_keyboard(tab); - - // Start playback and wait for it to finish. - yield play(tab); - - // Make sure it's possible to mute after the tab is playing. - yield test_muting_using_keyboard(tab); - - gBrowser.unpinTab(tab); - } - - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: PAGE - }, taskFn); -} - -function* test_on_browser(browser) { - let tab = gBrowser.getTabForBrowser(browser); - - // Test the icon in a normal tab. - yield test_playing_icon_on_tab(tab, browser, false); - - gBrowser.pinTab(tab); - - // Test the icon in a pinned tab. - yield test_playing_icon_on_tab(tab, browser, true); - - gBrowser.unpinTab(tab); - - // Retest with another browser in the foreground tab - if (gBrowser.selectedBrowser.currentURI.spec == PAGE) { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: "data:text/html,test" - }, () => test_on_browser(browser)); - } else { - yield test_browser_swapping(tab, browser); - } -} - -function* test_delayed_tabattr_removal() { - function* taskFn(browser) { - let tab = gBrowser.getTabForBrowser(browser); - yield play(tab); - - // Extend the delay to guarantee the soundplaying attribute - // is not removed from the tab when audio is stopped. Without - // the extended delay the attribute could be removed in the - // same tick and the test wouldn't catch that this broke. - yield pause(tab, {extendedDelay: true}); - } - - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: PAGE - }, taskFn); -} - -add_task(function*() { - yield new Promise((resolve) => { - SpecialPowers.pushPrefEnv({"set": [ - ["browser.tabs.showAudioPlayingIcon", true], - ]}, resolve); - }); -}); - -requestLongerTimeout(2); -add_task(function* test_page() { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: PAGE - }, test_on_browser); -}); - -add_task(test_click_on_pinned_tab_after_mute); - -add_task(test_cross_process_load); - -add_task(test_mute_keybinding); - -add_task(test_delayed_tabattr_removal); diff --git a/browser/base/content/test/general/browser_backButtonFitts.js b/browser/base/content/test/general/browser_backButtonFitts.js deleted file mode 100644 index 0e8aeeaee..000000000 --- a/browser/base/content/test/general/browser_backButtonFitts.js +++ /dev/null @@ -1,42 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -add_task(function* () { - let firstLocation = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, firstLocation); - - yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () { - // Push the state before maximizing the window and clicking below. - content.history.pushState("page2", "page2", "page2"); - - // While in the child process, add a listener for the popstate event here. This - // event will fire when the mouse click happens. - content.addEventListener("popstate", function onPopState() { - content.removeEventListener("popstate", onPopState, false); - sendAsyncMessage("Test:PopStateOccurred", { location: content.document.location.href }); - }, false); - }); - - window.maximize(); - - // Find where the nav-bar is vertically. - var navBar = document.getElementById("nav-bar"); - var boundingRect = navBar.getBoundingClientRect(); - var yPixel = boundingRect.top + Math.floor(boundingRect.height / 2); - var xPixel = 0; // Use the first pixel of the screen since it is maximized. - - let resultLocation = yield new Promise(resolve => { - messageManager.addMessageListener("Test:PopStateOccurred", function statePopped(message) { - messageManager.removeMessageListener("Test:PopStateOccurred", statePopped); - resolve(message.data.location); - }); - - EventUtils.synthesizeMouseAtPoint(xPixel, yPixel, {}, window); - }); - - is(resultLocation, firstLocation, "Clicking the first pixel should have navigated back."); - window.restore(); - - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js b/browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js deleted file mode 100644 index 91a4a7e9c..000000000 --- a/browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js +++ /dev/null @@ -1,76 +0,0 @@ -const TEST_PAGE = "http://mochi.test:8888/browser/browser/base/content/test/general/file_double_close_tab.html"; - -var expectingDialog = false; -var wantToClose = true; -var resolveDialogPromise; -function onTabModalDialogLoaded(node) { - ok(expectingDialog, "Should be expecting this dialog."); - expectingDialog = false; - if (wantToClose) { - // This accepts the dialog, closing it - node.Dialog.ui.button0.click(); - } else { - // This keeps the page open - node.Dialog.ui.button1.click(); - } - if (resolveDialogPromise) { - resolveDialogPromise(); - } -} - -SpecialPowers.pushPrefEnv({"set": [["dom.require_user_interaction_for_beforeunload", false]]}); - -// Listen for the dialog being created -Services.obs.addObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded", false); -registerCleanupFunction(() => { - Services.prefs.clearUserPref("browser.tabs.warnOnClose"); - Services.obs.removeObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded"); -}); - -add_task(function* closeLastTabInWindow() { - let newWin = yield promiseOpenAndLoadWindow({}, true); - let firstTab = newWin.gBrowser.selectedTab; - yield promiseTabLoadEvent(firstTab, TEST_PAGE); - let windowClosedPromise = promiseWindowWillBeClosed(newWin); - expectingDialog = true; - // close tab: - document.getAnonymousElementByAttribute(firstTab, "anonid", "close-button").click(); - yield windowClosedPromise; - ok(!expectingDialog, "There should have been a dialog."); - ok(newWin.closed, "Window should be closed."); -}); - -add_task(function* closeWindowWithMultipleTabsIncludingOneBeforeUnload() { - Services.prefs.setBoolPref("browser.tabs.warnOnClose", false); - let newWin = yield promiseOpenAndLoadWindow({}, true); - let firstTab = newWin.gBrowser.selectedTab; - yield promiseTabLoadEvent(firstTab, TEST_PAGE); - yield promiseTabLoadEvent(newWin.gBrowser.addTab(), "http://example.com/"); - let windowClosedPromise = promiseWindowWillBeClosed(newWin); - expectingDialog = true; - newWin.BrowserTryToCloseWindow(); - yield windowClosedPromise; - ok(!expectingDialog, "There should have been a dialog."); - ok(newWin.closed, "Window should be closed."); - Services.prefs.clearUserPref("browser.tabs.warnOnClose"); -}); - -add_task(function* closeWindoWithSingleTabTwice() { - let newWin = yield promiseOpenAndLoadWindow({}, true); - let firstTab = newWin.gBrowser.selectedTab; - yield promiseTabLoadEvent(firstTab, TEST_PAGE); - let windowClosedPromise = promiseWindowWillBeClosed(newWin); - expectingDialog = true; - wantToClose = false; - let firstDialogShownPromise = new Promise((resolve, reject) => { resolveDialogPromise = resolve; }); - document.getAnonymousElementByAttribute(firstTab, "anonid", "close-button").click(); - yield firstDialogShownPromise; - info("Got initial dialog, now trying again"); - expectingDialog = true; - wantToClose = true; - resolveDialogPromise = null; - document.getAnonymousElementByAttribute(firstTab, "anonid", "close-button").click(); - yield windowClosedPromise; - ok(!expectingDialog, "There should have been a dialog."); - ok(newWin.closed, "Window should be closed."); -}); diff --git a/browser/base/content/test/general/browser_blob-channelname.js b/browser/base/content/test/general/browser_blob-channelname.js deleted file mode 100644 index d87e4a896..000000000 --- a/browser/base/content/test/general/browser_blob-channelname.js +++ /dev/null @@ -1,11 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -Cu.import("resource://gre/modules/NetUtil.jsm"); - -function test() { - var file = new File([new Blob(['test'], {type: 'text/plain'})], "test-name"); - var url = URL.createObjectURL(file); - var channel = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true}); - - is(channel.contentDispositionFilename, 'test-name', "filename matches"); -} diff --git a/browser/base/content/test/general/browser_blockHPKP.js b/browser/base/content/test/general/browser_blockHPKP.js deleted file mode 100644 index c0d1233ab..000000000 --- a/browser/base/content/test/general/browser_blockHPKP.js +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -// Test that visiting a site pinned with HPKP headers does not succeed when it -// uses a certificate with a key not in the pinset. This should result in an -// about:neterror page -// Also verify that removal of the HPKP headers succeeds (via HPKP headers) -// and that after removal the visit to the site with the previously -// unauthorized pins succeeds. -// -// This test required three certs to be created in build/pgo/certs: -// 1. A new trusted root: -// a. certutil -S -s "Alternate trusted authority" -s "CN=Alternate Trusted Authority" -t "C,," -x -m 1 -v 120 -n "alternateTrustedAuthority" -Z SHA256 -g 2048 -2 -d . -// b. (export) certutil -L -d . -n "alternateTrustedAuthority" -a -o alternateroot.ca -// (files ended in .ca are added as trusted roots by the mochitest harness) -// 2. A good pinning server cert (signed by the pgo root): -// certutil -S -n "dynamicPinningGood" -s "CN=dynamic-pinning.example.com" -c "pgo temporary ca" -t "P,," -k rsa -g 2048 -Z SHA256 -m 8939454 -v 120 -8 "*.include-subdomains.pinning-dynamic.example.com,*.pinning-dynamic.example.com" -d . -// 3. A certificate with a different issuer, so as to cause a key pinning violation." -// certutil -S -n "dynamicPinningBad" -s "CN=bad.include-subdomains.pinning-dynamic.example.com" -c "alternateTrustedAuthority" -t "P,," -k rsa -g 2048 -Z SHA256 -m 893945439 -v 120 -8 "bad.include-subdomains.pinning-dynamic.example.com" -d . - -const gSSService = Cc["@mozilla.org/ssservice;1"] - .getService(Ci.nsISiteSecurityService); -const gIOService = Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService); - -const kPinningDomain = "include-subdomains.pinning-dynamic.example.com"; -const khpkpPinninEnablePref = "security.cert_pinning.process_headers_from_non_builtin_roots"; -const kpkpEnforcementPref = "security.cert_pinning.enforcement_level"; -const kBadPinningDomain = "bad.include-subdomains.pinning-dynamic.example.com"; -const kURLPath = "/browser/browser/base/content/test/general/pinning_headers.sjs?"; - -function test() { - waitForExplicitFinish(); - // Enable enforcing strict pinning and processing headers from - // non-builtin roots. - Services.prefs.setIntPref(kpkpEnforcementPref, 2); - Services.prefs.setBoolPref(khpkpPinninEnablePref, true); - registerCleanupFunction(function () { - Services.prefs.clearUserPref(kpkpEnforcementPref); - Services.prefs.clearUserPref(khpkpPinninEnablePref); - let uri = gIOService.newURI("https://" + kPinningDomain, null, null); - gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0); - }); - whenNewTabLoaded(window, loadPinningPage); -} - -// Start by making a successful connection to a domain that will pin a site -function loadPinningPage() { - - BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kPinningDomain + kURLPath + "valid").then(function() { - gBrowser.selectedBrowser.addEventListener("load", - successfulPinningPageListener, - true); - }); -} - -// After the site is pinned try to load with a subdomain site that should -// fail to validate -var successfulPinningPageListener = { - handleEvent: function() { - gBrowser.selectedBrowser.removeEventListener("load", this, true); - BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kBadPinningDomain).then(function() { - return promiseErrorPageLoaded(gBrowser.selectedBrowser); - }).then(errorPageLoaded); - } -}; - -// The browser should load about:neterror, when this happens, proceed -// to load the pinning domain again, this time removing the pinning information -function errorPageLoaded() { - ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let textElement = content.document.getElementById("errorShortDescText"); - let text = textElement.innerHTML; - ok(text.indexOf("MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE") > 0, - "Got a pinning error page"); - }).then(function() { - BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kPinningDomain + kURLPath + "zeromaxagevalid").then(function() { - return BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - }).then(pinningRemovalLoaded); - }); -} - -// After the pinning information has been removed (successful load) proceed -// to load again with the invalid pin domain. -function pinningRemovalLoaded() { - BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kBadPinningDomain).then(function() { - return BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - }).then(badPinningPageLoaded); -} - -// Finally, we should successfully load -// https://bad.include-subdomains.pinning-dynamic.example.com. -function badPinningPageLoaded() { - BrowserTestUtils.removeTab(gBrowser.selectedTab).then(function() { - ok(true, "load complete"); - finish(); - }); -} diff --git a/browser/base/content/test/general/browser_bookmark_popup.js b/browser/base/content/test/general/browser_bookmark_popup.js deleted file mode 100644 index c1ddd725e..000000000 --- a/browser/base/content/test/general/browser_bookmark_popup.js +++ /dev/null @@ -1,431 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -"use strict"; - -/** - * Test opening and closing the bookmarks panel. - */ - -let bookmarkPanel = document.getElementById("editBookmarkPanel"); -let bookmarkStar = document.getElementById("bookmarks-menu-button"); -let bookmarkPanelTitle = document.getElementById("editBookmarkPanelTitle"); -let editBookmarkPanelRemoveButtonRect; - -StarUI._closePanelQuickForTesting = true; - -function* test_bookmarks_popup({isNewBookmark, popupShowFn, popupEditFn, - shouldAutoClose, popupHideFn, isBookmarkRemoved}) { - yield BrowserTestUtils.withNewTab({gBrowser, url: "about:home"}, function*(browser) { - try { - if (!isNewBookmark) { - yield PlacesUtils.bookmarks.insert({ - parentGuid: PlacesUtils.bookmarks.unfiledGuid, - url: "about:home", - title: "Home Page" - }); - } - - info(`BookmarkingUI.status is ${BookmarkingUI.status}`); - yield BrowserTestUtils.waitForCondition( - () => BookmarkingUI.status != BookmarkingUI.STATUS_UPDATING, - "BookmarkingUI should not be updating"); - - is(bookmarkStar.hasAttribute("starred"), !isNewBookmark, - "Page should only be starred prior to popupshown if editing bookmark"); - is(bookmarkPanel.state, "closed", "Panel should be 'closed' to start test"); - let shownPromise = promisePopupShown(bookmarkPanel); - yield popupShowFn(browser); - yield shownPromise; - is(bookmarkPanel.state, "open", "Panel should be 'open' after shownPromise is resolved"); - - editBookmarkPanelRemoveButtonRect = - document.getElementById("editBookmarkPanelRemoveButton").getBoundingClientRect(); - - if (popupEditFn) { - yield popupEditFn(); - } - let bookmarks = []; - yield PlacesUtils.bookmarks.fetch({url: "about:home"}, bm => bookmarks.push(bm)); - is(bookmarks.length, 1, "Only one bookmark should exist"); - is(bookmarkStar.getAttribute("starred"), "true", "Page is starred"); - is(bookmarkPanelTitle.value, - isNewBookmark ? - gNavigatorBundle.getString("editBookmarkPanel.pageBookmarkedTitle") : - gNavigatorBundle.getString("editBookmarkPanel.editBookmarkTitle"), - "title should match isEditingBookmark state"); - - if (!shouldAutoClose) { - yield new Promise(resolve => setTimeout(resolve, 400)); - is(bookmarkPanel.state, "open", "Panel should still be 'open' for non-autoclose"); - } - - let hiddenPromise = promisePopupHidden(bookmarkPanel); - if (popupHideFn) { - yield popupHideFn(); - } - yield hiddenPromise; - is(bookmarkStar.hasAttribute("starred"), !isBookmarkRemoved, - "Page is starred after closing"); - } finally { - let bookmark = yield PlacesUtils.bookmarks.fetch({url: "about:home"}); - is(!!bookmark, !isBookmarkRemoved, - "bookmark should not be present if a panel action should've removed it"); - if (bookmark) { - yield PlacesUtils.bookmarks.remove(bookmark); - } - } - }); -} - -add_task(function* panel_shown_for_new_bookmarks_and_autocloses() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn() { - bookmarkStar.click(); - }, - shouldAutoClose: true, - isBookmarkRemoved: false, - }); -}); - -add_task(function* panel_shown_once_for_doubleclick_on_new_bookmark_star_and_autocloses() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn() { - EventUtils.synthesizeMouse(bookmarkStar, 10, 10, { clickCount: 2 }, - window); - }, - shouldAutoClose: true, - isBookmarkRemoved: false, - }); -}); - -add_task(function* panel_shown_once_for_slow_doubleclick_on_new_bookmark_star_and_autocloses() { - todo(false, "bug 1250267, may need to add some tracking state to " + - "browser-places.js for this."); - return; - - /* - yield test_bookmarks_popup({ - isNewBookmark: true, - *popupShowFn() { - EventUtils.synthesizeMouse(bookmarkStar, 10, 10, window); - yield new Promise(resolve => setTimeout(resolve, 300)); - EventUtils.synthesizeMouse(bookmarkStar, 10, 10, window); - }, - shouldAutoClose: true, - isBookmarkRemoved: false, - }); - */ -}); - -add_task(function* panel_shown_for_keyboardshortcut_on_new_bookmark_star_and_autocloses() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn() { - EventUtils.synthesizeKey("D", {accelKey: true}, window); - }, - shouldAutoClose: true, - isBookmarkRemoved: false, - }); -}); - -add_task(function* panel_shown_for_new_bookmarks_mousemove_mouseout() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn() { - bookmarkStar.click(); - }, - *popupEditFn() { - let mouseMovePromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mousemove"); - EventUtils.synthesizeMouseAtCenter(bookmarkPanel, {type: "mousemove"}); - info("Waiting for mousemove event"); - yield mouseMovePromise; - info("Got mousemove event"); - - yield new Promise(resolve => setTimeout(resolve, 400)); - is(bookmarkPanel.state, "open", "Panel should still be open on mousemove"); - }, - *popupHideFn() { - let mouseOutPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mouseout"); - EventUtils.synthesizeMouse(bookmarkPanel, 0, 0, {type: "mouseout"}); - EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"}); - info("Waiting for mouseout event"); - yield mouseOutPromise; - info("Got mouseout event, should autoclose now"); - }, - shouldAutoClose: false, - isBookmarkRemoved: false, - }); -}); - -add_task(function* panel_shown_for_new_bookmark_no_autoclose_close_with_ESC() { - yield test_bookmarks_popup({ - isNewBookmark: false, - popupShowFn() { - bookmarkStar.click(); - }, - shouldAutoClose: false, - popupHideFn() { - EventUtils.synthesizeKey("VK_ESCAPE", {accelKey: true}, window); - }, - isBookmarkRemoved: false, - }); -}); - -add_task(function* panel_shown_for_editing_no_autoclose_close_with_ESC() { - yield test_bookmarks_popup({ - isNewBookmark: false, - popupShowFn() { - bookmarkStar.click(); - }, - shouldAutoClose: false, - popupHideFn() { - EventUtils.synthesizeKey("VK_ESCAPE", {accelKey: true}, window); - }, - isBookmarkRemoved: false, - }); -}); - -add_task(function* panel_shown_for_new_bookmark_keypress_no_autoclose() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn() { - bookmarkStar.click(); - }, - popupEditFn() { - EventUtils.sendChar("VK_TAB", window); - }, - shouldAutoClose: false, - popupHideFn() { - bookmarkPanel.hidePopup(); - }, - isBookmarkRemoved: false, - }); -}); - - -add_task(function* panel_shown_for_new_bookmark_compositionstart_no_autoclose() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn() { - bookmarkStar.click(); - }, - *popupEditFn() { - let compositionStartPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "compositionstart"); - EventUtils.synthesizeComposition({ type: "compositionstart" }, window); - info("Waiting for compositionstart event"); - yield compositionStartPromise; - info("Got compositionstart event"); - }, - shouldAutoClose: false, - popupHideFn() { - EventUtils.synthesizeComposition({ type: "compositioncommitasis" }); - bookmarkPanel.hidePopup(); - }, - isBookmarkRemoved: false, - }); -}); - -add_task(function* panel_shown_for_new_bookmark_compositionstart_mouseout_no_autoclose() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn() { - bookmarkStar.click(); - }, - *popupEditFn() { - let mouseMovePromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mousemove"); - EventUtils.synthesizeMouseAtCenter(bookmarkPanel, {type: "mousemove"}); - info("Waiting for mousemove event"); - yield mouseMovePromise; - info("Got mousemove event"); - - let compositionStartPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "compositionstart"); - EventUtils.synthesizeComposition({ type: "compositionstart" }, window); - info("Waiting for compositionstart event"); - yield compositionStartPromise; - info("Got compositionstart event"); - - let mouseOutPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mouseout"); - EventUtils.synthesizeMouse(bookmarkPanel, 0, 0, {type: "mouseout"}); - EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"}); - info("Waiting for mouseout event"); - yield mouseOutPromise; - info("Got mouseout event, but shouldn't run autoclose"); - }, - shouldAutoClose: false, - popupHideFn() { - EventUtils.synthesizeComposition({ type: "compositioncommitasis" }); - bookmarkPanel.hidePopup(); - }, - isBookmarkRemoved: false, - }); -}); - -add_task(function* panel_shown_for_new_bookmark_compositionend_no_autoclose() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn() { - bookmarkStar.click(); - }, - *popupEditFn() { - let mouseMovePromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mousemove"); - EventUtils.synthesizeMouseAtCenter(bookmarkPanel, {type: "mousemove"}); - info("Waiting for mousemove event"); - yield mouseMovePromise; - info("Got mousemove event"); - - EventUtils.synthesizeComposition({ type: "compositioncommit", data: "committed text" }); - }, - popupHideFn() { - bookmarkPanel.hidePopup(); - }, - shouldAutoClose: false, - isBookmarkRemoved: false, - }); -}); - -add_task(function* contextmenu_new_bookmark_keypress_no_autoclose() { - yield test_bookmarks_popup({ - isNewBookmark: true, - *popupShowFn(browser) { - let contextMenu = document.getElementById("contentAreaContextMenu"); - let awaitPopupShown = BrowserTestUtils.waitForEvent(contextMenu, - "popupshown"); - let awaitPopupHidden = BrowserTestUtils.waitForEvent(contextMenu, - "popuphidden"); - yield BrowserTestUtils.synthesizeMouseAtCenter("body", { - type: "contextmenu", - button: 2 - }, browser); - yield awaitPopupShown; - document.getElementById("context-bookmarkpage").click(); - contextMenu.hidePopup(); - yield awaitPopupHidden; - }, - popupEditFn() { - EventUtils.sendChar("VK_TAB", window); - }, - shouldAutoClose: false, - popupHideFn() { - bookmarkPanel.hidePopup(); - }, - isBookmarkRemoved: false, - }); -}); - -add_task(function* bookmarks_menu_new_bookmark_remove_bookmark() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn(browser) { - document.getElementById("menu_bookmarkThisPage").doCommand(); - }, - shouldAutoClose: true, - popupHideFn() { - document.getElementById("editBookmarkPanelRemoveButton").click(); - }, - isBookmarkRemoved: true, - }); -}); - -add_task(function* ctrl_d_edit_bookmark_remove_bookmark() { - yield test_bookmarks_popup({ - isNewBookmark: false, - popupShowFn(browser) { - EventUtils.synthesizeKey("D", {accelKey: true}, window); - }, - shouldAutoClose: true, - popupHideFn() { - document.getElementById("editBookmarkPanelRemoveButton").click(); - }, - isBookmarkRemoved: true, - }); -}); - -add_task(function* enter_on_remove_bookmark_should_remove_bookmark() { - if (AppConstants.platform == "macosx") { - // "Full Keyboard Access" is disabled by default, and thus doesn't allow - // keyboard navigation to the "Remove Bookmarks" button by default. - return; - } - - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn(browser) { - EventUtils.synthesizeKey("D", {accelKey: true}, window); - }, - shouldAutoClose: true, - popupHideFn() { - while (!document.activeElement || - document.activeElement.id != "editBookmarkPanelRemoveButton") { - EventUtils.sendChar("VK_TAB", window); - } - EventUtils.sendChar("VK_RETURN", window); - }, - isBookmarkRemoved: true, - }); -}); - -add_task(function* ctrl_d_new_bookmark_mousedown_mouseout_no_autoclose() { - yield test_bookmarks_popup({ - isNewBookmark: true, - popupShowFn(browser) { - EventUtils.synthesizeKey("D", {accelKey: true}, window); - }, - *popupEditFn() { - let mouseMovePromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mousemove"); - EventUtils.synthesizeMouseAtCenter(bookmarkPanel, {type: "mousemove"}); - info("Waiting for mousemove event"); - yield mouseMovePromise; - info("Got mousemove event"); - - yield new Promise(resolve => setTimeout(resolve, 400)); - is(bookmarkPanel.state, "open", "Panel should still be open on mousemove"); - - EventUtils.synthesizeMouseAtCenter(bookmarkPanelTitle, {button: 1, type: "mousedown"}); - - let mouseOutPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mouseout"); - EventUtils.synthesizeMouse(bookmarkPanel, 0, 0, {type: "mouseout"}); - EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"}); - info("Waiting for mouseout event"); - yield mouseOutPromise; - }, - shouldAutoClose: false, - popupHideFn() { - document.getElementById("editBookmarkPanelRemoveButton").click(); - }, - isBookmarkRemoved: true, - }); -}); - -add_task(function* mouse_hovering_panel_should_prevent_autoclose() { - if (AppConstants.platform != "win") { - // This test requires synthesizing native mouse movement which is - // best supported on Windows. - return; - } - yield test_bookmarks_popup({ - isNewBookmark: true, - *popupShowFn(browser) { - yield new Promise(resolve => { - EventUtils.synthesizeNativeMouseMove( - document.documentElement, - editBookmarkPanelRemoveButtonRect.left, - editBookmarkPanelRemoveButtonRect.top, - resolve); - }); - EventUtils.synthesizeKey("D", {accelKey: true}, window); - }, - shouldAutoClose: false, - popupHideFn() { - document.getElementById("editBookmarkPanelRemoveButton").click(); - }, - isBookmarkRemoved: true, - }); -}); - -registerCleanupFunction(function() { - delete StarUI._closePanelQuickForTesting; -}); diff --git a/browser/base/content/test/general/browser_bookmark_titles.js b/browser/base/content/test/general/browser_bookmark_titles.js deleted file mode 100644 index 1f7082396..000000000 --- a/browser/base/content/test/general/browser_bookmark_titles.js +++ /dev/null @@ -1,98 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -// This file is tests for the default titles that new bookmarks get. - -var tests = [ - // Common page. - ['http://example.com/browser/browser/base/content/test/general/dummy_page.html', - 'Dummy test page'], - // Data URI. - ['data:text/html;charset=utf-8,<title>test%20data:%20url</title>', - 'test data: url'], - // about:neterror - ['data:application/vnd.mozilla.xul+xml,', - 'data:application/vnd.mozilla.xul+xml,'], - // about:certerror - ['https://untrusted.example.com/somepage.html', - 'https://untrusted.example.com/somepage.html'] -]; - -add_task(function* () { - gBrowser.selectedTab = gBrowser.addTab(); - let browser = gBrowser.selectedBrowser; - browser.stop(); // stop the about:blank load. - - // Test that a bookmark of each URI gets the corresponding default title. - for (let i = 0; i < tests.length; ++i) { - let [uri, title] = tests[i]; - - let promiseLoaded = promisePageLoaded(browser); - BrowserTestUtils.loadURI(browser, uri); - yield promiseLoaded; - yield checkBookmark(uri, title); - } - - // Network failure test: now that dummy_page.html is in history, bookmarking - // it should give the last known page title as the default bookmark title. - - // Simulate a network outage with offline mode. (Localhost is still - // accessible in offline mode, so disable the test proxy as well.) - BrowserOffline.toggleOfflineStatus(); - let proxy = Services.prefs.getIntPref('network.proxy.type'); - Services.prefs.setIntPref('network.proxy.type', 0); - registerCleanupFunction(function () { - BrowserOffline.toggleOfflineStatus(); - Services.prefs.setIntPref('network.proxy.type', proxy); - }); - - // LOAD_FLAGS_BYPASS_CACHE isn't good enough. So clear the cache. - Services.cache2.clear(); - - let [uri, title] = tests[0]; - - let promiseLoaded = promisePageLoaded(browser); - BrowserTestUtils.loadURI(browser, uri); - yield promiseLoaded; - - // The offline mode test is only good if the page failed to load. - yield ContentTask.spawn(browser, null, function() { - is(content.document.documentURI.substring(0, 14), 'about:neterror', - "Offline mode successfully simulated network outage."); - }); - yield checkBookmark(uri, title); - - gBrowser.removeCurrentTab(); -}); - -// Bookmark the current page and confirm that the new bookmark has the expected -// title. (Then delete the bookmark.) -function* checkBookmark(uri, expected_title) { - is(gBrowser.selectedBrowser.currentURI.spec, uri, - "Trying to bookmark the expected uri"); - - let promiseBookmark = promiseOnBookmarkItemAdded(gBrowser.selectedBrowser.currentURI); - PlacesCommandHook.bookmarkCurrentPage(false); - yield promiseBookmark; - - let id = PlacesUtils.getMostRecentBookmarkForURI(PlacesUtils._uri(uri)); - ok(id > 0, "Found the expected bookmark"); - let title = PlacesUtils.bookmarks.getItemTitle(id); - is(title, expected_title, "Bookmark got a good default title."); - - PlacesUtils.bookmarks.removeItem(id); -} - -// BrowserTestUtils.browserLoaded doesn't work for the about pages, so use a -// custom page load listener. -function promisePageLoaded(browser) -{ - return ContentTask.spawn(browser, null, function* () { - yield ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", true, - (event) => { - return event.originalTarget === content.document && - event.target.location.href !== "about:blank" - }); - }); -} diff --git a/browser/base/content/test/general/browser_bug1015721.js b/browser/base/content/test/general/browser_bug1015721.js deleted file mode 100644 index e3e715396..000000000 --- a/browser/base/content/test/general/browser_bug1015721.js +++ /dev/null @@ -1,54 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ -"use strict"; - -const TEST_PAGE = "http://example.org/browser/browser/base/content/test/general/zoom_test.html"; - -var gTab1, gTab2, gLevel1; - -function test() { - waitForExplicitFinish(); - - Task.spawn(function* () { - gTab1 = gBrowser.addTab(); - gTab2 = gBrowser.addTab(); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - yield FullZoomHelper.load(gTab1, TEST_PAGE); - yield FullZoomHelper.load(gTab2, TEST_PAGE); - }).then(zoomTab1, FullZoomHelper.failAndContinue(finish)); -} - -function zoomTab1() { - Task.spawn(function* () { - is(gBrowser.selectedTab, gTab1, "Tab 1 is selected"); - FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1"); - FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1"); - - let browser1 = gBrowser.getBrowserForTab(gTab1); - yield BrowserTestUtils.synthesizeMouse(null, 10, 10, { - wheel: true, ctrlKey: true, deltaY: -1, deltaMode: WheelEvent.DOM_DELTA_LINE - }, browser1); - - info("Waiting for tab 1 to be zoomed"); - yield promiseWaitForCondition(() => { - gLevel1 = ZoomManager.getZoomForBrowser(browser1); - return gLevel1 > 1; - }); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); - FullZoomHelper.zoomTest(gTab2, gLevel1, "Tab 2 should have zoomed along with tab 1"); - }).then(finishTest, FullZoomHelper.failAndContinue(finish)); -} - -function finishTest() { - Task.spawn(function* () { - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - yield FullZoom.reset(); - yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); - yield FullZoom.reset(); - yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); - }).then(finish, FullZoomHelper.failAndContinue(finish)); -} diff --git a/browser/base/content/test/general/browser_bug1045809.js b/browser/base/content/test/general/browser_bug1045809.js deleted file mode 100644 index 63b6b06d5..000000000 --- a/browser/base/content/test/general/browser_bug1045809.js +++ /dev/null @@ -1,68 +0,0 @@ -// Test that the Mixed Content Doorhanger Action to re-enable protection works - -const PREF_ACTIVE = "security.mixed_content.block_active_content"; - -var origBlockActive; - -add_task(function* () { - registerCleanupFunction(function() { - Services.prefs.setBoolPref(PREF_ACTIVE, origBlockActive); - gBrowser.removeCurrentTab(); - }); - - // Store original preferences so we can restore settings after testing - origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE); - - // Make sure mixed content blocking is on - Services.prefs.setBoolPref(PREF_ACTIVE, true); - - var url = - "https://test1.example.com/browser/browser/base/content/test/general/" + - "file_bug1045809_1.html"; - let tab = gBrowser.selectedTab = gBrowser.addTab(); - - // Test 1: mixed content must be blocked - yield promiseTabLoadEvent(tab, url); - yield* test1(gBrowser.getBrowserForTab(tab)); - - yield promiseTabLoadEvent(tab); - // Test 2: mixed content must NOT be blocked - yield* test2(gBrowser.getBrowserForTab(tab)); - - // Test 3: mixed content must be blocked again - yield promiseTabLoadEvent(tab); - yield* test3(gBrowser.getBrowserForTab(tab)); -}); - -function* test1(gTestBrowser) { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - yield ContentTask.spawn(gTestBrowser, null, function() { - var x = content.document.getElementsByTagName("iframe")[0].contentDocument.getElementById("mixedContentContainer"); - is(x, null, "Mixed Content is NOT to be found in Test1"); - }); - - // Disable Mixed Content Protection for the page (and reload) - gIdentityHandler.disableMixedContentProtection(); -} - -function* test2(gTestBrowser) { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false}); - - yield ContentTask.spawn(gTestBrowser, null, function() { - var x = content.document.getElementsByTagName("iframe")[0].contentDocument.getElementById("mixedContentContainer"); - isnot(x, null, "Mixed Content is to be found in Test2"); - }); - - // Re-enable Mixed Content Protection for the page (and reload) - gIdentityHandler.enableMixedContentProtection(); -} - -function* test3(gTestBrowser) { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - yield ContentTask.spawn(gTestBrowser, null, function() { - var x = content.document.getElementsByTagName("iframe")[0].contentDocument.getElementById("mixedContentContainer"); - is(x, null, "Mixed Content is NOT to be found in Test3"); - }); -} diff --git a/browser/base/content/test/general/browser_bug1064280_changeUrlInPinnedTab.js b/browser/base/content/test/general/browser_bug1064280_changeUrlInPinnedTab.js deleted file mode 100644 index 98e0e74db..000000000 --- a/browser/base/content/test/general/browser_bug1064280_changeUrlInPinnedTab.js +++ /dev/null @@ -1,36 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -add_task(function* () { - // Test that changing the URL in a pinned tab works correctly - - let TEST_LINK_INITIAL = "about:"; - let TEST_LINK_CHANGED = "about:support"; - - let appTab = gBrowser.addTab(TEST_LINK_INITIAL); - let browser = appTab.linkedBrowser; - yield BrowserTestUtils.browserLoaded(browser); - - gBrowser.pinTab(appTab); - is(appTab.pinned, true, "Tab was successfully pinned"); - - let initialTabsNo = gBrowser.tabs.length; - - let goButton = document.getElementById("urlbar-go-button"); - gBrowser.selectedTab = appTab; - gURLBar.focus(); - gURLBar.value = TEST_LINK_CHANGED; - - goButton.click(); - yield BrowserTestUtils.browserLoaded(browser); - - is(appTab.linkedBrowser.currentURI.spec, TEST_LINK_CHANGED, - "New page loaded in the app tab"); - is(gBrowser.tabs.length, initialTabsNo, "No additional tabs were opened"); -}); - -registerCleanupFunction(function () { - gBrowser.removeTab(gBrowser.selectedTab); -}); diff --git a/browser/base/content/test/general/browser_bug1261299.js b/browser/base/content/test/general/browser_bug1261299.js deleted file mode 100644 index 673ef2a0a..000000000 --- a/browser/base/content/test/general/browser_bug1261299.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/** - * Tests for Bug 1261299 - * Test that the service menu code path is called properly and the - * current selection (transferable) is cached properly on the parent process. - */ - -add_task(function* test_content_and_chrome_selection() -{ - let testPage = - 'data:text/html,' + - '<textarea id="textarea">Write something here</textarea>'; - let DOMWindowUtils = EventUtils._getDOMWindowUtils(window); - let selectedText; - - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, testPage); - yield BrowserTestUtils.synthesizeMouse("#textarea", 0, 0, {}, gBrowser.selectedBrowser); - yield BrowserTestUtils.synthesizeKey("KEY_ArrowRight", - {shiftKey: true, ctrlKey: true, code: "ArrowRight"}, gBrowser.selectedBrowser); - selectedText = DOMWindowUtils.GetSelectionAsPlaintext(); - is(selectedText, "Write something here", "The macOS services got the selected content text"); - - gURLBar.value = "test.mozilla.org"; - yield gURLBar.focus(); - yield BrowserTestUtils.synthesizeKey("KEY_ArrowRight", - {shiftKey: true, ctrlKey: true, code: "ArrowRight"}, gBrowser.selectedBrowser); - selectedText = DOMWindowUtils.GetSelectionAsPlaintext(); - is(selectedText, "test.mozilla.org", "The macOS services got the selected chrome text"); - - yield BrowserTestUtils.removeTab(tab); -}); - -// Test switching active selection. -// Each tab has a content selection and when you switch to that tab, its selection becomes -// active aka the current selection. -// Expect: The active selection is what is being sent to OSX service menu. - -add_task(function* test_active_selection_switches_properly() -{ - let testPage1 = - 'data:text/html,' + - '<textarea id="textarea">Write something here</textarea>'; - let testPage2 = - 'data:text/html,' + - '<textarea id="textarea">Nothing available</textarea>'; - let DOMWindowUtils = EventUtils._getDOMWindowUtils(window); - let selectedText; - - let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, testPage1); - yield BrowserTestUtils.synthesizeMouse("#textarea", 0, 0, {}, gBrowser.selectedBrowser); - yield BrowserTestUtils.synthesizeKey("KEY_ArrowRight", - {shiftKey: true, ctrlKey: true, code: "ArrowRight"}, gBrowser.selectedBrowser); - - let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, testPage2); - yield BrowserTestUtils.synthesizeMouse("#textarea", 0, 0, {}, gBrowser.selectedBrowser); - yield BrowserTestUtils.synthesizeKey("KEY_ArrowRight", - {shiftKey: true, ctrlKey: true, code: "ArrowRight"}, gBrowser.selectedBrowser); - - yield BrowserTestUtils.switchTab(gBrowser, tab1); - selectedText = DOMWindowUtils.GetSelectionAsPlaintext(); - is(selectedText, "Write something here", "The macOS services got the selected content text"); - - yield BrowserTestUtils.switchTab(gBrowser, tab2); - selectedText = DOMWindowUtils.GetSelectionAsPlaintext(); - is(selectedText, "Nothing available", "The macOS services got the selected content text"); - - yield BrowserTestUtils.removeTab(tab1); - yield BrowserTestUtils.removeTab(tab2); -}); diff --git a/browser/base/content/test/general/browser_bug1297539.js b/browser/base/content/test/general/browser_bug1297539.js deleted file mode 100644 index d7e675437..000000000 --- a/browser/base/content/test/general/browser_bug1297539.js +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/** - * Test for Bug 1297539 - * Test that the content event "pasteTransferable" - * (mozilla::EventMessage::eContentCommandPasteTransferable) - * is handled correctly for plain text and html in the remote case. - * - * Original test test_bug525389.html for command content event - * "pasteTransferable" runs only in the content process. - * This doesn't test the remote case. - * - */ - -"use strict"; - -function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); -} - -function getTransferableFromClipboard(asHTML) { - let trans = Cc["@mozilla.org/widget/transferable;1"]. - createInstance(Ci.nsITransferable); - trans.init(getLoadContext()); - if (asHTML) { - trans.addDataFlavor("text/html"); - } else { - trans.addDataFlavor("text/unicode"); - } - let clip = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard); - clip.getData(trans, Ci.nsIClipboard.kGlobalClipboard); - return trans; -} - -function* cutCurrentSelection(elementQueryString, property, browser) { - // Cut the current selection. - yield BrowserTestUtils.synthesizeKey("x", {accelKey: true}, browser); - - // The editor should be empty after cut. - yield ContentTask.spawn(browser, [elementQueryString, property], - function* ([contentElementQueryString, contentProperty]) { - let element = content.document.querySelector(contentElementQueryString); - is(element[contentProperty], "", - `${contentElementQueryString} should be empty after cut (superkey + x)`); - }); -} - -// Test that you are able to pasteTransferable for plain text -// which is handled by TextEditor::PasteTransferable to paste into the editor. -add_task(function* test_paste_transferable_plain_text() -{ - let testPage = - 'data:text/html,' + - '<textarea id="textarea">Write something here</textarea>'; - - yield BrowserTestUtils.withNewTab(testPage, function* (browser) { - // Select all the content in your editor element. - yield BrowserTestUtils.synthesizeMouse("#textarea", 0, 0, {}, browser); - yield BrowserTestUtils.synthesizeKey("a", {accelKey: true}, browser); - - yield* cutCurrentSelection("#textarea", "value", browser); - - let trans = getTransferableFromClipboard(false); - let DOMWindowUtils = EventUtils._getDOMWindowUtils(window); - DOMWindowUtils.sendContentCommandEvent("pasteTransferable", trans); - - yield ContentTask.spawn(browser, null, function* () { - let textArea = content.document.querySelector('#textarea'); - is(textArea.value, "Write something here", - "Send content command pasteTransferable successful"); - }); - }); -}); - -// Test that you are able to pasteTransferable for html -// which is handled by HTMLEditor::PasteTransferable to paste into the editor. -// -// On Linux, -// BrowserTestUtils.synthesizeKey("a", {accelKey: true}, browser); -// doesn't seem to trigger for contenteditable which is why we use -// Selection to select the contenteditable contents. -add_task(function* test_paste_transferable_html() -{ - let testPage = - 'data:text/html,' + - '<div contenteditable="true"><b>Bold Text</b><i>italics</i></div>'; - - yield BrowserTestUtils.withNewTab(testPage, function* (browser) { - // Select all the content in your editor element. - yield BrowserTestUtils.synthesizeMouse("div", 0, 0, {}, browser); - yield ContentTask.spawn(browser, {}, function* () { - let element = content.document.querySelector("div"); - let selection = content.window.getSelection(); - selection.selectAllChildren(element); - }); - - yield* cutCurrentSelection("div", "textContent", browser); - - let trans = getTransferableFromClipboard(true); - let DOMWindowUtils = EventUtils._getDOMWindowUtils(window); - DOMWindowUtils.sendContentCommandEvent("pasteTransferable", trans); - - yield ContentTask.spawn(browser, null, function* () { - let textArea = content.document.querySelector('div'); - is(textArea.innerHTML, "<b>Bold Text</b><i>italics</i>", - "Send content command pasteTransferable successful"); - }); - }); -}); diff --git a/browser/base/content/test/general/browser_bug1299667.js b/browser/base/content/test/general/browser_bug1299667.js deleted file mode 100644 index 084c8d49f..000000000 --- a/browser/base/content/test/general/browser_bug1299667.js +++ /dev/null @@ -1,71 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -const { addObserver, removeObserver } = Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService); - -function receive(topic) { - return new Promise((resolve, reject) => { - let timeout = setTimeout(() => { - reject(new Error("Timeout")); - }, 90000); - - const observer = { - observe: subject => { - removeObserver(observer, topic); - clearTimeout(timeout); - resolve(subject); - } - }; - addObserver(observer, topic, false); - }); -} - -add_task(function* () { - yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com"); - - yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () { - content.history.pushState({}, "2", "2.html"); - }); - - yield receive("sessionstore-state-write-complete"); - - // Wait for the session data to be flushed before continuing the test - yield new Promise(resolve => SessionStore.getSessionHistory(gBrowser.selectedTab, resolve)); - - let backButton = document.getElementById("back-button"); - let contextMenu = document.getElementById("backForwardMenu"); - - info("waiting for the history menu to open"); - - let popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown"); - EventUtils.synthesizeMouseAtCenter(backButton, {type: "contextmenu", button: 2}); - let event = yield popupShownPromise; - - ok(true, "history menu opened"); - - // Wait for the session data to be flushed before continuing the test - yield new Promise(resolve => SessionStore.getSessionHistory(gBrowser.selectedTab, resolve)); - - is(event.target.children.length, 2, "Two history items"); - - let node = event.target.firstChild; - is(node.getAttribute("uri"), "http://example.com/2.html", "first item uri"); - is(node.getAttribute("index"), "1", "first item index"); - is(node.getAttribute("historyindex"), "0", "first item historyindex"); - - node = event.target.lastChild; - is(node.getAttribute("uri"), "http://example.com/", "second item uri"); - is(node.getAttribute("index"), "0", "second item index"); - is(node.getAttribute("historyindex"), "-1", "second item historyindex"); - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden"); - event.target.hidePopup(); - yield popupHiddenPromise; - info("Hidden popup"); - - let onClose = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabClose"); - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - yield onClose; - info("Tab closed"); -}); diff --git a/browser/base/content/test/general/browser_bug321000.js b/browser/base/content/test/general/browser_bug321000.js deleted file mode 100644 index b30b7101d..000000000 --- a/browser/base/content/test/general/browser_bug321000.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- - * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : - * This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -const kTestString = " hello hello \n world\nworld "; - -var gTests = [ - - { desc: "Urlbar strips newlines and surrounding whitespace", - element: gURLBar, - expected: kTestString.replace(/\s*\n\s*/g, '') - }, - - { desc: "Searchbar replaces newlines with spaces", - element: document.getElementById('searchbar'), - expected: kTestString.replace(/\n/g, ' ') - }, - -]; - -// Test for bug 23485 and bug 321000. -// Urlbar should strip newlines, -// search bar should replace newlines with spaces. -function test() { - waitForExplicitFinish(); - - let cbHelper = Cc["@mozilla.org/widget/clipboardhelper;1"]. - getService(Ci.nsIClipboardHelper); - - // Put a multi-line string in the clipboard. - // Setting the clipboard value is an async OS operation, so we need to poll - // the clipboard for valid data before going on. - waitForClipboard(kTestString, function() { cbHelper.copyString(kTestString); }, - next_test, finish); -} - -function next_test() { - if (gTests.length) - test_paste(gTests.shift()); - else - finish(); -} - -function test_paste(aCurrentTest) { - var element = aCurrentTest.element; - - // Register input listener. - var inputListener = { - test: aCurrentTest, - handleEvent: function(event) { - element.removeEventListener(event.type, this, false); - - is(element.value, this.test.expected, this.test.desc); - - // Clear the field and go to next test. - element.value = ""; - setTimeout(next_test, 0); - } - } - element.addEventListener("input", inputListener, false); - - // Focus the window. - window.focus(); - gBrowser.selectedBrowser.focus(); - - // Focus the element and wait for focus event. - info("About to focus " + element.id); - element.addEventListener("focus", function() { - element.removeEventListener("focus", arguments.callee, false); - executeSoon(function() { - // Pasting is async because the Accel+V codepath ends up going through - // nsDocumentViewer::FireClipboardEvent. - info("Pasting into " + element.id); - EventUtils.synthesizeKey("v", { accelKey: true }); - }); - }, false); - element.focus(); -} diff --git a/browser/base/content/test/general/browser_bug356571.js b/browser/base/content/test/general/browser_bug356571.js deleted file mode 100644 index ab689d0f8..000000000 --- a/browser/base/content/test/general/browser_bug356571.js +++ /dev/null @@ -1,93 +0,0 @@ -// Bug 356571 - loadOneOrMoreURIs gives up if one of the URLs has an unknown protocol - -var Cr = Components.results; -var Cm = Components.manager; - -// Set to true when docShell alerts for unknown protocol error -var didFail = false; - -// Override Alert to avoid blocking the test due to unknown protocol error -const kPromptServiceUUID = "{6cc9c9fe-bc0b-432b-a410-253ef8bcc699}"; -const kPromptServiceContractID = "@mozilla.org/embedcomp/prompt-service;1"; - -// Save original prompt service factory -const kPromptServiceFactory = Cm.getClassObject(Cc[kPromptServiceContractID], - Ci.nsIFactory); - -var fakePromptServiceFactory = { - createInstance: function(aOuter, aIid) { - if (aOuter != null) - throw Cr.NS_ERROR_NO_AGGREGATION; - return promptService.QueryInterface(aIid); - } -}; - -var promptService = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIPromptService]), - alert: function() { - didFail = true; - } -}; - -/* FIXME -Cm.QueryInterface(Ci.nsIComponentRegistrar) - .registerFactory(Components.ID(kPromptServiceUUID), "Prompt Service", - kPromptServiceContractID, fakePromptServiceFactory); -*/ - -const kCompleteState = Ci.nsIWebProgressListener.STATE_STOP + - Ci.nsIWebProgressListener.STATE_IS_NETWORK; - -const kDummyPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; -const kURIs = [ - "bad://www.mozilla.org/", - kDummyPage, - kDummyPage, -]; - -var gProgressListener = { - _runCount: 0, - onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) { - if ((aStateFlags & kCompleteState) == kCompleteState) { - if (++this._runCount != kURIs.length) - return; - // Check we failed on unknown protocol (received an alert from docShell) - ok(didFail, "Correctly failed on unknown protocol"); - // Check we opened all tabs - ok(gBrowser.tabs.length == kURIs.length, "Correctly opened all expected tabs"); - finishTest(); - } - } -} - -function test() { - todo(false, "temp. disabled"); - return; /* FIXME */ - /* - waitForExplicitFinish(); - // Wait for all tabs to finish loading - gBrowser.addTabsProgressListener(gProgressListener); - loadOneOrMoreURIs(kURIs.join("|")); - */ -} - -function finishTest() { - // Unregister the factory so we do not leak - Cm.QueryInterface(Ci.nsIComponentRegistrar) - .unregisterFactory(Components.ID(kPromptServiceUUID), - fakePromptServiceFactory); - - // Restore the original factory - Cm.QueryInterface(Ci.nsIComponentRegistrar) - .registerFactory(Components.ID(kPromptServiceUUID), "Prompt Service", - kPromptServiceContractID, kPromptServiceFactory); - - // Remove the listener - gBrowser.removeTabsProgressListener(gProgressListener); - - // Close opened tabs - for (var i = gBrowser.tabs.length-1; i > 0; i--) - gBrowser.removeTab(gBrowser.tabs[i]); - - finish(); -} diff --git a/browser/base/content/test/general/browser_bug380960.js b/browser/base/content/test/general/browser_bug380960.js deleted file mode 100644 index d6b64543b..000000000 --- a/browser/base/content/test/general/browser_bug380960.js +++ /dev/null @@ -1,11 +0,0 @@ -function test() { - var tab = gBrowser.addTab("about:blank", { skipAnimation: true }); - gBrowser.removeTab(tab); - is(tab.parentNode, null, "tab removed immediately"); - - tab = gBrowser.addTab("about:blank", { skipAnimation: true }); - gBrowser.removeTab(tab, { animate: true }); - gBrowser.removeTab(tab); - is(tab.parentNode, null, "tab removed immediately when calling removeTab again after the animation was kicked off"); -} - diff --git a/browser/base/content/test/general/browser_bug386835.js b/browser/base/content/test/general/browser_bug386835.js deleted file mode 100644 index 1c3ba99c5..000000000 --- a/browser/base/content/test/general/browser_bug386835.js +++ /dev/null @@ -1,89 +0,0 @@ -var gTestPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; -var gTestImage = "http://example.org/browser/browser/base/content/test/general/moz.png"; -var gTab1, gTab2, gTab3; -var gLevel; -const BACK = 0; -const FORWARD = 1; - -function test() { - waitForExplicitFinish(); - - Task.spawn(function* () { - gTab1 = gBrowser.addTab(gTestPage); - gTab2 = gBrowser.addTab(); - gTab3 = gBrowser.addTab(); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - yield FullZoomHelper.load(gTab1, gTestPage); - yield FullZoomHelper.load(gTab2, gTestPage); - }).then(secondPageLoaded, FullZoomHelper.failAndContinue(finish)); -} - -function secondPageLoaded() { - Task.spawn(function* () { - FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1"); - FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1"); - FullZoomHelper.zoomTest(gTab3, 1, "Initial zoom of tab 3 should be 1"); - - // Now have three tabs, two with the test page, one blank. Tab 1 is selected - // Zoom tab 1 - FullZoom.enlarge(); - gLevel = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1)); - - ok(gLevel > 1, "New zoom for tab 1 should be greater than 1"); - FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2"); - FullZoomHelper.zoomTest(gTab3, 1, "Zooming tab 1 should not affect tab 3"); - - yield FullZoomHelper.load(gTab3, gTestPage); - }).then(thirdPageLoaded, FullZoomHelper.failAndContinue(finish)); -} - -function thirdPageLoaded() { - Task.spawn(function* () { - FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed"); - FullZoomHelper.zoomTest(gTab2, 1, "Tab 2 should still not be affected"); - FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should have zoomed as it was loading in the background"); - - // Switching to tab 2 should update its zoom setting. - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); - FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed"); - FullZoomHelper.zoomTest(gTab2, gLevel, "Tab 2 should be zoomed now"); - FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should still be zoomed"); - - yield FullZoomHelper.load(gTab1, gTestImage); - }).then(imageLoaded, FullZoomHelper.failAndContinue(finish)); -} - -function imageLoaded() { - Task.spawn(function* () { - FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 when image was loaded in the background"); - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - FullZoomHelper.zoomTest(gTab1, 1, "Zoom should still be 1 when tab with image is selected"); - }).then(imageZoomSwitch, FullZoomHelper.failAndContinue(finish)); -} - -function imageZoomSwitch() { - Task.spawn(function* () { - yield FullZoomHelper.navigate(BACK); - yield FullZoomHelper.navigate(FORWARD); - FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should not be zoomed when an image loads"); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); - FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should still not be zoomed when deselected"); - }).then(finishTest, FullZoomHelper.failAndContinue(finish)); -} - -var finishTestStarted = false; -function finishTest() { - Task.spawn(function* () { - ok(!finishTestStarted, "finishTest called more than once"); - finishTestStarted = true; - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - yield FullZoom.reset(); - yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); - yield FullZoom.reset(); - yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); - yield FullZoom.reset(); - yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab3); - }).then(finish, FullZoomHelper.failAndContinue(finish)); -} diff --git a/browser/base/content/test/general/browser_bug406216.js b/browser/base/content/test/general/browser_bug406216.js deleted file mode 100644 index e1bd38395..000000000 --- a/browser/base/content/test/general/browser_bug406216.js +++ /dev/null @@ -1,54 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/* - * "TabClose" event is possibly used for closing related tabs of the current. - * "removeTab" method should work correctly even if the number of tabs are - * changed while "TabClose" event. - */ - -var count = 0; -const URIS = ["about:config", - "about:plugins", - "about:buildconfig", - "data:text/html,<title>OK</title>"]; - -function test() { - waitForExplicitFinish(); - URIS.forEach(addTab); -} - -function addTab(aURI, aIndex) { - var tab = gBrowser.addTab(aURI); - if (aIndex == 0) - gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true}); - - tab.linkedBrowser.addEventListener("load", function (event) { - event.currentTarget.removeEventListener("load", arguments.callee, true); - if (++count == URIS.length) - executeSoon(doTabsTest); - }, true); -} - -function doTabsTest() { - is(gBrowser.tabs.length, URIS.length, "Correctly opened all expected tabs"); - - // sample of "close related tabs" feature - gBrowser.tabContainer.addEventListener("TabClose", function (event) { - event.currentTarget.removeEventListener("TabClose", arguments.callee, true); - var closedTab = event.originalTarget; - var scheme = closedTab.linkedBrowser.currentURI.scheme; - Array.slice(gBrowser.tabs).forEach(function (aTab) { - if (aTab != closedTab && aTab.linkedBrowser.currentURI.scheme == scheme) - gBrowser.removeTab(aTab, {skipPermitUnload: true}); - }); - }, true); - - gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true}); - is(gBrowser.tabs.length, 1, "Related tabs are not closed unexpectedly"); - - gBrowser.addTab("about:blank"); - gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true}); - finish(); -} diff --git a/browser/base/content/test/general/browser_bug408415.js b/browser/base/content/test/general/browser_bug408415.js deleted file mode 100644 index d8f80f8be..000000000 --- a/browser/base/content/test/general/browser_bug408415.js +++ /dev/null @@ -1,45 +0,0 @@ -add_task(function* test() { - let testPath = getRootDirectory(gTestPath); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, - function* (tabBrowser) { - const URI = testPath + "file_with_favicon.html"; - const expectedIcon = testPath + "file_generic_favicon.ico"; - - let got_favicon = Promise.defer(); - let listener = { - onLinkIconAvailable(browser, iconURI) { - if (got_favicon && iconURI && browser === tabBrowser) { - got_favicon.resolve(iconURI); - got_favicon = null; - } - } - }; - gBrowser.addTabsProgressListener(listener); - - BrowserTestUtils.loadURI(tabBrowser, URI); - - let iconURI = yield got_favicon.promise; - is(iconURI, expectedIcon, "Correct icon before pushState."); - - got_favicon = Promise.defer(); - got_favicon.promise.then(() => { ok(false, "shouldn't be called"); }, (e) => e); - yield ContentTask.spawn(tabBrowser, null, function() { - content.location.href += "#foo"; - }); - - // We've navigated and shouldn't get a call to onLinkIconAvailable. - TestUtils.executeSoon(() => { - got_favicon.reject(gBrowser.getIcon(gBrowser.getTabForBrowser(tabBrowser))); - }); - try { - yield got_favicon.promise; - } catch (e) { - iconURI = e; - } - is(iconURI, expectedIcon, "Correct icon after pushState."); - - gBrowser.removeTabsProgressListener(listener); - }); -}); - diff --git a/browser/base/content/test/general/browser_bug409481.js b/browser/base/content/test/general/browser_bug409481.js deleted file mode 100644 index 395ad93d4..000000000 --- a/browser/base/content/test/general/browser_bug409481.js +++ /dev/null @@ -1,83 +0,0 @@ -function test() { - waitForExplicitFinish(); - - // XXX This looks a bit odd, but is needed to avoid throwing when removing the - // event listeners below. See bug 310955. - document.getElementById("sidebar").addEventListener("load", delayedOpenUrl, true); - SidebarUI.show("viewWebPanelsSidebar"); -} - -function delayedOpenUrl() { - ok(true, "Ran delayedOpenUrl"); - setTimeout(openPanelUrl, 100); -} - -function openPanelUrl(event) { - ok(!document.getElementById("sidebar-box").hidden, "Sidebar showing"); - - var sidebar = document.getElementById("sidebar"); - var root = sidebar.contentDocument.documentElement; - ok(root.nodeName != "parsererror", "Sidebar is well formed"); - - sidebar.removeEventListener("load", delayedOpenUrl, true); - // XXX See comment above - sidebar.contentDocument.addEventListener("load", delayedRunTest, true); - var url = 'data:text/html,<div%20id="test_bug409481">Content!</div><a id="link" href="http://www.example.com/ctest">Link</a><input id="textbox">'; - sidebar.contentWindow.loadWebPanel(url); -} - -function delayedRunTest() { - ok(true, "Ran delayedRunTest"); - setTimeout(runTest, 100); -} - -function runTest(event) { - var sidebar = document.getElementById("sidebar"); - sidebar.contentDocument.removeEventListener("load", delayedRunTest, true); - - var browser = sidebar.contentDocument.getElementById("web-panels-browser"); - var div = browser && browser.contentDocument.getElementById("test_bug409481"); - ok(div && div.textContent == "Content!", "Sidebar content loaded"); - - var link = browser && browser.contentDocument.getElementById("link"); - sidebar.contentDocument.addEventListener("popupshown", contextMenuOpened, false); - - EventUtils.synthesizeMouseAtCenter(link, { type: "contextmenu", button: 2 }, browser.contentWindow); -} - -function contextMenuOpened() -{ - var sidebar = document.getElementById("sidebar"); - sidebar.contentDocument.removeEventListener("popupshown", contextMenuOpened, false); - - var copyLinkCommand = sidebar.contentDocument.getElementById("context-copylink"); - copyLinkCommand.addEventListener("command", copyLinkCommandExecuted, false); - copyLinkCommand.doCommand(); -} - -function copyLinkCommandExecuted(event) -{ - event.target.removeEventListener("command", copyLinkCommandExecuted, false); - - var sidebar = document.getElementById("sidebar"); - var browser = sidebar.contentDocument.getElementById("web-panels-browser"); - var textbox = browser && browser.contentDocument.getElementById("textbox"); - textbox.focus(); - document.commandDispatcher.getControllerForCommand("cmd_paste").doCommand("cmd_paste"); - is(textbox.value, "http://www.example.com/ctest", "copy link command"); - - sidebar.contentDocument.addEventListener("popuphidden", contextMenuClosed, false); - event.target.parentNode.hidePopup(); -} - -function contextMenuClosed() -{ - var sidebar = document.getElementById("sidebar"); - sidebar.contentDocument.removeEventListener("popuphidden", contextMenuClosed, false); - - SidebarUI.hide(); - - ok(document.getElementById("sidebar-box").hidden, "Sidebar successfully hidden"); - - finish(); -} diff --git a/browser/base/content/test/general/browser_bug409624.js b/browser/base/content/test/general/browser_bug409624.js deleted file mode 100644 index 8e46ec0c2..000000000 --- a/browser/base/content/test/general/browser_bug409624.js +++ /dev/null @@ -1,57 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -XPCOMUtils.defineLazyModuleGetter(this, "FormHistory", - "resource://gre/modules/FormHistory.jsm"); - -add_task(function* test() { - // This test relies on the form history being empty to start with delete - // all the items first. - yield new Promise((resolve, reject) => { - FormHistory.update({ op: "remove" }, - { handleError(error) { - reject(error); - }, - handleCompletion(reason) { - if (!reason) { - resolve(); - } else { - reject(); - } - }, - }); - }); - - let prefService = Cc["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefService); - - let tempScope = {}; - Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://browser/content/sanitize.js", tempScope); - let Sanitizer = tempScope.Sanitizer; - let s = new Sanitizer(); - s.prefDomain = "privacy.cpd."; - let prefBranch = prefService.getBranch(s.prefDomain); - - prefBranch.setBoolPref("cache", false); - prefBranch.setBoolPref("cookies", false); - prefBranch.setBoolPref("downloads", false); - prefBranch.setBoolPref("formdata", true); - prefBranch.setBoolPref("history", false); - prefBranch.setBoolPref("offlineApps", false); - prefBranch.setBoolPref("passwords", false); - prefBranch.setBoolPref("sessions", false); - prefBranch.setBoolPref("siteSettings", false); - - // Sanitize now so we can test the baseline point. - yield s.sanitize(); - ok(!gFindBar.hasTransactions, "pre-test baseline for sanitizer"); - - gFindBar.getElement("findbar-textbox").value = "m"; - ok(gFindBar.hasTransactions, "formdata can be cleared after input"); - - yield s.sanitize(); - is(gFindBar.getElement("findbar-textbox").value, "", "findBar textbox should be empty after sanitize"); - ok(!gFindBar.hasTransactions, "No transactions after sanitize"); -}); diff --git a/browser/base/content/test/general/browser_bug413915.js b/browser/base/content/test/general/browser_bug413915.js deleted file mode 100644 index 86c94c427..000000000 --- a/browser/base/content/test/general/browser_bug413915.js +++ /dev/null @@ -1,62 +0,0 @@ -XPCOMUtils.defineLazyModuleGetter(this, "Feeds", - "resource:///modules/Feeds.jsm"); - -function test() { - var exampleUri = makeURI("http://example.com/"); - var secman = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager); - var principal = secman.createCodebasePrincipal(exampleUri, {}); - - function testIsFeed(aTitle, aHref, aType, aKnown) { - var link = { title: aTitle, href: aHref, type: aType }; - return Feeds.isValidFeed(link, principal, aKnown); - } - - var href = "http://example.com/feed/"; - var atomType = "application/atom+xml"; - var funkyAtomType = " aPPLICAtion/Atom+XML "; - var rssType = "application/rss+xml"; - var funkyRssType = " Application/RSS+XML "; - var rdfType = "application/rdf+xml"; - var texmlType = "text/xml"; - var appxmlType = "application/xml"; - var noRss = "Foo"; - var rss = "RSS"; - - // things that should be valid - ok(testIsFeed(noRss, href, atomType, false) == atomType, - "detect Atom feed"); - ok(testIsFeed(noRss, href, funkyAtomType, false) == atomType, - "clean up and detect Atom feed"); - ok(testIsFeed(noRss, href, rssType, false) == rssType, - "detect RSS feed"); - ok(testIsFeed(noRss, href, funkyRssType, false) == rssType, - "clean up and detect RSS feed"); - - // things that should not be feeds - ok(testIsFeed(noRss, href, rdfType, false) == null, - "should not detect RDF non-feed"); - ok(testIsFeed(rss, href, rdfType, false) == null, - "should not detect RDF feed from type and title"); - ok(testIsFeed(noRss, href, texmlType, false) == null, - "should not detect text/xml non-feed"); - ok(testIsFeed(rss, href, texmlType, false) == null, - "should not detect text/xml feed from type and title"); - ok(testIsFeed(noRss, href, appxmlType, false) == null, - "should not detect application/xml non-feed"); - ok(testIsFeed(rss, href, appxmlType, false) == null, - "should not detect application/xml feed from type and title"); - - // security check only, returns cleaned up type or "application/rss+xml" - ok(testIsFeed(noRss, href, atomType, true) == atomType, - "feed security check should return Atom type"); - ok(testIsFeed(noRss, href, funkyAtomType, true) == atomType, - "feed security check should return cleaned up Atom type"); - ok(testIsFeed(noRss, href, rssType, true) == rssType, - "feed security check should return RSS type"); - ok(testIsFeed(noRss, href, funkyRssType, true) == rssType, - "feed security check should return cleaned up RSS type"); - ok(testIsFeed(noRss, href, "", true) == rssType, - "feed security check without type should return RSS type"); - ok(testIsFeed(noRss, href, "garbage", true) == "garbage", - "feed security check with garbage type should return garbage"); -} diff --git a/browser/base/content/test/general/browser_bug416661.js b/browser/base/content/test/general/browser_bug416661.js deleted file mode 100644 index a37971a34..000000000 --- a/browser/base/content/test/general/browser_bug416661.js +++ /dev/null @@ -1,43 +0,0 @@ -var tabElm, zoomLevel; -function start_test_prefNotSet() { - Task.spawn(function* () { - is(ZoomManager.zoom, 1, "initial zoom level should be 1"); - FullZoom.enlarge(); - - // capture the zoom level to test later - zoomLevel = ZoomManager.zoom; - isnot(zoomLevel, 1, "zoom level should have changed"); - - yield FullZoomHelper.load(gBrowser.selectedTab, "http://mochi.test:8888/browser/browser/base/content/test/general/moz.png"); - }).then(continue_test_prefNotSet, FullZoomHelper.failAndContinue(finish)); -} - -function continue_test_prefNotSet () { - Task.spawn(function* () { - is(ZoomManager.zoom, 1, "zoom level pref should not apply to an image"); - yield FullZoom.reset(); - - yield FullZoomHelper.load(gBrowser.selectedTab, "http://mochi.test:8888/browser/browser/base/content/test/general/zoom_test.html"); - }).then(end_test_prefNotSet, FullZoomHelper.failAndContinue(finish)); -} - -function end_test_prefNotSet() { - Task.spawn(function* () { - is(ZoomManager.zoom, zoomLevel, "the zoom level should have persisted"); - - // Reset the zoom so that other tests have a fresh zoom level - yield FullZoom.reset(); - yield FullZoomHelper.removeTabAndWaitForLocationChange(); - finish(); - }); -} - -function test() { - waitForExplicitFinish(); - - Task.spawn(function* () { - tabElm = gBrowser.addTab(); - yield FullZoomHelper.selectTabAndWaitForLocationChange(tabElm); - yield FullZoomHelper.load(tabElm, "http://mochi.test:8888/browser/browser/base/content/test/general/zoom_test.html"); - }).then(start_test_prefNotSet, FullZoomHelper.failAndContinue(finish)); -} diff --git a/browser/base/content/test/general/browser_bug417483.js b/browser/base/content/test/general/browser_bug417483.js deleted file mode 100644 index 43ff7b917..000000000 --- a/browser/base/content/test/general/browser_bug417483.js +++ /dev/null @@ -1,30 +0,0 @@ -add_task(function* () { - let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, true); - const htmlContent = "data:text/html, <iframe src='data:text/html,text text'></iframe>"; - gBrowser.loadURI(htmlContent); - yield loadedPromise; - - yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* (arg) { - let frame = content.frames[0]; - let sel = frame.getSelection(); - let range = frame.document.createRange(); - let tn = frame.document.body.childNodes[0]; - range.setStart(tn, 4); - range.setEnd(tn, 5); - sel.addRange(range); - frame.focus(); - }); - - let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - - let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown"); - yield BrowserTestUtils.synthesizeMouse("frame", 5, 5, - { type: "contextmenu", button: 2}, gBrowser.selectedBrowser); - yield popupShownPromise; - - ok(document.getElementById("frame-sep").hidden, "'frame-sep' should be hidden if the selection contains only spaces"); - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden"); - contentAreaContextMenu.hidePopup(); - yield popupHiddenPromise; -}); diff --git a/browser/base/content/test/general/browser_bug419612.js b/browser/base/content/test/general/browser_bug419612.js deleted file mode 100644 index 8c34b2d39..000000000 --- a/browser/base/content/test/general/browser_bug419612.js +++ /dev/null @@ -1,32 +0,0 @@ -function test() { - waitForExplicitFinish(); - - Task.spawn(function* () { - let testPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; - let tab1 = gBrowser.addTab(); - yield FullZoomHelper.selectTabAndWaitForLocationChange(tab1); - yield FullZoomHelper.load(tab1, testPage); - - let tab2 = gBrowser.addTab(); - yield FullZoomHelper.load(tab2, testPage); - - FullZoom.enlarge(); - let tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(tab2); - let tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser); - is(tab2Zoom, tab1Zoom, "Zoom should affect background tabs"); - - gPrefService.setBoolPref("browser.zoom.updateBackgroundTabs", false); - yield FullZoom.reset(); - gBrowser.selectedTab = tab1; - tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser); - tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser); - isnot(tab1Zoom, tab2Zoom, "Zoom should not affect background tabs"); - - if (gPrefService.prefHasUserValue("browser.zoom.updateBackgroundTabs")) - gPrefService.clearUserPref("browser.zoom.updateBackgroundTabs"); - yield FullZoomHelper.removeTabAndWaitForLocationChange(tab1); - yield FullZoomHelper.removeTabAndWaitForLocationChange(tab2); - }).then(finish, FullZoomHelper.failAndContinue(finish)); -} diff --git a/browser/base/content/test/general/browser_bug422590.js b/browser/base/content/test/general/browser_bug422590.js deleted file mode 100644 index f26919cc5..000000000 --- a/browser/base/content/test/general/browser_bug422590.js +++ /dev/null @@ -1,50 +0,0 @@ -function test() { - waitForExplicitFinish(); - // test the main (normal) browser window - testCustomize(window, testChromeless); -} - -function testChromeless() { - // test a chromeless window - var newWin = openDialog(getBrowserURL(), "_blank", - "chrome,dialog=no,location=yes,toolbar=no", "about:blank"); - ok(newWin, "got new window"); - - whenDelayedStartupFinished(newWin, function () { - // Check that the search bar is hidden - var searchBar = newWin.BrowserSearch.searchBar; - ok(searchBar, "got search bar"); - - var searchBarBO = searchBar.boxObject; - is(searchBarBO.width, 0, "search bar hidden"); - is(searchBarBO.height, 0, "search bar hidden"); - - testCustomize(newWin, function () { - newWin.close(); - finish(); - }); - }); -} - -function testCustomize(aWindow, aCallback) { - var fileMenu = aWindow.document.getElementById("file-menu"); - ok(fileMenu, "got file menu"); - is(fileMenu.disabled, false, "file menu initially enabled"); - - openToolbarCustomizationUI(function () { - // Can't use the property, since the binding may have since been removed - // if the element is hidden (see bug 422590) - is(fileMenu.getAttribute("disabled"), "true", - "file menu is disabled during toolbar customization"); - - closeToolbarCustomizationUI(onClose, aWindow); - }, aWindow); - - function onClose() { - is(fileMenu.getAttribute("disabled"), "false", - "file menu is enabled after toolbar customization"); - - if (aCallback) - aCallback(); - } -} diff --git a/browser/base/content/test/general/browser_bug423833.js b/browser/base/content/test/general/browser_bug423833.js deleted file mode 100644 index d4069338b..000000000 --- a/browser/base/content/test/general/browser_bug423833.js +++ /dev/null @@ -1,138 +0,0 @@ -/* Tests for proper behaviour of "Show this frame" context menu options */ - -// Two frames, one with text content, the other an error page -var invalidPage = 'http://127.0.0.1:55555/'; -var validPage = 'http://example.com/'; -var testPage = 'data:text/html,<frameset cols="400,400"><frame src="' + validPage + '"><frame src="' + invalidPage + '"></frameset>'; - -// Store the tab and window created in tests 2 and 3 respectively -var test2tab; -var test3window; - -// We use setInterval instead of setTimeout to avoid race conditions on error doc loads -var intervalID; - -function test() { - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", test1Setup, true); - content.location = testPage; -} - -function test1Setup() { - if (content.frames.length < 2 || - content.frames[1].location != invalidPage) - // The error frame hasn't loaded yet - return; - - gBrowser.selectedBrowser.removeEventListener("load", test1Setup, true); - - var badFrame = content.frames[1]; - document.popupNode = badFrame.document.firstChild; - - var contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - var contextMenu = new nsContextMenu(contentAreaContextMenu); - - // We'd like to use another load listener here, but error pages don't fire load events - contextMenu.showOnlyThisFrame(); - intervalID = setInterval(testShowOnlyThisFrame, 3000); -} - -function testShowOnlyThisFrame() { - if (content.location.href == testPage) - // This is a stale event from the original page loading - return; - - // We should now have loaded the error page frame content directly - // in the tab, make sure the URL is right. - clearInterval(intervalID); - - is(content.location.href, invalidPage, "Should navigate to page url, not about:neterror"); - - // Go back to the frames page - gBrowser.addEventListener("load", test2Setup, true); - content.location = testPage; -} - -function test2Setup() { - if (content.frames.length < 2 || - content.frames[1].location != invalidPage) - // The error frame hasn't loaded yet - return; - - gBrowser.removeEventListener("load", test2Setup, true); - - // Now let's do the whole thing again, but this time for "Open frame in new tab" - var badFrame = content.frames[1]; - - document.popupNode = badFrame.document.firstChild; - - var contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - var contextMenu = new nsContextMenu(contentAreaContextMenu); - - gBrowser.tabContainer.addEventListener("TabOpen", function (event) { - test2tab = event.target; - gBrowser.tabContainer.removeEventListener("TabOpen", arguments.callee, false); - }, false); - contextMenu.openFrameInTab(); - ok(test2tab, "openFrameInTab() opened a tab"); - - gBrowser.selectedTab = test2tab; - - intervalID = setInterval(testOpenFrameInTab, 3000); -} - -function testOpenFrameInTab() { - if (gBrowser.contentDocument.location.href == "about:blank") - // Wait another cycle - return; - - clearInterval(intervalID); - - // We should now have the error page in a new, active tab. - is(gBrowser.contentDocument.location.href, invalidPage, "New tab should have page url, not about:neterror"); - - // Clear up the new tab, and punt to test 3 - gBrowser.removeCurrentTab(); - - test3Setup(); -} - -function test3Setup() { - // One more time, for "Open frame in new window" - var badFrame = content.frames[1]; - document.popupNode = badFrame.document.firstChild; - - var contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - var contextMenu = new nsContextMenu(contentAreaContextMenu); - - Services.ww.registerNotification(function (aSubject, aTopic, aData) { - if (aTopic == "domwindowopened") - test3window = aSubject; - Services.ww.unregisterNotification(arguments.callee); - }); - - contextMenu.openFrame(); - - intervalID = setInterval(testOpenFrame, 3000); -} - -function testOpenFrame() { - if (!test3window || test3window.content.location.href == "about:blank") { - info("testOpenFrame: Wait another cycle"); - return; - } - - clearInterval(intervalID); - - is(test3window.content.location.href, invalidPage, "New window should have page url, not about:neterror"); - - test3window.close(); - cleanup(); -} - -function cleanup() { - gBrowser.removeCurrentTab(); - finish(); -} diff --git a/browser/base/content/test/general/browser_bug424101.js b/browser/base/content/test/general/browser_bug424101.js deleted file mode 100644 index 8000d2ae9..000000000 --- a/browser/base/content/test/general/browser_bug424101.js +++ /dev/null @@ -1,52 +0,0 @@ -/* Make sure that the context menu appears on form elements */ - -add_task(function *() { - yield BrowserTestUtils.openNewForegroundTab(gBrowser, "data:text/html,test"); - - let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - - let tests = [ - { element: "input", type: "text" }, - { element: "input", type: "password" }, - { element: "input", type: "image" }, - { element: "input", type: "button" }, - { element: "input", type: "submit" }, - { element: "input", type: "reset" }, - { element: "input", type: "checkbox" }, - { element: "input", type: "radio" }, - { element: "button" }, - { element: "select" }, - { element: "option" }, - { element: "optgroup" } - ]; - - for (let index = 0; index < tests.length; index++) { - let test = tests[index]; - - yield ContentTask.spawn(gBrowser.selectedBrowser, - { element: test.element, type: test.type, index: index }, - function* (arg) { - let element = content.document.createElement(arg.element); - element.id = "element" + arg.index; - if (arg.type) { - element.setAttribute("type", arg.type); - } - content.document.body.appendChild(element); - }); - - let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown"); - yield BrowserTestUtils.synthesizeMouseAtCenter("#element" + index, - { type: "contextmenu", button: 2}, gBrowser.selectedBrowser); - yield popupShownPromise; - - let typeAttr = test.type ? "type=" + test.type + " " : ""; - is(gContextMenu.shouldDisplay, true, - "context menu behavior for <" + test.element + " " + typeAttr + "> is wrong"); - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden"); - contentAreaContextMenu.hidePopup(); - yield popupHiddenPromise; - } - - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_bug427559.js b/browser/base/content/test/general/browser_bug427559.js deleted file mode 100644 index 78cecdefa..000000000 --- a/browser/base/content/test/general/browser_bug427559.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -/* - * Test bug 427559 to make sure focused elements that are no longer on the page - * will have focus transferred to the window when changing tabs back to that - * tab with the now-gone element. - */ - -// Default focus on a button and have it kill itself on blur. -const URL = 'data:text/html;charset=utf-8,' + - '<body><button onblur="this.remove()">' + - '<script>document.body.firstChild.focus()</script></body>'; - -function getFocusedLocalName(browser) { - return ContentTask.spawn(browser, null, function* () { - return content.document.activeElement.localName; - }); -} - -add_task(function* () { - let testTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, URL); - - let browser = testTab.linkedBrowser; - - is((yield getFocusedLocalName(browser)), "button", "button is focused"); - - let blankTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); - - yield BrowserTestUtils.switchTab(gBrowser, testTab); - - // Make sure focus is given to the window because the element is now gone. - is((yield getFocusedLocalName(browser)), "body", "body is focused"); - - // Cleanup. - gBrowser.removeTab(blankTab); - gBrowser.removeCurrentTab(); - -}); diff --git a/browser/base/content/test/general/browser_bug431826.js b/browser/base/content/test/general/browser_bug431826.js deleted file mode 100644 index 592ea9cef..000000000 --- a/browser/base/content/test/general/browser_bug431826.js +++ /dev/null @@ -1,50 +0,0 @@ -function remote(task) { - return ContentTask.spawn(gBrowser.selectedBrowser, null, task); -} - -add_task(function* () { - gBrowser.selectedTab = gBrowser.addTab(); - - let promise = remote(function () { - return ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", true, event => { - return content.document.documentURI != "about:blank"; - }).then(() => 0); // don't want to send the event to the chrome process - }); - gBrowser.loadURI("https://nocert.example.com/"); - yield promise; - - yield remote(() => { - // Confirm that we are displaying the contributed error page, not the default - let uri = content.document.documentURI; - Assert.ok(uri.startsWith("about:certerror"), "Broken page should go to about:certerror, not about:neterror"); - }); - - yield remote(() => { - let div = content.document.getElementById("badCertAdvancedPanel"); - // Confirm that the expert section is collapsed - Assert.ok(div, "Advanced content div should exist"); - Assert.equal(div.ownerGlobal.getComputedStyle(div).display, - "none", "Advanced content should not be visible by default"); - }); - - // Tweak the expert mode pref - gPrefService.setBoolPref("browser.xul.error_pages.expert_bad_cert", true); - - promise = remote(function () { - return ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", true); - }); - gBrowser.reload(); - yield promise; - - yield remote(() => { - let div = content.document.getElementById("badCertAdvancedPanel"); - Assert.ok(div, "Advanced content div should exist"); - Assert.equal(div.ownerGlobal.getComputedStyle(div).display, - "block", "Advanced content should be visible by default"); - }); - - // Clean up - gBrowser.removeCurrentTab(); - if (gPrefService.prefHasUserValue("browser.xul.error_pages.expert_bad_cert")) - gPrefService.clearUserPref("browser.xul.error_pages.expert_bad_cert"); -}); diff --git a/browser/base/content/test/general/browser_bug432599.js b/browser/base/content/test/general/browser_bug432599.js deleted file mode 100644 index a5f7c0b5e..000000000 --- a/browser/base/content/test/general/browser_bug432599.js +++ /dev/null @@ -1,127 +0,0 @@ -function invokeUsingCtrlD(phase) { - switch (phase) { - case 1: - EventUtils.synthesizeKey("d", { accelKey: true }); - break; - case 2: - case 4: - EventUtils.synthesizeKey("VK_ESCAPE", {}); - break; - case 3: - EventUtils.synthesizeKey("d", { accelKey: true }); - EventUtils.synthesizeKey("d", { accelKey: true }); - break; - } -} - -function invokeUsingStarButton(phase) { - switch (phase) { - case 1: - EventUtils.synthesizeMouseAtCenter(BookmarkingUI.star, {}); - break; - case 2: - case 4: - EventUtils.synthesizeKey("VK_ESCAPE", {}); - break; - case 3: - EventUtils.synthesizeMouseAtCenter(BookmarkingUI.star, - { clickCount: 2 }); - break; - } -} - -var testURL = "data:text/plain,Content"; -var bookmarkId; - -function add_bookmark(aURI, aTitle) { - return PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, - aURI, PlacesUtils.bookmarks.DEFAULT_INDEX, - aTitle); -} - -// test bug 432599 -function test() { - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onLoad() { - gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); - waitForStarChange(false, initTest); - }, true); - - content.location = testURL; -} - -function initTest() { - // First, bookmark the page. - bookmarkId = add_bookmark(makeURI(testURL), "Bug 432599 Test"); - - checkBookmarksPanel(invokers[currentInvoker], 1); -} - -function waitForStarChange(aValue, aCallback) { - let expectedStatus = aValue ? BookmarkingUI.STATUS_STARRED - : BookmarkingUI.STATUS_UNSTARRED; - if (BookmarkingUI.status == BookmarkingUI.STATUS_UPDATING || - BookmarkingUI.status != expectedStatus) { - info("Waiting for star button change."); - setTimeout(waitForStarChange, 50, aValue, aCallback); - return; - } - aCallback(); -} - -var invokers = [invokeUsingStarButton, invokeUsingCtrlD]; -var currentInvoker = 0; - -var initialValue; -var initialRemoveHidden; - -var popupElement = document.getElementById("editBookmarkPanel"); -var titleElement = document.getElementById("editBookmarkPanelTitle"); -var removeElement = document.getElementById("editBookmarkPanelRemoveButton"); - -function checkBookmarksPanel(invoker, phase) -{ - let onPopupShown = function(aEvent) { - if (aEvent.originalTarget == popupElement) { - popupElement.removeEventListener("popupshown", arguments.callee, false); - checkBookmarksPanel(invoker, phase + 1); - } - }; - let onPopupHidden = function(aEvent) { - if (aEvent.originalTarget == popupElement) { - popupElement.removeEventListener("popuphidden", arguments.callee, false); - if (phase < 4) { - checkBookmarksPanel(invoker, phase + 1); - } else { - ++currentInvoker; - if (currentInvoker < invokers.length) { - checkBookmarksPanel(invokers[currentInvoker], 1); - } else { - gBrowser.removeTab(gBrowser.selectedTab, {skipPermitUnload: true}); - PlacesUtils.bookmarks.removeItem(bookmarkId); - executeSoon(finish); - } - } - } - }; - - switch (phase) { - case 1: - case 3: - popupElement.addEventListener("popupshown", onPopupShown, false); - break; - case 2: - popupElement.addEventListener("popuphidden", onPopupHidden, false); - initialValue = titleElement.value; - initialRemoveHidden = removeElement.hidden; - break; - case 4: - popupElement.addEventListener("popuphidden", onPopupHidden, false); - is(titleElement.value, initialValue, "The bookmark panel's title should be the same"); - is(removeElement.hidden, initialRemoveHidden, "The bookmark panel's visibility should not change"); - break; - } - invoker(phase); -} diff --git a/browser/base/content/test/general/browser_bug435035.js b/browser/base/content/test/general/browser_bug435035.js deleted file mode 100644 index 7570ef0d7..000000000 --- a/browser/base/content/test/general/browser_bug435035.js +++ /dev/null @@ -1,17 +0,0 @@ -function test() { - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => { - is(document.getElementById("identity-box").className, - "unknownIdentity mixedDisplayContent", - "identity box has class name for mixed content"); - - gBrowser.removeCurrentTab(); - finish(); - }); - - gBrowser.loadURI( - "https://example.com/browser/browser/base/content/test/general/test_bug435035.html" - ); -} diff --git a/browser/base/content/test/general/browser_bug435325.js b/browser/base/content/test/general/browser_bug435325.js deleted file mode 100644 index 2ae15deff..000000000 --- a/browser/base/content/test/general/browser_bug435325.js +++ /dev/null @@ -1,69 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* Ensure that clicking the button in the Offline mode neterror page makes the browser go online. See bug 435325. */ - -var proxyPrefValue; - -function test() { - waitForExplicitFinish(); - - // Go offline and disable the proxy and cache, then try to load the test URL. - Services.io.offline = true; - - // Tests always connect to localhost, and per bug 87717, localhost is now - // reachable in offline mode. To avoid this, disable any proxy. - proxyPrefValue = Services.prefs.getIntPref("network.proxy.type"); - Services.prefs.setIntPref("network.proxy.type", 0); - - Services.prefs.setBoolPref("browser.cache.disk.enable", false); - Services.prefs.setBoolPref("browser.cache.memory.enable", false); - - gBrowser.selectedTab = gBrowser.addTab("http://example.com/"); - - let contentScript = ` - let listener = function () { - removeEventListener("DOMContentLoaded", listener); - sendAsyncMessage("Test:DOMContentLoaded", { uri: content.document.documentURI }); - }; - addEventListener("DOMContentLoaded", listener); - `; - - function pageloaded({ data }) { - mm.removeMessageListener("Test:DOMContentLoaded", pageloaded); - checkPage(data); - } - - let mm = gBrowser.selectedBrowser.messageManager; - mm.addMessageListener("Test:DOMContentLoaded", pageloaded); - mm.loadFrameScript("data:," + contentScript, true); -} - -function checkPage(data) { - ok(Services.io.offline, "Setting Services.io.offline to true."); - - is(data.uri.substring(0, 27), - "about:neterror?e=netOffline", "Loading the Offline mode neterror page."); - - // Re-enable the proxy so example.com is resolved to localhost, rather than - // the actual example.com. - Services.prefs.setIntPref("network.proxy.type", proxyPrefValue); - - Services.obs.addObserver(function observer(aSubject, aTopic) { - ok(!Services.io.offline, "After clicking the Try Again button, we're back " + - "online."); - Services.obs.removeObserver(observer, "network:offline-status-changed", false); - finish(); - }, "network:offline-status-changed", false); - - ContentTask.spawn(gBrowser.selectedBrowser, null, function* () { - content.document.getElementById("errorTryAgain").click(); - }); -} - -registerCleanupFunction(function() { - Services.prefs.setBoolPref("browser.cache.disk.enable", true); - Services.prefs.setBoolPref("browser.cache.memory.enable", true); - Services.io.offline = false; - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_bug441778.js b/browser/base/content/test/general/browser_bug441778.js deleted file mode 100644 index fa938541f..000000000 --- a/browser/base/content/test/general/browser_bug441778.js +++ /dev/null @@ -1,46 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/* - * Test the fix for bug 441778 to ensure site-specific page zoom doesn't get - * modified by sub-document loads of content from a different domain. - */ - -function test() { - waitForExplicitFinish(); - - const TEST_PAGE_URL = 'data:text/html,<body><iframe src=""></iframe></body>'; - const TEST_IFRAME_URL = "http://test2.example.org/"; - - Task.spawn(function* () { - // Prepare the test tab - let tab = gBrowser.addTab(); - yield FullZoomHelper.selectTabAndWaitForLocationChange(tab); - - let testBrowser = tab.linkedBrowser; - - yield FullZoomHelper.load(tab, TEST_PAGE_URL); - - // Change the zoom level and then save it so we can compare it to the level - // after loading the sub-document. - FullZoom.enlarge(); - var zoomLevel = ZoomManager.zoom; - - // Start the sub-document load. - let deferred = Promise.defer(); - executeSoon(function () { - BrowserTestUtils.browserLoaded(testBrowser, true).then(url => { - is(url, TEST_IFRAME_URL, "got the load event for the iframe"); - is(ZoomManager.zoom, zoomLevel, "zoom is retained after sub-document load"); - - FullZoomHelper.removeTabAndWaitForLocationChange(). - then(() => deferred.resolve()); - }); - ContentTask.spawn(testBrowser, TEST_IFRAME_URL, url => { - content.document.querySelector("iframe").src = url; - }); - }); - yield deferred.promise; - }).then(finish, FullZoomHelper.failAndContinue(finish)); -} diff --git a/browser/base/content/test/general/browser_bug455852.js b/browser/base/content/test/general/browser_bug455852.js deleted file mode 100644 index ce883b581..000000000 --- a/browser/base/content/test/general/browser_bug455852.js +++ /dev/null @@ -1,20 +0,0 @@ -add_task(function*() { - is(gBrowser.tabs.length, 1, "one tab is open"); - - gBrowser.selectedBrowser.focus(); - isnot(document.activeElement, gURLBar.inputField, "location bar is not focused"); - - var tab = gBrowser.selectedTab; - gPrefService.setBoolPref("browser.tabs.closeWindowWithLastTab", false); - - let tabClosedPromise = BrowserTestUtils.removeTab(tab, {dontRemove: true}); - EventUtils.synthesizeKey("w", { accelKey: true }); - yield tabClosedPromise; - - is(tab.parentNode, null, "ctrl+w removes the tab"); - is(gBrowser.tabs.length, 1, "a new tab has been opened"); - is(document.activeElement, gURLBar.inputField, "location bar is focused for the new tab"); - - if (gPrefService.prefHasUserValue("browser.tabs.closeWindowWithLastTab")) - gPrefService.clearUserPref("browser.tabs.closeWindowWithLastTab"); -}); diff --git a/browser/base/content/test/general/browser_bug460146.js b/browser/base/content/test/general/browser_bug460146.js deleted file mode 100644 index 1fdf0921c..000000000 --- a/browser/base/content/test/general/browser_bug460146.js +++ /dev/null @@ -1,51 +0,0 @@ -/* Check proper image url retrieval from all kinds of elements/styles */ - -function test() { - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - - gBrowser.selectedBrowser.addEventListener("load", function () { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec, - "mediaTab"); - - pageInfo.addEventListener("load", function () { - pageInfo.removeEventListener("load", arguments.callee, true); - pageInfo.onFinished.push(function () { - executeSoon(function () { - var imageTree = pageInfo.document.getElementById("imagetree"); - var imageRowsNum = imageTree.view.rowCount; - - ok(imageTree, "Image tree is null (media tab is broken)"); - - ok(imageRowsNum == 7, "Number of images listed: " + - imageRowsNum + ", should be 7"); - - pageInfo.close(); - gBrowser.removeCurrentTab(); - finish(); - }); - }); - }, true); - }, true); - - content.location = - "data:text/html," + - "<html>" + - " <head>" + - " <title>Test for media tab</title>" + - " <link rel='shortcut icon' href='file:///dummy_icon.ico'>" + // Icon - " </head>" + - " <body style='background-image:url(about:logo?a);'>" + // Background - " <img src='file:///dummy_image.gif'>" + // Image - " <ul>" + - " <li style='list-style:url(about:logo?b);'>List Item 1</li>" + // Bullet - " </ul> " + - " <div style='-moz-border-image: url(about:logo?c) 20 20 20 20;'>test</div>" + // Border - " <a href='' style='cursor: url(about:logo?d),default;'>test link</a>" + // Cursor - " <object type='image/svg+xml' width=20 height=20 data='file:///dummy_object.svg'></object>" + // Object - " </body>" + - "</html>"; -} diff --git a/browser/base/content/test/general/browser_bug462289.js b/browser/base/content/test/general/browser_bug462289.js deleted file mode 100644 index 1ce79f07e..000000000 --- a/browser/base/content/test/general/browser_bug462289.js +++ /dev/null @@ -1,81 +0,0 @@ -var tab1, tab2; - -function focus_in_navbar() -{ - var parent = document.activeElement.parentNode; - while (parent && parent.id != "nav-bar") - parent = parent.parentNode; - - return parent != null; -} - -function test() -{ - waitForExplicitFinish(); - - tab1 = gBrowser.addTab("about:blank", {skipAnimation: true}); - tab2 = gBrowser.addTab("about:blank", {skipAnimation: true}); - - EventUtils.synthesizeMouseAtCenter(tab1, {}); - executeSoon(step2); -} - -function step2() -{ - is(gBrowser.selectedTab, tab1, "1st click on tab1 selects tab"); - isnot(document.activeElement, tab1, "1st click on tab1 does not activate tab"); - - EventUtils.synthesizeMouseAtCenter(tab1, {}); - executeSoon(step3); -} - -function step3() -{ - is(gBrowser.selectedTab, tab1, "2nd click on selected tab1 keeps tab selected"); - isnot(document.activeElement, tab1, "2nd click on selected tab1 does not activate tab"); - - ok(true, "focusing URLBar then sending 1 Shift+Tab."); - gURLBar.focus(); - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); - is(gBrowser.selectedTab, tab1, "tab key to selected tab1 keeps tab selected"); - is(document.activeElement, tab1, "tab key to selected tab1 activates tab"); - - EventUtils.synthesizeMouseAtCenter(tab1, {}); - executeSoon(step4); -} - -function step4() -{ - is(gBrowser.selectedTab, tab1, "3rd click on activated tab1 keeps tab selected"); - is(document.activeElement, tab1, "3rd click on activated tab1 keeps tab activated"); - - gBrowser.addEventListener("TabSwitchDone", step5); - EventUtils.synthesizeMouseAtCenter(tab2, {}); -} - -function step5() -{ - gBrowser.removeEventListener("TabSwitchDone", step5); - - // The tabbox selects a tab within a setTimeout in a bubbling mousedown event - // listener, and focuses the current tab if another tab previously had focus. - is(gBrowser.selectedTab, tab2, "click on tab2 while tab1 is activated selects tab"); - is(document.activeElement, tab2, "click on tab2 while tab1 is activated activates tab"); - - info("focusing content then sending middle-button mousedown to tab2."); - gBrowser.selectedBrowser.focus(); - - EventUtils.synthesizeMouseAtCenter(tab2, {button: 1, type: "mousedown"}); - executeSoon(step6); -} - -function step6() -{ - is(gBrowser.selectedTab, tab2, "middle-button mousedown on selected tab2 keeps tab selected"); - isnot(document.activeElement, tab2, "middle-button mousedown on selected tab2 does not activate tab"); - - gBrowser.removeTab(tab2); - gBrowser.removeTab(tab1); - - finish(); -} diff --git a/browser/base/content/test/general/browser_bug462673.js b/browser/base/content/test/general/browser_bug462673.js deleted file mode 100644 index f5b090917..000000000 --- a/browser/base/content/test/general/browser_bug462673.js +++ /dev/null @@ -1,36 +0,0 @@ -add_task(function* () { - var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no"); - yield SimpleTest.promiseFocus(win); - - let tab = win.gBrowser.tabContainer.firstChild; - yield promiseTabLoadEvent(tab, getRootDirectory(gTestPath) + "test_bug462673.html"); - - is(win.gBrowser.browsers.length, 2, "test_bug462673.html has opened a second tab"); - is(win.gBrowser.selectedTab, tab.nextSibling, "dependent tab is selected"); - win.gBrowser.removeTab(tab); - - // Closing a tab will also close its parent chrome window, but async - yield promiseWindowWillBeClosed(win); -}); - -add_task(function* () { - var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no"); - yield SimpleTest.promiseFocus(win); - - let tab = win.gBrowser.tabContainer.firstChild; - yield promiseTabLoadEvent(tab, getRootDirectory(gTestPath) + "test_bug462673.html"); - - var newTab = win.gBrowser.addTab(); - var newBrowser = newTab.linkedBrowser; - win.gBrowser.removeTab(tab); - ok(!win.closed, "Window stays open"); - if (!win.closed) { - is(win.gBrowser.tabContainer.childElementCount, 1, "Window has one tab"); - is(win.gBrowser.browsers.length, 1, "Window has one browser"); - is(win.gBrowser.selectedTab, newTab, "Remaining tab is selected"); - is(win.gBrowser.selectedBrowser, newBrowser, "Browser for remaining tab is selected"); - is(win.gBrowser.mTabBox.selectedPanel, newBrowser.parentNode.parentNode.parentNode.parentNode, "Panel for remaining tab is selected"); - } - - yield promiseWindowClosed(win); -}); diff --git a/browser/base/content/test/general/browser_bug477014.js b/browser/base/content/test/general/browser_bug477014.js deleted file mode 100644 index 8a0fac6d8..000000000 --- a/browser/base/content/test/general/browser_bug477014.js +++ /dev/null @@ -1,25 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -// That's a gecko! -const iconURLSpec = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg=="; -var testPage="data:text/plain,test bug 477014"; - -add_task(function*() { - let tabToDetach = gBrowser.addTab(testPage); - yield waitForDocLoadComplete(tabToDetach.linkedBrowser); - - gBrowser.setIcon(tabToDetach, iconURLSpec, - Services.scriptSecurityManager.getSystemPrincipal()); - tabToDetach.setAttribute("busy", "true"); - - // detach and set the listener on the new window - let newWindow = gBrowser.replaceTabWithWindow(tabToDetach); - yield promiseWaitForEvent(tabToDetach.linkedBrowser, "SwapDocShells"); - - is(newWindow.gBrowser.selectedTab.hasAttribute("busy"), true, "Busy attribute should be correct"); - is(newWindow.gBrowser.getIcon(), iconURLSpec, "Icon should be correct"); - - newWindow.close(); -}); diff --git a/browser/base/content/test/general/browser_bug479408.js b/browser/base/content/test/general/browser_bug479408.js deleted file mode 100644 index 0dfa96f2e..000000000 --- a/browser/base/content/test/general/browser_bug479408.js +++ /dev/null @@ -1,17 +0,0 @@ -function test() { - waitForExplicitFinish(); - let tab = gBrowser.selectedTab = gBrowser.addTab( - "http://mochi.test:8888/browser/browser/base/content/test/general/browser_bug479408_sample.html"); - - gBrowser.addEventListener("DOMLinkAdded", function(aEvent) { - gBrowser.removeEventListener("DOMLinkAdded", arguments.callee, true); - - executeSoon(function() { - ok(!tab.linkedBrowser.engines, - "the subframe's search engine wasn't detected"); - - gBrowser.removeTab(tab); - finish(); - }); - }, true); -} diff --git a/browser/base/content/test/general/browser_bug479408_sample.html b/browser/base/content/test/general/browser_bug479408_sample.html deleted file mode 100644 index f83f02bb9..000000000 --- a/browser/base/content/test/general/browser_bug479408_sample.html +++ /dev/null @@ -1,4 +0,0 @@ -<!DOCTYPE html> -<title>Testcase for bug 479408</title> - -<iframe src='data:text/html,<link%20rel="search"%20type="application/opensearchdescription+xml"%20title="Search%20bug%20479408"%20href="http://example.com/search.xml">'> diff --git a/browser/base/content/test/general/browser_bug481560.js b/browser/base/content/test/general/browser_bug481560.js deleted file mode 100644 index bb9249e75..000000000 --- a/browser/base/content/test/general/browser_bug481560.js +++ /dev/null @@ -1,21 +0,0 @@ -function test() { - waitForExplicitFinish(); - - whenNewWindowLoaded(null, function (win) { - waitForFocus(function () { - function onTabClose() { - ok(false, "shouldn't have gotten the TabClose event for the last tab"); - } - var tab = win.gBrowser.selectedTab; - tab.addEventListener("TabClose", onTabClose, false); - - EventUtils.synthesizeKey("w", { accelKey: true }, win); - - ok(win.closed, "accel+w closed the window immediately"); - - tab.removeEventListener("TabClose", onTabClose, false); - - finish(); - }, win); - }); -} diff --git a/browser/base/content/test/general/browser_bug484315.js b/browser/base/content/test/general/browser_bug484315.js deleted file mode 100644 index fb23ae33a..000000000 --- a/browser/base/content/test/general/browser_bug484315.js +++ /dev/null @@ -1,23 +0,0 @@ -function test() { - var contentWin = window.open("about:blank", "", "width=100,height=100"); - var enumerator = Services.wm.getEnumerator("navigator:browser"); - - while (enumerator.hasMoreElements()) { - let win = enumerator.getNext(); - if (win.content == contentWin) { - gPrefService.setBoolPref("browser.tabs.closeWindowWithLastTab", false); - win.gBrowser.removeCurrentTab(); - ok(win.closed, "popup is closed"); - - // clean up - if (!win.closed) - win.close(); - if (gPrefService.prefHasUserValue("browser.tabs.closeWindowWithLastTab")) - gPrefService.clearUserPref("browser.tabs.closeWindowWithLastTab"); - - return; - } - } - - throw "couldn't find the content window"; -} diff --git a/browser/base/content/test/general/browser_bug491431.js b/browser/base/content/test/general/browser_bug491431.js deleted file mode 100644 index d270e912e..000000000 --- a/browser/base/content/test/general/browser_bug491431.js +++ /dev/null @@ -1,34 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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 testPage = "data:text/plain,test bug 491431 Page"; - -function test() { - waitForExplicitFinish(); - - let newWin, tabA, tabB; - - // test normal close - tabA = gBrowser.addTab(testPage); - gBrowser.tabContainer.addEventListener("TabClose", function(firstTabCloseEvent) { - gBrowser.tabContainer.removeEventListener("TabClose", arguments.callee, true); - ok(!firstTabCloseEvent.detail.adoptedBy, "This was a normal tab close"); - - // test tab close by moving - tabB = gBrowser.addTab(testPage); - gBrowser.tabContainer.addEventListener("TabClose", function(secondTabCloseEvent) { - gBrowser.tabContainer.removeEventListener("TabClose", arguments.callee, true); - executeSoon(function() { - ok(secondTabCloseEvent.detail.adoptedBy, "This was a tab closed by moving"); - - // cleanup - newWin.close(); - executeSoon(finish); - }); - }, true); - newWin = gBrowser.replaceTabWithWindow(tabB); - }, true); - gBrowser.removeTab(tabA); -} - diff --git a/browser/base/content/test/general/browser_bug495058.js b/browser/base/content/test/general/browser_bug495058.js deleted file mode 100644 index a82c6c931..000000000 --- a/browser/base/content/test/general/browser_bug495058.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Tests that the right elements of a tab are focused when it is - * torn out into its own window. - */ - -const URIS = [ - "about:blank", - "about:sessionrestore", - "about:privatebrowsing", -]; - -add_task(function*() { - for (let uri of URIS) { - let tab = gBrowser.addTab(); - yield BrowserTestUtils.loadURI(tab.linkedBrowser, uri); - - let win = gBrowser.replaceTabWithWindow(tab); - yield TestUtils.topicObserved("browser-delayed-startup-finished", - subject => subject == win); - tab = win.gBrowser.selectedTab; - - // BrowserTestUtils doesn't get the add-on shims, which means that - // MozAfterPaint won't get shimmed over if we add an event handler - // for it in the parent. - if (tab.linkedBrowser.isRemoteBrowser) { - yield BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, "MozAfterPaint"); - } else { - yield BrowserTestUtils.waitForEvent(tab.linkedBrowser, "MozAfterPaint"); - } - - Assert.equal(win.gBrowser.currentURI.spec, uri, uri + ": uri loaded in detached tab"); - Assert.equal(win.document.activeElement, win.gBrowser.selectedBrowser, uri + ": browser is focused"); - Assert.equal(win.gURLBar.value, "", uri + ": urlbar is empty"); - Assert.ok(win.gURLBar.placeholder, uri + ": placeholder text is present"); - - yield BrowserTestUtils.closeWindow(win); - } -}); diff --git a/browser/base/content/test/general/browser_bug517902.js b/browser/base/content/test/general/browser_bug517902.js deleted file mode 100644 index bc1d16f4b..000000000 --- a/browser/base/content/test/general/browser_bug517902.js +++ /dev/null @@ -1,42 +0,0 @@ -/* Make sure that "View Image Info" loads the correct image data */ - -function test() { - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - - gBrowser.selectedBrowser.addEventListener("load", function () { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - var doc = gBrowser.contentDocument; - var testImg = doc.getElementById("test-image"); - var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec, - "mediaTab", testImg); - - pageInfo.addEventListener("load", function () { - pageInfo.removeEventListener("load", arguments.callee, true); - pageInfo.onFinished.push(function () { - executeSoon(function () { - var pageInfoImg = pageInfo.document.getElementById("thepreviewimage"); - - is(pageInfoImg.src, testImg.src, "selected image has the correct source"); - is(pageInfoImg.width, testImg.width, "selected image has the correct width"); - is(pageInfoImg.height, testImg.height, "selected image has the correct height"); - - pageInfo.close(); - gBrowser.removeCurrentTab(); - finish(); - }); - }); - }, true); - }, true); - - content.location = - "data:text/html," + - "<style type='text/css'>%23test-image,%23not-test-image {background-image: url('about:logo?c');}</style>" + - "<img src='about:logo?b' height=300 width=350 alt=2 id='not-test-image'>" + - "<img src='about:logo?b' height=300 width=350 alt=2>" + - "<img src='about:logo?a' height=200 width=250>" + - "<img src='about:logo?b' height=200 width=250 alt=1>" + - "<img src='about:logo?b' height=100 width=150 alt=2 id='test-image'>"; -} diff --git a/browser/base/content/test/general/browser_bug519216.js b/browser/base/content/test/general/browser_bug519216.js deleted file mode 100644 index d3a517086..000000000 --- a/browser/base/content/test/general/browser_bug519216.js +++ /dev/null @@ -1,45 +0,0 @@ -function test() { - waitForExplicitFinish(); - gBrowser.addProgressListener(progressListener1); - gBrowser.addProgressListener(progressListener2); - gBrowser.addProgressListener(progressListener3); - gBrowser.loadURI("data:text/plain,bug519216"); -} - -var calledListener1 = false; -var progressListener1 = { - onLocationChange: function onLocationChange() { - calledListener1 = true; - gBrowser.removeProgressListener(this); - } -}; - -var calledListener2 = false; -var progressListener2 = { - onLocationChange: function onLocationChange() { - ok(calledListener1, "called progressListener1 before progressListener2"); - calledListener2 = true; - gBrowser.removeProgressListener(this); - } -}; - -var progressListener3 = { - onLocationChange: function onLocationChange() { - ok(calledListener2, "called progressListener2 before progressListener3"); - gBrowser.removeProgressListener(this); - gBrowser.addProgressListener(progressListener4); - executeSoon(function () { - expectListener4 = true; - gBrowser.reload(); - }); - } -}; - -var expectListener4 = false; -var progressListener4 = { - onLocationChange: function onLocationChange() { - ok(expectListener4, "didn't call progressListener4 for the first location change"); - gBrowser.removeProgressListener(this); - executeSoon(finish); - } -}; diff --git a/browser/base/content/test/general/browser_bug520538.js b/browser/base/content/test/general/browser_bug520538.js deleted file mode 100644 index e0b64db9d..000000000 --- a/browser/base/content/test/general/browser_bug520538.js +++ /dev/null @@ -1,15 +0,0 @@ -function test() { - var tabCount = gBrowser.tabs.length; - gBrowser.selectedBrowser.focus(); - browserDOMWindow.openURI(makeURI("about:blank"), - null, - Ci.nsIBrowserDOMWindow.OPEN_NEWTAB, - Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL); - is(gBrowser.tabs.length, tabCount + 1, - "'--new-tab about:blank' opens a new tab"); - is(gBrowser.selectedTab, gBrowser.tabs[tabCount], - "'--new-tab about:blank' selects the new tab"); - is(document.activeElement, gURLBar.inputField, - "'--new-tab about:blank' focuses the location bar"); - gBrowser.removeCurrentTab(); -} diff --git a/browser/base/content/test/general/browser_bug521216.js b/browser/base/content/test/general/browser_bug521216.js deleted file mode 100644 index 735ae92f6..000000000 --- a/browser/base/content/test/general/browser_bug521216.js +++ /dev/null @@ -1,50 +0,0 @@ -var expected = ["TabOpen", "onStateChange", "onLocationChange", "onLinkIconAvailable"]; -var actual = []; -var tabIndex = -1; -this.__defineGetter__("tab", () => gBrowser.tabs[tabIndex]); - -function test() { - waitForExplicitFinish(); - tabIndex = gBrowser.tabs.length; - gBrowser.addTabsProgressListener(progressListener); - gBrowser.tabContainer.addEventListener("TabOpen", TabOpen, false); - gBrowser.addTab("data:text/html,<html><head><link href='about:logo' rel='shortcut icon'>"); -} - -function record(aName) { - info("got " + aName); - if (actual.indexOf(aName) == -1) - actual.push(aName); - if (actual.length == expected.length) { - is(actual.toString(), expected.toString(), - "got events and progress notifications in expected order"); - - executeSoon(function(tab) { - gBrowser.removeTab(tab); - gBrowser.removeTabsProgressListener(progressListener); - gBrowser.tabContainer.removeEventListener("TabOpen", TabOpen, false); - finish(); - }.bind(null, tab)); - } -} - -function TabOpen(aEvent) { - if (aEvent.target == tab) - record(arguments.callee.name); -} - -var progressListener = { - onLocationChange: function onLocationChange(aBrowser) { - if (aBrowser == tab.linkedBrowser) - record(arguments.callee.name); - }, - onStateChange: function onStateChange(aBrowser) { - if (aBrowser == tab.linkedBrowser) - record(arguments.callee.name); - }, - onLinkIconAvailable: function onLinkIconAvailable(aBrowser, aIconURL) { - if (aBrowser == tab.linkedBrowser && - aIconURL == "about:logo") - record(arguments.callee.name); - } -}; diff --git a/browser/base/content/test/general/browser_bug533232.js b/browser/base/content/test/general/browser_bug533232.js deleted file mode 100644 index 6c7a0e51f..000000000 --- a/browser/base/content/test/general/browser_bug533232.js +++ /dev/null @@ -1,36 +0,0 @@ -function test() { - var tab1 = gBrowser.selectedTab; - var tab2 = gBrowser.addTab(); - var childTab1; - var childTab2; - - childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true }); - gBrowser.selectedTab = childTab1; - gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); - is(idx(gBrowser.selectedTab), idx(tab1), - "closing a tab next to its parent selects the parent"); - - childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true }); - gBrowser.selectedTab = tab2; - gBrowser.selectedTab = childTab1; - gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); - is(idx(gBrowser.selectedTab), idx(tab2), - "closing a tab next to its parent doesn't select the parent if another tab had been selected ad interim"); - - gBrowser.selectedTab = tab1; - childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true }); - childTab2 = gBrowser.addTab("about:blank", { relatedToCurrent: true }); - gBrowser.selectedTab = childTab1; - gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); - is(idx(gBrowser.selectedTab), idx(childTab2), - "closing a tab next to its parent selects the next tab with the same parent"); - gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); - is(idx(gBrowser.selectedTab), idx(tab2), - "closing the last tab in a set of child tabs doesn't go back to the parent"); - - gBrowser.removeTab(tab2, { skipPermitUnload: true }); -} - -function idx(tab) { - return Array.indexOf(gBrowser.tabs, tab); -} diff --git a/browser/base/content/test/general/browser_bug537013.js b/browser/base/content/test/general/browser_bug537013.js deleted file mode 100644 index 5ae1586ea..000000000 --- a/browser/base/content/test/general/browser_bug537013.js +++ /dev/null @@ -1,135 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* Tests for bug 537013 to ensure proper tab-sequestration of find bar. */ - -var tabs = []; -var texts = [ - "This side up.", - "The world is coming to an end. Please log off.", - "Klein bottle for sale. Inquire within.", - "To err is human; to forgive is not company policy." -]; - -var Clipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard); -var HasFindClipboard = Clipboard.supportsFindClipboard(); - -function addTabWithText(aText, aCallback) { - let newTab = gBrowser.addTab("data:text/html;charset=utf-8,<h1 id='h1'>" + - aText + "</h1>"); - tabs.push(newTab); - gBrowser.selectedTab = newTab; -} - -function setFindString(aString) { - gFindBar.open(); - gFindBar._findField.focus(); - gFindBar._findField.select(); - EventUtils.sendString(aString); - is(gFindBar._findField.value, aString, "Set the field correctly!"); -} - -var newWindow; - -function test() { - waitForExplicitFinish(); - registerCleanupFunction(function () { - while (tabs.length) { - gBrowser.removeTab(tabs.pop()); - } - }); - texts.forEach(aText => addTabWithText(aText)); - - // Set up the first tab - gBrowser.selectedTab = tabs[0]; - - setFindString(texts[0]); - // Turn on highlight for testing bug 891638 - gFindBar.toggleHighlight(true); - - // Make sure the second tab is correct, then set it up - gBrowser.selectedTab = tabs[1]; - gBrowser.selectedTab.addEventListener("TabFindInitialized", continueTests1); - // Initialize the findbar - gFindBar; -} -function continueTests1() { - gBrowser.selectedTab.removeEventListener("TabFindInitialized", - continueTests1); - ok(true, "'TabFindInitialized' event properly dispatched!"); - ok(gFindBar.hidden, "Second tab doesn't show find bar!"); - gFindBar.open(); - is(gFindBar._findField.value, texts[0], - "Second tab kept old find value for new initialization!"); - setFindString(texts[1]); - - // Confirm the first tab is still correct, ensure re-hiding works as expected - gBrowser.selectedTab = tabs[0]; - ok(!gFindBar.hidden, "First tab shows find bar!"); - // When the Find Clipboard is supported, this test not relevant. - if (!HasFindClipboard) - is(gFindBar._findField.value, texts[0], "First tab persists find value!"); - ok(gFindBar.getElement("highlight").checked, - "Highlight button state persists!"); - - // While we're here, let's test the backout of bug 253793. - gBrowser.reload(); - gBrowser.addEventListener("DOMContentLoaded", continueTests2, true); -} - -function continueTests2() { - gBrowser.removeEventListener("DOMContentLoaded", continueTests2, true); - ok(gFindBar.getElement("highlight").checked, "Highlight never reset!"); - continueTests3(); -} - -function continueTests3() { - ok(gFindBar.getElement("highlight").checked, "Highlight button reset!"); - gFindBar.close(); - ok(gFindBar.hidden, "First tab doesn't show find bar!"); - gBrowser.selectedTab = tabs[1]; - ok(!gFindBar.hidden, "Second tab shows find bar!"); - // Test for bug 892384 - is(gFindBar._findField.getAttribute("focused"), "true", - "Open findbar refocused on tab change!"); - gURLBar.focus(); - gBrowser.selectedTab = tabs[0]; - ok(gFindBar.hidden, "First tab doesn't show find bar!"); - - // Set up a third tab, no tests here - gBrowser.selectedTab = tabs[2]; - setFindString(texts[2]); - - // Now we jump to the second, then first, and then fourth - gBrowser.selectedTab = tabs[1]; - // Test for bug 892384 - ok(!gFindBar._findField.hasAttribute("focused"), - "Open findbar not refocused on tab change!"); - gBrowser.selectedTab = tabs[0]; - gBrowser.selectedTab = tabs[3]; - ok(gFindBar.hidden, "Fourth tab doesn't show find bar!"); - is(gFindBar, gBrowser.getFindBar(), "Find bar is right one!"); - gFindBar.open(); - // Disabled the following assertion due to intermittent failure on OSX 10.6 Debug. - if (!HasFindClipboard) { - is(gFindBar._findField.value, texts[1], - "Fourth tab has second tab's find value!"); - } - - newWindow = gBrowser.replaceTabWithWindow(tabs.pop()); - whenDelayedStartupFinished(newWindow, checkNewWindow); -} - -// Test that findbar gets restored when a tab is moved to a new window. -function checkNewWindow() { - ok(!newWindow.gFindBar.hidden, "New window shows find bar!"); - // Disabled the following assertion due to intermittent failure on OSX 10.6 Debug. - if (!HasFindClipboard) { - is(newWindow.gFindBar._findField.value, texts[1], - "New window find bar has correct find value!"); - } - ok(!newWindow.gFindBar.getElement("find-next").disabled, - "New window findbar has enabled buttons!"); - newWindow.close(); - finish(); -} diff --git a/browser/base/content/test/general/browser_bug537474.js b/browser/base/content/test/general/browser_bug537474.js deleted file mode 100644 index f1139f235..000000000 --- a/browser/base/content/test/general/browser_bug537474.js +++ /dev/null @@ -1,8 +0,0 @@ -add_task(function *() { - let browserLoadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - browserDOMWindow.openURI(makeURI("about:"), null, - Ci.nsIBrowserDOMWindow.OPEN_CURRENTWINDOW, null) - yield browserLoadedPromise; - is(gBrowser.currentURI.spec, "about:", "page loads in the current content window"); -}); - diff --git a/browser/base/content/test/general/browser_bug550565.js b/browser/base/content/test/general/browser_bug550565.js deleted file mode 100644 index b0e094e07..000000000 --- a/browser/base/content/test/general/browser_bug550565.js +++ /dev/null @@ -1,44 +0,0 @@ -add_task(function* test() { - let testPath = getRootDirectory(gTestPath); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, - function* (tabBrowser) { - const URI = testPath + "file_with_favicon.html"; - const expectedIcon = testPath + "file_generic_favicon.ico"; - - let got_favicon = Promise.defer(); - let listener = { - onLinkIconAvailable(browser, iconURI) { - if (got_favicon && iconURI && browser === tabBrowser) { - got_favicon.resolve(iconURI); - got_favicon = null; - } - } - }; - gBrowser.addTabsProgressListener(listener); - - BrowserTestUtils.loadURI(tabBrowser, URI); - - let iconURI = yield got_favicon.promise; - is(iconURI, expectedIcon, "Correct icon before pushState."); - - got_favicon = Promise.defer(); - got_favicon.promise.then(() => { ok(false, "shouldn't be called"); }, (e) => e); - yield ContentTask.spawn(tabBrowser, null, function() { - content.history.pushState("page2", "page2", "page2"); - }); - - // We've navigated and shouldn't get a call to onLinkIconAvailable. - TestUtils.executeSoon(() => { - got_favicon.reject(gBrowser.getIcon(gBrowser.getTabForBrowser(tabBrowser))); - }); - try { - yield got_favicon.promise; - } catch (e) { - iconURI = e; - } - is(iconURI, expectedIcon, "Correct icon after pushState."); - - gBrowser.removeTabsProgressListener(listener); - }); -}); diff --git a/browser/base/content/test/general/browser_bug553455.js b/browser/base/content/test/general/browser_bug553455.js deleted file mode 100644 index c29a810de..000000000 --- a/browser/base/content/test/general/browser_bug553455.js +++ /dev/null @@ -1,1200 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -const TESTROOT = "http://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/"; -const TESTROOT2 = "http://example.org/browser/toolkit/mozapps/extensions/test/xpinstall/"; -const SECUREROOT = "https://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/"; -const XPINSTALL_URL = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul"; -const PREF_INSTALL_REQUIREBUILTINCERTS = "extensions.install.requireBuiltInCerts"; -const PROGRESS_NOTIFICATION = "addon-progress"; - -const { REQUIRE_SIGNING } = Cu.import("resource://gre/modules/addons/AddonConstants.jsm", {}); -const { Task } = Cu.import("resource://gre/modules/Task.jsm"); - -var rootDir = getRootDirectory(gTestPath); -var rootPath = rootDir.split('/'); -var chromeName = rootPath[0] + '//' + rootPath[2]; -var croot = chromeName + "/content/browser/toolkit/mozapps/extensions/test/xpinstall/"; -var jar = getJar(croot); -if (jar) { - var tmpdir = extractJarToTmp(jar); - croot = 'file://' + tmpdir.path + '/'; -} -const CHROMEROOT = croot; - -var gApp = document.getElementById("bundle_brand").getString("brandShortName"); -var gVersion = Services.appinfo.version; - -function getObserverTopic(aNotificationId) { - let topic = aNotificationId; - if (topic == "xpinstall-disabled") - topic = "addon-install-disabled"; - else if (topic == "addon-progress") - topic = "addon-install-started"; - else if (topic == "addon-install-restart") - topic = "addon-install-complete"; - return topic; -} - -function waitForProgressNotification(aPanelOpen = false, aExpectedCount = 1) { - return Task.spawn(function* () { - let notificationId = PROGRESS_NOTIFICATION; - info("Waiting for " + notificationId + " notification"); - - let topic = getObserverTopic(notificationId); - - let observerPromise = new Promise(resolve => { - Services.obs.addObserver(function observer(aSubject, aTopic, aData) { - // Ignore the progress notification unless that is the notification we want - if (notificationId != PROGRESS_NOTIFICATION && - aTopic == getObserverTopic(PROGRESS_NOTIFICATION)) { - return; - } - Services.obs.removeObserver(observer, topic); - resolve(); - }, topic, false); - }); - - let panelEventPromise; - if (aPanelOpen) { - panelEventPromise = Promise.resolve(); - } else { - panelEventPromise = new Promise(resolve => { - PopupNotifications.panel.addEventListener("popupshowing", function eventListener() { - PopupNotifications.panel.removeEventListener("popupshowing", eventListener); - resolve(); - }); - }); - } - - yield observerPromise; - yield panelEventPromise; - - info("Saw a notification"); - ok(PopupNotifications.isPanelOpen, "Panel should be open"); - is(PopupNotifications.panel.childNodes.length, aExpectedCount, "Should be the right number of notifications"); - if (PopupNotifications.panel.childNodes.length) { - let nodes = Array.from(PopupNotifications.panel.childNodes); - let notification = nodes.find(n => n.id == notificationId + "-notification"); - ok(notification, `Should have seen the right notification`); - } - - return PopupNotifications.panel; - }); -} - -function waitForNotification(aId, aExpectedCount = 1) { - return Task.spawn(function* () { - info("Waiting for " + aId + " notification"); - - let topic = getObserverTopic(aId); - - let observerPromise = new Promise(resolve => { - Services.obs.addObserver(function observer(aSubject, aTopic, aData) { - // Ignore the progress notification unless that is the notification we want - if (aId != PROGRESS_NOTIFICATION && - aTopic == getObserverTopic(PROGRESS_NOTIFICATION)) { - return; - } - Services.obs.removeObserver(observer, topic); - resolve(); - }, topic, false); - }); - - let panelEventPromise = new Promise(resolve => { - PopupNotifications.panel.addEventListener("PanelUpdated", function eventListener(e) { - // Skip notifications that are not the one that we are supposed to be looking for - if (e.detail.indexOf(aId) == -1) { - return; - } - PopupNotifications.panel.removeEventListener("PanelUpdated", eventListener); - resolve(); - }); - }); - - yield observerPromise; - yield panelEventPromise; - - info("Saw a notification"); - ok(PopupNotifications.isPanelOpen, "Panel should be open"); - is(PopupNotifications.panel.childNodes.length, aExpectedCount, "Should be the right number of notifications"); - if (PopupNotifications.panel.childNodes.length) { - let nodes = Array.from(PopupNotifications.panel.childNodes); - let notification = nodes.find(n => n.id == aId + "-notification"); - ok(notification, `Should have seen the right notification`); - } - - return PopupNotifications.panel; - }); -} - -function waitForNotificationClose() { - return new Promise(resolve => { - info("Waiting for notification to close"); - PopupNotifications.panel.addEventListener("popuphidden", function listener() { - PopupNotifications.panel.removeEventListener("popuphidden", listener, false); - resolve(); - }, false); - }); -} - -function waitForInstallDialog() { - return Task.spawn(function* () { - if (Preferences.get("xpinstall.customConfirmationUI", false)) { - yield waitForNotification("addon-install-confirmation"); - return; - } - - info("Waiting for install dialog"); - - let window = yield new Promise(resolve => { - Services.wm.addListener({ - onOpenWindow: function(aXULWindow) { - Services.wm.removeListener(this); - resolve(aXULWindow); - }, - onCloseWindow: function(aXULWindow) { - }, - onWindowTitleChange: function(aXULWindow, aNewTitle) { - } - }); - }); - info("Install dialog opened, waiting for focus"); - - let domwindow = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindow); - yield new Promise(resolve => { - waitForFocus(function() { - resolve(); - }, domwindow); - }); - info("Saw install dialog"); - is(domwindow.document.location.href, XPINSTALL_URL, "Should have seen the right window open"); - - // Override the countdown timer on the accept button - let button = domwindow.document.documentElement.getButton("accept"); - button.disabled = false; - - return; - }); -} - -function removeTab() { - return Promise.all([ - waitForNotificationClose(), - BrowserTestUtils.removeTab(gBrowser.selectedTab) - ]); -} - -function acceptInstallDialog() { - if (Preferences.get("xpinstall.customConfirmationUI", false)) { - document.getElementById("addon-install-confirmation-accept").click(); - } else { - let win = Services.wm.getMostRecentWindow("Addons:Install"); - win.document.documentElement.acceptDialog(); - } -} - -function cancelInstallDialog() { - if (Preferences.get("xpinstall.customConfirmationUI", false)) { - document.getElementById("addon-install-confirmation-cancel").click(); - } else { - let win = Services.wm.getMostRecentWindow("Addons:Install"); - win.document.documentElement.cancelDialog(); - } -} - -function waitForSingleNotification(aCallback) { - return Task.spawn(function* () { - while (PopupNotifications.panel.childNodes.length == 2) { - yield new Promise(resolve => executeSoon(resolve)); - - info("Waiting for single notification"); - // Notification should never close while we wait - ok(PopupNotifications.isPanelOpen, "Notification should still be open"); - } - }); -} - -function setupRedirect(aSettings) { - var url = "https://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/redirect.sjs?mode=setup"; - for (var name in aSettings) { - url += "&" + name + "=" + aSettings[name]; - } - - var req = new XMLHttpRequest(); - req.open("GET", url, false); - req.send(null); -} - -function getInstalls() { - return new Promise(resolve => { - AddonManager.getAllInstalls(installs => resolve(installs)); - }); -} - -var TESTS = [ -function test_disabledInstall() { - return Task.spawn(function* () { - Services.prefs.setBoolPref("xpinstall.enabled", false); - - let notificationPromise = waitForNotification("xpinstall-disabled"); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "amosigned.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.button.label, "Enable", "Should have seen the right button"); - is(notification.getAttribute("label"), - "Software installation is currently disabled. Click Enable and try again."); - - let closePromise = waitForNotificationClose(); - // Click on Enable - EventUtils.synthesizeMouseAtCenter(notification.button, {}); - yield closePromise; - - try { - ok(Services.prefs.getBoolPref("xpinstall.enabled"), "Installation should be enabled"); - } - catch (e) { - ok(false, "xpinstall.enabled should be set"); - } - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - let installs = yield getInstalls(); - is(installs.length, 0, "Shouldn't be any pending installs"); - }); -}, - -function test_blockedInstall() { - return Task.spawn(function* () { - let notificationPromise = waitForNotification("addon-install-blocked"); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "amosigned.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.button.label, "Allow", "Should have seen the right button"); - is(notification.getAttribute("origin"), "example.com", - "Should have seen the right origin host"); - is(notification.getAttribute("label"), - gApp + " prevented this site from asking you to install software on your computer.", - "Should have seen the right message"); - - let dialogPromise = waitForInstallDialog(); - // Click on Allow - EventUtils.synthesizeMouse(notification.button, 20, 10, {}); - // Notification should have changed to progress notification - ok(PopupNotifications.isPanelOpen, "Notification should still be open"); - notification = panel.childNodes[0]; - is(notification.id, "addon-progress-notification", "Should have seen the progress notification"); - yield dialogPromise; - - notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(); - panel = yield notificationPromise; - - notification = panel.childNodes[0]; - is(notification.button.label, "Restart Now", "Should have seen the right button"); - is(notification.getAttribute("label"), - "XPI Test will be installed after you restart " + gApp + ".", - "Should have seen the right message"); - - let installs = yield getInstalls(); - is(installs.length, 1, "Should be one pending install"); - installs[0].cancel(); - yield removeTab(); - }); -}, - -function test_whitelistedInstall() { - return Task.spawn(function* () { - let originalTab = gBrowser.selectedTab; - let tab; - gBrowser.selectedTab = originalTab; - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "amosigned.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" - + triggers).then(newTab => tab = newTab); - yield progressPromise; - yield dialogPromise; - yield BrowserTestUtils.waitForCondition(() => !!tab, "tab should be present"); - - is(gBrowser.selectedTab, tab, - "tab selected in response to the addon-install-confirmation notification"); - - let notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.button.label, "Restart Now", "Should have seen the right button"); - is(notification.getAttribute("label"), - "XPI Test will be installed after you restart " + gApp + ".", - "Should have seen the right message"); - - let installs = yield getInstalls(); - is(installs.length, 1, "Should be one pending install"); - installs[0].cancel(); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_failedDownload() { - return Task.spawn(function* () { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let failPromise = waitForNotification("addon-install-failed"); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "missing.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - let panel = yield failPromise; - - let notification = panel.childNodes[0]; - is(notification.getAttribute("label"), - "The add-on could not be downloaded because of a connection failure.", - "Should have seen the right message"); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_corruptFile() { - return Task.spawn(function* () { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let failPromise = waitForNotification("addon-install-failed"); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "corrupt.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - let panel = yield failPromise; - - let notification = panel.childNodes[0]; - is(notification.getAttribute("label"), - "The add-on downloaded from this site could not be installed " + - "because it appears to be corrupt.", - "Should have seen the right message"); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_incompatible() { - return Task.spawn(function* () { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let failPromise = waitForNotification("addon-install-failed"); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "incompatible.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - let panel = yield failPromise; - - let notification = panel.childNodes[0]; - is(notification.getAttribute("label"), - "XPI Test could not be installed because it is not compatible with " + - gApp + " " + gVersion + ".", - "Should have seen the right message"); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_restartless() { - return Task.spawn(function* () { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "restartless.xpi" - })); - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - yield dialogPromise; - - let notificationPromise = waitForNotification("addon-install-complete"); - acceptInstallDialog(); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.getAttribute("label"), - "XPI Test has been installed successfully.", - "Should have seen the right message"); - - let installs = yield getInstalls(); - is(installs.length, 0, "Should be no pending installs"); - - let addon = yield new Promise(resolve => { - AddonManager.getAddonByID("restartless-xpi@tests.mozilla.org", result => { - resolve(result); - }); - }); - addon.uninstall(); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - - let closePromise = waitForNotificationClose(); - gBrowser.removeTab(gBrowser.selectedTab); - yield closePromise; - }); -}, - -function test_multiple() { - return Task.spawn(function* () { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "Unsigned XPI": "amosigned.xpi", - "Restartless XPI": "restartless.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - let panel = yield progressPromise; - yield dialogPromise; - - let notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(); - yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.button.label, "Restart Now", "Should have seen the right button"); - is(notification.getAttribute("label"), - "2 add-ons will be installed after you restart " + gApp + ".", - "Should have seen the right message"); - - let installs = yield getInstalls(); - is(installs.length, 1, "Should be one pending install"); - installs[0].cancel(); - - let addon = yield new Promise(resolve => { - AddonManager.getAddonByID("restartless-xpi@tests.mozilla.org", function (result) { - resolve(result); - }); - }); - addon.uninstall(); - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_sequential() { - return Task.spawn(function* () { - // This test is only relevant if using the new doorhanger UI - if (!Preferences.get("xpinstall.customConfirmationUI", false)) { - return; - } - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "Restartless XPI": "restartless.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - yield dialogPromise; - - // Should see the right add-on - let container = document.getElementById("addon-install-confirmation-content"); - is(container.childNodes.length, 1, "Should be one item listed"); - is(container.childNodes[0].firstChild.getAttribute("value"), "XPI Test", "Should have the right add-on"); - - progressPromise = waitForProgressNotification(true, 2); - triggers = encodeURIComponent(JSON.stringify({ - "Theme XPI": "theme.xpi" - })); - gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - - // Should still have the right add-on in the confirmation notification - is(container.childNodes.length, 1, "Should be one item listed"); - is(container.childNodes[0].firstChild.getAttribute("value"), "XPI Test", "Should have the right add-on"); - - // Wait for the install to complete, we won't see a new confirmation - // notification - yield new Promise(resolve => { - Services.obs.addObserver(function observer() { - Services.obs.removeObserver(observer, "addon-install-confirmation"); - resolve(); - }, "addon-install-confirmation", false); - }); - - // Make sure browser-addons.js executes first - yield new Promise(resolve => executeSoon(resolve)); - - // Should have dropped the progress notification - is(PopupNotifications.panel.childNodes.length, 1, "Should be the right number of notifications"); - is(PopupNotifications.panel.childNodes[0].id, "addon-install-confirmation-notification", - "Should only be showing one install confirmation"); - - // Should still have the right add-on in the confirmation notification - is(container.childNodes.length, 1, "Should be one item listed"); - is(container.childNodes[0].firstChild.getAttribute("value"), "XPI Test", "Should have the right add-on"); - - cancelInstallDialog(); - - ok(PopupNotifications.isPanelOpen, "Panel should still be open"); - is(PopupNotifications.panel.childNodes.length, 1, "Should be the right number of notifications"); - is(PopupNotifications.panel.childNodes[0].id, "addon-install-confirmation-notification", - "Should still have an install confirmation open"); - - // Should have the next add-on's confirmation dialog - is(container.childNodes.length, 1, "Should be one item listed"); - is(container.childNodes[0].firstChild.getAttribute("value"), "Theme Test", "Should have the right add-on"); - - Services.perms.remove(makeURI("http://example.com"), "install"); - let closePromise = waitForNotificationClose(); - cancelInstallDialog(); - yield closePromise; - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - }); -}, - -function test_someUnverified() { - return Task.spawn(function* () { - // This test is only relevant if using the new doorhanger UI and allowing - // unsigned add-ons - if (!Preferences.get("xpinstall.customConfirmationUI", false) || - Preferences.get("xpinstall.signatures.required", true) || - REQUIRE_SIGNING) { - return; - } - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "Extension XPI": "restartless-unsigned.xpi", - "Theme XPI": "theme.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - yield dialogPromise; - - let notification = document.getElementById("addon-install-confirmation-notification"); - let message = notification.getAttribute("label"); - is(message, "Caution: This site would like to install 2 add-ons in " + gApp + - ", some of which are unverified. Proceed at your own risk.", - "Should see the right message"); - - let container = document.getElementById("addon-install-confirmation-content"); - is(container.childNodes.length, 2, "Should be two items listed"); - is(container.childNodes[0].firstChild.getAttribute("value"), "XPI Test", "Should have the right add-on"); - is(container.childNodes[0].lastChild.getAttribute("class"), - "addon-install-confirmation-unsigned", "Should have the unverified marker"); - is(container.childNodes[1].firstChild.getAttribute("value"), "Theme Test", "Should have the right add-on"); - is(container.childNodes[1].childNodes.length, 1, "Shouldn't have the unverified marker"); - - let notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(); - yield notificationPromise; - - let [addon, theme] = yield new Promise(resolve => { - AddonManager.getAddonsByIDs(["restartless-xpi@tests.mozilla.org", - "theme-xpi@tests.mozilla.org"], - function(addons) { - resolve(addons); - }); - }); - addon.uninstall(); - // Installing a new theme tries to switch to it, switch back to the - // default theme. - theme.userDisabled = true; - theme.uninstall(); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_allUnverified() { - return Task.spawn(function* () { - // This test is only relevant if using the new doorhanger UI and allowing - // unsigned add-ons - if (!Preferences.get("xpinstall.customConfirmationUI", false) || - Preferences.get("xpinstall.signatures.required", true) || - REQUIRE_SIGNING) { - return; - } - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "Extension XPI": "restartless-unsigned.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - yield dialogPromise; - - let notification = document.getElementById("addon-install-confirmation-notification"); - let message = notification.getAttribute("label"); - is(message, "Caution: This site would like to install an unverified add-on in " + gApp + ". Proceed at your own risk."); - - let container = document.getElementById("addon-install-confirmation-content"); - is(container.childNodes.length, 1, "Should be one item listed"); - is(container.childNodes[0].firstChild.getAttribute("value"), "XPI Test", "Should have the right add-on"); - is(container.childNodes[0].childNodes.length, 1, "Shouldn't have the unverified marker"); - - let notificationPromise = waitForNotification("addon-install-complete"); - acceptInstallDialog(); - yield notificationPromise; - - let addon = yield new Promise(resolve => { - AddonManager.getAddonByID("restartless-xpi@tests.mozilla.org", function(result) { - resolve(result); - }); - }); - addon.uninstall(); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_url() { - return Task.spawn(function* () { - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - gBrowser.selectedTab = gBrowser.addTab("about:blank"); - yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - gBrowser.loadURI(TESTROOT + "amosigned.xpi"); - yield progressPromise; - yield dialogPromise; - - let notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.button.label, "Restart Now", "Should have seen the right button"); - is(notification.getAttribute("label"), - "XPI Test will be installed after you restart " + gApp + ".", - "Should have seen the right message"); - - let installs = yield getInstalls(); - is(installs.length, 1, "Should be one pending install"); - installs[0].cancel(); - - yield removeTab(); - }); -}, - -function test_localFile() { - return Task.spawn(function* () { - let cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"] - .getService(Components.interfaces.nsIChromeRegistry); - let path; - try { - path = cr.convertChromeURL(makeURI(CHROMEROOT + "corrupt.xpi")).spec; - } catch (ex) { - path = CHROMEROOT + "corrupt.xpi"; - } - - let failPromise = new Promise(resolve => { - Services.obs.addObserver(function observer() { - Services.obs.removeObserver(observer, "addon-install-failed"); - resolve(); - }, "addon-install-failed", false); - }); - gBrowser.selectedTab = gBrowser.addTab("about:blank"); - yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - gBrowser.loadURI(path); - yield failPromise; - - // Wait for the browser code to add the failure notification - yield waitForSingleNotification(); - - let notification = PopupNotifications.panel.childNodes[0]; - is(notification.id, "addon-install-failed-notification", "Should have seen the install fail"); - is(notification.getAttribute("label"), - "This add-on could not be installed because it appears to be corrupt.", - "Should have seen the right message"); - - yield removeTab(); - }); -}, - -function test_tabClose() { - return Task.spawn(function* () { - if (!Preferences.get("xpinstall.customConfirmationUI", false)) { - runNextTest(); - return; - } - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - gBrowser.selectedTab = gBrowser.addTab("about:blank"); - yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - gBrowser.loadURI(TESTROOT + "amosigned.xpi"); - yield progressPromise; - yield dialogPromise; - - let installs = yield getInstalls(); - is(installs.length, 1, "Should be one pending install"); - - let closePromise = waitForNotificationClose(); - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - yield closePromise; - - installs = yield getInstalls(); - is(installs.length, 0, "Should be no pending install since the tab is closed"); - }); -}, - -// Add-ons should be cancelled and the install notification destroyed when -// navigating to a new origin -function test_tabNavigate() { - return Task.spawn(function* () { - if (!Preferences.get("xpinstall.customConfirmationUI", false)) { - return; - } - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "Extension XPI": "amosigned.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - yield dialogPromise; - - let closePromise = waitForNotificationClose(); - let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - gBrowser.loadURI("about:blank"); - yield closePromise; - - let installs = yield getInstalls(); - is(installs.length, 0, "Should be no pending install"); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield loadPromise; - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - }); -}, - -function test_urlBar() { - return Task.spawn(function* () { - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - - gBrowser.selectedTab = gBrowser.addTab("about:blank"); - yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - gURLBar.value = TESTROOT + "amosigned.xpi"; - gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); - - yield progressPromise; - let installDialog = yield dialogPromise; - - let notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(installDialog); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.button.label, "Restart Now", "Should have seen the right button"); - is(notification.getAttribute("label"), - "XPI Test will be installed after you restart " + gApp + ".", - "Should have seen the right message"); - - let installs = yield getInstalls(); - is(installs.length, 1, "Should be one pending install"); - installs[0].cancel(); - - yield removeTab(); - }); -}, - -function test_wrongHost() { - return Task.spawn(function* () { - let requestedUrl = TESTROOT2 + "enabled.html"; - gBrowser.selectedTab = gBrowser.addTab(); - - let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, requestedUrl); - gBrowser.loadURI(TESTROOT2 + "enabled.html"); - yield loadedPromise; - - let progressPromise = waitForProgressNotification(); - let notificationPromise = waitForNotification("addon-install-failed"); - gBrowser.loadURI(TESTROOT + "corrupt.xpi"); - yield progressPromise; - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.getAttribute("label"), - "The add-on downloaded from this site could not be installed " + - "because it appears to be corrupt.", - "Should have seen the right message"); - - yield removeTab(); - }); -}, - -function test_reload() { - return Task.spawn(function* () { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "Unsigned XPI": "amosigned.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - yield dialogPromise; - - let notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.button.label, "Restart Now", "Should have seen the right button"); - is(notification.getAttribute("label"), - "XPI Test will be installed after you restart " + gApp + ".", - "Should have seen the right message"); - - function testFail() { - ok(false, "Reloading should not have hidden the notification"); - } - PopupNotifications.panel.addEventListener("popuphiding", testFail, false); - let requestedUrl = TESTROOT2 + "enabled.html"; - let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, requestedUrl); - gBrowser.loadURI(TESTROOT2 + "enabled.html"); - yield loadedPromise; - PopupNotifications.panel.removeEventListener("popuphiding", testFail, false); - - let installs = yield getInstalls(); - is(installs.length, 1, "Should be one pending install"); - installs[0].cancel(); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_theme() { - return Task.spawn(function* () { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "Theme XPI": "theme.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - yield dialogPromise; - - let notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - is(notification.button.label, "Restart Now", "Should have seen the right button"); - is(notification.getAttribute("label"), - "Theme Test will be installed after you restart " + gApp + ".", - "Should have seen the right message"); - - let addon = yield new Promise(resolve => { - AddonManager.getAddonByID("{972ce4c6-7e08-4474-a285-3208198ce6fd}", function(result) { - resolve(result); - }); - }); - ok(addon.userDisabled, "Should be switching away from the default theme."); - // Undo the pending theme switch - addon.userDisabled = false; - - addon = yield new Promise(resolve => { - AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(result) { - resolve(result); - }); - }); - isnot(addon, null, "Test theme will have been installed"); - addon.uninstall(); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_renotifyBlocked() { - return Task.spawn(function* () { - let notificationPromise = waitForNotification("addon-install-blocked"); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "amosigned.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - let panel = yield notificationPromise; - - let closePromise = waitForNotificationClose(); - // hide the panel (this simulates the user dismissing it) - panel.hidePopup(); - yield closePromise; - - info("Timeouts after this probably mean bug 589954 regressed"); - - yield new Promise(resolve => executeSoon(resolve)); - - notificationPromise = waitForNotification("addon-install-blocked"); - gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); - yield notificationPromise; - - let installs = yield getInstalls(); - is(installs.length, 2, "Should be two pending installs"); - - closePromise = waitForNotificationClose(); - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - yield closePromise; - - installs = yield getInstalls(); - is(installs.length, 0, "Should have cancelled the installs"); - }); -}, - -function test_renotifyInstalled() { - return Task.spawn(function* () { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let progressPromise = waitForProgressNotification(); - let dialogPromise = waitForInstallDialog(); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "amosigned.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - yield dialogPromise; - - // Wait for the complete notification - let notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(); - let panel = yield notificationPromise; - - let closePromise = waitForNotificationClose(); - // hide the panel (this simulates the user dismissing it) - panel.hidePopup(); - yield closePromise; - - // Install another - yield new Promise(resolve => executeSoon(resolve)); - - progressPromise = waitForProgressNotification(); - dialogPromise = waitForInstallDialog(); - gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); - yield progressPromise; - yield dialogPromise; - - info("Timeouts after this probably mean bug 589954 regressed"); - - // Wait for the complete notification - notificationPromise = waitForNotification("addon-install-restart"); - acceptInstallDialog(); - yield notificationPromise; - - let installs = yield getInstalls(); - is(installs.length, 1, "Should be one pending installs"); - installs[0].cancel(); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield removeTab(); - }); -}, - -function test_cancel() { - return Task.spawn(function* () { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); - - let notificationPromise = waitForNotification(PROGRESS_NOTIFICATION); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "slowinstall.sjs?file=amosigned.xpi" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - // Close the notification - let anchor = document.getElementById("addons-notification-icon"); - anchor.click(); - // Reopen the notification - anchor.click(); - - ok(PopupNotifications.isPanelOpen, "Notification should still be open"); - is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification"); - notification = panel.childNodes[0]; - is(notification.id, "addon-progress-notification", "Should have seen the progress notification"); - let button = document.getElementById("addon-progress-cancel"); - - // Cancel the download - let install = notification.notification.options.installs[0]; - let cancelledPromise = new Promise(resolve => { - install.addListener({ - onDownloadCancelled: function() { - install.removeListener(this); - resolve(); - } - }); - }); - EventUtils.synthesizeMouseAtCenter(button, {}); - yield cancelledPromise; - - yield new Promise(resolve => executeSoon(resolve)); - - ok(!PopupNotifications.isPanelOpen, "Notification should be closed"); - - let installs = yield getInstalls(); - is(installs.length, 0, "Should be no pending install"); - - Services.perms.remove(makeURI("http://example.com/"), "install"); - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - }); -}, - -function test_failedSecurity() { - return Task.spawn(function* () { - Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false); - setupRedirect({ - "Location": TESTROOT + "amosigned.xpi" - }); - - let notificationPromise = waitForNotification("addon-install-blocked"); - let triggers = encodeURIComponent(JSON.stringify({ - "XPI": "redirect.sjs?mode=redirect" - })); - BrowserTestUtils.openNewForegroundTab(gBrowser, SECUREROOT + "installtrigger.html?" + triggers); - let panel = yield notificationPromise; - - let notification = panel.childNodes[0]; - // Click on Allow - EventUtils.synthesizeMouse(notification.button, 20, 10, {}); - - // Notification should have changed to progress notification - ok(PopupNotifications.isPanelOpen, "Notification should still be open"); - is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification"); - notification = panel.childNodes[0]; - is(notification.id, "addon-progress-notification", "Should have seen the progress notification"); - - // Wait for it to fail - yield new Promise(resolve => { - Services.obs.addObserver(function observer() { - Services.obs.removeObserver(observer, "addon-install-failed"); - resolve(); - }, "addon-install-failed", false); - }); - - // Allow the browser code to add the failure notification and then wait - // for the progress notification to dismiss itself - yield waitForSingleNotification(); - is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification"); - notification = panel.childNodes[0]; - is(notification.id, "addon-install-failed-notification", "Should have seen the install fail"); - - Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, true); - yield removeTab(); - }); -} -]; - -var gTestStart = null; - -var XPInstallObserver = { - observe: function (aSubject, aTopic, aData) { - var installInfo = aSubject.QueryInterface(Components.interfaces.amIWebInstallInfo); - info("Observed " + aTopic + " for " + installInfo.installs.length + " installs"); - installInfo.installs.forEach(function(aInstall) { - info("Install of " + aInstall.sourceURI.spec + " was in state " + aInstall.state); - }); - } -}; - -add_task(function* () { - requestLongerTimeout(4); - - Services.prefs.setBoolPref("extensions.logging.enabled", true); - Services.prefs.setBoolPref("extensions.strictCompatibility", true); - Services.prefs.setBoolPref("extensions.install.requireSecureOrigin", false); - Services.prefs.setIntPref("security.dialog_enable_delay", 0); - - Services.obs.addObserver(XPInstallObserver, "addon-install-started", false); - Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false); - Services.obs.addObserver(XPInstallObserver, "addon-install-failed", false); - Services.obs.addObserver(XPInstallObserver, "addon-install-complete", false); - - registerCleanupFunction(function() { - // Make sure no more test parts run in case we were timed out - TESTS = []; - - AddonManager.getAllInstalls(function(aInstalls) { - aInstalls.forEach(function(aInstall) { - aInstall.cancel(); - }); - }); - - Services.prefs.clearUserPref("extensions.logging.enabled"); - Services.prefs.clearUserPref("extensions.strictCompatibility"); - Services.prefs.clearUserPref("extensions.install.requireSecureOrigin"); - Services.prefs.clearUserPref("security.dialog_enable_delay"); - - Services.obs.removeObserver(XPInstallObserver, "addon-install-started"); - Services.obs.removeObserver(XPInstallObserver, "addon-install-blocked"); - Services.obs.removeObserver(XPInstallObserver, "addon-install-failed"); - Services.obs.removeObserver(XPInstallObserver, "addon-install-complete"); - }); - - for (let i = 0; i < TESTS.length; ++i) { - if (gTestStart) - info("Test part took " + (Date.now() - gTestStart) + "ms"); - - ok(!PopupNotifications.isPanelOpen, "Notification should be closed"); - - let installs = yield new Promise(resolve => { - AddonManager.getAllInstalls(function(aInstalls) { - resolve(aInstalls); - }); - }); - - is(installs.length, 0, "Should be no active installs"); - info("Running " + TESTS[i].name); - gTestStart = Date.now(); - yield TESTS[i](); - } -}); diff --git a/browser/base/content/test/general/browser_bug555224.js b/browser/base/content/test/general/browser_bug555224.js deleted file mode 100644 index d27bf0040..000000000 --- a/browser/base/content/test/general/browser_bug555224.js +++ /dev/null @@ -1,40 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ -const TEST_PAGE = "/browser/browser/base/content/test/general/dummy_page.html"; -var gTestTab, gBgTab, gTestZoom; - -function testBackgroundLoad() { - Task.spawn(function* () { - is(ZoomManager.zoom, gTestZoom, "opening a background tab should not change foreground zoom"); - - yield FullZoomHelper.removeTabAndWaitForLocationChange(gBgTab); - - yield FullZoom.reset(); - yield FullZoomHelper.removeTabAndWaitForLocationChange(gTestTab); - finish(); - }); -} - -function testInitialZoom() { - Task.spawn(function* () { - is(ZoomManager.zoom, 1, "initial zoom level should be 1"); - FullZoom.enlarge(); - - gTestZoom = ZoomManager.zoom; - isnot(gTestZoom, 1, "zoom level should have changed"); - - gBgTab = gBrowser.addTab(); - yield FullZoomHelper.load(gBgTab, "http://mochi.test:8888" + TEST_PAGE); - }).then(testBackgroundLoad, FullZoomHelper.failAndContinue(finish)); -} - -function test() { - waitForExplicitFinish(); - - Task.spawn(function* () { - gTestTab = gBrowser.addTab(); - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTestTab); - yield FullZoomHelper.load(gTestTab, "http://example.org" + TEST_PAGE); - }).then(testInitialZoom, FullZoomHelper.failAndContinue(finish)); -} diff --git a/browser/base/content/test/general/browser_bug555767.js b/browser/base/content/test/general/browser_bug555767.js deleted file mode 100644 index bc774f7dc..000000000 --- a/browser/base/content/test/general/browser_bug555767.js +++ /dev/null @@ -1,54 +0,0 @@ - /* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - - add_task(function* () { - let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; - let tabSelected = false; - - // Open the base tab - let baseTab = gBrowser.addTab(testURL); - - // Wait for the tab to be fully loaded so matching happens correctly - yield promiseTabLoaded(baseTab); - if (baseTab.linkedBrowser.currentURI.spec == "about:blank") - return; - baseTab.linkedBrowser.removeEventListener("load", arguments.callee, true); - - let testTab = gBrowser.addTab(); - - // Select the testTab - gBrowser.selectedTab = testTab; - - // Set the urlbar to include the moz-action - gURLBar.value = "moz-action:switchtab," + JSON.stringify({url: testURL}); - // Focus the urlbar so we can press enter - gURLBar.focus(); - - // Functions for TabClose and TabSelect - function onTabClose(aEvent) { - gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, false); - // Make sure we get the TabClose event for testTab - is(aEvent.originalTarget, testTab, "Got the TabClose event for the right tab"); - // Confirm that we did select the tab - ok(tabSelected, "Confirming that the tab was selected"); - gBrowser.removeTab(baseTab); - finish(); - } - function onTabSelect(aEvent) { - gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect, false); - // Make sure we got the TabSelect event for baseTab - is(aEvent.originalTarget, baseTab, "Got the TabSelect event for the right tab"); - // Confirm that the selected tab is in fact base tab - is(gBrowser.selectedTab, baseTab, "We've switched to the correct tab"); - tabSelected = true; - } - - // Add the TabClose, TabSelect event listeners before we press enter - gBrowser.tabContainer.addEventListener("TabClose", onTabClose, false); - gBrowser.tabContainer.addEventListener("TabSelect", onTabSelect, false); - - // Press enter! - EventUtils.synthesizeKey("VK_RETURN", {}); - }); - diff --git a/browser/base/content/test/general/browser_bug559991.js b/browser/base/content/test/general/browser_bug559991.js deleted file mode 100644 index b1516a8b4..000000000 --- a/browser/base/content/test/general/browser_bug559991.js +++ /dev/null @@ -1,42 +0,0 @@ -var tab; - -function test() { - - // ---------- - // Test setup - - waitForExplicitFinish(); - - gPrefService.setBoolPref("browser.zoom.updateBackgroundTabs", true); - gPrefService.setBoolPref("browser.zoom.siteSpecific", true); - - let uri = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; - - Task.spawn(function* () { - tab = gBrowser.addTab(); - yield FullZoomHelper.load(tab, uri); - - // ------------------------------------------------------------------- - // Test - Trigger a tab switch that should update the zoom level - yield FullZoomHelper.selectTabAndWaitForLocationChange(tab); - ok(true, "applyPrefToSetting was called"); - }).then(endTest, FullZoomHelper.failAndContinue(endTest)); -} - -// ------------- -// Test clean-up -function endTest() { - Task.spawn(function* () { - yield FullZoomHelper.removeTabAndWaitForLocationChange(tab); - - tab = null; - - if (gPrefService.prefHasUserValue("browser.zoom.updateBackgroundTabs")) - gPrefService.clearUserPref("browser.zoom.updateBackgroundTabs"); - - if (gPrefService.prefHasUserValue("browser.zoom.siteSpecific")) - gPrefService.clearUserPref("browser.zoom.siteSpecific"); - - finish(); - }); -} diff --git a/browser/base/content/test/general/browser_bug561636.js b/browser/base/content/test/general/browser_bug561636.js deleted file mode 100644 index 69bc475c3..000000000 --- a/browser/base/content/test/general/browser_bug561636.js +++ /dev/null @@ -1,370 +0,0 @@ -var gInvalidFormPopup = document.getElementById('invalid-form-popup'); -ok(gInvalidFormPopup, - "The browser should have a popup to show when a form is invalid"); - -function checkPopupShow() -{ - ok(gInvalidFormPopup.state == 'showing' || gInvalidFormPopup.state == 'open', - "[Test " + testId + "] The invalid form popup should be shown"); -} - -function checkPopupHide() -{ - ok(gInvalidFormPopup.state != 'showing' && gInvalidFormPopup.state != 'open', - "[Test " + testId + "] The invalid form popup should not be shown"); -} - -var gObserver = { - QueryInterface : XPCOMUtils.generateQI([Ci.nsIFormSubmitObserver]), - - notifyInvalidSubmit : function (aFormElement, aInvalidElements) - { - } -}; - -var testId = 0; - -function incrementTest() -{ - testId++; - info("Starting next part of test"); -} - -function getDocHeader() -{ - return "<html><head><meta charset='utf-8'></head><body>" + getEmptyFrame(); -} - -function getDocFooter() -{ - return "</body></html>"; -} - -function getEmptyFrame() -{ - return "<iframe style='width:100px; height:30px; margin:3px; border:1px solid lightgray;' " + - "name='t' srcdoc=\"<html><head><meta charset='utf-8'></head><body>form target</body></html>\"></iframe>"; -} - -function* openNewTab(uri, background) -{ - let tab = gBrowser.addTab(); - let browser = gBrowser.getBrowserForTab(tab); - if (!background) { - gBrowser.selectedTab = tab; - } - yield promiseTabLoadEvent(tab, "data:text/html," + escape(uri)); - return browser; -} - -function* clickChildElement(browser) -{ - yield ContentTask.spawn(browser, {}, function* () { - content.document.getElementById('s').click(); - }); -} - -function* blurChildElement(browser) -{ - yield ContentTask.spawn(browser, {}, function* () { - content.document.getElementById('i').blur(); - }); -} - -function* checkChildFocus(browser, message) -{ - yield ContentTask.spawn(browser, [message, testId], function* (args) { - let [msg, id] = args; - var focused = content.document.activeElement == content.document.getElementById('i'); - - var validMsg = true; - if (msg) { - validMsg = (msg == content.document.getElementById('i').validationMessage); - } - - Assert.equal(focused, true, "Test " + id + " First invalid element should be focused"); - Assert.equal(validMsg, true, "Test " + id + " The panel should show the message from validationMessage"); - }); -} - -/** - * In this test, we check that no popup appears if the form is valid. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri); - - yield clickChildElement(browser); - - yield new Promise((resolve, reject) => { - // XXXndeakin This isn't really going to work when the content is another process - executeSoon(function() { - checkPopupHide(); - resolve(); - }); - }); - - gBrowser.removeCurrentTab(); -}); - -/** - * In this test, we check that, when an invalid form is submitted, - * the invalid element is focused and a popup appears. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - yield clickChildElement(browser); - yield popupShownPromise; - - checkPopupShow(); - yield checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); - - gBrowser.removeCurrentTab(); -}); - -/** - * In this test, we check that, when an invalid form is submitted, - * the first invalid element is focused and a popup appears. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input><input id='i' required><input required><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - yield clickChildElement(browser); - yield popupShownPromise; - - checkPopupShow(); - yield checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); - - gBrowser.removeCurrentTab(); -}); - -/** - * In this test, we check that, we hide the popup by interacting with the - * invalid element if the element becomes valid. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - yield clickChildElement(browser); - yield popupShownPromise; - - checkPopupShow(); - yield checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); - - let popupHiddenPromise = promiseWaitForEvent(gInvalidFormPopup, "popuphidden"); - EventUtils.synthesizeKey("a", {}); - yield popupHiddenPromise; - - gBrowser.removeCurrentTab(); -}); - -/** - * In this test, we check that, we don't hide the popup by interacting with the - * invalid element if the element is still invalid. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input type='email' id='i' required><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - yield clickChildElement(browser); - yield popupShownPromise; - - checkPopupShow(); - yield checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); - - yield new Promise((resolve, reject) => { - EventUtils.synthesizeKey("a", {}); - executeSoon(function() { - checkPopupShow(); - resolve(); - }) - }); - - gBrowser.removeCurrentTab(); -}); - -/** - * In this test, we check that we can hide the popup by blurring the invalid - * element. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - yield clickChildElement(browser); - yield popupShownPromise; - - checkPopupShow(); - yield checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); - - let popupHiddenPromise = promiseWaitForEvent(gInvalidFormPopup, "popuphidden"); - yield blurChildElement(browser); - yield popupHiddenPromise; - - gBrowser.removeCurrentTab(); -}); - -/** - * In this test, we check that we can hide the popup by pressing TAB. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - yield clickChildElement(browser); - yield popupShownPromise; - - checkPopupShow(); - yield checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); - - let popupHiddenPromise = promiseWaitForEvent(gInvalidFormPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {}); - yield popupHiddenPromise; - - gBrowser.removeCurrentTab(); -}); - -/** - * In this test, we check that the popup will hide if we move to another tab. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter(); - let browser1 = yield openNewTab(uri); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - yield clickChildElement(browser1); - yield popupShownPromise; - - checkPopupShow(); - yield checkChildFocus(browser1, gInvalidFormPopup.firstChild.textContent); - - let popupHiddenPromise = promiseWaitForEvent(gInvalidFormPopup, "popuphidden"); - - let browser2 = yield openNewTab("data:text/html,<html></html>"); - yield popupHiddenPromise; - - gBrowser.removeTab(gBrowser.getTabForBrowser(browser1)); - gBrowser.removeTab(gBrowser.getTabForBrowser(browser2)); -}); - -/** - * In this test, we check that nothing happen if the invalid form is - * submitted in a background tab. - */ -add_task(function* () -{ - // Observers don't propagate currently across processes. We may add support for this in the - // future via the addon compat layer. - if (gMultiProcessBrowser) { - return; - } - - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri, true); - isnot(gBrowser.selectedBrowser, browser, "This tab should have been loaded in background"); - - let notifierPromise = new Promise((resolve, reject) => { - gObserver.notifyInvalidSubmit = function() { - executeSoon(function() { - checkPopupHide(); - - // Clean-up - Services.obs.removeObserver(gObserver, "invalidformsubmit"); - gObserver.notifyInvalidSubmit = function () {}; - resolve(); - }); - }; - - Services.obs.addObserver(gObserver, "invalidformsubmit", false); - - executeSoon(function () { - browser.contentDocument.getElementById('s').click(); - }); - }); - - yield notifierPromise; - - gBrowser.removeTab(gBrowser.getTabForBrowser(browser)); -}); - -/** - * In this test, we check that the author defined error message is shown. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input x-moz-errormessage='foo' required id='i'><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - yield clickChildElement(browser); - yield popupShownPromise; - - checkPopupShow(); - yield checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); - - is(gInvalidFormPopup.firstChild.textContent, "foo", - "The panel should show the author defined error message"); - - gBrowser.removeCurrentTab(); -}); - -/** - * In this test, we check that the message is correctly updated when it changes. - */ -add_task(function* () -{ - incrementTest(); - let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input type='email' required id='i'><input id='s' type='submit'></form>" + getDocFooter(); - let browser = yield openNewTab(uri); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - yield clickChildElement(browser); - yield popupShownPromise; - - checkPopupShow(); - yield checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); - - let inputPromise = promiseWaitForEvent(gBrowser.contentDocument.getElementById('i'), "input"); - EventUtils.synthesizeKey('f', {}); - yield inputPromise; - - // Now, the element suffers from another error, the message should have - // been updated. - yield new Promise((resolve, reject) => { - // XXXndeakin This isn't really going to work when the content is another process - executeSoon(function() { - checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); - resolve(); - }); - }); - - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_bug563588.js b/browser/base/content/test/general/browser_bug563588.js deleted file mode 100644 index a1774fb7e..000000000 --- a/browser/base/content/test/general/browser_bug563588.js +++ /dev/null @@ -1,30 +0,0 @@ -function press(key, expectedPos) { - var originalSelectedTab = gBrowser.selectedTab; - EventUtils.synthesizeKey("VK_" + key.toUpperCase(), { accelKey: true }); - is(gBrowser.selectedTab, originalSelectedTab, - "accel+" + key + " doesn't change which tab is selected"); - is(gBrowser.tabContainer.selectedIndex, expectedPos, - "accel+" + key + " moves the tab to the expected position"); - is(document.activeElement, gBrowser.selectedTab, - "accel+" + key + " leaves the selected tab focused"); -} - -function test() { - gBrowser.addTab(); - gBrowser.addTab(); - is(gBrowser.tabs.length, 3, "got three tabs"); - is(gBrowser.tabs[0], gBrowser.selectedTab, "first tab is selected"); - - gBrowser.selectedTab.focus(); - is(document.activeElement, gBrowser.selectedTab, "selected tab is focused"); - - press("right", 1); - press("down", 2); - press("left", 1); - press("up", 0); - press("end", 2); - press("home", 0); - - gBrowser.removeCurrentTab(); - gBrowser.removeCurrentTab(); -} diff --git a/browser/base/content/test/general/browser_bug565575.js b/browser/base/content/test/general/browser_bug565575.js deleted file mode 100644 index 3555a2e7f..000000000 --- a/browser/base/content/test/general/browser_bug565575.js +++ /dev/null @@ -1,14 +0,0 @@ -add_task(function* () { - gBrowser.selectedBrowser.focus(); - - yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => BrowserOpenTab(), false); - ok(gURLBar.focused, "location bar is focused for a new tab"); - - yield BrowserTestUtils.switchTab(gBrowser, gBrowser.tabs[0]); - ok(!gURLBar.focused, "location bar isn't focused for the previously selected tab"); - - yield BrowserTestUtils.switchTab(gBrowser, gBrowser.tabs[1]); - ok(gURLBar.focused, "location bar is re-focused when selecting the new tab"); - - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_bug567306.js b/browser/base/content/test/general/browser_bug567306.js deleted file mode 100644 index 742ff6726..000000000 --- a/browser/base/content/test/general/browser_bug567306.js +++ /dev/null @@ -1,50 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -var {Ci: interfaces, Cc: classes} = Components; - -var Clipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard); -var HasFindClipboard = Clipboard.supportsFindClipboard(); - -add_task(function* () { - let newwindow = yield BrowserTestUtils.openNewBrowserWindow(); - - let selectedBrowser = newwindow.gBrowser.selectedBrowser; - yield new Promise((resolve, reject) => { - selectedBrowser.addEventListener("pageshow", function pageshowListener() { - if (selectedBrowser.currentURI.spec == "about:blank") - return; - - selectedBrowser.removeEventListener("pageshow", pageshowListener, true); - ok(true, "pageshow listener called: " + newwindow.content.location); - resolve(); - }, true); - selectedBrowser.loadURI("data:text/html,<h1 id='h1'>Select Me</h1>"); - }); - - yield SimpleTest.promiseFocus(newwindow); - - ok(!newwindow.gFindBarInitialized, "find bar is not yet initialized"); - let findBar = newwindow.gFindBar; - - yield ContentTask.spawn(selectedBrowser, { }, function* () { - let elt = content.document.getElementById("h1"); - let selection = content.getSelection(); - let range = content.document.createRange(); - range.setStart(elt, 0); - range.setEnd(elt, 1); - selection.removeAllRanges(); - selection.addRange(range); - }); - - yield findBar.onFindCommand(); - - // When the OS supports the Find Clipboard (OSX), the find field value is - // persisted across Fx sessions, thus not useful to test. - if (!HasFindClipboard) - is(findBar._findField.value, "Select Me", "Findbar is initialized with selection"); - findBar.close(); - yield promiseWindowClosed(newwindow); -}); - diff --git a/browser/base/content/test/general/browser_bug575561.js b/browser/base/content/test/general/browser_bug575561.js deleted file mode 100644 index b6d17a447..000000000 --- a/browser/base/content/test/general/browser_bug575561.js +++ /dev/null @@ -1,97 +0,0 @@ -requestLongerTimeout(2); - -const TEST_URL = "http://example.com/browser/browser/base/content/test/general/app_bug575561.html"; - -add_task(function*() { - SimpleTest.requestCompleteLog(); - - // Pinned: Link to the same domain should not open a new tab - // Tests link to http://example.com/browser/browser/base/content/test/general/dummy_page.html - yield testLink(0, true, false); - // Pinned: Link to a different subdomain should open a new tab - // Tests link to http://test1.example.com/browser/browser/base/content/test/general/dummy_page.html - yield testLink(1, true, true); - - // Pinned: Link to a different domain should open a new tab - // Tests link to http://example.org/browser/browser/base/content/test/general/dummy_page.html - yield testLink(2, true, true); - - // Not Pinned: Link to a different domain should not open a new tab - // Tests link to http://example.org/browser/browser/base/content/test/general/dummy_page.html - yield testLink(2, false, false); - - // Pinned: Targetted link should open a new tab - // Tests link to http://example.org/browser/browser/base/content/test/general/dummy_page.html with target="foo" - yield testLink(3, true, true); - - // Pinned: Link in a subframe should not open a new tab - // Tests link to http://example.org/browser/browser/base/content/test/general/dummy_page.html in subframe - yield testLink(0, true, false, true); - - // Pinned: Link to the same domain (with www prefix) should not open a new tab - // Tests link to http://www.example.com/browser/browser/base/content/test/general/dummy_page.html - yield testLink(4, true, false); - - // Pinned: Link to a data: URI should not open a new tab - // Tests link to data:text/html,<!DOCTYPE html><html><body>Another Page</body></html> - yield testLink(5, true, false); - - // Pinned: Link to an about: URI should not open a new tab - // Tests link to about:logo - yield testLink(function(doc) { - let link = doc.createElement("a"); - link.textContent = "Link to Mozilla"; - link.href = "about:logo"; - doc.body.appendChild(link); - return link; - }, true, false, false, "about:robots"); -}); - -var waitForPageLoad = Task.async(function*(browser, linkLocation) { - yield waitForDocLoadComplete(); - - is(browser.contentDocument.location.href, linkLocation, "Link should not open in a new tab"); -}); - -var waitForTabOpen = Task.async(function*() { - let event = yield promiseWaitForEvent(gBrowser.tabContainer, "TabOpen", true); - ok(true, "Link should open a new tab"); - - yield waitForDocLoadComplete(event.target.linkedBrowser); - yield Promise.resolve(); - - gBrowser.removeCurrentTab(); -}); - -var testLink = Task.async(function*(aLinkIndexOrFunction, pinTab, expectNewTab, testSubFrame, aURL = TEST_URL) { - let appTab = gBrowser.addTab(aURL, {skipAnimation: true}); - if (pinTab) - gBrowser.pinTab(appTab); - gBrowser.selectedTab = appTab; - - yield waitForDocLoadComplete(); - - let browser = appTab.linkedBrowser; - if (testSubFrame) - browser = browser.contentDocument.querySelector("iframe"); - - let link; - if (typeof aLinkIndexOrFunction == "function") { - link = aLinkIndexOrFunction(browser.contentDocument); - } else { - link = browser.contentDocument.querySelectorAll("a")[aLinkIndexOrFunction]; - } - - let promise; - if (expectNewTab) - promise = waitForTabOpen(); - else - promise = waitForPageLoad(browser, link.href); - - info("Clicking " + link.textContent); - link.click(); - - yield promise; - - gBrowser.removeTab(appTab); -}); diff --git a/browser/base/content/test/general/browser_bug575830.js b/browser/base/content/test/general/browser_bug575830.js deleted file mode 100644 index 5393c08d7..000000000 --- a/browser/base/content/test/general/browser_bug575830.js +++ /dev/null @@ -1,33 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ -"use strict"; - -function test() { - let tab1, tab2; - const TEST_IMAGE = "http://example.org/browser/browser/base/content/test/general/moz.png"; - - waitForExplicitFinish(); - - Task.spawn(function* () { - tab1 = gBrowser.addTab(); - tab2 = gBrowser.addTab(); - yield FullZoomHelper.selectTabAndWaitForLocationChange(tab1); - yield FullZoomHelper.load(tab1, TEST_IMAGE); - - is(ZoomManager.zoom, 1, "initial zoom level for first should be 1"); - - FullZoom.enlarge(); - let zoom = ZoomManager.zoom; - isnot(zoom, 1, "zoom level should have changed"); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(tab2); - is(ZoomManager.zoom, 1, "initial zoom level for second tab should be 1"); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(tab1); - is(ZoomManager.zoom, zoom, "zoom level for first tab should not have changed"); - - yield FullZoomHelper.removeTabAndWaitForLocationChange(tab1); - yield FullZoomHelper.removeTabAndWaitForLocationChange(tab2); - }).then(finish, FullZoomHelper.failAndContinue(finish)); -} diff --git a/browser/base/content/test/general/browser_bug577121.js b/browser/base/content/test/general/browser_bug577121.js deleted file mode 100644 index 5ebfdc115..000000000 --- a/browser/base/content/test/general/browser_bug577121.js +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - Services.prefs.setBoolPref("browser.tabs.animate", false); - registerCleanupFunction(function() { - Services.prefs.clearUserPref("browser.tabs.animate"); - }); - - // Open 2 other tabs, and pin the second one. Like that, the initial tab - // should get closed. - let testTab1 = gBrowser.addTab(); - let testTab2 = gBrowser.addTab(); - gBrowser.pinTab(testTab2); - - // Now execute "Close other Tabs" on the first manually opened tab (tab1). - // -> tab2 ist pinned, tab1 should remain open and the initial tab should - // get closed. - gBrowser.removeAllTabsBut(testTab1); - - is(gBrowser.tabs.length, 2, "there are two remaining tabs open"); - is(gBrowser.tabs[0], testTab2, "pinned tab2 stayed open"); - is(gBrowser.tabs[1], testTab1, "tab1 stayed open"); - - // Cleanup. Close only one tab because we need an opened tab at the end of - // the test. - gBrowser.removeTab(testTab2); -} diff --git a/browser/base/content/test/general/browser_bug578534.js b/browser/base/content/test/general/browser_bug578534.js deleted file mode 100644 index 0d61cca76..000000000 --- a/browser/base/content/test/general/browser_bug578534.js +++ /dev/null @@ -1,23 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -add_task(function* test() { - let uriString = "http://example.com/"; - let cookieBehavior = "network.cookie.cookieBehavior"; - let uriObj = Services.io.newURI(uriString, null, null) - let cp = Components.classes["@mozilla.org/cookie/permission;1"] - .getService(Components.interfaces.nsICookiePermission); - - yield SpecialPowers.pushPrefEnv({ set: [[ cookieBehavior, 2 ]] }); - cp.setAccess(uriObj, cp.ACCESS_ALLOW); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: uriString }, function* (browser) { - yield ContentTask.spawn(browser, null, function() { - is(content.navigator.cookieEnabled, true, - "navigator.cookieEnabled should be true"); - }); - }); - - cp.setAccess(uriObj, cp.ACCESS_DEFAULT); -}); diff --git a/browser/base/content/test/general/browser_bug579872.js b/browser/base/content/test/general/browser_bug579872.js deleted file mode 100644 index bc10ca0c8..000000000 --- a/browser/base/content/test/general/browser_bug579872.js +++ /dev/null @@ -1,28 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - let newTab = gBrowser.addTab(); - waitForExplicitFinish(); - BrowserTestUtils.browserLoaded(newTab.linkedBrowser).then(mainPart); - - function mainPart() { - gBrowser.pinTab(newTab); - gBrowser.selectedTab = newTab; - - openUILinkIn("javascript:var x=0;", "current"); - is(gBrowser.tabs.length, 2, "Should open in current tab"); - - openUILinkIn("http://example.com/1", "current"); - is(gBrowser.tabs.length, 2, "Should open in current tab"); - - openUILinkIn("http://example.org/", "current"); - is(gBrowser.tabs.length, 3, "Should open in new tab"); - - gBrowser.removeTab(newTab); - gBrowser.removeTab(gBrowser.tabs[1]); // example.org tab - finish(); - } - newTab.linkedBrowser.loadURI("http://example.com"); -} diff --git a/browser/base/content/test/general/browser_bug580638.js b/browser/base/content/test/general/browser_bug580638.js deleted file mode 100644 index 66defafe3..000000000 --- a/browser/base/content/test/general/browser_bug580638.js +++ /dev/null @@ -1,60 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - waitForExplicitFinish(); - - function testState(aPinned) { - function elemAttr(id, attr) { - return document.getElementById(id).getAttribute(attr); - } - - if (aPinned) { - is(elemAttr("key_close", "disabled"), "true", - "key_close should be disabled when a pinned-tab is selected"); - is(elemAttr("menu_close", "key"), "", - "menu_close shouldn't have a key set when a pinned is selected"); - } - else { - is(elemAttr("key_close", "disabled"), "", - "key_closed shouldn't have disabled state set when a non-pinned tab is selected"); - is(elemAttr("menu_close", "key"), "key_close", - "menu_close should have key_close set as its key when a non-pinned tab is selected"); - } - } - - let lastSelectedTab = gBrowser.selectedTab; - ok(!lastSelectedTab.pinned, "We should have started with a regular tab selected"); - - testState(false); - - let pinnedTab = gBrowser.addTab("about:blank"); - gBrowser.pinTab(pinnedTab); - - // Just pinning the tab shouldn't change the key state. - testState(false); - - // Test updating key state after selecting a tab. - gBrowser.selectedTab = pinnedTab; - testState(true); - - gBrowser.selectedTab = lastSelectedTab; - testState(false); - - gBrowser.selectedTab = pinnedTab; - testState(true); - - // Test updating the key state after un/pinning the tab. - gBrowser.unpinTab(pinnedTab); - testState(false); - - gBrowser.pinTab(pinnedTab); - testState(true); - - // Test updating the key state after removing the tab. - gBrowser.removeTab(pinnedTab); - testState(false); - - finish(); -} diff --git a/browser/base/content/test/general/browser_bug580956.js b/browser/base/content/test/general/browser_bug580956.js deleted file mode 100644 index b8e7bc20b..000000000 --- a/browser/base/content/test/general/browser_bug580956.js +++ /dev/null @@ -1,26 +0,0 @@ -function numClosedTabs() { - return SessionStore.getClosedTabCount(window); -} - -function isUndoCloseEnabled() { - updateTabContextMenu(); - return !document.getElementById("context_undoCloseTab").disabled; -} - -function test() { - waitForExplicitFinish(); - - gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", 0); - gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo"); - is(numClosedTabs(), 0, "There should be 0 closed tabs."); - ok(!isUndoCloseEnabled(), "Undo Close Tab should be disabled."); - - var tab = gBrowser.addTab("http://mochi.test:8888/"); - var browser = gBrowser.getBrowserForTab(tab); - BrowserTestUtils.browserLoaded(browser).then(() => { - BrowserTestUtils.removeTab(tab).then(() => { - ok(isUndoCloseEnabled(), "Undo Close Tab should be enabled."); - finish(); - }); - }); -} diff --git a/browser/base/content/test/general/browser_bug581242.js b/browser/base/content/test/general/browser_bug581242.js deleted file mode 100644 index 668c0cd41..000000000 --- a/browser/base/content/test/general/browser_bug581242.js +++ /dev/null @@ -1,21 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - // Create a new tab and load about:addons - let blanktab = gBrowser.addTab(); - gBrowser.selectedTab = blanktab; - BrowserOpenAddonsMgr(); - - is(blanktab, gBrowser.selectedTab, "Current tab should be blank tab"); - // Verify that about:addons loads - waitForExplicitFinish(); - gBrowser.selectedBrowser.addEventListener("load", function() { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - let browser = blanktab.linkedBrowser; - is(browser.currentURI.spec, "about:addons", "about:addons should load into blank tab."); - gBrowser.removeTab(blanktab); - finish(); - }, true); -} diff --git a/browser/base/content/test/general/browser_bug581253.js b/browser/base/content/test/general/browser_bug581253.js deleted file mode 100644 index 0c537c3d3..000000000 --- a/browser/base/content/test/general/browser_bug581253.js +++ /dev/null @@ -1,86 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -var testURL = "data:text/plain,nothing but plain text"; -var testTag = "581253_tag"; -var timerID = -1; - -function test() { - registerCleanupFunction(function() { - PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId); - if (timerID > 0) { - clearTimeout(timerID); - } - }); - waitForExplicitFinish(); - - let tab = gBrowser.selectedTab = gBrowser.addTab(); - tab.linkedBrowser.addEventListener("load", (function(event) { - tab.linkedBrowser.removeEventListener("load", arguments.callee, true); - - let uri = makeURI(testURL); - let bmTxn = - new PlacesCreateBookmarkTransaction(uri, - PlacesUtils.unfiledBookmarksFolderId, - -1, "", null, []); - PlacesUtils.transactionManager.doTransaction(bmTxn); - - ok(PlacesUtils.bookmarks.isBookmarked(uri), "the test url is bookmarked"); - waitForStarChange(true, onStarred); - }), true); - - content.location = testURL; -} - -function waitForStarChange(aValue, aCallback) { - let expectedStatus = aValue ? BookmarkingUI.STATUS_STARRED - : BookmarkingUI.STATUS_UNSTARRED; - if (BookmarkingUI.status == BookmarkingUI.STATUS_UPDATING || - BookmarkingUI.status != expectedStatus) { - info("Waiting for star button change."); - setTimeout(waitForStarChange, 50, aValue, aCallback); - return; - } - aCallback(); -} - -function onStarred() { - is(BookmarkingUI.status, BookmarkingUI.STATUS_STARRED, - "star button indicates that the page is bookmarked"); - - let uri = makeURI(testURL); - let tagTxn = new PlacesTagURITransaction(uri, [testTag]); - PlacesUtils.transactionManager.doTransaction(tagTxn); - - StarUI.panel.addEventListener("popupshown", onPanelShown, false); - BookmarkingUI.star.click(); -} - -function onPanelShown(aEvent) { - if (aEvent.target == StarUI.panel) { - StarUI.panel.removeEventListener("popupshown", arguments.callee, false); - let tagsField = document.getElementById("editBMPanel_tagsField"); - ok(tagsField.value == testTag, "tags field value was set"); - tagsField.focus(); - - StarUI.panel.addEventListener("popuphidden", onPanelHidden, false); - let removeButton = document.getElementById("editBookmarkPanelRemoveButton"); - removeButton.click(); - } -} - -function onPanelHidden(aEvent) { - if (aEvent.target == StarUI.panel) { - StarUI.panel.removeEventListener("popuphidden", arguments.callee, false); - - executeSoon(function() { - ok(!PlacesUtils.bookmarks.isBookmarked(makeURI(testURL)), - "the bookmark for the test url has been removed"); - is(BookmarkingUI.status, BookmarkingUI.STATUS_UNSTARRED, - "star button indicates that the bookmark has been removed"); - gBrowser.removeCurrentTab(); - PlacesTestUtils.clearHistory().then(finish); - }); - } -} diff --git a/browser/base/content/test/general/browser_bug585558.js b/browser/base/content/test/general/browser_bug585558.js deleted file mode 100644 index bae832b4d..000000000 --- a/browser/base/content/test/general/browser_bug585558.js +++ /dev/null @@ -1,153 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -var tabs = []; - -function addTab(aURL) { - tabs.push(gBrowser.addTab(aURL, {skipAnimation: true})); -} - -function testAttrib(elem, attrib, attribValue, msg) { - is(elem.hasAttribute(attrib), attribValue, msg); -} - -function test() { - waitForExplicitFinish(); - - is(gBrowser.tabs.length, 1, "one tab is open initially"); - - // Add several new tabs in sequence, hiding some, to ensure that the - // correct attributes get set - - addTab("http://mochi.test:8888/#0"); - addTab("http://mochi.test:8888/#1"); - addTab("http://mochi.test:8888/#2"); - addTab("http://mochi.test:8888/#3"); - - gBrowser.selectedTab = gBrowser.tabs[0]; - testAttrib(gBrowser.tabs[0], "first-visible-tab", true, - "First tab marked first-visible-tab!"); - testAttrib(gBrowser.tabs[4], "last-visible-tab", true, - "Fifth tab marked last-visible-tab!"); - testAttrib(gBrowser.tabs[0], "selected", true, "First tab marked selected!"); - testAttrib(gBrowser.tabs[0], "afterselected-visible", false, - "First tab not marked afterselected-visible!"); - testAttrib(gBrowser.tabs[1], "afterselected-visible", true, - "Second tab marked afterselected-visible!"); - gBrowser.hideTab(gBrowser.tabs[1]); - executeSoon(test_hideSecond); -} - -function test_hideSecond() { - testAttrib(gBrowser.tabs[2], "afterselected-visible", true, - "Third tab marked afterselected-visible!"); - gBrowser.showTab(gBrowser.tabs[1]) - executeSoon(test_showSecond); -} - -function test_showSecond() { - testAttrib(gBrowser.tabs[1], "afterselected-visible", true, - "Second tab marked afterselected-visible!"); - testAttrib(gBrowser.tabs[2], "afterselected-visible", false, - "Third tab not marked as afterselected-visible!"); - gBrowser.selectedTab = gBrowser.tabs[1]; - gBrowser.hideTab(gBrowser.tabs[0]); - executeSoon(test_hideFirst); -} - -function test_hideFirst() { - testAttrib(gBrowser.tabs[0], "first-visible-tab", false, - "Hidden first tab not marked first-visible-tab!"); - testAttrib(gBrowser.tabs[1], "first-visible-tab", true, - "Second tab marked first-visible-tab!"); - gBrowser.showTab(gBrowser.tabs[0]); - executeSoon(test_showFirst); -} - -function test_showFirst() { - testAttrib(gBrowser.tabs[0], "first-visible-tab", true, - "First tab marked first-visible-tab!"); - gBrowser.selectedTab = gBrowser.tabs[2]; - testAttrib(gBrowser.tabs[3], "afterselected-visible", true, - "Fourth tab marked afterselected-visible!"); - - gBrowser.moveTabTo(gBrowser.selectedTab, 1); - executeSoon(test_movedLower); -} - -function test_movedLower() { - testAttrib(gBrowser.tabs[2], "afterselected-visible", true, - "Third tab marked afterselected-visible!"); - test_hoverOne(); -} - -function test_hoverOne() { - EventUtils.synthesizeMouseAtCenter(gBrowser.tabs[4], { type: "mousemove" }); - testAttrib(gBrowser.tabs[3], "beforehovered", true, "Fourth tab marked beforehovered"); - EventUtils.synthesizeMouseAtCenter(gBrowser.tabs[3], { type: "mousemove" }); - testAttrib(gBrowser.tabs[2], "beforehovered", true, "Third tab marked beforehovered!"); - testAttrib(gBrowser.tabs[2], "afterhovered", false, "Third tab not marked afterhovered!"); - testAttrib(gBrowser.tabs[4], "afterhovered", true, "Fifth tab marked afterhovered!"); - testAttrib(gBrowser.tabs[4], "beforehovered", false, "Fifth tab not marked beforehovered!"); - testAttrib(gBrowser.tabs[0], "beforehovered", false, "First tab not marked beforehovered!"); - testAttrib(gBrowser.tabs[0], "afterhovered", false, "First tab not marked afterhovered!"); - testAttrib(gBrowser.tabs[1], "beforehovered", false, "Second tab not marked beforehovered!"); - testAttrib(gBrowser.tabs[1], "afterhovered", false, "Second tab not marked afterhovered!"); - testAttrib(gBrowser.tabs[3], "beforehovered", false, "Fourth tab not marked beforehovered!"); - testAttrib(gBrowser.tabs[3], "afterhovered", false, "Fourth tab not marked afterhovered!"); - gBrowser.removeTab(tabs.pop()); - executeSoon(test_hoverStatePersistence); -} - -function test_hoverStatePersistence() { - // Test that the afterhovered and beforehovered attributes are still there when - // a tab is selected and then unselected again. See bug 856107. - - function assertState() { - testAttrib(gBrowser.tabs[0], "beforehovered", true, "First tab still marked beforehovered!"); - testAttrib(gBrowser.tabs[0], "afterhovered", false, "First tab not marked afterhovered!"); - testAttrib(gBrowser.tabs[2], "afterhovered", true, "Third tab still marked afterhovered!"); - testAttrib(gBrowser.tabs[2], "beforehovered", false, "Third tab not marked afterhovered!"); - testAttrib(gBrowser.tabs[1], "beforehovered", false, "Second tab not marked beforehovered!"); - testAttrib(gBrowser.tabs[1], "afterhovered", false, "Second tab not marked afterhovered!"); - testAttrib(gBrowser.tabs[3], "beforehovered", false, "Fourth tab not marked beforehovered!"); - testAttrib(gBrowser.tabs[3], "afterhovered", false, "Fourth tab not marked afterhovered!"); - } - - gBrowser.selectedTab = gBrowser.tabs[3]; - EventUtils.synthesizeMouseAtCenter(gBrowser.tabs[1], { type: "mousemove" }); - assertState(); - gBrowser.selectedTab = gBrowser.tabs[1]; - assertState(); - gBrowser.selectedTab = gBrowser.tabs[3]; - assertState(); - executeSoon(test_pinning); -} - -function test_pinning() { - gBrowser.selectedTab = gBrowser.tabs[3]; - testAttrib(gBrowser.tabs[3], "last-visible-tab", true, - "Fourth tab marked last-visible-tab!"); - testAttrib(gBrowser.tabs[3], "selected", true, "Fourth tab marked selected!"); - testAttrib(gBrowser.tabs[3], "afterselected-visible", false, - "Fourth tab not marked afterselected-visible!"); - // Causes gBrowser.tabs to change indices - gBrowser.pinTab(gBrowser.tabs[3]); - testAttrib(gBrowser.tabs[3], "last-visible-tab", true, - "Fourth tab marked last-visible-tab!"); - testAttrib(gBrowser.tabs[1], "afterselected-visible", true, - "Second tab marked afterselected-visible!"); - testAttrib(gBrowser.tabs[0], "first-visible-tab", true, - "First tab marked first-visible-tab!"); - testAttrib(gBrowser.tabs[0], "selected", true, "First tab marked selected!"); - gBrowser.selectedTab = gBrowser.tabs[1]; - testAttrib(gBrowser.tabs[2], "afterselected-visible", true, - "Third tab marked afterselected-visible!"); - test_cleanUp(); -} - -function test_cleanUp() { - tabs.forEach(gBrowser.removeTab, gBrowser); - finish(); -} diff --git a/browser/base/content/test/general/browser_bug585785.js b/browser/base/content/test/general/browser_bug585785.js deleted file mode 100644 index 4f9045231..000000000 --- a/browser/base/content/test/general/browser_bug585785.js +++ /dev/null @@ -1,35 +0,0 @@ -var tab; - -function test() { - waitForExplicitFinish(); - - tab = gBrowser.addTab(); - isnot(tab.getAttribute("fadein"), "true", "newly opened tab is yet to fade in"); - - // Try to remove the tab right before the opening animation's first frame - window.requestAnimationFrame(checkAnimationState); -} - -function checkAnimationState() { - is(tab.getAttribute("fadein"), "true", "tab opening animation initiated"); - - info(window.getComputedStyle(tab).maxWidth); - gBrowser.removeTab(tab, { animate: true }); - if (!tab.parentNode) { - ok(true, "tab removed synchronously since the opening animation hasn't moved yet"); - finish(); - return; - } - - info("tab didn't close immediately, so the tab opening animation must have started moving"); - info("waiting for the tab to close asynchronously"); - tab.addEventListener("transitionend", function (event) { - if (event.propertyName == "max-width") { - tab.removeEventListener("transitionend", arguments.callee, false); - executeSoon(function () { - ok(!tab.parentNode, "tab removed asynchronously"); - finish(); - }); - } - }, false); -} diff --git a/browser/base/content/test/general/browser_bug585830.js b/browser/base/content/test/general/browser_bug585830.js deleted file mode 100644 index 6d3adf198..000000000 --- a/browser/base/content/test/general/browser_bug585830.js +++ /dev/null @@ -1,25 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - let tab1 = gBrowser.selectedTab; - let tab2 = gBrowser.addTab("about:blank", {skipAnimation: true}); - gBrowser.addTab(); - gBrowser.selectedTab = tab2; - - gBrowser.removeCurrentTab({animate: true}); - gBrowser.tabContainer.advanceSelectedTab(-1, true); - is(gBrowser.selectedTab, tab1, "First tab should be selected"); - gBrowser.removeTab(tab2); - - // test for "null has no properties" fix. See Bug 585830 Comment 13 - gBrowser.removeCurrentTab({animate: true}); - try { - gBrowser.tabContainer.advanceSelectedTab(-1, false); - } catch (err) { - ok(false, "Shouldn't throw"); - } - - gBrowser.removeTab(tab1); -} diff --git a/browser/base/content/test/general/browser_bug590206.js b/browser/base/content/test/general/browser_bug590206.js deleted file mode 100644 index f73d144e9..000000000 --- a/browser/base/content/test/general/browser_bug590206.js +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Test the identity mode UI for a variety of page types - */ - -"use strict"; - -const DUMMY = "browser/browser/base/content/test/general/dummy_page.html"; - -function loadNewTab(url) { - return BrowserTestUtils.openNewForegroundTab(gBrowser, url); -} - -function getIdentityMode() { - return document.getElementById("identity-box").className; -} - -function getConnectionState() { - gIdentityHandler.refreshIdentityPopup(); - return document.getElementById("identity-popup").getAttribute("connection"); -} - -// This test is slow on Linux debug e10s -requestLongerTimeout(2); - -add_task(function* test_webpage() { - let oldTab = gBrowser.selectedTab; - - let newTab = yield loadNewTab("http://example.com/" + DUMMY); - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = oldTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = newTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.removeTab(newTab); -}); - -add_task(function* test_blank() { - let oldTab = gBrowser.selectedTab; - - let newTab = yield loadNewTab("about:blank"); - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = oldTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = newTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.removeTab(newTab); -}); - -add_task(function* test_chrome() { - let oldTab = gBrowser.selectedTab; - - let newTab = yield loadNewTab("chrome://mozapps/content/extensions/extensions.xul"); - is(getConnectionState(), "file", "Connection should be file"); - - gBrowser.selectedTab = oldTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = newTab; - is(getConnectionState(), "file", "Connection should be file"); - - gBrowser.removeTab(newTab); -}); - -add_task(function* test_https() { - let oldTab = gBrowser.selectedTab; - - let newTab = yield loadNewTab("https://example.com/" + DUMMY); - is(getIdentityMode(), "verifiedDomain", "Identity should be verified"); - - gBrowser.selectedTab = oldTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = newTab; - is(getIdentityMode(), "verifiedDomain", "Identity should be verified"); - - gBrowser.removeTab(newTab); -}); - -add_task(function* test_addons() { - let oldTab = gBrowser.selectedTab; - - let newTab = yield loadNewTab("about:addons"); - is(getIdentityMode(), "chromeUI", "Identity should be chrome"); - - gBrowser.selectedTab = oldTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = newTab; - is(getIdentityMode(), "chromeUI", "Identity should be chrome"); - - gBrowser.removeTab(newTab); -}); - -add_task(function* test_file() { - let oldTab = gBrowser.selectedTab; - let fileURI = getTestFilePath(""); - - let newTab = yield loadNewTab(fileURI); - is(getConnectionState(), "file", "Connection should be file"); - - gBrowser.selectedTab = oldTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = newTab; - is(getConnectionState(), "file", "Connection should be file"); - - gBrowser.removeTab(newTab); -}); - -add_task(function* test_resource_uri() { - let oldTab = gBrowser.selectedTab; - let dataURI = "resource://gre/modules/Services.jsm"; - - let newTab = yield loadNewTab(dataURI); - - is(getConnectionState(), "file", "Connection should be file"); - - gBrowser.selectedTab = oldTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = newTab; - is(getConnectionState(), "file", "Connection should be file"); - - gBrowser.removeTab(newTab); -}); - -add_task(function* test_data_uri() { - let oldTab = gBrowser.selectedTab; - let dataURI = "data:text/html,hi" - - let newTab = yield loadNewTab(dataURI); - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = oldTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = newTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.removeTab(newTab); -}); - -add_task(function* test_about_uri() { - let oldTab = gBrowser.selectedTab; - let aboutURI = "about:robots" - - let newTab = yield loadNewTab(aboutURI); - is(getConnectionState(), "file", "Connection should be file"); - - gBrowser.selectedTab = oldTab; - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - - gBrowser.selectedTab = newTab; - is(getConnectionState(), "file", "Connection should be file"); - - gBrowser.removeTab(newTab); -}); diff --git a/browser/base/content/test/general/browser_bug592338.js b/browser/base/content/test/general/browser_bug592338.js deleted file mode 100644 index ca9cc361a..000000000 --- a/browser/base/content/test/general/browser_bug592338.js +++ /dev/null @@ -1,163 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -const TESTROOT = "http://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/"; - -var tempScope = {}; -Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", tempScope); -var LightweightThemeManager = tempScope.LightweightThemeManager; - -function wait_for_notification(aCallback) { - PopupNotifications.panel.addEventListener("popupshown", function() { - PopupNotifications.panel.removeEventListener("popupshown", arguments.callee, false); - aCallback(PopupNotifications.panel); - }, false); -} - -var TESTS = [ -function test_install_http() { - is(LightweightThemeManager.currentTheme, null, "Should be no lightweight theme selected"); - - var pm = Services.perms; - pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION); - - gBrowser.selectedTab = gBrowser.addTab("http://example.org/browser/browser/base/content/test/general/bug592338.html"); - gBrowser.selectedBrowser.addEventListener("pageshow", function() { - if (gBrowser.contentDocument.location.href == "about:blank") - return; - - gBrowser.selectedBrowser.removeEventListener("pageshow", arguments.callee, false); - - executeSoon(function() { - BrowserTestUtils.synthesizeMouse("#theme-install", 2, 2, {}, gBrowser.selectedBrowser); - - is(LightweightThemeManager.currentTheme, null, "Should not have installed the test theme"); - - gBrowser.removeTab(gBrowser.selectedTab); - - pm.remove(makeURI("http://example.org/"), "install"); - - runNextTest(); - }); - }, false); -}, - -function test_install_lwtheme() { - is(LightweightThemeManager.currentTheme, null, "Should be no lightweight theme selected"); - - var pm = Services.perms; - pm.add(makeURI("https://example.com/"), "install", pm.ALLOW_ACTION); - - gBrowser.selectedTab = gBrowser.addTab("https://example.com/browser/browser/base/content/test/general/bug592338.html"); - gBrowser.selectedBrowser.addEventListener("pageshow", function() { - if (gBrowser.contentDocument.location.href == "about:blank") - return; - - gBrowser.selectedBrowser.removeEventListener("pageshow", arguments.callee, false); - - BrowserTestUtils.synthesizeMouse("#theme-install", 2, 2, {}, gBrowser.selectedBrowser); - let notificationBox = gBrowser.getNotificationBox(gBrowser.selectedBrowser); - waitForCondition( - () => notificationBox.getNotificationWithValue("lwtheme-install-notification"), - () => { - is(LightweightThemeManager.currentTheme.id, "test", "Should have installed the test theme"); - - LightweightThemeManager.currentTheme = null; - gBrowser.removeTab(gBrowser.selectedTab); - Services.perms.remove(makeURI("http://example.com/"), "install"); - - runNextTest(); - } - ); - }, false); -}, - -function test_lwtheme_switch_theme() { - is(LightweightThemeManager.currentTheme, null, "Should be no lightweight theme selected"); - - AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(aAddon) { - aAddon.userDisabled = false; - ok(aAddon.isActive, "Theme should have immediately enabled"); - Services.prefs.setBoolPref("extensions.dss.enabled", false); - - var pm = Services.perms; - pm.add(makeURI("https://example.com/"), "install", pm.ALLOW_ACTION); - - gBrowser.selectedTab = gBrowser.addTab("https://example.com/browser/browser/base/content/test/general/bug592338.html"); - gBrowser.selectedBrowser.addEventListener("pageshow", function() { - if (gBrowser.contentDocument.location.href == "about:blank") - return; - - gBrowser.selectedBrowser.removeEventListener("pageshow", arguments.callee, false); - - executeSoon(function() { - wait_for_notification(function(aPanel) { - is(LightweightThemeManager.currentTheme, null, "Should not have installed the test lwtheme"); - ok(aAddon.isActive, "Test theme should still be active"); - - let notification = aPanel.childNodes[0]; - is(notification.button.label, "Restart Now", "Should have seen the right button"); - - ok(aAddon.userDisabled, "Should be waiting to disable the test theme"); - aAddon.userDisabled = false; - Services.prefs.setBoolPref("extensions.dss.enabled", true); - - gBrowser.removeTab(gBrowser.selectedTab); - - Services.perms.remove(makeURI("http://example.com"), "install"); - - runNextTest(); - }); - BrowserTestUtils.synthesizeMouse("#theme-install", 2, 2, {}, gBrowser.selectedBrowser); - }); - }, false); - }); -} -]; - -function runNextTest() { - AddonManager.getAllInstalls(function(aInstalls) { - is(aInstalls.length, 0, "Should be no active installs"); - - if (TESTS.length == 0) { - AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(aAddon) { - aAddon.uninstall(); - - Services.prefs.setBoolPref("extensions.logging.enabled", false); - Services.prefs.setBoolPref("extensions.dss.enabled", false); - - finish(); - }); - return; - } - - info("Running " + TESTS[0].name); - TESTS.shift()(); - }); -} - -function test() { - waitForExplicitFinish(); - - Services.prefs.setBoolPref("extensions.logging.enabled", true); - - AddonManager.getInstallForURL(TESTROOT + "theme.xpi", function(aInstall) { - aInstall.addListener({ - onInstallEnded: function() { - AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(aAddon) { - isnot(aAddon, null, "Should have installed the test theme."); - - // In order to switch themes while the test is running we turn on dynamic - // theme switching. This means the test isn't exactly correct but should - // do some good - Services.prefs.setBoolPref("extensions.dss.enabled", true); - - runNextTest(); - }); - } - }); - - aInstall.install(); - }, "application/x-xpinstall"); -} diff --git a/browser/base/content/test/general/browser_bug594131.js b/browser/base/content/test/general/browser_bug594131.js deleted file mode 100644 index ce09026ac..000000000 --- a/browser/base/content/test/general/browser_bug594131.js +++ /dev/null @@ -1,21 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - let newTab = gBrowser.addTab("http://example.com"); - waitForExplicitFinish(); - BrowserTestUtils.browserLoaded(newTab.linkedBrowser).then(mainPart); - - function mainPart() { - gBrowser.pinTab(newTab); - gBrowser.selectedTab = newTab; - - openUILinkIn("http://example.org/", "current", { inBackground: true }); - isnot(gBrowser.selectedTab, newTab, "shouldn't load in background"); - - gBrowser.removeTab(newTab); - gBrowser.removeTab(gBrowser.tabs[1]); // example.org tab - finish(); - } -} diff --git a/browser/base/content/test/general/browser_bug595507.js b/browser/base/content/test/general/browser_bug595507.js deleted file mode 100644 index 54ae42346..000000000 --- a/browser/base/content/test/general/browser_bug595507.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Make sure that the form validation error message shows even if the form is in an iframe. - */ -add_task(function* () { - let uri = "<iframe src=\"data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>\"</iframe>"; - - var gInvalidFormPopup = document.getElementById('invalid-form-popup'); - ok(gInvalidFormPopup, - "The browser should have a popup to show when a form is invalid"); - - let tab = gBrowser.addTab(); - let browser = gBrowser.getBrowserForTab(tab); - gBrowser.selectedTab = tab; - - yield promiseTabLoadEvent(tab, "data:text/html," + escape(uri)); - - let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown"); - - yield ContentTask.spawn(browser, {}, function* () { - content.document.getElementsByTagName('iframe')[0] - .contentDocument.getElementById('s').click(); - }); - yield popupShownPromise; - - yield ContentTask.spawn(browser, {}, function* () { - let childdoc = content.document.getElementsByTagName('iframe')[0].contentDocument; - Assert.equal(childdoc.activeElement, childdoc.getElementById("i"), - "First invalid element should be focused"); - }); - - ok(gInvalidFormPopup.state == 'showing' || gInvalidFormPopup.state == 'open', - "The invalid form popup should be shown"); - - gBrowser.removeCurrentTab(); -}); - diff --git a/browser/base/content/test/general/browser_bug596687.js b/browser/base/content/test/general/browser_bug596687.js deleted file mode 100644 index 5c2b4fbfe..000000000 --- a/browser/base/content/test/general/browser_bug596687.js +++ /dev/null @@ -1,25 +0,0 @@ -add_task(function* test() { - var tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser); - - var gotTabAttrModified = false; - var gotTabClose = false; - - function onTabClose() { - gotTabClose = true; - tab.addEventListener("TabAttrModified", onTabAttrModified, false); - } - - function onTabAttrModified() { - gotTabAttrModified = true; - } - - tab.addEventListener("TabClose", onTabClose, false); - - yield BrowserTestUtils.removeTab(tab); - - ok(gotTabClose, "should have got the TabClose event"); - ok(!gotTabAttrModified, "shouldn't have got the TabAttrModified event after TabClose"); - - tab.removeEventListener("TabClose", onTabClose, false); - tab.removeEventListener("TabAttrModified", onTabAttrModified, false); -}); diff --git a/browser/base/content/test/general/browser_bug597218.js b/browser/base/content/test/general/browser_bug597218.js deleted file mode 100644 index 5f4ededc3..000000000 --- a/browser/base/content/test/general/browser_bug597218.js +++ /dev/null @@ -1,38 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - waitForExplicitFinish(); - - // establish initial state - is(gBrowser.tabs.length, 1, "we start with one tab"); - - // create a tab - let tab = gBrowser.loadOneTab("about:blank"); - ok(!tab.hidden, "tab starts out not hidden"); - is(gBrowser.tabs.length, 2, "we now have two tabs"); - - // make sure .hidden is read-only - tab.hidden = true; - ok(!tab.hidden, "can't set .hidden directly"); - - // hide the tab - gBrowser.hideTab(tab); - ok(tab.hidden, "tab is hidden"); - - // now pin it and make sure it gets unhidden - gBrowser.pinTab(tab); - ok(tab.pinned, "tab was pinned"); - ok(!tab.hidden, "tab was unhidden"); - - // try hiding it now that it's pinned; shouldn't be able to - gBrowser.hideTab(tab); - ok(!tab.hidden, "tab did not hide"); - - // clean up - gBrowser.removeTab(tab); - is(gBrowser.tabs.length, 1, "we finish with one tab"); - - finish(); -} diff --git a/browser/base/content/test/general/browser_bug609700.js b/browser/base/content/test/general/browser_bug609700.js deleted file mode 100644 index 8b4f1ea91..000000000 --- a/browser/base/content/test/general/browser_bug609700.js +++ /dev/null @@ -1,20 +0,0 @@ -function test() { - waitForExplicitFinish(); - - Services.ww.registerNotification(function (aSubject, aTopic, aData) { - if (aTopic == "domwindowopened") { - Services.ww.unregisterNotification(arguments.callee); - - ok(true, "duplicateTabIn opened a new window"); - - whenDelayedStartupFinished(aSubject, function () { - executeSoon(function () { - aSubject.close(); - finish(); - }); - }, false); - } - }); - - duplicateTabIn(gBrowser.selectedTab, "window"); -} diff --git a/browser/base/content/test/general/browser_bug623893.js b/browser/base/content/test/general/browser_bug623893.js deleted file mode 100644 index fa6da1b22..000000000 --- a/browser/base/content/test/general/browser_bug623893.js +++ /dev/null @@ -1,37 +0,0 @@ -add_task(function* test() { - yield BrowserTestUtils.withNewTab("data:text/plain;charset=utf-8,1", function* (browser) { - BrowserTestUtils.loadURI(browser, "data:text/plain;charset=utf-8,2"); - yield BrowserTestUtils.browserLoaded(browser); - - BrowserTestUtils.loadURI(browser, "data:text/plain;charset=utf-8,3"); - yield BrowserTestUtils.browserLoaded(browser); - - yield duplicate(0, "maintained the original index"); - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - - yield duplicate(-1, "went back"); - yield duplicate(1, "went forward"); - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - }); -}); - -function promiseGetIndex(browser) { - return ContentTask.spawn(browser, null, function() { - let shistory = docShell.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsISHistory); - return shistory.index; - }); -} - -let duplicate = Task.async(function* (delta, msg, cb) { - var startIndex = yield promiseGetIndex(gBrowser.selectedBrowser); - - duplicateTabIn(gBrowser.selectedTab, "tab", delta); - - let tab = gBrowser.selectedTab; - yield BrowserTestUtils.waitForEvent(tab, "SSTabRestored"); - - let endIndex = yield promiseGetIndex(gBrowser.selectedBrowser); - is(endIndex, startIndex + delta, msg); -}); diff --git a/browser/base/content/test/general/browser_bug624734.js b/browser/base/content/test/general/browser_bug624734.js deleted file mode 100644 index d6fc7acbc..000000000 --- a/browser/base/content/test/general/browser_bug624734.js +++ /dev/null @@ -1,29 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// Bug 624734 - Star UI has no tooltip until bookmarked page is visited - -function finishTest() { - is(BookmarkingUI.button.getAttribute("buttontooltiptext"), - BookmarkingUI._unstarredTooltip, - "Star icon should have the unstarred tooltip text"); - - gBrowser.removeCurrentTab(); - finish(); -} - -function test() { - waitForExplicitFinish(); - - let tab = gBrowser.selectedTab = gBrowser.addTab(); - BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => { - if (BookmarkingUI.status == BookmarkingUI.STATUS_UPDATING) { - waitForCondition(() => BookmarkingUI.status != BookmarkingUI.STATUS_UPDATING, finishTest, "BookmarkingUI was updating for too long"); - } else { - finishTest(); - } - }); - - tab.linkedBrowser.loadURI("http://example.com/browser/browser/base/content/test/general/dummy_page.html"); -} diff --git a/browser/base/content/test/general/browser_bug633691.js b/browser/base/content/test/general/browser_bug633691.js deleted file mode 100644 index 28a8440ff..000000000 --- a/browser/base/content/test/general/browser_bug633691.js +++ /dev/null @@ -1,28 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -add_task(function* test() { - const URL = "data:text/html,<iframe width='700' height='700'></iframe>"; - yield BrowserTestUtils.withNewTab({ gBrowser, url: URL }, function* (browser) { - yield ContentTask.spawn(browser, - { is_element_hidden_: is_element_hidden.toSource(), - is_hidden_: is_hidden.toSource() }, - function* ({ is_element_hidden_, is_hidden_ }) { - let loadError = - ContentTaskUtils.waitForEvent(this, "AboutNetErrorLoad", false, null, true); - let iframe = content.document.querySelector("iframe"); - iframe.src = "https://expired.example.com/"; - - yield loadError; - - let is_hidden = eval(`(() => ${is_hidden_})()`); - let is_element_hidden = eval(`(() => ${is_element_hidden_})()`); - let doc = content.document.getElementsByTagName("iframe")[0].contentDocument; - let aP = doc.getElementById("badCertAdvancedPanel"); - ok(aP, "Advanced content should exist"); - void is_hidden; // Quiet eslint warnings (actual use under is_element_hidden) - is_element_hidden(aP, "Advanced content should not be visible by default") - }); - }); -}); diff --git a/browser/base/content/test/general/browser_bug647886.js b/browser/base/content/test/general/browser_bug647886.js deleted file mode 100644 index 6c28c465c..000000000 --- a/browser/base/content/test/general/browser_bug647886.js +++ /dev/null @@ -1,40 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -add_task(function* () { - yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com"); - - yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () { - content.history.pushState({}, "2", "2.html"); - }); - - var backButton = document.getElementById("back-button"); - var rect = backButton.getBoundingClientRect(); - - info("waiting for the history menu to open"); - - let popupShownPromise = BrowserTestUtils.waitForEvent(backButton, "popupshown"); - EventUtils.synthesizeMouseAtCenter(backButton, {type: "mousedown"}); - EventUtils.synthesizeMouse(backButton, rect.width / 2, rect.height, {type: "mouseup"}); - let event = yield popupShownPromise; - - ok(true, "history menu opened"); - - // Wait for the session data to be flushed before continuing the test - yield new Promise(resolve => SessionStore.getSessionHistory(gBrowser.selectedTab, resolve)); - - is(event.target.children.length, 2, "Two history items"); - - let node = event.target.firstChild; - is(node.getAttribute("uri"), "http://example.com/2.html", "first item uri"); - is(node.getAttribute("index"), "1", "first item index"); - is(node.getAttribute("historyindex"), "0", "first item historyindex"); - - node = event.target.lastChild; - is(node.getAttribute("uri"), "http://example.com/", "second item uri"); - is(node.getAttribute("index"), "0", "second item index"); - is(node.getAttribute("historyindex"), "-1", "second item historyindex"); - - event.target.hidePopup(); - gBrowser.removeTab(gBrowser.selectedTab); -}); diff --git a/browser/base/content/test/general/browser_bug655584.js b/browser/base/content/test/general/browser_bug655584.js deleted file mode 100644 index b836e3173..000000000 --- a/browser/base/content/test/general/browser_bug655584.js +++ /dev/null @@ -1,23 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// Bug 655584 - awesomebar suggestions don't update after tab is closed - -add_task(function* () { - var tab1 = gBrowser.addTab(); - var tab2 = gBrowser.addTab(); - - // When urlbar in a new tab is focused, and a tab switch occurs, - // the urlbar popup should be closed - yield BrowserTestUtils.switchTab(gBrowser, tab2); - gURLBar.focus(); // focus the urlbar in the tab we will switch to - yield BrowserTestUtils.switchTab(gBrowser, tab1); - gURLBar.openPopup(); - yield BrowserTestUtils.switchTab(gBrowser, tab2); - ok(!gURLBar.popupOpen, "urlbar focused in tab to switch to, close popup"); - - // cleanup - gBrowser.removeCurrentTab(); - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_bug664672.js b/browser/base/content/test/general/browser_bug664672.js deleted file mode 100644 index 2064f77d0..000000000 --- a/browser/base/content/test/general/browser_bug664672.js +++ /dev/null @@ -1,19 +0,0 @@ -function test() { - waitForExplicitFinish(); - - var tab = gBrowser.addTab(); - - tab.addEventListener("TabClose", function () { - tab.removeEventListener("TabClose", arguments.callee, false); - - ok(tab.linkedBrowser, "linkedBrowser should still exist during the TabClose event"); - - executeSoon(function () { - ok(!tab.linkedBrowser, "linkedBrowser should be gone after the TabClose event"); - - finish(); - }); - }, false); - - gBrowser.removeTab(tab); -} diff --git a/browser/base/content/test/general/browser_bug676619.js b/browser/base/content/test/general/browser_bug676619.js deleted file mode 100644 index 6b596481d..000000000 --- a/browser/base/content/test/general/browser_bug676619.js +++ /dev/null @@ -1,124 +0,0 @@ -function test () { - requestLongerTimeout(3); - waitForExplicitFinish(); - - var isHTTPS = false; - - function loadListener() { - function testLocation(link, url, next) { - new TabOpenListener(url, function () { - gBrowser.removeTab(this.tab); - }, function () { - next(); - }); - - ContentTask.spawn(gBrowser.selectedBrowser, link, contentLink => { - content.document.getElementById(contentLink).click(); - }); - } - - function testLink(link, name, next) { - addWindowListener("chrome://mozapps/content/downloads/unknownContentType.xul", function (win) { - ContentTask.spawn(gBrowser.selectedBrowser, null, () => { - Assert.equal(content.document.getElementById("unload-flag").textContent, - "Okay", "beforeunload shouldn't have fired"); - }).then(() => { - is(win.document.getElementById("location").value, name, "file name should match"); - win.close(); - next(); - }); - }); - - ContentTask.spawn(gBrowser.selectedBrowser, link, contentLink => { - content.document.getElementById(contentLink).click(); - }); - } - - testLink("link1", "test.txt", - testLink.bind(null, "link2", "video.ogg", - testLink.bind(null, "link3", "just some video", - testLink.bind(null, "link4", "with-target.txt", - testLink.bind(null, "link5", "javascript.txt", - testLink.bind(null, "link6", "test.blob", - testLocation.bind(null, "link7", "http://example.com/", - function () { - if (isHTTPS) { - finish(); - } else { - // same test again with https: - isHTTPS = true; - gBrowser.loadURI("https://example.com:443/browser/browser/base/content/test/general/download_page.html"); - } - }))))))); - - } - - BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => { - loadListener(); - BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(loadListener); - }); - - gBrowser.loadURI("http://mochi.test:8888/browser/browser/base/content/test/general/download_page.html"); -} - - -function addWindowListener(aURL, aCallback) { - Services.wm.addListener({ - onOpenWindow: function(aXULWindow) { - info("window opened, waiting for focus"); - Services.wm.removeListener(this); - - var domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindow); - waitForFocus(function() { - is(domwindow.document.location.href, aURL, "should have seen the right window open"); - aCallback(domwindow); - }, domwindow); - }, - onCloseWindow: function(aXULWindow) { }, - onWindowTitleChange: function(aXULWindow, aNewTitle) { } - }); -} - -// This listens for the next opened tab and checks it is of the right url. -// opencallback is called when the new tab is fully loaded -// closecallback is called when the tab is closed -function TabOpenListener(url, opencallback, closecallback) { - this.url = url; - this.opencallback = opencallback; - this.closecallback = closecallback; - - gBrowser.tabContainer.addEventListener("TabOpen", this, false); -} - -TabOpenListener.prototype = { - url: null, - opencallback: null, - closecallback: null, - tab: null, - browser: null, - - handleEvent: function(event) { - if (event.type == "TabOpen") { - gBrowser.tabContainer.removeEventListener("TabOpen", this, false); - this.tab = event.originalTarget; - this.browser = this.tab.linkedBrowser; - BrowserTestUtils.browserLoaded(this.browser, false, this.url).then(() => { - this.tab.addEventListener("TabClose", this, false); - var url = this.browser.currentURI.spec; - is(url, this.url, "Should have opened the correct tab"); - this.opencallback(); - }); - } else if (event.type == "TabClose") { - if (event.originalTarget != this.tab) - return; - this.tab.removeEventListener("TabClose", this, false); - this.opencallback = null; - this.tab = null; - this.browser = null; - // Let the window close complete - executeSoon(this.closecallback); - this.closecallback = null; - } - } -}; diff --git a/browser/base/content/test/general/browser_bug678392-1.html b/browser/base/content/test/general/browser_bug678392-1.html deleted file mode 100644 index c3b235dd0..000000000 --- a/browser/base/content/test/general/browser_bug678392-1.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN" -"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html> - <head> - <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> - <meta content="utf-8" http-equiv="encoding"> - <title>bug678392 - 1</title> - </head> - <body> -bug 678392 test page 1 - </body> -</html>
\ No newline at end of file diff --git a/browser/base/content/test/general/browser_bug678392-2.html b/browser/base/content/test/general/browser_bug678392-2.html deleted file mode 100644 index 9b18efcf7..000000000 --- a/browser/base/content/test/general/browser_bug678392-2.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN" -"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html> - <head> - <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> - <meta content="utf-8" http-equiv="encoding"> - <title>bug678392 - 2</title> - </head> - <body> -bug 678392 test page 2 - </body> -</html>
\ No newline at end of file diff --git a/browser/base/content/test/general/browser_bug678392.js b/browser/base/content/test/general/browser_bug678392.js deleted file mode 100644 index 6aedeefdf..000000000 --- a/browser/base/content/test/general/browser_bug678392.js +++ /dev/null @@ -1,191 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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 HTTPROOT = "http://example.com/browser/browser/base/content/test/general/"; - -function maxSnapshotOverride() { - return 5; -} - -function test() { - waitForExplicitFinish(); - - BrowserOpenTab(); - let tab = gBrowser.selectedTab; - registerCleanupFunction(function () { gBrowser.removeTab(tab); }); - - ok(gHistorySwipeAnimation, "gHistorySwipeAnimation exists."); - - if (!gHistorySwipeAnimation._isSupported()) { - is(gHistorySwipeAnimation.active, false, "History swipe animation is not " + - "active when not supported by the platform."); - finish(); - return; - } - - gHistorySwipeAnimation._getMaxSnapshots = maxSnapshotOverride; - gHistorySwipeAnimation.init(); - - is(gHistorySwipeAnimation.active, true, "History swipe animation support " + - "was successfully initialized when supported."); - - cleanupArray(); - load(gBrowser.selectedTab, HTTPROOT + "browser_bug678392-2.html", test0); -} - -function load(aTab, aUrl, aCallback) { - aTab.linkedBrowser.addEventListener("load", function onload(aEvent) { - aEvent.currentTarget.removeEventListener("load", onload, true); - waitForFocus(aCallback, content); - }, true); - aTab.linkedBrowser.loadURI(aUrl); -} - -function cleanupArray() { - let arr = gHistorySwipeAnimation._trackedSnapshots; - while (arr.length > 0) { - delete arr[0].browser.snapshots[arr[0].index]; // delete actual snapshot - arr.splice(0, 1); - } -} - -function testArrayCleanup() { - // Test cleanup of array of tracked snapshots. - let arr = gHistorySwipeAnimation._trackedSnapshots; - is(arr.length, 0, "Snapshots were removed correctly from the array of " + - "tracked snapshots."); -} - -function test0() { - // Test growing of array of tracked snapshots. - let tab = gBrowser.selectedTab; - - load(tab, HTTPROOT + "browser_bug678392-1.html", function() { - ok(gHistorySwipeAnimation._trackedSnapshots, "Array for snapshot " + - "tracking is initialized."); - is(gHistorySwipeAnimation._trackedSnapshots.length, 1, "Snapshot array " + - "has correct length of 1 after loading one page."); - load(tab, HTTPROOT + "browser_bug678392-2.html", function() { - is(gHistorySwipeAnimation._trackedSnapshots.length, 2, "Snapshot array " + - " has correct length of 2 after loading two pages."); - load(tab, HTTPROOT + "browser_bug678392-1.html", function() { - is(gHistorySwipeAnimation._trackedSnapshots.length, 3, "Snapshot " + - "array has correct length of 3 after loading three pages."); - load(tab, HTTPROOT + "browser_bug678392-2.html", function() { - is(gHistorySwipeAnimation._trackedSnapshots.length, 4, "Snapshot " + - "array has correct length of 4 after loading four pages."); - cleanupArray(); - testArrayCleanup(); - test1(); - }); - }); - }); - }); -} - -function verifyRefRemoved(aIndex, aBrowser) { - let wasFound = false; - let arr = gHistorySwipeAnimation._trackedSnapshots; - for (let i = 0; i < arr.length; i++) { - if (arr[i].index == aIndex && arr[i].browser == aBrowser) - wasFound = true; - } - is(wasFound, false, "The reference that was previously removed was " + - "still found in the array of tracked snapshots."); -} - -function test1() { - // Test presence of snpashots in per-tab array of snapshots and removal of - // individual snapshots (and corresponding references in the array of - // tracked snapshots). - let tab = gBrowser.selectedTab; - - load(tab, HTTPROOT + "browser_bug678392-1.html", function() { - var historyIndex = gBrowser.webNavigation.sessionHistory.index - 1; - load(tab, HTTPROOT + "browser_bug678392-2.html", function() { - load(tab, HTTPROOT + "browser_bug678392-1.html", function() { - load(tab, HTTPROOT + "browser_bug678392-2.html", function() { - let browser = gBrowser.selectedBrowser; - ok(browser.snapshots, "Array of snapshots exists in browser."); - ok(browser.snapshots[historyIndex], "First page exists in snapshot " + - "array."); - ok(browser.snapshots[historyIndex + 1], "Second page exists in " + - "snapshot array."); - ok(browser.snapshots[historyIndex + 2], "Third page exists in " + - "snapshot array."); - ok(browser.snapshots[historyIndex + 3], "Fourth page exists in " + - "snapshot array."); - is(gHistorySwipeAnimation._trackedSnapshots.length, 4, "Length of " + - "array of tracked snapshots is equal to 4 after loading four " + - "pages."); - - // Test removal of reference in the middle of the array. - gHistorySwipeAnimation._removeTrackedSnapshot(historyIndex + 1, - browser); - verifyRefRemoved(historyIndex + 1, browser); - is(gHistorySwipeAnimation._trackedSnapshots.length, 3, "Length of " + - "array of tracked snapshots is equal to 3 after removing one" + - "reference from the array with length 4."); - - // Test removal of reference at end of array. - gHistorySwipeAnimation._removeTrackedSnapshot(historyIndex + 3, - browser); - verifyRefRemoved(historyIndex + 3, browser); - is(gHistorySwipeAnimation._trackedSnapshots.length, 2, "Length of " + - "array of tracked snapshots is equal to 2 after removing two" + - "references from the array with length 4."); - - // Test removal of reference at head of array. - gHistorySwipeAnimation._removeTrackedSnapshot(historyIndex, - browser); - verifyRefRemoved(historyIndex, browser); - is(gHistorySwipeAnimation._trackedSnapshots.length, 1, "Length of " + - "array of tracked snapshots is equal to 1 after removing three" + - "references from the array with length 4."); - - cleanupArray(); - test2(); - }); - }); - }); - }); -} - -function test2() { - // Test growing of snapshot array across tabs. - let tab = gBrowser.selectedTab; - - load(tab, HTTPROOT + "browser_bug678392-1.html", function() { - load(tab, HTTPROOT + "browser_bug678392-2.html", function() { - is(gHistorySwipeAnimation._trackedSnapshots.length, 2, "Length of " + - "snapshot array is equal to 2 after loading two pages"); - let prevTab = tab; - tab = gBrowser.addTab("about:newtab"); - gBrowser.selectedTab = tab; - load(tab, HTTPROOT + "browser_bug678392-2.html" /* initial page */, - function() { - load(tab, HTTPROOT + "browser_bug678392-1.html", function() { - load(tab, HTTPROOT + "browser_bug678392-2.html", function() { - is(gHistorySwipeAnimation._trackedSnapshots.length, 4, "Length " + - "of snapshot array is equal to 4 after loading two pages in " + - "two tabs each."); - gBrowser.removeCurrentTab(); - gBrowser.selectedTab = prevTab; - cleanupArray(); - test3(); - }); - }); - }); - }); - }); -} - -function test3() { - // Test uninit of gHistorySwipeAnimation. - // This test MUST be the last one to execute. - gHistorySwipeAnimation.uninit(); - is(gHistorySwipeAnimation.active, false, "History swipe animation support " + - "was successfully uninitialized"); - finish(); -} diff --git a/browser/base/content/test/general/browser_bug710878.js b/browser/base/content/test/general/browser_bug710878.js deleted file mode 100644 index dd99d67cf..000000000 --- a/browser/base/content/test/general/browser_bug710878.js +++ /dev/null @@ -1,34 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -const PAGE = "data:text/html;charset=utf-8,<a href='%23xxx'><span>word1 <span> word2 </span></span><span> word3</span></a>"; - -/** - * Tests that we correctly compute the text for context menu - * selection of some content. - */ -add_task(function*() { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: PAGE, - }, function*(browser) { - let contextMenu = document.getElementById("contentAreaContextMenu"); - let awaitPopupShown = BrowserTestUtils.waitForEvent(contextMenu, - "popupshown"); - let awaitPopupHidden = BrowserTestUtils.waitForEvent(contextMenu, - "popuphidden"); - - yield BrowserTestUtils.synthesizeMouseAtCenter("a", { - type: "contextmenu", - button: 2, - }, browser); - - yield awaitPopupShown; - - is(gContextMenu.linkTextStr, "word1 word2 word3", - "Text under link is correctly computed."); - - contextMenu.hidePopup(); - yield awaitPopupHidden; - }); -}); diff --git a/browser/base/content/test/general/browser_bug719271.js b/browser/base/content/test/general/browser_bug719271.js deleted file mode 100644 index c3bb9cd26..000000000 --- a/browser/base/content/test/general/browser_bug719271.js +++ /dev/null @@ -1,95 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ -"use strict"; - -const TEST_PAGE = "http://example.org/browser/browser/base/content/test/general/zoom_test.html"; -const TEST_VIDEO = "http://example.org/browser/browser/base/content/test/general/video.ogg"; - -var gTab1, gTab2, gLevel1; - -function test() { - waitForExplicitFinish(); - - Task.spawn(function* () { - gTab1 = gBrowser.addTab(); - gTab2 = gBrowser.addTab(); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - yield FullZoomHelper.load(gTab1, TEST_PAGE); - yield FullZoomHelper.load(gTab2, TEST_VIDEO); - }).then(zoomTab1, FullZoomHelper.failAndContinue(finish)); -} - -function zoomTab1() { - Task.spawn(function* () { - is(gBrowser.selectedTab, gTab1, "Tab 1 is selected"); - - // Reset zoom level if we run this test > 1 time in same browser session. - var level1 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1)); - if (level1 > 1) - FullZoom.reduce(); - - FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1"); - FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1"); - - FullZoom.enlarge(); - gLevel1 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1)); - - ok(gLevel1 > 1, "New zoom for tab 1 should be greater than 1"); - FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2"); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); - FullZoomHelper.zoomTest(gTab2, 1, "Tab 2 is still unzoomed after it is selected"); - FullZoomHelper.zoomTest(gTab1, gLevel1, "Tab 1 is still zoomed"); - }).then(zoomTab2, FullZoomHelper.failAndContinue(finish)); -} - -function zoomTab2() { - Task.spawn(function* () { - is(gBrowser.selectedTab, gTab2, "Tab 2 is selected"); - - FullZoom.reduce(); - let level2 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab2)); - - ok(level2 < 1, "New zoom for tab 2 should be less than 1"); - FullZoomHelper.zoomTest(gTab1, gLevel1, "Zooming tab 2 should not affect tab 1"); - - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - FullZoomHelper.zoomTest(gTab1, gLevel1, "Tab 1 should have the same zoom after it's selected"); - }).then(testNavigation, FullZoomHelper.failAndContinue(finish)); -} - -function testNavigation() { - Task.spawn(function* () { - yield FullZoomHelper.load(gTab1, TEST_VIDEO); - FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 when a video was loaded"); - yield waitForNextTurn(); // trying to fix orange bug 806046 - yield FullZoomHelper.navigate(FullZoomHelper.BACK); - FullZoomHelper.zoomTest(gTab1, gLevel1, "Zoom should be restored when a page is loaded"); - yield waitForNextTurn(); // trying to fix orange bug 806046 - yield FullZoomHelper.navigate(FullZoomHelper.FORWARD); - FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 again when navigating back to a video"); - }).then(finishTest, FullZoomHelper.failAndContinue(finish)); -} - -function waitForNextTurn() { - let deferred = Promise.defer(); - setTimeout(() => deferred.resolve(), 0); - return deferred.promise; -} - -var finishTestStarted = false; -function finishTest() { - Task.spawn(function* () { - ok(!finishTestStarted, "finishTest called more than once"); - finishTestStarted = true; - - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - yield FullZoom.reset(); - yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); - yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); - yield FullZoom.reset(); - yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); - }).then(finish, FullZoomHelper.failAndContinue(finish)); -} diff --git a/browser/base/content/test/general/browser_bug724239.js b/browser/base/content/test/general/browser_bug724239.js deleted file mode 100644 index 430751b91..000000000 --- a/browser/base/content/test/general/browser_bug724239.js +++ /dev/null @@ -1,11 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -add_task(function* test() { - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, - function* (browser) { - BrowserTestUtils.loadURI(browser, "http://example.com"); - yield BrowserTestUtils.browserLoaded(browser); - ok(!gBrowser.canGoBack, "about:newtab wasn't added to the session history"); - }); -}); diff --git a/browser/base/content/test/general/browser_bug734076.js b/browser/base/content/test/general/browser_bug734076.js deleted file mode 100644 index 9de7d913f..000000000 --- a/browser/base/content/test/general/browser_bug734076.js +++ /dev/null @@ -1,114 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -add_task(function* () -{ - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, null, false); - - let browser = tab.linkedBrowser; - browser.stop(); // stop the about:blank load - - let writeDomainURL = encodeURI("data:text/html,<script>document.write(document.domain);</script>"); - - let tests = [ - { - name: "view background image", - url: "http://mochi.test:8888/", - element: "body", - go: function () { - return ContentTask.spawn(gBrowser.selectedBrowser, { writeDomainURL: writeDomainURL }, function* (arg) { - let contentBody = content.document.body; - contentBody.style.backgroundImage = "url('" + arg.writeDomainURL + "')"; - - return "context-viewbgimage"; - }); - }, - verify: function () { - return ContentTask.spawn(gBrowser.selectedBrowser, null, function* (arg) { - Assert.ok(!content.document.body.textContent, - "no domain was inherited for view background image"); - }); - } - }, - { - name: "view image", - url: "http://mochi.test:8888/", - element: "img", - go: function () { - return ContentTask.spawn(gBrowser.selectedBrowser, { writeDomainURL: writeDomainURL }, function* (arg) { - let doc = content.document; - let img = doc.createElement("img"); - img.height = 100; - img.width = 100; - img.setAttribute("src", arg.writeDomainURL); - doc.body.insertBefore(img, doc.body.firstChild); - - return "context-viewimage"; - }); - }, - verify: function () { - return ContentTask.spawn(gBrowser.selectedBrowser, null, function* (arg) { - Assert.ok(!content.document.body.textContent, - "no domain was inherited for view image"); - }); - } - }, - { - name: "show only this frame", - url: "http://mochi.test:8888/", - element: "iframe", - go: function () { - return ContentTask.spawn(gBrowser.selectedBrowser, { writeDomainURL: writeDomainURL }, function* (arg) { - let doc = content.document; - let iframe = doc.createElement("iframe"); - iframe.setAttribute("src", arg.writeDomainURL); - doc.body.insertBefore(iframe, doc.body.firstChild); - - // Wait for the iframe to load. - return new Promise(resolve => { - iframe.addEventListener("load", function onload() { - iframe.removeEventListener("load", onload, true); - resolve("context-showonlythisframe"); - }, true); - }); - }); - }, - verify: function () { - return ContentTask.spawn(gBrowser.selectedBrowser, null, function* (arg) { - Assert.ok(!content.document.body.textContent, - "no domain was inherited for 'show only this frame'"); - }); - } - } - ]; - - let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - - for (let test of tests) { - let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - gBrowser.loadURI(test.url); - yield loadedPromise; - - info("Run subtest " + test.name); - let commandToRun = yield test.go(); - - let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown"); - yield BrowserTestUtils.synthesizeMouse(test.element, 3, 3, - { type: "contextmenu", button: 2 }, gBrowser.selectedBrowser); - yield popupShownPromise; - info("onImage: " + gContextMenu.onImage); - info("target: " + gContextMenu.target.tagName); - - let loadedAfterCommandPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - document.getElementById(commandToRun).click(); - yield loadedAfterCommandPromise; - - yield test.verify(); - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden"); - contentAreaContextMenu.hidePopup(); - yield popupHiddenPromise; - } - - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_bug735471.js b/browser/base/content/test/general/browser_bug735471.js deleted file mode 100644 index 9afb52c4b..000000000 --- a/browser/base/content/test/general/browser_bug735471.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public 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/. - */ - - -function test() { - waitForExplicitFinish(); - // Open a new tab. - whenNewTabLoaded(window, testPreferences); -} - -function testPreferences() { - whenTabLoaded(gBrowser.selectedTab, function () { - is(content.location.href, "about:preferences", "Checking if the preferences tab was opened"); - - gBrowser.removeCurrentTab(); - finish(); - }); - - openPreferences(); -} diff --git a/browser/base/content/test/general/browser_bug749738.js b/browser/base/content/test/general/browser_bug749738.js deleted file mode 100644 index 7e805b799..000000000 --- a/browser/base/content/test/general/browser_bug749738.js +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -"use strict"; - -const DUMMY_PAGE = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; - -function test() { - waitForExplicitFinish(); - - let tab = gBrowser.addTab(); - gBrowser.selectedTab = tab; - - BrowserTestUtils.loadURI(tab.linkedBrowser, DUMMY_PAGE); - BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => { - gFindBar.onFindCommand(); - EventUtils.sendString("Dummy"); - gBrowser.removeTab(tab); - - try { - gFindBar.close(); - ok(true, "findbar.close should not throw an exception"); - } catch (e) { - ok(false, "findbar.close threw exception: " + e); - } - finish(); - }); -} diff --git a/browser/base/content/test/general/browser_bug763468_perwindowpb.js b/browser/base/content/test/general/browser_bug763468_perwindowpb.js deleted file mode 100644 index 23cb14b8c..000000000 --- a/browser/base/content/test/general/browser_bug763468_perwindowpb.js +++ /dev/null @@ -1,70 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ -"use strict"; - -/* globals - waitForExplicitFinish, whenNewWindowLoaded, whenNewTabLoaded, - executeSoon, registerCleanupFunction, finish, is -*/ -/* exported test */ - -// This test makes sure that opening a new tab in private browsing mode opens about:privatebrowsing -function test() { - // initialization - waitForExplicitFinish(); - - let windowsToClose = []; - let newTabURL; - let mode; - - function doTest(aIsPrivateMode, aWindow, aCallback) { - whenNewTabLoaded(aWindow, function() { - if (aIsPrivateMode) { - mode = "per window private browsing"; - newTabURL = "about:privatebrowsing"; - } else { - mode = "normal"; - newTabURL = "about:newtab"; - } - - is(aWindow.gBrowser.currentURI.spec, newTabURL, - "URL of NewTab should be " + newTabURL + " in " + mode + " mode"); - - aWindow.gBrowser.removeTab(aWindow.gBrowser.selectedTab); - aCallback(); - }); - } - - function testOnWindow(aOptions, aCallback) { - whenNewWindowLoaded(aOptions, function(aWin) { - windowsToClose.push(aWin); - // execute should only be called when need, like when you are opening - // web pages on the test. If calling executeSoon() is not necesary, then - // call whenNewWindowLoaded() instead of testOnWindow() on your test. - executeSoon(() => aCallback(aWin)); - }); - } - - // this function is called after calling finish() on the test. - registerCleanupFunction(function() { - windowsToClose.forEach(function(aWin) { - aWin.close(); - }); - }); - - // test first when not on private mode - testOnWindow({}, function(aWin) { - doTest(false, aWin, function() { - // then test when on private mode - testOnWindow({private: true}, function(aWin2) { - doTest(true, aWin2, function() { - // then test again when not on private mode - testOnWindow({}, function(aWin3) { - doTest(false, aWin3, finish); - }); - }); - }); - }); - }); -} diff --git a/browser/base/content/test/general/browser_bug767836_perwindowpb.js b/browser/base/content/test/general/browser_bug767836_perwindowpb.js deleted file mode 100644 index 7f5d15e76..000000000 --- a/browser/base/content/test/general/browser_bug767836_perwindowpb.js +++ /dev/null @@ -1,90 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ -"use strict"; -/* globals waitForExplicitFinish, executeSoon, finish, whenNewWindowLoaded, ok */ -/* globals is */ -/* exported test */ - -function test() { - // initialization - waitForExplicitFinish(); - - let aboutNewTabService = Components.classes["@mozilla.org/browser/aboutnewtab-service;1"] - .getService(Components.interfaces.nsIAboutNewTabService); - let newTabURL; - let testURL = "http://example.com/"; - let defaultURL = aboutNewTabService.newTabURL; - let mode; - - function doTest(aIsPrivateMode, aWindow, aCallback) { - openNewTab(aWindow, function() { - if (aIsPrivateMode) { - mode = "per window private browsing"; - newTabURL = "about:privatebrowsing"; - } else { - mode = "normal"; - newTabURL = "about:newtab"; - } - - // Check the new tab opened while in normal/private mode - is(aWindow.gBrowser.selectedBrowser.currentURI.spec, newTabURL, - "URL of NewTab should be " + newTabURL + " in " + mode + " mode"); - // Set the custom newtab url - aboutNewTabService.newTabURL = testURL; - is(aboutNewTabService.newTabURL, testURL, "Custom newtab url is set"); - - // Open a newtab after setting the custom newtab url - openNewTab(aWindow, function() { - is(aWindow.gBrowser.selectedBrowser.currentURI.spec, testURL, - "URL of NewTab should be the custom url"); - - // Clear the custom url. - aboutNewTabService.resetNewTabURL(); - is(aboutNewTabService.newTabURL, defaultURL, "No custom newtab url is set"); - - aWindow.gBrowser.removeTab(aWindow.gBrowser.selectedTab); - aWindow.gBrowser.removeTab(aWindow.gBrowser.selectedTab); - aWindow.close(); - aCallback(); - }); - }); - } - - function testOnWindow(aIsPrivate, aCallback) { - whenNewWindowLoaded({private: aIsPrivate}, function(win) { - executeSoon(() => aCallback(win)); - }); - } - - // check whether any custom new tab url has been configured - ok(!aboutNewTabService.overridden, "No custom newtab url is set"); - - // test normal mode - testOnWindow(false, function(aWindow) { - doTest(false, aWindow, function() { - // test private mode - testOnWindow(true, function(aWindow2) { - doTest(true, aWindow2, function() { - finish(); - }); - }); - }); - }); -} - -function openNewTab(aWindow, aCallback) { - // Open a new tab - aWindow.BrowserOpenTab(); - - let browser = aWindow.gBrowser.selectedBrowser; - if (browser.contentDocument.readyState === "complete") { - executeSoon(aCallback); - return; - } - - browser.addEventListener("load", function onLoad() { - browser.removeEventListener("load", onLoad, true); - executeSoon(aCallback); - }, true); -} diff --git a/browser/base/content/test/general/browser_bug817947.js b/browser/base/content/test/general/browser_bug817947.js deleted file mode 100644 index 3a76e36d3..000000000 --- a/browser/base/content/test/general/browser_bug817947.js +++ /dev/null @@ -1,55 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - - -const URL = "http://mochi.test:8888/browser/"; -const PREF = "browser.sessionstore.restore_on_demand"; - -function test() { - waitForExplicitFinish(); - - Services.prefs.setBoolPref(PREF, true); - registerCleanupFunction(function () { - Services.prefs.clearUserPref(PREF); - }); - - preparePendingTab(function (aTab) { - let win = gBrowser.replaceTabWithWindow(aTab); - - whenDelayedStartupFinished(win, function () { - let [tab] = win.gBrowser.tabs; - - whenLoaded(tab.linkedBrowser, function () { - is(tab.linkedBrowser.currentURI.spec, URL, "correct url should be loaded"); - ok(!tab.hasAttribute("pending"), "tab should not be pending"); - - win.close(); - finish(); - }); - }); - }); -} - -function preparePendingTab(aCallback) { - let tab = gBrowser.addTab(URL); - - whenLoaded(tab.linkedBrowser, function () { - BrowserTestUtils.removeTab(tab).then(() => { - let [{state}] = JSON.parse(SessionStore.getClosedTabData(window)); - - tab = gBrowser.addTab("about:blank"); - whenLoaded(tab.linkedBrowser, function () { - SessionStore.setTabState(tab, JSON.stringify(state)); - ok(tab.hasAttribute("pending"), "tab should be pending"); - aCallback(tab); - }); - }); - }); -} - -function whenLoaded(aElement, aCallback) { - aElement.addEventListener("load", function onLoad() { - aElement.removeEventListener("load", onLoad, true); - executeSoon(aCallback); - }, true); -} diff --git a/browser/base/content/test/general/browser_bug822367.js b/browser/base/content/test/general/browser_bug822367.js deleted file mode 100644 index 0d60c05cd..000000000 --- a/browser/base/content/test/general/browser_bug822367.js +++ /dev/null @@ -1,187 +0,0 @@ -/* - * User Override Mixed Content Block - Tests for Bug 822367 - */ - - -const PREF_DISPLAY = "security.mixed_content.block_display_content"; -const PREF_ACTIVE = "security.mixed_content.block_active_content"; - -// We alternate for even and odd test cases to simulate different hosts -const gHttpTestRoot = "https://example.com/browser/browser/base/content/test/general/"; -const gHttpTestRoot2 = "https://test1.example.com/browser/browser/base/content/test/general/"; - -var gTestBrowser = null; - -add_task(function* test() { - yield SpecialPowers.pushPrefEnv({ set: [[ PREF_DISPLAY, true ], - [ PREF_ACTIVE, true ]] }); - - var newTab = gBrowser.addTab(); - gBrowser.selectedTab = newTab; - gTestBrowser = gBrowser.selectedBrowser; - newTab.linkedBrowser.stop() - - // Mixed Script Test - var url = gHttpTestRoot + "file_bug822367_1.html"; - BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -// Mixed Script Test -add_task(function* MixedTest1A() { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - let {gIdentityHandler} = gTestBrowser.ownerGlobal; - gIdentityHandler.disableMixedContentProtection(); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -add_task(function* MixedTest1B() { - yield ContentTask.spawn(gTestBrowser, null, function* () { - yield ContentTaskUtils.waitForCondition( - () => content.document.getElementById("p1").innerHTML == "hello", - "Waited too long for mixed script to run in Test 1"); - }); -}); - -// Mixed Display Test - Doorhanger should not appear -add_task(function* MixedTest2() { - var url = gHttpTestRoot2 + "file_bug822367_2.html"; - BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); - - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: false, passiveLoaded: false}); -}); - -// Mixed Script and Display Test - User Override should cause both the script and the image to load. -add_task(function* MixedTest3() { - var url = gHttpTestRoot + "file_bug822367_3.html"; - BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -add_task(function* MixedTest3A() { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - let {gIdentityHandler} = gTestBrowser.ownerGlobal; - gIdentityHandler.disableMixedContentProtection(); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -add_task(function* MixedTest3B() { - yield ContentTask.spawn(gTestBrowser, null, function* () { - let p1 = ContentTaskUtils.waitForCondition( - () => content.document.getElementById("p1").innerHTML == "hello", - "Waited too long for mixed script to run in Test 3"); - let p2 = ContentTaskUtils.waitForCondition( - () => content.document.getElementById("p2").innerHTML == "bye", - "Waited too long for mixed image to load in Test 3"); - yield Promise.all([ p1, p2 ]); - }); - - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: true}); -}); - -// Location change - User override on one page doesn't propogate to another page after location change. -add_task(function* MixedTest4() { - var url = gHttpTestRoot2 + "file_bug822367_4.html"; - BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -add_task(function* MixedTest4A() { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - let {gIdentityHandler} = gTestBrowser.ownerGlobal; - gIdentityHandler.disableMixedContentProtection(); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -add_task(function* MixedTest4B() { - let url = gHttpTestRoot + "file_bug822367_4B.html"; - yield ContentTask.spawn(gTestBrowser, url, function* (wantedUrl) { - yield ContentTaskUtils.waitForCondition( - () => content.document.location == wantedUrl, - "Waited too long for mixed script to run in Test 4"); - }); -}); - -add_task(function* MixedTest4C() { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - yield ContentTask.spawn(gTestBrowser, null, function* () { - yield ContentTaskUtils.waitForCondition( - () => content.document.getElementById("p1").innerHTML == "", - "Mixed script loaded in test 4 after location change!"); - }); -}); - -// Mixed script attempts to load in a document.open() -add_task(function* MixedTest5() { - var url = gHttpTestRoot + "file_bug822367_5.html"; - BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -add_task(function* MixedTest5A() { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - let {gIdentityHandler} = gTestBrowser.ownerGlobal; - gIdentityHandler.disableMixedContentProtection(); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -add_task(function* MixedTest5B() { - yield ContentTask.spawn(gTestBrowser, null, function* () { - yield ContentTaskUtils.waitForCondition( - () => content.document.getElementById("p1").innerHTML == "hello", - "Waited too long for mixed script to run in Test 5"); - }); -}); - -// Mixed script attempts to load in a document.open() that is within an iframe. -add_task(function* MixedTest6() { - var url = gHttpTestRoot2 + "file_bug822367_6.html"; - BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -add_task(function* MixedTest6A() { - gTestBrowser.removeEventListener("load", MixedTest6A, true); - let {gIdentityHandler} = gTestBrowser.ownerGlobal; - - yield BrowserTestUtils.waitForCondition( - () => gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"), - "Waited too long for control center to get mixed active blocked state"); -}); - -add_task(function* MixedTest6B() { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - let {gIdentityHandler} = gTestBrowser.ownerGlobal; - gIdentityHandler.disableMixedContentProtection(); - - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -add_task(function* MixedTest6C() { - yield ContentTask.spawn(gTestBrowser, null, function* () { - function test() { - try { - return content.document.getElementById("f1").contentDocument.getElementById("p1").innerHTML == "hello"; - } catch (e) { - return false; - } - } - - yield ContentTaskUtils.waitForCondition(test, "Waited too long for mixed script to run in Test 6"); - }); -}); - -add_task(function* MixedTest6D() { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false}); -}); - -add_task(function* cleanup() { - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_bug832435.js b/browser/base/content/test/general/browser_bug832435.js deleted file mode 100644 index 6be2604cd..000000000 --- a/browser/base/content/test/general/browser_bug832435.js +++ /dev/null @@ -1,23 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - waitForExplicitFinish(); - ok(true, "Starting up"); - - gBrowser.selectedBrowser.focus(); - gURLBar.addEventListener("focus", function onFocus() { - gURLBar.removeEventListener("focus", onFocus); - ok(true, "Invoked onfocus handler"); - EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }); - - // javscript: URIs are evaluated async. - SimpleTest.executeSoon(function() { - ok(true, "Evaluated without crashing"); - finish(); - }); - }); - gURLBar.inputField.value = "javascript: var foo = '11111111'; "; - gURLBar.focus(); -} diff --git a/browser/base/content/test/general/browser_bug839103.js b/browser/base/content/test/general/browser_bug839103.js deleted file mode 100644 index 5240c92ed..000000000 --- a/browser/base/content/test/general/browser_bug839103.js +++ /dev/null @@ -1,120 +0,0 @@ -const gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); - -add_task(function* test() { - yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, - function* (browser) { - yield ContentTask.spawn(browser, gTestRoot, testBody); - }); -}); - -// This function runs entirely in the content process. It doesn't have access -// any free variables in this file. -function* testBody(testRoot) { - const gStyleSheet = "bug839103.css"; - - let loaded = ContentTaskUtils.waitForEvent(this, "load", true); - content.location = testRoot + "test_bug839103.html"; - - yield loaded; - function unexpectedContentEvent(event) { - ok(false, "Received a " + event.type + " event on content"); - } - - // We've seen the original stylesheet in the document. - // Now add a stylesheet on the fly and make sure we see it. - let doc = content.document; - doc.styleSheetChangeEventsEnabled = true; - doc.addEventListener("StyleSheetAdded", unexpectedContentEvent); - doc.addEventListener("StyleSheetRemoved", unexpectedContentEvent); - doc.addEventListener("StyleSheetApplicableStateChanged", unexpectedContentEvent); - doc.defaultView.addEventListener("StyleSheetAdded", unexpectedContentEvent); - doc.defaultView.addEventListener("StyleSheetRemoved", unexpectedContentEvent); - doc.defaultView.addEventListener("StyleSheetApplicableStateChanged", unexpectedContentEvent); - - let link = doc.createElement("link"); - link.setAttribute("rel", "stylesheet"); - link.setAttribute("type", "text/css"); - link.setAttribute("href", testRoot + gStyleSheet); - - let sheetAdded = - ContentTaskUtils.waitForEvent(this, "StyleSheetAdded", true); - let stateChanged = - ContentTaskUtils.waitForEvent(this, "StyleSheetApplicableStateChanged", true); - doc.body.appendChild(link); - - let evt = yield sheetAdded; - info("received dynamic style sheet event"); - is(evt.type, "StyleSheetAdded", "evt.type has expected value"); - is(evt.target, doc, "event targets correct document"); - ok(evt.stylesheet, "evt.stylesheet is defined"); - ok(evt.stylesheet.toString().includes("CSSStyleSheet"), "evt.stylesheet is a stylesheet"); - ok(evt.documentSheet, "style sheet is a document sheet"); - - evt = yield stateChanged; - info("received dynamic style sheet applicable state change event"); - is(evt.type, "StyleSheetApplicableStateChanged", "evt.type has expected value"); - is(evt.target, doc, "event targets correct document"); - is(evt.stylesheet, link.sheet, "evt.stylesheet has the right value"); - is(evt.applicable, true, "evt.applicable has the right value"); - - stateChanged = - ContentTaskUtils.waitForEvent(this, "StyleSheetApplicableStateChanged", true); - link.disabled = true; - - evt = yield stateChanged; - is(evt.type, "StyleSheetApplicableStateChanged", "evt.type has expected value"); - info("received dynamic style sheet applicable state change event after media=\"\" changed"); - is(evt.target, doc, "event targets correct document"); - is(evt.stylesheet, link.sheet, "evt.stylesheet has the right value"); - is(evt.applicable, false, "evt.applicable has the right value"); - - let sheetRemoved = - ContentTaskUtils.waitForEvent(this, "StyleSheetRemoved", true); - doc.body.removeChild(link); - - evt = yield sheetRemoved; - info("received dynamic style sheet removal"); - is(evt.type, "StyleSheetRemoved", "evt.type has expected value"); - is(evt.target, doc, "event targets correct document"); - ok(evt.stylesheet, "evt.stylesheet is defined"); - ok(evt.stylesheet.toString().includes("CSSStyleSheet"), "evt.stylesheet is a stylesheet"); - ok(evt.stylesheet.href.includes(gStyleSheet), "evt.stylesheet is the removed stylesheet"); - - let ruleAdded = - ContentTaskUtils.waitForEvent(this, "StyleRuleAdded", true); - doc.querySelector("style").sheet.insertRule("*{color:black}", 0); - - evt = yield ruleAdded; - info("received style rule added event"); - is(evt.type, "StyleRuleAdded", "evt.type has expected value"); - is(evt.target, doc, "event targets correct document"); - ok(evt.stylesheet, "evt.stylesheet is defined"); - ok(evt.stylesheet.toString().includes("CSSStyleSheet"), "evt.stylesheet is a stylesheet"); - ok(evt.rule, "evt.rule is defined"); - is(evt.rule.cssText, "* { color: black; }", "evt.rule.cssText has expected value"); - - let ruleChanged = - ContentTaskUtils.waitForEvent(this, "StyleRuleChanged", true); - evt.rule.style.cssText = "color:green"; - - evt = yield ruleChanged; - ok(true, "received style rule changed event"); - is(evt.type, "StyleRuleChanged", "evt.type has expected value"); - is(evt.target, doc, "event targets correct document"); - ok(evt.stylesheet, "evt.stylesheet is defined"); - ok(evt.stylesheet.toString().includes("CSSStyleSheet"), "evt.stylesheet is a stylesheet"); - ok(evt.rule, "evt.rule is defined"); - is(evt.rule.cssText, "* { color: green; }", "evt.rule.cssText has expected value"); - - let ruleRemoved = - ContentTaskUtils.waitForEvent(this, "StyleRuleRemoved", true); - evt.stylesheet.deleteRule(0); - - evt = yield ruleRemoved; - info("received style rule removed event"); - is(evt.type, "StyleRuleRemoved", "evt.type has expected value"); - is(evt.target, doc, "event targets correct document"); - ok(evt.stylesheet, "evt.stylesheet is defined"); - ok(evt.stylesheet.toString().includes("CSSStyleSheet"), "evt.stylesheet is a stylesheet"); - ok(evt.rule, "evt.rule is defined"); -} diff --git a/browser/base/content/test/general/browser_bug882977.js b/browser/base/content/test/general/browser_bug882977.js deleted file mode 100644 index ed958e06b..000000000 --- a/browser/base/content/test/general/browser_bug882977.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -/** - * Tests that the identity-box shows the chromeUI styling - * when viewing about:home in a new window. - */ -add_task(function*() { - let homepage = "about:home"; - yield SpecialPowers.pushPrefEnv({ - "set": [ - ["browser.startup.homepage", homepage], - ["browser.startup.page", 1], - ] - }); - - let win = OpenBrowserWindow(); - yield BrowserTestUtils.firstBrowserLoaded(win, false); - - let browser = win.gBrowser.selectedBrowser; - is(browser.currentURI.spec, homepage, "Loaded the correct homepage"); - checkIdentityMode(win); - - yield BrowserTestUtils.closeWindow(win); -}); - -function checkIdentityMode(win) { - let identityMode = win.document.getElementById("identity-box").className; - is(identityMode, "chromeUI", "Identity state should be chromeUI for about:home in a new window"); -} diff --git a/browser/base/content/test/general/browser_bug902156.js b/browser/base/content/test/general/browser_bug902156.js deleted file mode 100644 index 74969ead4..000000000 --- a/browser/base/content/test/general/browser_bug902156.js +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Description of the Tests for - * - Bug 902156: Persist "disable protection" option for Mixed Content Blocker - * - * 1. Navigate to the same domain via document.location - * - Load a html page which has mixed content - * - Control Center button to disable protection appears - we disable it - * - Load a new page from the same origin using document.location - * - Control Center button should not appear anymore! - * - * 2. Navigate to the same domain via simulateclick for a link on the page - * - Load a html page which has mixed content - * - Control Center button to disable protection appears - we disable it - * - Load a new page from the same origin simulating a click - * - Control Center button should not appear anymore! - * - * 3. Navigate to a differnet domain and show the content is still blocked - * - Load a different html page which has mixed content - * - Control Center button to disable protection should appear again because - * we navigated away from html page where we disabled the protection. - * - * Note, for all tests we set gHttpTestRoot to use 'https'. - */ - -const PREF_ACTIVE = "security.mixed_content.block_active_content"; - -// We alternate for even and odd test cases to simulate different hosts -const gHttpTestRoot1 = "https://test1.example.com/browser/browser/base/content/test/general/"; -const gHttpTestRoot2 = "https://test2.example.com/browser/browser/base/content/test/general/"; - -var origBlockActive; -var gTestBrowser = null; - -registerCleanupFunction(function() { - // Set preferences back to their original values - Services.prefs.setBoolPref(PREF_ACTIVE, origBlockActive); -}); - -function cleanUpAfterTests() { - gBrowser.removeCurrentTab(); - window.focus(); - finish(); -} - -// ------------------------ Test 1 ------------------------------ - -function test1A() { - BrowserTestUtils.browserLoaded(gTestBrowser).then(test1B); - - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - // Disable Mixed Content Protection for the page (and reload) - let {gIdentityHandler} = gTestBrowser.ownerGlobal; - gIdentityHandler.disableMixedContentProtection(); -} - -function test1B() { - var expected = "Mixed Content Blocker disabled"; - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test1C, "Error: Waited too long for mixed script to run in Test 1B"); -} - -function test1C() { - var actual = content.document.getElementById('mctestdiv').innerHTML; - is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1C"); - - // The Script loaded after we disabled the page, now we are going to reload the - // page and see if our decision is persistent - BrowserTestUtils.browserLoaded(gTestBrowser).then(test1D); - - var url = gHttpTestRoot1 + "file_bug902156_2.html"; - gTestBrowser.loadURI(url); -} - -function test1D() { - // The Control Center button should appear but isMixedContentBlocked should be NOT true, - // because our decision of disabling the mixed content blocker is persistent. - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false}); - - var actual = content.document.getElementById('mctestdiv').innerHTML; - is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1D"); - - // move on to Test 2 - test2(); -} - -// ------------------------ Test 2 ------------------------------ - -function test2() { - BrowserTestUtils.browserLoaded(gTestBrowser).then(test2A); - var url = gHttpTestRoot2 + "file_bug902156_2.html"; - gTestBrowser.loadURI(url); -} - -function test2A() { - BrowserTestUtils.browserLoaded(gTestBrowser).then(test2B); - - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - // Disable Mixed Content Protection for the page (and reload) - let {gIdentityHandler} = gTestBrowser.ownerGlobal; - gIdentityHandler.disableMixedContentProtection(); -} - -function test2B() { - var expected = "Mixed Content Blocker disabled"; - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test2C, "Error: Waited too long for mixed script to run in Test 2B"); -} - -function test2C() { - var actual = content.document.getElementById('mctestdiv').innerHTML; - is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 2C"); - - // The Script loaded after we disabled the page, now we are going to reload the - // page and see if our decision is persistent - BrowserTestUtils.browserLoaded(gTestBrowser).then(test2D); - - // reload the page using the provided link in the html file - var mctestlink = content.document.getElementById("mctestlink"); - mctestlink.click(); -} - -function test2D() { - // The Control Center button should appear but isMixedContentBlocked should be NOT true, - // because our decision of disabling the mixed content blocker is persistent. - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: false}); - - var actual = content.document.getElementById('mctestdiv').innerHTML; - is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 2D"); - - // move on to Test 3 - test3(); -} - -// ------------------------ Test 3 ------------------------------ - -function test3() { - BrowserTestUtils.browserLoaded(gTestBrowser).then(test3A); - var url = gHttpTestRoot1 + "file_bug902156_3.html"; - gTestBrowser.loadURI(url); -} - -function test3A() { - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - // We are done with tests, clean up - cleanUpAfterTests(); -} - -// ------------------------------------------------------ - -function test() { - // Performing async calls, e.g. 'onload', we have to wait till all of them finished - waitForExplicitFinish(); - - // Store original preferences so we can restore settings after testing - origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE); - - Services.prefs.setBoolPref(PREF_ACTIVE, true); - - // Not really sure what this is doing - var newTab = gBrowser.addTab(); - gBrowser.selectedTab = newTab; - gTestBrowser = gBrowser.selectedBrowser; - newTab.linkedBrowser.stop() - - // Starting Test Number 1: - BrowserTestUtils.browserLoaded(gTestBrowser).then(test1A); - var url = gHttpTestRoot1 + "file_bug902156_1.html"; - gTestBrowser.loadURI(url); -} diff --git a/browser/base/content/test/general/browser_bug906190.js b/browser/base/content/test/general/browser_bug906190.js deleted file mode 100644 index 613f50efd..000000000 --- a/browser/base/content/test/general/browser_bug906190.js +++ /dev/null @@ -1,240 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* - * Tests the persistence of the "disable protection" option for Mixed Content - * Blocker in child tabs (bug 906190). - */ - -requestLongerTimeout(2); - -// We use the different urls for testing same origin checks before allowing -// mixed content on child tabs. -const gHttpTestRoot1 = "https://test1.example.com/browser/browser/base/content/test/general/"; -const gHttpTestRoot2 = "https://test2.example.com/browser/browser/base/content/test/general/"; - -/** - * For all tests, we load the pages over HTTPS and test both: - * - |CTRL+CLICK| - * - |RIGHT CLICK -> OPEN LINK IN TAB| - */ -function* doTest(parentTabSpec, childTabSpec, testTaskFn, waitForMetaRefresh) { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: parentTabSpec, - }, function* (browser) { - // As a sanity check, test that active content has been blocked as expected. - yield assertMixedContentBlockingState(gBrowser, { - activeLoaded: false, activeBlocked: true, passiveLoaded: false, - }); - - // Disable the Mixed Content Blocker for the page, which reloads it. - let promiseReloaded = BrowserTestUtils.browserLoaded(browser); - gIdentityHandler.disableMixedContentProtection(); - yield promiseReloaded; - - // Wait for the script in the page to update the contents of the test div. - let testDiv = content.document.getElementById('mctestdiv'); - yield promiseWaitForCondition( - () => testDiv.innerHTML == "Mixed Content Blocker disabled"); - - // Add the link for the child tab to the page. - let mainDiv = content.document.createElement("div"); - mainDiv.innerHTML = - '<p><a id="linkToOpenInNewTab" href="' + childTabSpec + '">Link</a></p>'; - content.document.body.appendChild(mainDiv); - - // Execute the test in the child tabs with the two methods to open it. - for (let openFn of [simulateCtrlClick, simulateContextMenuOpenInTab]) { - let promiseTabLoaded = waitForSomeTabToLoad(); - openFn(browser); - yield promiseTabLoaded; - gBrowser.selectTabAtIndex(2); - - if (waitForMetaRefresh) { - yield waitForSomeTabToLoad(); - } - - yield testTaskFn(); - - gBrowser.removeCurrentTab(); - } - }); -} - -function simulateCtrlClick(browser) { - BrowserTestUtils.synthesizeMouseAtCenter("#linkToOpenInNewTab", - { ctrlKey: true, metaKey: true }, - browser); -} - -function simulateContextMenuOpenInTab(browser) { - BrowserTestUtils.waitForEvent(document, "popupshown", false, event => { - // These are operations that must be executed synchronously with the event. - document.getElementById("context-openlinkintab").doCommand(); - event.target.hidePopup(); - return true; - }); - BrowserTestUtils.synthesizeMouseAtCenter("#linkToOpenInNewTab", - { type: "contextmenu", button: 2 }, - browser); -} - -// Waits for a load event somewhere in the browser but ignore events coming -// from <xul:browser>s without a tab assigned. That are most likely browsers -// that preload the new tab page. -function waitForSomeTabToLoad() { - return new Promise(resolve => { - gBrowser.addEventListener("load", function onLoad(event) { - let tab = gBrowser._getTabForContentWindow(event.target.defaultView.top); - if (tab) { - gBrowser.removeEventListener("load", onLoad, true); - resolve(); - } - }, true); - }); -} - -/** - * Ensure the Mixed Content Blocker is enabled. - */ -add_task(function* test_initialize() { - yield new Promise(resolve => SpecialPowers.pushPrefEnv({ - "set": [["security.mixed_content.block_active_content", true]], - }, resolve)); -}); - -/** - * 1. - Load a html page which has mixed content - * - Doorhanger to disable protection appears - we disable it - * - Load a subpage from the same origin in a new tab simulating a click - * - Doorhanger should >> NOT << appear anymore! - */ -add_task(function* test_same_origin() { - yield doTest(gHttpTestRoot1 + "file_bug906190_1.html", - gHttpTestRoot1 + "file_bug906190_2.html", function* () { - // The doorhanger should appear but activeBlocked should be >> NOT << true, - // because our decision of disabling the mixed content blocker is persistent - // across tabs. - yield assertMixedContentBlockingState(gBrowser, { - activeLoaded: true, activeBlocked: false, passiveLoaded: false, - }); - - is(content.document.getElementById('mctestdiv').innerHTML, - "Mixed Content Blocker disabled", "OK: Executed mixed script"); - }); -}); - -/** - * 2. - Load a html page which has mixed content - * - Doorhanger to disable protection appears - we disable it - * - Load a new page from a different origin in a new tab simulating a click - * - Doorhanger >> SHOULD << appear again! - */ -add_task(function* test_different_origin() { - yield doTest(gHttpTestRoot1 + "file_bug906190_2.html", - gHttpTestRoot2 + "file_bug906190_2.html", function* () { - // The doorhanger should appear and activeBlocked should be >> TRUE <<, - // because our decision of disabling the mixed content blocker should only - // persist if pages are from the same domain. - yield assertMixedContentBlockingState(gBrowser, { - activeLoaded: false, activeBlocked: true, passiveLoaded: false, - }); - - is(content.document.getElementById('mctestdiv').innerHTML, - "Mixed Content Blocker enabled", "OK: Blocked mixed script"); - }); -}); - -/** - * 3. - Load a html page which has mixed content - * - Doorhanger to disable protection appears - we disable it - * - Load a new page from the same origin in a new tab simulating a click - * - Redirect to another page from the same origin using meta-refresh - * - Doorhanger should >> NOT << appear again! - */ -add_task(function* test_same_origin_metarefresh_same_origin() { - // file_bug906190_3_4.html redirects to page test1.example.com/* using meta-refresh - yield doTest(gHttpTestRoot1 + "file_bug906190_1.html", - gHttpTestRoot1 + "file_bug906190_3_4.html", function* () { - // The doorhanger should appear but activeBlocked should be >> NOT << true! - yield assertMixedContentBlockingState(gBrowser, { - activeLoaded: true, activeBlocked: false, passiveLoaded: false, - }); - - is(content.document.getElementById('mctestdiv').innerHTML, - "Mixed Content Blocker disabled", "OK: Executed mixed script"); - }, true); -}); - -/** - * 4. - Load a html page which has mixed content - * - Doorhanger to disable protection appears - we disable it - * - Load a new page from the same origin in a new tab simulating a click - * - Redirect to another page from a different origin using meta-refresh - * - Doorhanger >> SHOULD << appear again! - */ -add_task(function* test_same_origin_metarefresh_different_origin() { - yield doTest(gHttpTestRoot2 + "file_bug906190_1.html", - gHttpTestRoot2 + "file_bug906190_3_4.html", function* () { - // The doorhanger should appear and activeBlocked should be >> TRUE <<. - yield assertMixedContentBlockingState(gBrowser, { - activeLoaded: false, activeBlocked: true, passiveLoaded: false, - }); - - is(content.document.getElementById('mctestdiv').innerHTML, - "Mixed Content Blocker enabled", "OK: Blocked mixed script"); - }, true); -}); - -/** - * 5. - Load a html page which has mixed content - * - Doorhanger to disable protection appears - we disable it - * - Load a new page from the same origin in a new tab simulating a click - * - Redirect to another page from the same origin using 302 redirect - */ -add_task(function* test_same_origin_302redirect_same_origin() { - // the sjs files returns a 302 redirect- note, same origins - yield doTest(gHttpTestRoot1 + "file_bug906190_1.html", - gHttpTestRoot1 + "file_bug906190.sjs", function* () { - // The doorhanger should appear but activeBlocked should be >> NOT << true. - // Currently it is >> TRUE << - see follow up bug 914860 - ok(!gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"), - "OK: Mixed Content is NOT being blocked"); - - is(content.document.getElementById('mctestdiv').innerHTML, - "Mixed Content Blocker disabled", "OK: Executed mixed script"); - }); -}); - -/** - * 6. - Load a html page which has mixed content - * - Doorhanger to disable protection appears - we disable it - * - Load a new page from the same origin in a new tab simulating a click - * - Redirect to another page from a different origin using 302 redirect - */ -add_task(function* test_same_origin_302redirect_different_origin() { - // the sjs files returns a 302 redirect - note, different origins - yield doTest(gHttpTestRoot2 + "file_bug906190_1.html", - gHttpTestRoot2 + "file_bug906190.sjs", function* () { - // The doorhanger should appear and activeBlocked should be >> TRUE <<. - yield assertMixedContentBlockingState(gBrowser, { - activeLoaded: false, activeBlocked: true, passiveLoaded: false, - }); - - is(content.document.getElementById('mctestdiv').innerHTML, - "Mixed Content Blocker enabled", "OK: Blocked mixed script"); - }); -}); - -/** - * 7. - Test memory leak issue on redirection error. See Bug 1269426. - */ -add_task(function* test_bad_redirection() { - // the sjs files returns a 302 redirect - note, different origins - yield doTest(gHttpTestRoot2 + "file_bug906190_1.html", - gHttpTestRoot2 + "file_bug906190.sjs?bad-redirection=1", function* () { - // Nothing to do. Just see if memory leak is reported in the end. - ok(true, "Nothing to do"); - }); -}); diff --git a/browser/base/content/test/general/browser_bug963945.js b/browser/base/content/test/general/browser_bug963945.js deleted file mode 100644 index 4531964b0..000000000 --- a/browser/base/content/test/general/browser_bug963945.js +++ /dev/null @@ -1,23 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/* - * This test ensures the about:addons tab is only - * opened one time when in private browsing. - */ - -add_task(function* test() { - let win = yield BrowserTestUtils.openNewBrowserWindow({private: true}); - - let tab = win.gBrowser.selectedTab = win.gBrowser.addTab("about:addons"); - yield BrowserTestUtils.browserLoaded(tab.linkedBrowser); - yield promiseWaitForFocus(win); - - EventUtils.synthesizeKey("a", { ctrlKey: true, shiftKey: true }, win); - - is(win.gBrowser.tabs.length, 2, "about:addons tab was re-focused."); - is(win.gBrowser.currentURI.spec, "about:addons", "Addons tab was opened."); - - yield BrowserTestUtils.closeWindow(win); -}); diff --git a/browser/base/content/test/general/browser_bug970746.js b/browser/base/content/test/general/browser_bug970746.js deleted file mode 100644 index 623623e55..000000000 --- a/browser/base/content/test/general/browser_bug970746.js +++ /dev/null @@ -1,121 +0,0 @@ -/* Make sure context menu includes option to search hyperlink text on search engine */ - -add_task(function *() { - const url = "http://mochi.test:8888/browser/browser/base/content/test/general/browser_bug970746.xhtml"; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, url); - - const ellipsis = "\u2026"; - - let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - - // Tests if the "Search <engine> for '<some terms>'" context menu item is shown for the - // given query string of an element. Tests to make sure label includes the proper search terms. - // - // Each test: - // - // id: The id of the element to test. - // isSelected: Flag to enable selecting (text highlight) the contents of the element - // shouldBeShown: The display state of the menu item - // expectedLabelContents: The menu item label should contain a portion of this string. - // Will only be tested if shouldBeShown is true. - let tests = [ - { - id: "link", - isSelected: true, - shouldBeShown: true, - expectedLabelContents: "I'm a link!", - }, - { - id: "link", - isSelected: false, - shouldBeShown: true, - expectedLabelContents: "I'm a link!", - }, - { - id: "longLink", - isSelected: true, - shouldBeShown: true, - expectedLabelContents: "I'm a really lo" + ellipsis, - }, - { - id: "longLink", - isSelected: false, - shouldBeShown: true, - expectedLabelContents: "I'm a really lo" + ellipsis, - }, - { - id: "plainText", - isSelected: true, - shouldBeShown: true, - expectedLabelContents: "Right clicking " + ellipsis, - }, - { - id: "plainText", - isSelected: false, - shouldBeShown: false, - }, - { - id: "mixedContent", - isSelected: true, - shouldBeShown: true, - expectedLabelContents: "I'm some text, " + ellipsis, - }, - { - id: "mixedContent", - isSelected: false, - shouldBeShown: false, - }, - { - id: "partialLink", - isSelected: true, - shouldBeShown: true, - expectedLabelContents: "link selection", - }, - { - id: "partialLink", - isSelected: false, - shouldBeShown: true, - expectedLabelContents: "A partial link " + ellipsis, - }, - { - id: "surrogatePair", - isSelected: true, - shouldBeShown: true, - expectedLabelContents: "This character\uD83D\uDD25" + ellipsis, - } - ]; - - for (let test of tests) { - yield ContentTask.spawn(gBrowser.selectedBrowser, - { selectElement: test.isSelected ? test.id : null }, - function* (arg) { - let selection = content.getSelection(); - selection.removeAllRanges(); - - if (arg.selectElement) { - selection.selectAllChildren(content.document.getElementById(arg.selectElement)); - } - }); - - let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown"); - yield BrowserTestUtils.synthesizeMouseAtCenter("#" + test.id, - { type: "contextmenu", button: 2}, gBrowser.selectedBrowser); - yield popupShownPromise; - - let menuItem = document.getElementById("context-searchselect"); - is(menuItem.hidden, !test.shouldBeShown, - "search context menu item is shown for '#" + test.id + "' and selected is '" + test.isSelected + "'"); - - if (test.shouldBeShown) { - ok(menuItem.label.includes(test.expectedLabelContents), - "Menu item text '" + menuItem.label + "' contains the correct search terms '" + test.expectedLabelContents + "'"); - } - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden"); - contentAreaContextMenu.hidePopup(); - yield popupHiddenPromise; - } - - // cleanup - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_bug970746.xhtml b/browser/base/content/test/general/browser_bug970746.xhtml deleted file mode 100644 index 9d78d7147..000000000 --- a/browser/base/content/test/general/browser_bug970746.xhtml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html xmlns="http://www.w3.org/1999/xhtml"> - <body> - <a href="http://mozilla.org" id="link">I'm a link!</a> - <a href="http://mozilla.org" id="longLink">I'm a really long link and I should be truncated.</a> - - <span id="plainText"> - Right clicking me when I'm selected should show the menu item. - </span> - <span id="mixedContent"> - I'm some text, and <a href="http://mozilla.org">I'm a link!</a> - </span> - - <a href="http://mozilla.org">A partial <span id="partialLink">link selection</span></a> - - <span id="surrogatePair"> - This character🔥 shouldn't be truncated. - </span> - </body> -</html> diff --git a/browser/base/content/test/general/browser_clipboard.js b/browser/base/content/test/general/browser_clipboard.js deleted file mode 100644 index 33c6de52d..000000000 --- a/browser/base/content/test/general/browser_clipboard.js +++ /dev/null @@ -1,174 +0,0 @@ -// This test is used to check copy and paste in editable areas to ensure that non-text -// types (html and images) are copied to and pasted from the clipboard properly. - -var testPage = "<body style='margin: 0'>" + - " <img id='img' tabindex='1' src='http://example.org/browser/browser/base/content/test/general/moz.png'>" + - " <div id='main' contenteditable='true'>Test <b>Bold</b> After Text</div>" + - "</body>"; - -add_task(function*() { - let tab = gBrowser.addTab(); - let browser = gBrowser.getBrowserForTab(tab); - - gBrowser.selectedTab = tab; - - yield promiseTabLoadEvent(tab, "data:text/html," + escape(testPage)); - yield SimpleTest.promiseFocus(browser.contentWindowAsCPOW); - - const modifier = (navigator.platform.indexOf("Mac") >= 0) ? - Components.interfaces.nsIDOMWindowUtils.MODIFIER_META : - Components.interfaces.nsIDOMWindowUtils.MODIFIER_CONTROL; - - // On windows, HTML clipboard includes extra data. - // The values are from widget/windows/nsDataObj.cpp. - const htmlPrefix = (navigator.platform.indexOf("Win") >= 0) ? "<html><body>\n<!--StartFragment-->" : ""; - const htmlPostfix = (navigator.platform.indexOf("Win") >= 0) ? "<!--EndFragment-->\n</body>\n</html>" : ""; - - yield ContentTask.spawn(browser, { modifier, htmlPrefix, htmlPostfix }, function* (arg) { - var doc = content.document; - var main = doc.getElementById("main"); - main.focus(); - - const utils = content.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindowUtils); - - function sendKey(key) { - if (utils.sendKeyEvent("keydown", key, 0, arg.modifier)) { - utils.sendKeyEvent("keypress", key, key.charCodeAt(0), arg.modifier); - } - utils.sendKeyEvent("keyup", key, 0, arg.modifier); - } - - // Select an area of the text. - let selection = doc.getSelection(); - selection.modify("move", "left", "line"); - selection.modify("move", "right", "character"); - selection.modify("move", "right", "character"); - selection.modify("move", "right", "character"); - selection.modify("extend", "right", "word"); - selection.modify("extend", "right", "word"); - - yield new Promise((resolve, reject) => { - addEventListener("copy", function copyEvent(event) { - removeEventListener("copy", copyEvent, true); - // The data is empty as the selection is copied during the event default phase. - Assert.equal(event.clipboardData.mozItemCount, 0, "Zero items on clipboard"); - resolve(); - }, true) - - sendKey("c"); - }); - - selection.modify("move", "right", "line"); - - yield new Promise((resolve, reject) => { - addEventListener("paste", function copyEvent(event) { - removeEventListener("paste", copyEvent, true); - let clipboardData = event.clipboardData; - Assert.equal(clipboardData.mozItemCount, 1, "One item on clipboard"); - Assert.equal(clipboardData.types.length, 2, "Two types on clipboard"); - Assert.equal(clipboardData.types[0], "text/html", "text/html on clipboard"); - Assert.equal(clipboardData.types[1], "text/plain", "text/plain on clipboard"); - Assert.equal(clipboardData.getData("text/html"), arg.htmlPrefix + - "t <b>Bold</b>" + arg.htmlPostfix, "text/html value"); - Assert.equal(clipboardData.getData("text/plain"), "t Bold", "text/plain value"); - resolve(); - }, true) - sendKey("v"); - }); - - Assert.equal(main.innerHTML, "Test <b>Bold</b> After Textt <b>Bold</b>", "Copy and paste html"); - - selection.modify("extend", "left", "word"); - selection.modify("extend", "left", "word"); - selection.modify("extend", "left", "character"); - - yield new Promise((resolve, reject) => { - addEventListener("cut", function copyEvent(event) { - removeEventListener("cut", copyEvent, true); - event.clipboardData.setData("text/plain", "Some text"); - event.clipboardData.setData("text/html", "<i>Italic</i> "); - selection.deleteFromDocument(); - event.preventDefault(); - resolve(); - }, true) - sendKey("x"); - }); - - selection.modify("move", "left", "line"); - - yield new Promise((resolve, reject) => { - addEventListener("paste", function copyEvent(event) { - removeEventListener("paste", copyEvent, true); - let clipboardData = event.clipboardData; - Assert.equal(clipboardData.mozItemCount, 1, "One item on clipboard 2"); - Assert.equal(clipboardData.types.length, 2, "Two types on clipboard 2"); - Assert.equal(clipboardData.types[0], "text/html", "text/html on clipboard 2"); - Assert.equal(clipboardData.types[1], "text/plain", "text/plain on clipboard 2"); - Assert.equal(clipboardData.getData("text/html"), arg.htmlPrefix + - "<i>Italic</i> " + arg.htmlPostfix, "text/html value 2"); - Assert.equal(clipboardData.getData("text/plain"), "Some text", "text/plain value 2"); - resolve(); - }, true) - sendKey("v"); - }); - - Assert.equal(main.innerHTML, "<i>Italic</i> Test <b>Bold</b> After<b></b>", - "Copy and paste html 2"); - }); - - // Next, check that the Copy Image command works. - - // The context menu needs to be opened to properly initialize for the copy - // image command to run. - let contextMenu = document.getElementById("contentAreaContextMenu"); - let contextMenuShown = promisePopupShown(contextMenu); - BrowserTestUtils.synthesizeMouseAtCenter("#img", { type: "contextmenu", button: 2 }, gBrowser.selectedBrowser); - yield contextMenuShown; - - document.getElementById("context-copyimage-contents").doCommand(); - - contextMenu.hidePopup(); - yield promisePopupHidden(contextMenu); - - // Focus the content again - yield SimpleTest.promiseFocus(browser.contentWindowAsCPOW); - - yield ContentTask.spawn(browser, { modifier, htmlPrefix, htmlPostfix }, function* (arg) { - var doc = content.document; - var main = doc.getElementById("main"); - main.focus(); - - yield new Promise((resolve, reject) => { - addEventListener("paste", function copyEvent(event) { - removeEventListener("paste", copyEvent, true); - let clipboardData = event.clipboardData; - - // DataTransfer doesn't support the image types yet, so only text/html - // will be present. - if (clipboardData.getData("text/html") !== arg.htmlPrefix + - '<img id="img" tabindex="1" src="http://example.org/browser/browser/base/content/test/general/moz.png">' + - arg.htmlPostfix) { - reject('Clipboard Data did not contain an image, was ' + clipboardData.getData("text/html")); - } - resolve(); - }, true) - - const utils = content.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindowUtils); - - if (utils.sendKeyEvent("keydown", "v", 0, arg.modifier)) { - utils.sendKeyEvent("keypress", "v", "v".charCodeAt(0), arg.modifier); - } - utils.sendKeyEvent("keyup", "v", 0, arg.modifier); - }); - - // The new content should now include an image. - Assert.equal(main.innerHTML, '<i>Italic</i> <img id="img" tabindex="1" ' + - 'src="http://example.org/browser/browser/base/content/test/general/moz.png">' + - 'Test <b>Bold</b> After<b></b>', "Paste after copy image"); - }); - - gBrowser.removeCurrentTab(); -}); - diff --git a/browser/base/content/test/general/browser_clipboard_pastefile.js b/browser/base/content/test/general/browser_clipboard_pastefile.js deleted file mode 100644 index fe87284f3..000000000 --- a/browser/base/content/test/general/browser_clipboard_pastefile.js +++ /dev/null @@ -1,62 +0,0 @@ -// This test is used to check that pasting files removes all non-file data from -// event.clipboardData. - -add_task(function*() { - var textbox = document.createElement("textbox"); - document.documentElement.appendChild(textbox); - - textbox.focus(); - textbox.value = "Text"; - textbox.select(); - - yield new Promise((resolve, reject) => { - textbox.addEventListener("copy", function copyEvent(event) { - textbox.removeEventListener("copy", copyEvent, true); - event.clipboardData.setData("text/plain", "Alternate"); - // For this test, it doesn't matter that the file isn't actually a file. - event.clipboardData.setData("application/x-moz-file", "Sample"); - event.preventDefault(); - resolve(); - }, true) - - EventUtils.synthesizeKey("c", { accelKey: true }); - }); - - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, - "https://example.com/browser/browser/base/content/test/general/clipboard_pastefile.html"); - let browser = tab.linkedBrowser; - - yield ContentTask.spawn(browser, { }, function* (arg) { - content.document.getElementById("input").focus(); - }); - - yield BrowserTestUtils.synthesizeKey("v", { accelKey: true }, browser); - - let output = yield ContentTask.spawn(browser, { }, function* (arg) { - return content.document.getElementById("output").textContent; - }); - is (output, "Passed", "Paste file"); - - textbox.focus(); - - yield new Promise((resolve, reject) => { - textbox.addEventListener("paste", function copyEvent(event) { - textbox.removeEventListener("paste", copyEvent, true); - - let dt = event.clipboardData; - is(dt.types.length, 3, "number of types"); - ok(dt.types.includes("text/plain"), "text/plain exists in types"); - ok(dt.mozTypesAt(0).contains("text/plain"), "text/plain exists in mozTypesAt"); - is(dt.getData("text/plain"), "Alternate", "text/plain returned in getData"); - is(dt.mozGetDataAt("text/plain", 0), "Alternate", "text/plain returned in mozGetDataAt"); - - resolve(); - }, true); - - EventUtils.synthesizeKey("v", { accelKey: true }); - }); - - document.documentElement.removeChild(textbox); - - yield BrowserTestUtils.removeTab(tab); -}); diff --git a/browser/base/content/test/general/browser_contentAltClick.js b/browser/base/content/test/general/browser_contentAltClick.js deleted file mode 100644 index 1a3b0fccc..000000000 --- a/browser/base/content/test/general/browser_contentAltClick.js +++ /dev/null @@ -1,107 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/** - * Test for Bug 1109146. - * The tests opens a new tab and alt + clicks to download files - * and confirms those files are on the download list. - * - * The difference between this and the test "browser_contentAreaClick.js" is that - * the code path in e10s uses ContentClick.jsm instead of browser.js::contentAreaClick() util. - */ -"use strict"; - -XPCOMUtils.defineLazyModuleGetter(this, "Downloads", - "resource://gre/modules/Downloads.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils", - "resource://testing-common/PlacesTestUtils.jsm"); - -function setup() { - gPrefService.setBoolPref("browser.altClickSave", true); - - let testPage = - 'data:text/html,' + - '<p><a id="commonlink" href="http://mochi.test/moz/">Common link</a></p>' + - '<p><math id="mathxlink" xmlns="http://www.w3.org/1998/Math/MathML" xlink:type="simple" xlink:href="http://mochi.test/moz/"><mtext>MathML XLink</mtext></math></p>' + - '<p><svg id="svgxlink" xmlns="http://www.w3.org/2000/svg" width="100px" height="50px" version="1.1"><a xlink:type="simple" xlink:href="http://mochi.test/moz/"><text transform="translate(10, 25)">SVG XLink</text></a></svg></p>'; - - return BrowserTestUtils.openNewForegroundTab(gBrowser, testPage); -} - -function* clean_up() { - // Remove downloads. - let downloadList = yield Downloads.getList(Downloads.ALL); - let downloads = yield downloadList.getAll(); - for (let download of downloads) { - yield downloadList.remove(download); - yield download.finalize(true); - } - // Remove download history. - yield PlacesTestUtils.clearHistory(); - - gPrefService.clearUserPref("browser.altClickSave"); - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -} - -add_task(function* test_alt_click() -{ - yield setup(); - - let downloadList = yield Downloads.getList(Downloads.ALL); - let downloads = []; - let downloadView; - // When 1 download has been attempted then resolve the promise. - let finishedAllDownloads = new Promise( (resolve) => { - downloadView = { - onDownloadAdded: function (aDownload) { - downloads.push(aDownload); - resolve(); - }, - }; - }); - yield downloadList.addView(downloadView); - yield BrowserTestUtils.synthesizeMouseAtCenter("#commonlink", {altKey: true}, gBrowser.selectedBrowser); - - // Wait for all downloads to be added to the download list. - yield finishedAllDownloads; - yield downloadList.removeView(downloadView); - - is(downloads.length, 1, "1 downloads"); - is(downloads[0].source.url, "http://mochi.test/moz/", "Downloaded #commonlink element"); - - yield* clean_up(); -}); - -add_task(function* test_alt_click_on_xlinks() -{ - yield setup(); - - let downloadList = yield Downloads.getList(Downloads.ALL); - let downloads = []; - let downloadView; - // When all 2 downloads have been attempted then resolve the promise. - let finishedAllDownloads = new Promise( (resolve) => { - downloadView = { - onDownloadAdded: function (aDownload) { - downloads.push(aDownload); - if (downloads.length == 2) { - resolve(); - } - }, - }; - }); - yield downloadList.addView(downloadView); - yield BrowserTestUtils.synthesizeMouseAtCenter("#mathxlink", {altKey: true}, gBrowser.selectedBrowser); - yield BrowserTestUtils.synthesizeMouseAtCenter("#svgxlink", {altKey: true}, gBrowser.selectedBrowser); - - // Wait for all downloads to be added to the download list. - yield finishedAllDownloads; - yield downloadList.removeView(downloadView); - - is(downloads.length, 2, "2 downloads"); - is(downloads[0].source.url, "http://mochi.test/moz/", "Downloaded #mathxlink element"); - is(downloads[1].source.url, "http://mochi.test/moz/", "Downloaded #svgxlink element"); - - yield* clean_up(); -}); diff --git a/browser/base/content/test/general/browser_contentAreaClick.js b/browser/base/content/test/general/browser_contentAreaClick.js deleted file mode 100644 index facdfb498..000000000 --- a/browser/base/content/test/general/browser_contentAreaClick.js +++ /dev/null @@ -1,307 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/** - * Test for bug 549340. - * Test for browser.js::contentAreaClick() util. - * - * The test opens a new browser window, then replaces browser.js methods invoked - * by contentAreaClick with a mock function that tracks which methods have been - * called. - * Each sub-test synthesizes a mouse click event on links injected in content, - * the event is collected by a click handler that ensures that contentAreaClick - * correctly prevent default events, and follows the correct code path. - */ - -var gTests = [ - - { - desc: "Simple left click", - setup: function() {}, - clean: function() {}, - event: {}, - targets: [ "commonlink", "mathxlink", "svgxlink", "maplink" ], - expectedInvokedMethods: [], - preventDefault: false, - }, - - { - desc: "Ctrl/Cmd left click", - setup: function() {}, - clean: function() {}, - event: { ctrlKey: true, - metaKey: true }, - targets: [ "commonlink", "mathxlink", "svgxlink", "maplink" ], - expectedInvokedMethods: [ "urlSecurityCheck", "openLinkIn" ], - preventDefault: true, - }, - - // The next test was once handling feedService.forcePreview(). Now it should - // just be like Alt click. - { - desc: "Shift+Alt left click", - setup: function() { - gPrefService.setBoolPref("browser.altClickSave", true); - }, - clean: function() { - gPrefService.clearUserPref("browser.altClickSave"); - }, - event: { shiftKey: true, - altKey: true }, - targets: [ "commonlink", "maplink" ], - expectedInvokedMethods: [ "gatherTextUnder", "saveURL" ], - preventDefault: true, - }, - - { - desc: "Shift+Alt left click on XLinks", - setup: function() { - gPrefService.setBoolPref("browser.altClickSave", true); - }, - clean: function() { - gPrefService.clearUserPref("browser.altClickSave"); - }, - event: { shiftKey: true, - altKey: true }, - targets: [ "mathxlink", "svgxlink"], - expectedInvokedMethods: [ "saveURL" ], - preventDefault: true, - }, - - { - desc: "Shift click", - setup: function() {}, - clean: function() {}, - event: { shiftKey: true }, - targets: [ "commonlink", "mathxlink", "svgxlink", "maplink" ], - expectedInvokedMethods: [ "urlSecurityCheck", "openLinkIn" ], - preventDefault: true, - }, - - { - desc: "Alt click", - setup: function() { - gPrefService.setBoolPref("browser.altClickSave", true); - }, - clean: function() { - gPrefService.clearUserPref("browser.altClickSave"); - }, - event: { altKey: true }, - targets: [ "commonlink", "maplink" ], - expectedInvokedMethods: [ "gatherTextUnder", "saveURL" ], - preventDefault: true, - }, - - { - desc: "Alt click on XLinks", - setup: function() { - gPrefService.setBoolPref("browser.altClickSave", true); - }, - clean: function() { - gPrefService.clearUserPref("browser.altClickSave"); - }, - event: { altKey: true }, - targets: [ "mathxlink", "svgxlink" ], - expectedInvokedMethods: [ "saveURL" ], - preventDefault: true, - }, - - { - desc: "Panel click", - setup: function() {}, - clean: function() {}, - event: {}, - targets: [ "panellink" ], - expectedInvokedMethods: [ "urlSecurityCheck", "loadURI" ], - preventDefault: true, - }, - - { - desc: "Simple middle click opentab", - setup: function() {}, - clean: function() {}, - event: { button: 1 }, - targets: [ "commonlink", "mathxlink", "svgxlink", "maplink" ], - expectedInvokedMethods: [ "urlSecurityCheck", "openLinkIn" ], - preventDefault: true, - }, - - { - desc: "Simple middle click openwin", - setup: function() { - gPrefService.setBoolPref("browser.tabs.opentabfor.middleclick", false); - }, - clean: function() { - gPrefService.clearUserPref("browser.tabs.opentabfor.middleclick"); - }, - event: { button: 1 }, - targets: [ "commonlink", "mathxlink", "svgxlink", "maplink" ], - expectedInvokedMethods: [ "urlSecurityCheck", "openLinkIn" ], - preventDefault: true, - }, - - { - desc: "Middle mouse paste", - setup: function() { - gPrefService.setBoolPref("middlemouse.contentLoadURL", true); - gPrefService.setBoolPref("general.autoScroll", false); - }, - clean: function() { - gPrefService.clearUserPref("middlemouse.contentLoadURL"); - gPrefService.clearUserPref("general.autoScroll"); - }, - event: { button: 1 }, - targets: [ "emptylink" ], - expectedInvokedMethods: [ "middleMousePaste" ], - preventDefault: true, - }, - -]; - -// Array of method names that will be replaced in the new window. -var gReplacedMethods = [ - "middleMousePaste", - "urlSecurityCheck", - "loadURI", - "gatherTextUnder", - "saveURL", - "openLinkIn", - "getShortcutOrURIAndPostData", -]; - -// Reference to the new window. -var gTestWin = null; - -// List of methods invoked by a specific call to contentAreaClick. -var gInvokedMethods = []; - -// The test currently running. -var gCurrentTest = null; - -function test() { - waitForExplicitFinish(); - - gTestWin = openDialog(location, "", "chrome,all,dialog=no", "about:blank"); - whenDelayedStartupFinished(gTestWin, function () { - info("Browser window opened"); - waitForFocus(function() { - info("Browser window focused"); - waitForFocus(function() { - info("Setting up browser..."); - setupTestBrowserWindow(); - info("Running tests..."); - executeSoon(runNextTest); - }, gTestWin.content, true); - }, gTestWin); - }); -} - -// Click handler used to steal click events. -var gClickHandler = { - handleEvent: function (event) { - let linkId = event.target.id || event.target.localName; - is(event.type, "click", - gCurrentTest.desc + ":Handler received a click event on " + linkId); - - let isPanelClick = linkId == "panellink"; - gTestWin.contentAreaClick(event, isPanelClick); - let prevent = event.defaultPrevented; - is(prevent, gCurrentTest.preventDefault, - gCurrentTest.desc + ": event.defaultPrevented is correct (" + prevent + ")") - - // Check that all required methods have been called. - gCurrentTest.expectedInvokedMethods.forEach(function(aExpectedMethodName) { - isnot(gInvokedMethods.indexOf(aExpectedMethodName), -1, - gCurrentTest.desc + ":" + aExpectedMethodName + " was invoked"); - }); - - if (gInvokedMethods.length != gCurrentTest.expectedInvokedMethods.length) { - ok(false, "Wrong number of invoked methods"); - gInvokedMethods.forEach(method => info(method + " was invoked")); - } - - event.preventDefault(); - event.stopPropagation(); - - executeSoon(runNextTest); - } -} - -// Wraps around the methods' replacement mock function. -function wrapperMethod(aInvokedMethods, aMethodName) { - return function () { - aInvokedMethods.push(aMethodName); - // At least getShortcutOrURIAndPostData requires to return url - return (aMethodName == "getShortcutOrURIAndPostData") ? arguments.url : arguments[0]; - } -} - -function setupTestBrowserWindow() { - // Steal click events and don't propagate them. - gTestWin.addEventListener("click", gClickHandler, true); - - // Replace methods. - gReplacedMethods.forEach(function (aMethodName) { - gTestWin["old_" + aMethodName] = gTestWin[aMethodName]; - gTestWin[aMethodName] = wrapperMethod(gInvokedMethods, aMethodName); - }); - - // Inject links in content. - let doc = gTestWin.content.document; - let mainDiv = doc.createElement("div"); - mainDiv.innerHTML = - '<p><a id="commonlink" href="http://mochi.test/moz/">Common link</a></p>' + - '<p><a id="panellink" href="http://mochi.test/moz/">Panel link</a></p>' + - '<p><a id="emptylink">Empty link</a></p>' + - '<p><math id="mathxlink" xmlns="http://www.w3.org/1998/Math/MathML" xlink:type="simple" xlink:href="http://mochi.test/moz/"><mtext>MathML XLink</mtext></math></p>' + - '<p><svg id="svgxlink" xmlns="http://www.w3.org/2000/svg" width="100px" height="50px" version="1.1"><a xlink:type="simple" xlink:href="http://mochi.test/moz/"><text transform="translate(10, 25)">SVG XLink</text></a></svg></p>' + - '<p><map name="map" id="map"><area href="http://mochi.test/moz/" shape="rect" coords="0,0,128,128" /></map><img id="maplink" usemap="#map" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAIAAABMXPacAAAABGdBTUEAALGPC%2FxhBQAAAOtJREFUeF7t0IEAAAAAgKD9qRcphAoDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGBgwIAAAT0N51AAAAAASUVORK5CYII%3D"/></p>' - doc.body.appendChild(mainDiv); -} - -function runNextTest() { - if (!gCurrentTest) { - gCurrentTest = gTests.shift(); - gCurrentTest.setup(); - } - - if (gCurrentTest.targets.length == 0) { - info(gCurrentTest.desc + ": cleaning up...") - gCurrentTest.clean(); - - if (gTests.length > 0) { - gCurrentTest = gTests.shift(); - gCurrentTest.setup(); - } - else { - finishTest(); - return; - } - } - - // Move to next target. - gInvokedMethods.length = 0; - let target = gCurrentTest.targets.shift(); - - info(gCurrentTest.desc + ": testing " + target); - - // Fire click event. - let targetElt = gTestWin.content.document.getElementById(target); - ok(targetElt, gCurrentTest.desc + ": target is valid (" + targetElt.id + ")"); - EventUtils.synthesizeMouseAtCenter(targetElt, gCurrentTest.event, gTestWin.content); -} - -function finishTest() { - info("Restoring browser..."); - gTestWin.removeEventListener("click", gClickHandler, true); - - // Restore original methods. - gReplacedMethods.forEach(function (aMethodName) { - gTestWin[aMethodName] = gTestWin["old_" + aMethodName]; - delete gTestWin["old_" + aMethodName]; - }); - - gTestWin.close(); - finish(); -} diff --git a/browser/base/content/test/general/browser_contentSearchUI.js b/browser/base/content/test/general/browser_contentSearchUI.js deleted file mode 100644 index 003f80aff..000000000 --- a/browser/base/content/test/general/browser_contentSearchUI.js +++ /dev/null @@ -1,771 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -const TEST_PAGE_BASENAME = "contentSearchUI.html"; -const TEST_CONTENT_SCRIPT_BASENAME = "contentSearchUI.js"; -const TEST_ENGINE_PREFIX = "browser_searchSuggestionEngine"; -const TEST_ENGINE_BASENAME = "searchSuggestionEngine.xml"; -const TEST_ENGINE_2_BASENAME = "searchSuggestionEngine2.xml"; - -const TEST_MSG = "ContentSearchUIControllerTest"; - -requestLongerTimeout(2); - -add_task(function* emptyInput() { - yield setUp(); - - let state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - - state = yield msg("key", "VK_BACK_SPACE"); - checkState(state, "", [], -1); - - yield msg("reset"); -}); - -add_task(function* blur() { - yield setUp(); - - let state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - - state = yield msg("blur"); - checkState(state, "x", [], -1); - - yield msg("reset"); -}); - -add_task(function* upDownKeys() { - yield setUp(); - - let state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - - // Cycle down the suggestions starting from no selection. - state = yield msg("key", "VK_DOWN"); - checkState(state, "xfoo", ["xfoo", "xbar"], 0); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "xbar", ["xfoo", "xbar"], 1); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "x", ["xfoo", "xbar"], 2); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "x", ["xfoo", "xbar"], 3); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "x", ["xfoo", "xbar"], -1); - - // Cycle up starting from no selection. - state = yield msg("key", "VK_UP"); - checkState(state, "x", ["xfoo", "xbar"], 3); - - state = yield msg("key", "VK_UP"); - checkState(state, "x", ["xfoo", "xbar"], 2); - - state = yield msg("key", "VK_UP"); - checkState(state, "xbar", ["xfoo", "xbar"], 1); - - state = yield msg("key", "VK_UP"); - checkState(state, "xfoo", ["xfoo", "xbar"], 0); - - state = yield msg("key", "VK_UP"); - checkState(state, "x", ["xfoo", "xbar"], -1); - - yield msg("reset"); -}); - -add_task(function* rightLeftKeys() { - yield setUp(); - - let state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - - state = yield msg("key", "VK_LEFT"); - checkState(state, "x", ["xfoo", "xbar"], -1); - - state = yield msg("key", "VK_LEFT"); - checkState(state, "x", ["xfoo", "xbar"], -1); - - state = yield msg("key", "VK_RIGHT"); - checkState(state, "x", ["xfoo", "xbar"], -1); - - state = yield msg("key", "VK_RIGHT"); - checkState(state, "x", [], -1); - - state = yield msg("key", { key: "VK_DOWN", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "xfoo", ["xfoo", "xbar"], 0); - - // This should make the xfoo suggestion sticky. To make sure it sticks, - // trigger suggestions again and cycle through them by pressing Down until - // nothing is selected again. - state = yield msg("key", "VK_RIGHT"); - checkState(state, "xfoo", [], -1); - - state = yield msg("key", { key: "VK_DOWN", waitForSuggestions: true }); - checkState(state, "xfoo", ["xfoofoo", "xfoobar"], -1); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "xfoofoo", ["xfoofoo", "xfoobar"], 0); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "xfoobar", ["xfoofoo", "xfoobar"], 1); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "xfoo", ["xfoofoo", "xfoobar"], 2); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "xfoo", ["xfoofoo", "xfoobar"], 3); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "xfoo", ["xfoofoo", "xfoobar"], -1); - - yield msg("reset"); -}); - -add_task(function* tabKey() { - yield setUp(); - yield msg("key", { key: "x", waitForSuggestions: true }); - - let state = yield msg("key", "VK_TAB"); - checkState(state, "x", ["xfoo", "xbar"], 2); - - state = yield msg("key", "VK_TAB"); - checkState(state, "x", ["xfoo", "xbar"], 3); - - state = yield msg("key", { key: "VK_TAB", modifiers: { shiftKey: true }}); - checkState(state, "x", ["xfoo", "xbar"], 2); - - state = yield msg("key", { key: "VK_TAB", modifiers: { shiftKey: true }}); - checkState(state, "x", [], -1); - - yield setUp(); - - yield msg("key", { key: "VK_DOWN", waitForSuggestions: true }); - - for (let i = 0; i < 3; ++i) { - state = yield msg("key", "VK_TAB"); - } - checkState(state, "x", [], -1); - - yield setUp(); - - yield msg("key", { key: "VK_DOWN", waitForSuggestions: true }); - state = yield msg("key", "VK_DOWN"); - checkState(state, "xfoo", ["xfoo", "xbar"], 0); - - state = yield msg("key", "VK_TAB"); - checkState(state, "xfoo", ["xfoo", "xbar"], 0, 0); - - state = yield msg("key", "VK_TAB"); - checkState(state, "xfoo", ["xfoo", "xbar"], 0, 1); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 1); - - state = yield msg("key", "VK_DOWN"); - checkState(state, "x", ["xfoo", "xbar"], 2); - - state = yield msg("key", "VK_UP"); - checkState(state, "xbar", ["xfoo", "xbar"], 1); - - state = yield msg("key", "VK_TAB"); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 0); - - state = yield msg("key", "VK_TAB"); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 1); - - state = yield msg("key", "VK_TAB"); - checkState(state, "xbar", [], -1); - - yield msg("reset"); -}); - -add_task(function* cycleSuggestions() { - yield setUp(); - yield msg("key", { key: "x", waitForSuggestions: true }); - - let cycle = Task.async(function* (aSelectedButtonIndex) { - let modifiers = { - shiftKey: true, - accelKey: true, - }; - - let state = yield msg("key", { key: "VK_DOWN", modifiers: modifiers }); - checkState(state, "xfoo", ["xfoo", "xbar"], 0, aSelectedButtonIndex); - - state = yield msg("key", { key: "VK_DOWN", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1, aSelectedButtonIndex); - - state = yield msg("key", { key: "VK_DOWN", modifiers: modifiers }); - checkState(state, "x", ["xfoo", "xbar"], -1, aSelectedButtonIndex); - - state = yield msg("key", { key: "VK_DOWN", modifiers: modifiers }); - checkState(state, "xfoo", ["xfoo", "xbar"], 0, aSelectedButtonIndex); - - state = yield msg("key", { key: "VK_UP", modifiers: modifiers }); - checkState(state, "x", ["xfoo", "xbar"], -1, aSelectedButtonIndex); - - state = yield msg("key", { key: "VK_UP", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1, aSelectedButtonIndex); - - state = yield msg("key", { key: "VK_UP", modifiers: modifiers }); - checkState(state, "xfoo", ["xfoo", "xbar"], 0, aSelectedButtonIndex); - - state = yield msg("key", { key: "VK_UP", modifiers: modifiers }); - checkState(state, "x", ["xfoo", "xbar"], -1, aSelectedButtonIndex); - }); - - yield cycle(); - - // Repeat with a one-off selected. - let state = yield msg("key", "VK_TAB"); - checkState(state, "x", ["xfoo", "xbar"], 2); - yield cycle(0); - - // Repeat with the settings button selected. - state = yield msg("key", "VK_TAB"); - checkState(state, "x", ["xfoo", "xbar"], 3); - yield cycle(1); - - yield msg("reset"); -}); - -add_task(function* cycleOneOffs() { - yield setUp(); - yield msg("key", { key: "x", waitForSuggestions: true }); - - yield msg("addDuplicateOneOff"); - - let state = yield msg("key", "VK_DOWN"); - state = yield msg("key", "VK_DOWN"); - checkState(state, "xbar", ["xfoo", "xbar"], 1); - - let modifiers = { - altKey: true, - }; - - state = yield msg("key", { key: "VK_DOWN", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 0); - - state = yield msg("key", { key: "VK_DOWN", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 1); - - state = yield msg("key", { key: "VK_DOWN", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1); - - state = yield msg("key", { key: "VK_UP", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 1); - - state = yield msg("key", { key: "VK_UP", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 0); - - state = yield msg("key", { key: "VK_UP", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1); - - // If the settings button is selected, pressing alt+up/down should select the - // last/first one-off respectively (and deselect the settings button). - yield msg("key", "VK_TAB"); - yield msg("key", "VK_TAB"); - state = yield msg("key", "VK_TAB"); // Settings button selected. - checkState(state, "xbar", ["xfoo", "xbar"], 1, 2); - - state = yield msg("key", { key: "VK_UP", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 1); - - state = yield msg("key", "VK_TAB"); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 2); - - state = yield msg("key", { key: "VK_DOWN", modifiers: modifiers }); - checkState(state, "xbar", ["xfoo", "xbar"], 1, 0); - - yield msg("removeLastOneOff"); - yield msg("reset"); -}); - -add_task(function* mouse() { - yield setUp(); - - let state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - - state = yield msg("mousemove", 0); - checkState(state, "x", ["xfoo", "xbar"], 0); - - state = yield msg("mousemove", 1); - checkState(state, "x", ["xfoo", "xbar"], 1); - - state = yield msg("mousemove", 2); - checkState(state, "x", ["xfoo", "xbar"], 1, 0); - - state = yield msg("mousemove", 3); - checkState(state, "x", ["xfoo", "xbar"], 1, 1); - - state = yield msg("mousemove", -1); - checkState(state, "x", ["xfoo", "xbar"], 1); - - yield msg("reset"); - yield setUp(); - - state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - - state = yield msg("mousemove", 0); - checkState(state, "x", ["xfoo", "xbar"], 0); - - state = yield msg("mousemove", 2); - checkState(state, "x", ["xfoo", "xbar"], 0, 0); - - state = yield msg("mousemove", -1); - checkState(state, "x", ["xfoo", "xbar"], 0); - - yield msg("reset"); -}); - -add_task(function* formHistory() { - yield setUp(); - - // Type an X and add it to form history. - let state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - // Wait for Satchel to say it's been added to form history. - let deferred = Promise.defer(); - Services.obs.addObserver(function onAdd(subj, topic, data) { - if (data == "formhistory-add") { - Services.obs.removeObserver(onAdd, "satchel-storage-changed"); - executeSoon(() => deferred.resolve()); - } - }, "satchel-storage-changed", false); - yield Promise.all([msg("addInputValueToFormHistory"), deferred.promise]); - - // Reset the input. - state = yield msg("reset"); - checkState(state, "", [], -1); - - // Type an X again. The form history entry should appear. - state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", [{ str: "x", type: "formHistory" }, "xfoo", "xbar"], - -1); - - // Select the form history entry and delete it. - state = yield msg("key", "VK_DOWN"); - checkState(state, "x", [{ str: "x", type: "formHistory" }, "xfoo", "xbar"], - 0); - - // Wait for Satchel. - deferred = Promise.defer(); - Services.obs.addObserver(function onRemove(subj, topic, data) { - if (data == "formhistory-remove") { - Services.obs.removeObserver(onRemove, "satchel-storage-changed"); - executeSoon(() => deferred.resolve()); - } - }, "satchel-storage-changed", false); - - state = yield msg("key", "VK_DELETE"); - checkState(state, "x", ["xfoo", "xbar"], -1); - - yield deferred.promise; - - // Reset the input. - state = yield msg("reset"); - checkState(state, "", [], -1); - - // Type an X again. The form history entry should still be gone. - state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - - yield msg("reset"); -}); - -add_task(function* cycleEngines() { - yield setUp(); - yield msg("key", { key: "VK_DOWN", waitForSuggestions: true }); - - let promiseEngineChange = function(newEngineName) { - let deferred = Promise.defer(); - Services.obs.addObserver(function resolver(subj, topic, data) { - if (data != "engine-current") { - return; - } - SimpleTest.is(subj.name, newEngineName, "Engine cycled correctly"); - Services.obs.removeObserver(resolver, "browser-search-engine-modified"); - deferred.resolve(); - }, "browser-search-engine-modified", false); - return deferred.promise; - } - - let p = promiseEngineChange(TEST_ENGINE_PREFIX + " " + TEST_ENGINE_2_BASENAME); - yield msg("key", { key: "VK_DOWN", modifiers: { accelKey: true }}); - yield p; - - p = promiseEngineChange(TEST_ENGINE_PREFIX + " " + TEST_ENGINE_BASENAME); - yield msg("key", { key: "VK_UP", modifiers: { accelKey: true }}); - yield p; - - yield msg("reset"); -}); - -add_task(function* search() { - yield setUp(); - - let modifiers = {}; - ["altKey", "ctrlKey", "metaKey", "shiftKey"].forEach(k => modifiers[k] = true); - - // Test typing a query and pressing enter. - let p = msg("waitForSearch"); - yield msg("key", { key: "x", waitForSuggestions: true }); - yield msg("key", { key: "VK_RETURN", modifiers: modifiers }); - let mesg = yield p; - let eventData = { - engineName: TEST_ENGINE_PREFIX + " " + TEST_ENGINE_BASENAME, - searchString: "x", - healthReportKey: "test", - searchPurpose: "test", - originalEvent: modifiers, - }; - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - // Test typing a query, then selecting a suggestion and pressing enter. - p = msg("waitForSearch"); - yield msg("key", { key: "x", waitForSuggestions: true }); - yield msg("key", "VK_DOWN"); - yield msg("key", "VK_DOWN"); - yield msg("key", { key: "VK_RETURN", modifiers: modifiers }); - mesg = yield p; - eventData.searchString = "xfoo"; - eventData.engineName = TEST_ENGINE_PREFIX + " " + TEST_ENGINE_BASENAME; - eventData.selection = { - index: 1, - kind: "key", - } - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - // Test typing a query, then selecting a one-off button and pressing enter. - p = msg("waitForSearch"); - yield msg("key", { key: "x", waitForSuggestions: true }); - yield msg("key", "VK_UP"); - yield msg("key", "VK_UP"); - yield msg("key", { key: "VK_RETURN", modifiers: modifiers }); - mesg = yield p; - delete eventData.selection; - eventData.searchString = "x"; - eventData.engineName = TEST_ENGINE_PREFIX + " " + TEST_ENGINE_2_BASENAME; - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - // Test typing a query and clicking the search engine header. - p = msg("waitForSearch"); - modifiers.button = 0; - yield msg("key", { key: "x", waitForSuggestions: true }); - yield msg("mousemove", -1); - yield msg("click", { eltIdx: -1, modifiers: modifiers }); - mesg = yield p; - eventData.originalEvent = modifiers; - eventData.engineName = TEST_ENGINE_PREFIX + " " + TEST_ENGINE_BASENAME; - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - // Test typing a query and then clicking a suggestion. - yield msg("key", { key: "x", waitForSuggestions: true }); - p = msg("waitForSearch"); - yield msg("mousemove", 1); - yield msg("click", { eltIdx: 1, modifiers: modifiers }); - mesg = yield p; - eventData.searchString = "xfoo"; - eventData.selection = { - index: 1, - kind: "mouse", - }; - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - // Test typing a query and then clicking a one-off button. - yield msg("key", { key: "x", waitForSuggestions: true }); - p = msg("waitForSearch"); - yield msg("mousemove", 3); - yield msg("click", { eltIdx: 3, modifiers: modifiers }); - mesg = yield p; - eventData.searchString = "x"; - eventData.engineName = TEST_ENGINE_PREFIX + " " + TEST_ENGINE_2_BASENAME; - delete eventData.selection; - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - // Test selecting a suggestion, then clicking a one-off without deselecting the - // suggestion. - yield msg("key", { key: "x", waitForSuggestions: true }); - p = msg("waitForSearch"); - yield msg("mousemove", 1); - yield msg("mousemove", 3); - yield msg("click", { eltIdx: 3, modifiers: modifiers }); - mesg = yield p; - eventData.searchString = "xfoo" - eventData.selection = { - index: 1, - kind: "mouse", - }; - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - // Same as above, but with the keyboard. - delete modifiers.button; - yield msg("key", { key: "x", waitForSuggestions: true }); - p = msg("waitForSearch"); - yield msg("key", "VK_DOWN"); - yield msg("key", "VK_DOWN"); - yield msg("key", "VK_TAB"); - yield msg("key", { key: "VK_RETURN", modifiers: modifiers }); - mesg = yield p; - eventData.selection = { - index: 1, - kind: "key", - }; - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - // Test searching when using IME composition. - let state = yield msg("startComposition", { data: "" }); - checkState(state, "", [], -1); - state = yield msg("changeComposition", { data: "x", waitForSuggestions: true }); - checkState(state, "x", [{ str: "x", type: "formHistory" }, - { str: "xfoo", type: "formHistory" }, "xbar"], -1); - yield msg("commitComposition"); - delete modifiers.button; - p = msg("waitForSearch"); - yield msg("key", { key: "VK_RETURN", modifiers: modifiers }); - mesg = yield p; - eventData.searchString = "x" - eventData.originalEvent = modifiers; - eventData.engineName = TEST_ENGINE_PREFIX + " " + TEST_ENGINE_BASENAME; - delete eventData.selection; - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - state = yield msg("startComposition", { data: "" }); - checkState(state, "", [], -1); - state = yield msg("changeComposition", { data: "x", waitForSuggestions: true }); - checkState(state, "x", [{ str: "x", type: "formHistory" }, - { str: "xfoo", type: "formHistory" }, "xbar"], -1); - - // Mouse over the first suggestion. - state = yield msg("mousemove", 0); - checkState(state, "x", [{ str: "x", type: "formHistory" }, - { str: "xfoo", type: "formHistory" }, "xbar"], 0); - - // Mouse over the second suggestion. - state = yield msg("mousemove", 1); - checkState(state, "x", [{ str: "x", type: "formHistory" }, - { str: "xfoo", type: "formHistory" }, "xbar"], 1); - - modifiers.button = 0; - p = msg("waitForSearch"); - yield msg("click", { eltIdx: 1, modifiers: modifiers }); - mesg = yield p; - eventData.searchString = "xfoo"; - eventData.originalEvent = modifiers; - eventData.selection = { - index: 1, - kind: "mouse", - }; - SimpleTest.isDeeply(eventData, mesg, "Search event data"); - - yield promiseTab(); - yield setUp(); - - // Remove form history entries. - // Wait for Satchel. - let deferred = Promise.defer(); - let historyCount = 2; - Services.obs.addObserver(function onRemove(subj, topic, data) { - if (data == "formhistory-remove") { - if (--historyCount) { - return; - } - Services.obs.removeObserver(onRemove, "satchel-storage-changed"); - executeSoon(() => deferred.resolve()); - } - }, "satchel-storage-changed", false); - - yield msg("key", { key: "x", waitForSuggestions: true }); - yield msg("key", "VK_DOWN"); - yield msg("key", "VK_DOWN"); - yield msg("key", "VK_DELETE"); - yield msg("key", "VK_DOWN"); - yield msg("key", "VK_DELETE"); - yield deferred.promise; - - yield msg("reset"); - state = yield msg("key", { key: "x", waitForSuggestions: true }); - checkState(state, "x", ["xfoo", "xbar"], -1); - - yield promiseTab(); - yield setUp(); - yield msg("reset"); -}); - -add_task(function* settings() { - yield setUp(); - yield msg("key", { key: "VK_DOWN", waitForSuggestions: true }); - yield msg("key", "VK_UP"); - let p = msg("waitForSearchSettings"); - yield msg("key", "VK_RETURN"); - yield p; - - yield msg("reset"); -}); - -var gDidInitialSetUp = false; - -function setUp(aNoEngine) { - return Task.spawn(function* () { - if (!gDidInitialSetUp) { - Cu.import("resource:///modules/ContentSearch.jsm"); - let originalOnMessageSearch = ContentSearch._onMessageSearch; - let originalOnMessageManageEngines = ContentSearch._onMessageManageEngines; - ContentSearch._onMessageSearch = () => {}; - ContentSearch._onMessageManageEngines = () => {}; - registerCleanupFunction(() => { - ContentSearch._onMessageSearch = originalOnMessageSearch; - ContentSearch._onMessageManageEngines = originalOnMessageManageEngines; - }); - yield setUpEngines(); - yield promiseTab(); - gDidInitialSetUp = true; - } - yield msg("focus"); - }); -} - -function msg(type, data=null) { - gMsgMan.sendAsyncMessage(TEST_MSG, { - type: type, - data: data, - }); - let deferred = Promise.defer(); - gMsgMan.addMessageListener(TEST_MSG, function onMsg(msgObj) { - if (msgObj.data.type != type) { - return; - } - gMsgMan.removeMessageListener(TEST_MSG, onMsg); - deferred.resolve(msgObj.data.data); - }); - return deferred.promise; -} - -function checkState(actualState, expectedInputVal, expectedSuggestions, - expectedSelectedIdx, expectedSelectedButtonIdx) { - expectedSuggestions = expectedSuggestions.map(sugg => { - return typeof(sugg) == "object" ? sugg : { - str: sugg, - type: "remote", - }; - }); - - if (expectedSelectedIdx == -1 && expectedSelectedButtonIdx != undefined) { - expectedSelectedIdx = expectedSuggestions.length + expectedSelectedButtonIdx; - } - - let expectedState = { - selectedIndex: expectedSelectedIdx, - numSuggestions: expectedSuggestions.length, - suggestionAtIndex: expectedSuggestions.map(s => s.str), - isFormHistorySuggestionAtIndex: - expectedSuggestions.map(s => s.type == "formHistory"), - - tableHidden: expectedSuggestions.length == 0, - - inputValue: expectedInputVal, - ariaExpanded: expectedSuggestions.length == 0 ? "false" : "true", - }; - if (expectedSelectedButtonIdx != undefined) { - expectedState.selectedButtonIndex = expectedSelectedButtonIdx; - } - else if (expectedSelectedIdx < expectedSuggestions.length) { - expectedState.selectedButtonIndex = -1; - } - else { - expectedState.selectedButtonIndex = expectedSelectedIdx - expectedSuggestions.length; - } - - SimpleTest.isDeeply(actualState, expectedState, "State"); -} - -var gMsgMan; - -function* promiseTab() { - let deferred = Promise.defer(); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser); - registerCleanupFunction(() => BrowserTestUtils.removeTab(tab)); - let pageURL = getRootDirectory(gTestPath) + TEST_PAGE_BASENAME; - tab.linkedBrowser.addEventListener("load", function onLoad(event) { - tab.linkedBrowser.removeEventListener("load", onLoad, true); - gMsgMan = tab.linkedBrowser.messageManager; - gMsgMan.sendAsyncMessage("ContentSearch", { - type: "AddToWhitelist", - data: [pageURL], - }); - promiseMsg("ContentSearch", "AddToWhitelistAck", gMsgMan).then(() => { - let jsURL = getRootDirectory(gTestPath) + TEST_CONTENT_SCRIPT_BASENAME; - gMsgMan.loadFrameScript(jsURL, false); - deferred.resolve(msg("init")); - }); - }, true, true); - openUILinkIn(pageURL, "current"); - return deferred.promise; -} - -function promiseMsg(name, type, msgMan) { - let deferred = Promise.defer(); - info("Waiting for " + name + " message " + type + "..."); - msgMan.addMessageListener(name, function onMsg(msgObj) { - info("Received " + name + " message " + msgObj.data.type + "\n"); - if (msgObj.data.type == type) { - msgMan.removeMessageListener(name, onMsg); - deferred.resolve(msgObj); - } - }); - return deferred.promise; -} - -function setUpEngines() { - return Task.spawn(function* () { - info("Removing default search engines"); - let currentEngineName = Services.search.currentEngine.name; - let currentEngines = Services.search.getVisibleEngines(); - info("Adding test search engines"); - let engine1 = yield promiseNewSearchEngine(TEST_ENGINE_BASENAME); - yield promiseNewSearchEngine(TEST_ENGINE_2_BASENAME); - Services.search.currentEngine = engine1; - for (let engine of currentEngines) { - Services.search.removeEngine(engine); - } - registerCleanupFunction(() => { - Services.search.restoreDefaultEngines(); - Services.search.currentEngine = Services.search.getEngineByName(currentEngineName); - }); - }); -} diff --git a/browser/base/content/test/general/browser_contextmenu.js b/browser/base/content/test/general/browser_contextmenu.js deleted file mode 100644 index 3e0135848..000000000 --- a/browser/base/content/test/general/browser_contextmenu.js +++ /dev/null @@ -1,996 +0,0 @@ -"use strict"; - -let contextMenu; -let LOGIN_FILL_ITEMS = [ - "---", null, - "fill-login", null, - [ - "fill-login-no-logins", false, - "---", null, - "fill-login-saved-passwords", true - ], null, -]; -let hasPocket = Services.prefs.getBoolPref("extensions.pocket.enabled"); -let hasContainers = Services.prefs.getBoolPref("privacy.userContext.enabled"); - -const example_base = "http://example.com/browser/browser/base/content/test/general/"; -const chrome_base = "chrome://mochitests/content/browser/browser/base/content/test/general/"; - -Services.scriptloader.loadSubScript(chrome_base + "contextmenu_common.js", this); - -// Below are test cases for XUL element -add_task(function* test_xul_text_link_label() { - let url = chrome_base + "subtst_contextmenu_xul.xul"; - - yield BrowserTestUtils.openNewForegroundTab(gBrowser, url); - - yield test_contextmenu("#test-xul-text-link-label", - ["context-openlinkintab", true, - ...(hasContainers ? ["context-openlinkinusercontext-menu", true] : []), - // We need a blank entry here because the containers submenu is - // dynamically generated with no ids. - ...(hasContainers ? ["", null] : []), - "context-openlink", true, - "context-openlinkprivate", true, - "---", null, - "context-bookmarklink", true, - "context-savelink", true, - ...(hasPocket ? ["context-savelinktopocket", true] : []), - "context-copylink", true, - "context-searchselect", true - ] - ); - - // Clean up so won't affect HTML element test cases - lastElementSelector = null; - gBrowser.removeCurrentTab(); -}); - -// Below are test cases for HTML element - -add_task(function* test_setup_html() { - let url = example_base + "subtst_contextmenu.html"; - - yield BrowserTestUtils.openNewForegroundTab(gBrowser, url); - - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let doc = content.document; - let videoIframe = doc.querySelector("#test-video-in-iframe"); - let video = videoIframe.contentDocument.querySelector("video"); - let awaitPause = ContentTaskUtils.waitForEvent(video, "pause"); - video.pause(); - yield awaitPause; - - let audioIframe = doc.querySelector("#test-audio-in-iframe"); - // media documents always use a <video> tag. - let audio = audioIframe.contentDocument.querySelector("video"); - awaitPause = ContentTaskUtils.waitForEvent(audio, "pause"); - audio.pause(); - yield awaitPause; - }); -}); - -let plainTextItems; -add_task(function* test_plaintext() { - plainTextItems = ["context-navigation", null, - ["context-back", false, - "context-forward", false, - "context-reload", true, - "context-bookmarkpage", true], null, - "---", null, - "context-savepage", true, - ...(hasPocket ? ["context-pocket", true] : []), - "---", null, - "context-viewbgimage", false, - "context-selectall", true, - "---", null, - "context-viewsource", true, - "context-viewinfo", true - ]; - yield test_contextmenu("#test-text", plainTextItems); -}); - -add_task(function* test_link() { - yield test_contextmenu("#test-link", - ["context-openlinkintab", true, - ...(hasContainers ? ["context-openlinkinusercontext-menu", true] : []), - // We need a blank entry here because the containers submenu is - // dynamically generated with no ids. - ...(hasContainers ? ["", null] : []), - "context-openlink", true, - "context-openlinkprivate", true, - "---", null, - "context-bookmarklink", true, - "context-savelink", true, - ...(hasPocket ? ["context-savelinktopocket", true] : []), - "context-copylink", true, - "context-searchselect", true - ] - ); -}); - -add_task(function* test_mailto() { - yield test_contextmenu("#test-mailto", - ["context-copyemail", true, - "context-searchselect", true - ] - ); -}); - -add_task(function* test_image() { - yield test_contextmenu("#test-image", - ["context-viewimage", true, - "context-copyimage-contents", true, - "context-copyimage", true, - "---", null, - "context-saveimage", true, - "context-sendimage", true, - "context-setDesktopBackground", true, - "context-viewimageinfo", true - ] - ); -}); - -add_task(function* test_canvas() { - yield test_contextmenu("#test-canvas", - ["context-viewimage", true, - "context-saveimage", true, - "context-selectall", true - ] - ); -}); - -add_task(function* test_video_ok() { - yield test_contextmenu("#test-video-ok", - ["context-media-play", true, - "context-media-mute", true, - "context-media-playbackrate", null, - ["context-media-playbackrate-050x", true, - "context-media-playbackrate-100x", true, - "context-media-playbackrate-125x", true, - "context-media-playbackrate-150x", true, - "context-media-playbackrate-200x", true], null, - "context-media-loop", true, - "context-media-hidecontrols", true, - "context-video-fullscreen", true, - "---", null, - "context-viewvideo", true, - "context-copyvideourl", true, - "---", null, - "context-savevideo", true, - "context-video-saveimage", true, - "context-sendvideo", true, - "context-castvideo", null, - [], null - ] - ); -}); - -add_task(function* test_audio_in_video() { - yield test_contextmenu("#test-audio-in-video", - ["context-media-play", true, - "context-media-mute", true, - "context-media-playbackrate", null, - ["context-media-playbackrate-050x", true, - "context-media-playbackrate-100x", true, - "context-media-playbackrate-125x", true, - "context-media-playbackrate-150x", true, - "context-media-playbackrate-200x", true], null, - "context-media-loop", true, - "context-media-showcontrols", true, - "---", null, - "context-copyaudiourl", true, - "---", null, - "context-saveaudio", true, - "context-sendaudio", true - ] - ); -}); - -add_task(function* test_video_bad() { - yield test_contextmenu("#test-video-bad", - ["context-media-play", false, - "context-media-mute", false, - "context-media-playbackrate", null, - ["context-media-playbackrate-050x", false, - "context-media-playbackrate-100x", false, - "context-media-playbackrate-125x", false, - "context-media-playbackrate-150x", false, - "context-media-playbackrate-200x", false], null, - "context-media-loop", true, - "context-media-hidecontrols", false, - "context-video-fullscreen", false, - "---", null, - "context-viewvideo", true, - "context-copyvideourl", true, - "---", null, - "context-savevideo", true, - "context-video-saveimage", false, - "context-sendvideo", true, - "context-castvideo", null, - [], null - ] - ); -}); - -add_task(function* test_video_bad2() { - yield test_contextmenu("#test-video-bad2", - ["context-media-play", false, - "context-media-mute", false, - "context-media-playbackrate", null, - ["context-media-playbackrate-050x", false, - "context-media-playbackrate-100x", false, - "context-media-playbackrate-125x", false, - "context-media-playbackrate-150x", false, - "context-media-playbackrate-200x", false], null, - "context-media-loop", true, - "context-media-hidecontrols", false, - "context-video-fullscreen", false, - "---", null, - "context-viewvideo", false, - "context-copyvideourl", false, - "---", null, - "context-savevideo", false, - "context-video-saveimage", false, - "context-sendvideo", false, - "context-castvideo", null, - [], null - ] - ); -}); - -add_task(function* test_iframe() { - yield test_contextmenu("#test-iframe", - ["context-navigation", null, - ["context-back", false, - "context-forward", false, - "context-reload", true, - "context-bookmarkpage", true], null, - "---", null, - "context-savepage", true, - ...(hasPocket ? ["context-pocket", true] : []), - "---", null, - "context-viewbgimage", false, - "context-selectall", true, - "frame", null, - ["context-showonlythisframe", true, - "context-openframeintab", true, - "context-openframe", true, - "---", null, - "context-reloadframe", true, - "---", null, - "context-bookmarkframe", true, - "context-saveframe", true, - "---", null, - "context-printframe", true, - "---", null, - "context-viewframesource", true, - "context-viewframeinfo", true], null, - "---", null, - "context-viewsource", true, - "context-viewinfo", true - ] - ); -}); - -add_task(function* test_video_in_iframe() { - yield test_contextmenu("#test-video-in-iframe", - ["context-media-play", true, - "context-media-mute", true, - "context-media-playbackrate", null, - ["context-media-playbackrate-050x", true, - "context-media-playbackrate-100x", true, - "context-media-playbackrate-125x", true, - "context-media-playbackrate-150x", true, - "context-media-playbackrate-200x", true], null, - "context-media-loop", true, - "context-media-hidecontrols", true, - "context-video-fullscreen", true, - "---", null, - "context-viewvideo", true, - "context-copyvideourl", true, - "---", null, - "context-savevideo", true, - "context-video-saveimage", true, - "context-sendvideo", true, - "context-castvideo", null, - [], null, - "frame", null, - ["context-showonlythisframe", true, - "context-openframeintab", true, - "context-openframe", true, - "---", null, - "context-reloadframe", true, - "---", null, - "context-bookmarkframe", true, - "context-saveframe", true, - "---", null, - "context-printframe", true, - "---", null, - "context-viewframeinfo", true], null] - ); -}); - -add_task(function* test_audio_in_iframe() { - yield test_contextmenu("#test-audio-in-iframe", - ["context-media-play", true, - "context-media-mute", true, - "context-media-playbackrate", null, - ["context-media-playbackrate-050x", true, - "context-media-playbackrate-100x", true, - "context-media-playbackrate-125x", true, - "context-media-playbackrate-150x", true, - "context-media-playbackrate-200x", true], null, - "context-media-loop", true, - "---", null, - "context-copyaudiourl", true, - "---", null, - "context-saveaudio", true, - "context-sendaudio", true, - "frame", null, - ["context-showonlythisframe", true, - "context-openframeintab", true, - "context-openframe", true, - "---", null, - "context-reloadframe", true, - "---", null, - "context-bookmarkframe", true, - "context-saveframe", true, - "---", null, - "context-printframe", true, - "---", null, - "context-viewframeinfo", true], null] - ); -}); - -add_task(function* test_image_in_iframe() { - yield test_contextmenu("#test-image-in-iframe", - ["context-viewimage", true, - "context-copyimage-contents", true, - "context-copyimage", true, - "---", null, - "context-saveimage", true, - "context-sendimage", true, - "context-setDesktopBackground", true, - "context-viewimageinfo", true, - "frame", null, - ["context-showonlythisframe", true, - "context-openframeintab", true, - "context-openframe", true, - "---", null, - "context-reloadframe", true, - "---", null, - "context-bookmarkframe", true, - "context-saveframe", true, - "---", null, - "context-printframe", true, - "---", null, - "context-viewframeinfo", true], null] - ); -}); - -add_task(function* test_textarea() { - // Disabled since this is seeing spell-check-enabled - // instead of spell-add-dictionaries-main - todo(false, "spell checker tests are failing, bug 1246296"); - return; - - /* - yield test_contextmenu("#test-textarea", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, - "context-delete", false, - "---", null, - "context-selectall", true, - "---", null, - "spell-add-dictionaries-main", true, - ], - { - skipFocusChange: true, - } - ); - */ -}); - -add_task(function* test_textarea_spellcheck() { - todo(false, "spell checker tests are failing, bug 1246296"); - return; - - /* - yield test_contextmenu("#test-textarea", - ["*chubbiness", true, // spelling suggestion - "spell-add-to-dictionary", true, - "---", null, - "context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", true, - "---", null, - "spell-check-enabled", true, - "spell-dictionaries", true, - ["spell-check-dictionary-en-US", true, - "---", null, - "spell-add-dictionaries", true], null - ], - { - waitForSpellCheck: true, - offsetX: 6, - offsetY: 6, - postCheckContextMenuFn() { - document.getElementById("spell-add-to-dictionary").doCommand(); - } - } - ); - */ -}); - -add_task(function* test_plaintext2() { - yield test_contextmenu("#test-text", plainTextItems); -}); - -add_task(function* test_undo_add_to_dictionary() { - todo(false, "spell checker tests are failing, bug 1246296"); - return; - - /* - yield test_contextmenu("#test-textarea", - ["spell-undo-add-to-dictionary", true, - "---", null, - "context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", true, - "---", null, - "spell-check-enabled", true, - "spell-dictionaries", true, - ["spell-check-dictionary-en-US", true, - "---", null, - "spell-add-dictionaries", true], null - ], - { - waitForSpellCheck: true, - postCheckContextMenuFn() { - document.getElementById("spell-undo-add-to-dictionary") - .doCommand(); - } - } - ); - */ -}); - -add_task(function* test_contenteditable() { - todo(false, "spell checker tests are failing, bug 1246296"); - return; - - /* - yield test_contextmenu("#test-contenteditable", - ["spell-no-suggestions", false, - "spell-add-to-dictionary", true, - "---", null, - "context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", true, - "---", null, - "spell-check-enabled", true, - "spell-dictionaries", true, - ["spell-check-dictionary-en-US", true, - "---", null, - "spell-add-dictionaries", true], null - ], - {waitForSpellCheck: true} - ); - */ -}); - -add_task(function* test_copylinkcommand() { - yield test_contextmenu("#test-link", null, { - postCheckContextMenuFn: function*() { - document.commandDispatcher - .getControllerForCommand("cmd_copyLink") - .doCommand("cmd_copyLink"); - - // The easiest way to check the clipboard is to paste the contents - // into a textbox. - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let doc = content.document; - let input = doc.getElementById("test-input"); - input.focus(); - input.value = ""; - }); - document.commandDispatcher - .getControllerForCommand("cmd_paste") - .doCommand("cmd_paste"); - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let doc = content.document; - let input = doc.getElementById("test-input"); - Assert.equal(input.value, "http://mozilla.com/", "paste for command cmd_paste"); - }); - } - }); -}); - -add_task(function* test_pagemenu() { - yield test_contextmenu("#test-pagemenu", - ["context-navigation", null, - ["context-back", false, - "context-forward", false, - "context-reload", true, - "context-bookmarkpage", true], null, - "---", null, - "+Plain item", {type: "", icon: "", checked: false, disabled: false}, - "+Disabled item", {type: "", icon: "", checked: false, disabled: true}, - "+Item w/ textContent", {type: "", icon: "", checked: false, disabled: false}, - "---", null, - "+Checkbox", {type: "checkbox", icon: "", checked: true, disabled: false}, - "---", null, - "+Radio1", {type: "checkbox", icon: "", checked: true, disabled: false}, - "+Radio2", {type: "checkbox", icon: "", checked: false, disabled: false}, - "+Radio3", {type: "checkbox", icon: "", checked: false, disabled: false}, - "---", null, - "+Item w/ icon", {type: "", icon: "favicon.ico", checked: false, disabled: false}, - "+Item w/ bad icon", {type: "", icon: "", checked: false, disabled: false}, - "---", null, - "generated-submenu-1", true, - ["+Radio1", {type: "checkbox", icon: "", checked: false, disabled: false}, - "+Radio2", {type: "checkbox", icon: "", checked: true, disabled: false}, - "+Radio3", {type: "checkbox", icon: "", checked: false, disabled: false}, - "---", null, - "+Checkbox", {type: "checkbox", icon: "", checked: false, disabled: false}], null, - "---", null, - "context-savepage", true, - ...(hasPocket ? ["context-pocket", true] : []), - "---", null, - "context-viewbgimage", false, - "context-selectall", true, - "---", null, - "context-viewsource", true, - "context-viewinfo", true - ], - {postCheckContextMenuFn: function*() { - let item = contextMenu.getElementsByAttribute("generateditemid", "1")[0]; - ok(item, "Got generated XUL menu item"); - item.doCommand(); - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let pagemenu = content.document.getElementById("test-pagemenu"); - Assert.ok(!pagemenu.hasAttribute("hopeless"), "attribute got removed"); - }); - } - }); -}); - -add_task(function* test_dom_full_screen() { - yield test_contextmenu("#test-dom-full-screen", - ["context-navigation", null, - ["context-back", false, - "context-forward", false, - "context-reload", true, - "context-bookmarkpage", true], null, - "---", null, - "context-leave-dom-fullscreen", true, - "---", null, - "context-savepage", true, - ...(hasPocket ? ["context-pocket", true] : []), - "---", null, - "context-viewbgimage", false, - "context-selectall", true, - "---", null, - "context-viewsource", true, - "context-viewinfo", true - ], - { - shiftkey: true, - *preCheckContextMenuFn() { - yield pushPrefs(["full-screen-api.allow-trusted-requests-only", false], - ["full-screen-api.transition-duration.enter", "0 0"], - ["full-screen-api.transition-duration.leave", "0 0"]) - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let doc = content.document; - let win = doc.defaultView; - let full_screen_element = doc.getElementById("test-dom-full-screen"); - let awaitFullScreenChange = - ContentTaskUtils.waitForEvent(win, "fullscreenchange"); - full_screen_element.requestFullscreen(); - yield awaitFullScreenChange; - }); - }, - *postCheckContextMenuFn() { - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let win = content.document.defaultView; - let awaitFullScreenChange = - ContentTaskUtils.waitForEvent(win, "fullscreenchange"); - content.document.exitFullscreen(); - yield awaitFullScreenChange; - }); - } - } - ); -}); - -add_task(function* test_pagemenu2() { - yield test_contextmenu("#test-text", - ["context-navigation", null, - ["context-back", false, - "context-forward", false, - "context-reload", true, - "context-bookmarkpage", true], null, - "---", null, - "context-savepage", true, - ...(hasPocket ? ["context-pocket", true] : []), - "---", null, - "context-viewbgimage", false, - "context-selectall", true, - "---", null, - "context-viewsource", true, - "context-viewinfo", true - ], - {shiftkey: true} - ); -}); - -add_task(function* test_select_text() { - yield test_contextmenu("#test-select-text", - ["context-copy", true, - "context-selectall", true, - "---", null, - "context-searchselect", true, - "context-viewpartialsource-selection", true - ], - { - offsetX: 6, - offsetY: 6, - *preCheckContextMenuFn() { - yield selectText("#test-select-text"); - } - } - ); -}); - -add_task(function* test_select_text_link() { - yield test_contextmenu("#test-select-text-link", - ["context-openlinkincurrent", true, - "context-openlinkintab", true, - ...(hasContainers ? ["context-openlinkinusercontext-menu", true] : []), - // We need a blank entry here because the containers submenu is - // dynamically generated with no ids. - ...(hasContainers ? ["", null] : []), - "context-openlink", true, - "context-openlinkprivate", true, - "---", null, - "context-bookmarklink", true, - "context-savelink", true, - "context-copy", true, - "context-selectall", true, - "---", null, - "context-searchselect", true, - "context-viewpartialsource-selection", true - ], - { - offsetX: 6, - offsetY: 6, - *preCheckContextMenuFn() { - yield selectText("#test-select-text-link"); - }, - *postCheckContextMenuFn() { - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let win = content.document.defaultView; - win.getSelection().removeAllRanges(); - }); - } - } - ); -}); - -add_task(function* test_imagelink() { - yield test_contextmenu("#test-image-link", - ["context-openlinkintab", true, - ...(hasContainers ? ["context-openlinkinusercontext-menu", true] : []), - // We need a blank entry here because the containers submenu is - // dynamically generated with no ids. - ...(hasContainers ? ["", null] : []), - "context-openlink", true, - "context-openlinkprivate", true, - "---", null, - "context-bookmarklink", true, - "context-savelink", true, - ...(hasPocket ? ["context-savelinktopocket", true] : []), - "context-copylink", true, - "---", null, - "context-viewimage", true, - "context-copyimage-contents", true, - "context-copyimage", true, - "---", null, - "context-saveimage", true, - "context-sendimage", true, - "context-setDesktopBackground", true, - "context-viewimageinfo", true - ] - ); -}); - -add_task(function* test_select_input_text() { - todo(false, "spell checker tests are failing, bug 1246296"); - return; - - /* - yield test_contextmenu("#test-select-input-text", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", true, - "---", null, - "context-selectall", true, - "context-searchselect", true, - "---", null, - "spell-check-enabled", true - ].concat(LOGIN_FILL_ITEMS), - { - *preCheckContextMenuFn() { - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let doc = content.document; - let win = doc.defaultView; - win.getSelection().removeAllRanges(); - let element = doc.querySelector("#test-select-input-text"); - element.select(); - }); - } - } - ); - */ -}); - -add_task(function* test_select_input_text_password() { - todo(false, "spell checker tests are failing, bug 1246296"); - return; - - /* - yield test_contextmenu("#test-select-input-text-type-password", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", true, - "---", null, - "context-selectall", true, - "---", null, - "spell-check-enabled", true, - // spell checker is shown on input[type="password"] on this testcase - "spell-dictionaries", true, - ["spell-check-dictionary-en-US", true, - "---", null, - "spell-add-dictionaries", true], null - ].concat(LOGIN_FILL_ITEMS), - { - *preCheckContextMenuFn() { - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let doc = content.document; - let win = doc.defaultView; - win.getSelection().removeAllRanges(); - let element = doc.querySelector("#test-select-input-text-type-password"); - element.select(); - }); - }, - *postCheckContextMenuFn() { - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let win = content.document.defaultView; - win.getSelection().removeAllRanges(); - }); - } - } - ); - */ -}); - -add_task(function* test_click_to_play_blocked_plugin() { - yield test_contextmenu("#test-plugin", - ["context-navigation", null, - ["context-back", false, - "context-forward", false, - "context-reload", true, - "context-bookmarkpage", true], null, - "---", null, - "context-ctp-play", true, - "context-ctp-hide", true, - "---", null, - "context-savepage", true, - ...(hasPocket ? ["context-pocket", true] : []), - "---", null, - "context-viewbgimage", false, - "context-selectall", true, - "---", null, - "context-viewsource", true, - "context-viewinfo", true - ], - { - preCheckContextMenuFn: function*() { - pushPrefs(["plugins.click_to_play", true]); - setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); - }, - postCheckContextMenuFn: function*() { - getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED; - } - } - ); -}); - -add_task(function* test_longdesc() { - yield test_contextmenu("#test-longdesc", - ["context-viewimage", true, - "context-copyimage-contents", true, - "context-copyimage", true, - "---", null, - "context-saveimage", true, - "context-sendimage", true, - "context-setDesktopBackground", true, - "context-viewimageinfo", true, - "context-viewimagedesc", true - ] - ); -}); - -add_task(function* test_srcdoc() { - yield test_contextmenu("#test-srcdoc", - ["context-navigation", null, - ["context-back", false, - "context-forward", false, - "context-reload", true, - "context-bookmarkpage", true], null, - "---", null, - "context-savepage", true, - ...(hasPocket ? ["context-pocket", true] : []), - "---", null, - "context-viewbgimage", false, - "context-selectall", true, - "frame", null, - ["context-reloadframe", true, - "---", null, - "context-saveframe", true, - "---", null, - "context-printframe", true, - "---", null, - "context-viewframesource", true, - "context-viewframeinfo", true], null, - "---", null, - "context-viewsource", true, - "context-viewinfo", true - ] - ); -}); - -add_task(function* test_input_spell_false() { - todo(false, "spell checker tests are failing, bug 1246296"); - return; - - /* - yield test_contextmenu("#test-contenteditable-spellcheck-false", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", true, - ] - ); - */ -}); - -const remoteClientsFixture = [ { id: 1, name: "Foo"}, { id: 2, name: "Bar"} ]; - -add_task(function* test_plaintext_sendpagetodevice() { - if (!gFxAccounts.sendTabToDeviceEnabled) { - return; - } - const oldGetter = setupRemoteClientsFixture(remoteClientsFixture); - - let plainTextItemsWithSendPage = - ["context-navigation", null, - ["context-back", false, - "context-forward", false, - "context-reload", true, - "context-bookmarkpage", true], null, - "---", null, - "context-savepage", true, - ...(hasPocket ? ["context-pocket", true] : []), - "---", null, - "context-sendpagetodevice", true, - ["*Foo", true, - "*Bar", true, - "---", null, - "*All Devices", true], null, - "---", null, - "context-viewbgimage", false, - "context-selectall", true, - "---", null, - "context-viewsource", true, - "context-viewinfo", true - ]; - yield test_contextmenu("#test-text", plainTextItemsWithSendPage, { - *onContextMenuShown() { - yield openMenuItemSubmenu("context-sendpagetodevice"); - } - }); - - restoreRemoteClients(oldGetter); -}); - -add_task(function* test_link_sendlinktodevice() { - if (!gFxAccounts.sendTabToDeviceEnabled) { - return; - } - const oldGetter = setupRemoteClientsFixture(remoteClientsFixture); - - yield test_contextmenu("#test-link", - ["context-openlinkintab", true, - ...(hasContainers ? ["context-openlinkinusercontext-menu", true] : []), - // We need a blank entry here because the containers submenu is - // dynamically generated with no ids. - ...(hasContainers ? ["", null] : []), - "context-openlink", true, - "context-openlinkprivate", true, - "---", null, - "context-bookmarklink", true, - "context-savelink", true, - ...(hasPocket ? ["context-savelinktopocket", true] : []), - "context-copylink", true, - "context-searchselect", true, - "---", null, - "context-sendlinktodevice", true, - ["*Foo", true, - "*Bar", true, - "---", null, - "*All Devices", true], null, - ], - { - *onContextMenuShown() { - yield openMenuItemSubmenu("context-sendlinktodevice"); - } - }); - - restoreRemoteClients(oldGetter); -}); - -add_task(function* test_cleanup_html() { - gBrowser.removeCurrentTab(); -}); - -/** - * Selects the text of the element that matches the provided `selector` - * - * @param {String} selector - * A selector passed to querySelector to find - * the element that will be referenced. - */ -function* selectText(selector) { - yield ContentTask.spawn(gBrowser.selectedBrowser, selector, function*(contentSelector) { - info(`Selecting text of ${contentSelector}`); - let doc = content.document; - let win = doc.defaultView; - win.getSelection().removeAllRanges(); - let div = doc.createRange(); - let element = doc.querySelector(contentSelector); - Assert.ok(element, "Found element to select text from"); - div.setStartBefore(element); - div.setEndAfter(element); - win.getSelection().addRange(div); - }); -} diff --git a/browser/base/content/test/general/browser_contextmenu_childprocess.js b/browser/base/content/test/general/browser_contextmenu_childprocess.js deleted file mode 100644 index 3d52be9ab..000000000 --- a/browser/base/content/test/general/browser_contextmenu_childprocess.js +++ /dev/null @@ -1,84 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -const gBaseURL = "https://example.com/browser/browser/base/content/test/general/"; - -add_task(function *() { - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gBaseURL + "subtst_contextmenu.html"); - - let contextMenu = document.getElementById("contentAreaContextMenu"); - - // Get the point of the element with the page menu (test-pagemenu) and - // synthesize a right mouse click there. - let popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown"); - yield BrowserTestUtils.synthesizeMouse("#test-pagemenu", 5, 5, { type : "contextmenu", button : 2 }, tab.linkedBrowser); - yield popupShownPromise; - - checkMenu(contextMenu); - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden"); - contextMenu.hidePopup(); - yield popupHiddenPromise; - - yield BrowserTestUtils.removeTab(tab); -}); - -function checkItems(menuitem, arr) -{ - for (let i = 0; i < arr.length; i += 2) { - let str = arr[i]; - let details = arr[i + 1]; - if (str == "---") { - is(menuitem.localName, "menuseparator", "menuseparator"); - } - else if ("children" in details) { - is(menuitem.localName, "menu", "submenu"); - is(menuitem.getAttribute("label"), str, str + " label"); - checkItems(menuitem.firstChild.firstChild, details.children); - } - else { - is(menuitem.localName, "menuitem", str + " menuitem"); - - is(menuitem.getAttribute("label"), str, str + " label"); - is(menuitem.getAttribute("type"), details.type, str + " type"); - is(menuitem.getAttribute("image"), details.icon ? gBaseURL + details.icon : "", str + " icon"); - - if (details.checked) - is(menuitem.getAttribute("checked"), "true", str + " checked"); - else - ok(!menuitem.hasAttribute("checked"), str + " checked"); - - if (details.disabled) - is(menuitem.getAttribute("disabled"), "true", str + " disabled"); - else - ok(!menuitem.hasAttribute("disabled"), str + " disabled"); - } - - menuitem = menuitem.nextSibling; - } -} - -function checkMenu(contextMenu) -{ - let items = [ "Plain item", {type: "", icon: "", checked: false, disabled: false}, - "Disabled item", {type: "", icon: "", checked: false, disabled: true}, - "Item w/ textContent", {type: "", icon: "", checked: false, disabled: false}, - "---", null, - "Checkbox", {type: "checkbox", icon: "", checked: true, disabled: false}, - "---", null, - "Radio1", {type: "checkbox", icon: "", checked: true, disabled: false}, - "Radio2", {type: "checkbox", icon: "", checked: false, disabled: false}, - "Radio3", {type: "checkbox", icon: "", checked: false, disabled: false}, - "---", null, - "Item w/ icon", {type: "", icon: "favicon.ico", checked: false, disabled: false}, - "Item w/ bad icon", {type: "", icon: "", checked: false, disabled: false}, - "---", null, - "Submenu", { children: - ["Radio1", {type: "checkbox", icon: "", checked: false, disabled: false}, - "Radio2", {type: "checkbox", icon: "", checked: true, disabled: false}, - "Radio3", {type: "checkbox", icon: "", checked: false, disabled: false}, - "---", null, - "Checkbox", {type: "checkbox", icon: "", checked: false, disabled: false}] } - ]; - checkItems(contextMenu.childNodes[2], items); -} diff --git a/browser/base/content/test/general/browser_contextmenu_input.js b/browser/base/content/test/general/browser_contextmenu_input.js deleted file mode 100644 index cfc7b7529..000000000 --- a/browser/base/content/test/general/browser_contextmenu_input.js +++ /dev/null @@ -1,243 +0,0 @@ -"use strict"; - -let contextMenu; -let hasPocket = Services.prefs.getBoolPref("extensions.pocket.enabled"); - -add_task(function* test_setup() { - const example_base = "http://example.com/browser/browser/base/content/test/general/"; - const url = example_base + "subtst_contextmenu_input.html"; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, url); - - const chrome_base = "chrome://mochitests/content/browser/browser/base/content/test/general/"; - const contextmenu_common = chrome_base + "contextmenu_common.js"; - Services.scriptloader.loadSubScript(contextmenu_common, this); -}); - -add_task(function* test_text_input() { - yield test_contextmenu("#input_text", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", false, - "---", null, - "spell-check-enabled", true]); -}); - -add_task(function* test_text_input_spellcheck() { - yield test_contextmenu("#input_spellcheck_no_value", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", false, - "---", null, - "spell-check-enabled", true, - "spell-dictionaries", true, - ["spell-check-dictionary-en-US", true, - "---", null, - "spell-add-dictionaries", true], null], - { - waitForSpellCheck: true, - // Need to dynamically add/remove the "password" type or LoginManager - // will think that the form inputs on the page are part of a login - // and will add fill-login context menu items. - *preCheckContextMenuFn() { - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let doc = content.document; - let input = doc.getElementById("input_spellcheck_no_value"); - input.setAttribute("spellcheck", "true"); - input.clientTop; // force layout flush - }); - }, - } - ); -}); - -add_task(function* test_text_input_spellcheckwrong() { - yield test_contextmenu("#input_spellcheck_incorrect", - ["*prodigality", true, // spelling suggestion - "spell-add-to-dictionary", true, - "---", null, - "context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", true, - "---", null, - "spell-check-enabled", true, - "spell-dictionaries", true, - ["spell-check-dictionary-en-US", true, - "---", null, - "spell-add-dictionaries", true], null], - {waitForSpellCheck: true} - ); -}); - -add_task(function* test_text_input_spellcheckcorrect() { - yield test_contextmenu("#input_spellcheck_correct", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", true, - "---", null, - "spell-check-enabled", true, - "spell-dictionaries", true, - ["spell-check-dictionary-en-US", true, - "---", null, - "spell-add-dictionaries", true], null], - {waitForSpellCheck: true} - ); -}); - -add_task(function* test_text_input_disabled() { - yield test_contextmenu("#input_disabled", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", true, - "---", null, - "spell-check-enabled", true], - {skipFocusChange: true} - ); -}); - -add_task(function* test_password_input() { - todo(false, "context-selectall is enabled on osx-e10s, and windows when" + - " it should be disabled"); - yield test_contextmenu("#input_password", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", null, - "---", null, - "fill-login", null, - ["fill-login-no-logins", false, - "---", null, - "fill-login-saved-passwords", true], null], - { - skipFocusChange: true, - // Need to dynamically add/remove the "password" type or LoginManager - // will think that the form inputs on the page are part of a login - // and will add fill-login context menu items. - *preCheckContextMenuFn() { - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let doc = content.document; - let input = doc.getElementById("input_password"); - input.type = "password"; - input.clientTop; // force layout flush - }); - }, - *postCheckContextMenuFn() { - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - let doc = content.document; - let input = doc.getElementById("input_password"); - input.type = "text"; - input.clientTop; // force layout flush - }); - }, - } - ); -}); - -add_task(function* test_tel_email_url_number_input() { - todo(false, "context-selectall is enabled on osx-e10s, and windows when" + - " it should be disabled"); - for (let selector of ["#input_email", "#input_url", "#input_tel", "#input_number"]) { - yield test_contextmenu(selector, - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", null], - {skipFocusChange: true} - ); - } -}); - -add_task(function* test_date_time_color_range_month_week_datetimelocal_input() { - for (let selector of ["#input_date", "#input_time", "#input_color", - "#input_range", "#input_month", "#input_week", - "#input_datetime-local"]) { - yield test_contextmenu(selector, - ["context-navigation", null, - ["context-back", false, - "context-forward", false, - "context-reload", true, - "context-bookmarkpage", true], null, - "---", null, - "context-savepage", true, - ...(hasPocket ? ["context-pocket", true] : []), - "---", null, - "context-viewbgimage", false, - "context-selectall", null, - "---", null, - "context-viewsource", true, - "context-viewinfo", true], - {skipFocusChange: true} - ); - } -}); - -add_task(function* test_search_input() { - todo(false, "context-selectall is enabled on osx-e10s, and windows when" + - " it should be disabled"); - yield test_contextmenu("#input_search", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", null, - "---", null, - "spell-check-enabled", true], - {skipFocusChange: true} - ); -}); - -add_task(function* test_text_input_readonly() { - todo(false, "context-selectall is enabled on osx-e10s, and windows when" + - " it should be disabled"); - todo(false, "spell-check should not be enabled for input[readonly]. see bug 1246296"); - yield test_contextmenu("#input_readonly", - ["context-undo", false, - "---", null, - "context-cut", true, - "context-copy", true, - "context-paste", null, // ignore clipboard state - "context-delete", false, - "---", null, - "context-selectall", null], - {skipFocusChange: true} - ); -}); - -add_task(function* test_cleanup() { - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); diff --git a/browser/base/content/test/general/browser_csp_block_all_mixedcontent.js b/browser/base/content/test/general/browser_csp_block_all_mixedcontent.js deleted file mode 100644 index 00a06f53e..000000000 --- a/browser/base/content/test/general/browser_csp_block_all_mixedcontent.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Description of the Test: - * We load an https page which uses a CSP including block-all-mixed-content. - * The page tries to load a script over http. We make sure the UI is not - * influenced when blocking the mixed content. In particular the page - * should still appear fully encrypted with a green lock. - */ - -const PRE_PATH = "https://example.com/browser/browser/base/content/test/general/"; -var gTestBrowser = null; - -// ------------------------------------------------------ -function cleanUpAfterTests() { - gBrowser.removeCurrentTab(); - window.focus(); - finish(); -} - -// ------------------------------------------------------ -function verifyUInotDegraded() { - // make sure that not mixed content is loaded and also not blocked - assertMixedContentBlockingState( - gTestBrowser, - { activeLoaded: false, - activeBlocked: false, - passiveLoaded: false - } - ); - // clean up and finish test - cleanUpAfterTests(); -} - -// ------------------------------------------------------ -function runTests() { - var newTab = gBrowser.addTab(); - gBrowser.selectedTab = newTab; - gTestBrowser = gBrowser.selectedBrowser; - newTab.linkedBrowser.stop(); - - // Starting the test - BrowserTestUtils.browserLoaded(gTestBrowser).then(verifyUInotDegraded); - var url = PRE_PATH + "file_csp_block_all_mixedcontent.html"; - gTestBrowser.loadURI(url); -} - -// ------------------------------------------------------ -function test() { - // Performing async calls, e.g. 'onload', we have to wait till all of them finished - waitForExplicitFinish(); - - SpecialPowers.pushPrefEnv( - { 'set': [["security.mixed_content.block_active_content", true]] }, - function() { runTests(); } - ); -} diff --git a/browser/base/content/test/general/browser_ctrlTab.js b/browser/base/content/test/general/browser_ctrlTab.js deleted file mode 100644 index d16aaeca4..000000000 --- a/browser/base/content/test/general/browser_ctrlTab.js +++ /dev/null @@ -1,185 +0,0 @@ -add_task(function* () { - gPrefService.setBoolPref("browser.ctrlTab.previews", true); - - gBrowser.addTab(); - gBrowser.addTab(); - gBrowser.addTab(); - - checkTabs(4); - - yield ctrlTabTest([2], 1, 0); - yield ctrlTabTest([2, 3, 1], 2, 2); - yield ctrlTabTest([], 4, 2); - - { - let selectedIndex = gBrowser.tabContainer.selectedIndex; - yield pressCtrlTab(); - yield pressCtrlTab(true); - yield releaseCtrl(); - is(gBrowser.tabContainer.selectedIndex, selectedIndex, - "Ctrl+Tab -> Ctrl+Shift+Tab keeps the selected tab"); - } - - { // test for bug 445369 - let tabs = gBrowser.tabs.length; - yield pressCtrlTab(); - yield synthesizeCtrlW(); - is(gBrowser.tabs.length, tabs - 1, "Ctrl+Tab -> Ctrl+W removes one tab"); - yield releaseCtrl(); - } - - { // test for bug 667314 - let tabs = gBrowser.tabs.length; - yield pressCtrlTab(); - yield pressCtrlTab(true); - yield synthesizeCtrlW(); - is(gBrowser.tabs.length, tabs - 1, "Ctrl+Tab -> Ctrl+W removes the selected tab"); - yield releaseCtrl(); - } - - gBrowser.addTab(); - checkTabs(3); - yield ctrlTabTest([2, 1, 0], 7, 1); - - { // test for bug 1292049 - let tabToClose = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:buildconfig"); - checkTabs(4); - selectTabs([0, 1, 2, 3]); - - yield BrowserTestUtils.removeTab(tabToClose); - checkTabs(3); - undoCloseTab(); - checkTabs(4); - is(gBrowser.tabContainer.selectedIndex, 3, "tab is selected after closing and restoring it"); - - yield ctrlTabTest([], 1, 2); - } - - { // test for bug 445369 - checkTabs(4); - selectTabs([1, 2, 0]); - - let selectedTab = gBrowser.selectedTab; - let tabToRemove = gBrowser.tabs[1]; - - yield pressCtrlTab(); - yield pressCtrlTab(); - yield synthesizeCtrlW(); - ok(!tabToRemove.parentNode, - "Ctrl+Tab*2 -> Ctrl+W removes the second most recently selected tab"); - - yield pressCtrlTab(true); - yield pressCtrlTab(true); - yield releaseCtrl(); - ok(selectedTab.selected, - "Ctrl+Tab*2 -> Ctrl+W -> Ctrl+Shift+Tab*2 keeps the selected tab"); - } - gBrowser.removeTab(gBrowser.tabContainer.lastChild); - checkTabs(2); - - yield ctrlTabTest([1], 1, 0); - - gBrowser.removeTab(gBrowser.tabContainer.lastChild); - checkTabs(1); - - { // test for bug 445768 - let focusedWindow = document.commandDispatcher.focusedWindow; - let eventConsumed = true; - let detectKeyEvent = function (event) { - eventConsumed = event.defaultPrevented; - }; - document.addEventListener("keypress", detectKeyEvent, false); - yield pressCtrlTab(); - document.removeEventListener("keypress", detectKeyEvent, false); - ok(eventConsumed, "Ctrl+Tab consumed by the tabbed browser if one tab is open"); - is(focusedWindow, document.commandDispatcher.focusedWindow, - "Ctrl+Tab doesn't change focus if one tab is open"); - } - - // cleanup - if (gPrefService.prefHasUserValue("browser.ctrlTab.previews")) - gPrefService.clearUserPref("browser.ctrlTab.previews"); - - /* private utility functions */ - - function* pressCtrlTab(aShiftKey) { - let promise; - if (!isOpen() && canOpen()) { - promise = BrowserTestUtils.waitForEvent(ctrlTab.panel, "popupshown"); - } else { - promise = BrowserTestUtils.waitForEvent(document, "keyup"); - } - EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: !!aShiftKey }); - return promise; - } - - function* releaseCtrl() { - let promise; - if (isOpen()) { - promise = BrowserTestUtils.waitForEvent(ctrlTab.panel, "popuphidden"); - } else { - promise = BrowserTestUtils.waitForEvent(document, "keyup"); - } - EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" }); - return promise; - } - - function* synthesizeCtrlW() { - let promise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabClose"); - EventUtils.synthesizeKey("w", { ctrlKey: true }); - return promise; - } - - function isOpen() { - return ctrlTab.isOpen; - } - - function canOpen() { - return gPrefService.getBoolPref("browser.ctrlTab.previews") && gBrowser.tabs.length > 2; - } - - function checkTabs(aTabs) { - is(gBrowser.tabs.length, aTabs, "number of open tabs should be " + aTabs); - } - - function selectTabs(tabs) { - tabs.forEach(function (index) { - gBrowser.selectedTab = gBrowser.tabs[index]; - }); - } - - function* ctrlTabTest(tabsToSelect, tabTimes, expectedIndex) { - selectTabs(tabsToSelect); - - var indexStart = gBrowser.tabContainer.selectedIndex; - var tabCount = gBrowser.tabs.length; - var normalized = tabTimes % tabCount; - var where = normalized == 1 ? "back to the previously selected tab" : - normalized + " tabs back in most-recently-selected order"; - - for (let i = 0; i < tabTimes; i++) { - yield pressCtrlTab(); - - if (tabCount > 2) - is(gBrowser.tabContainer.selectedIndex, indexStart, - "Selected tab doesn't change while tabbing"); - } - - if (tabCount > 2) { - ok(isOpen(), - "With " + tabCount + " tabs open, Ctrl+Tab opens the preview panel"); - - yield releaseCtrl(); - - ok(!isOpen(), - "Releasing Ctrl closes the preview panel"); - } else { - ok(!isOpen(), - "With " + tabCount + " tabs open, Ctrl+Tab doesn't open the preview panel"); - } - - is(gBrowser.tabContainer.selectedIndex, expectedIndex, - "With "+ tabCount +" tabs open and tab " + indexStart - + " selected, Ctrl+Tab*" + tabTimes + " goes " + where); - } -}); diff --git a/browser/base/content/test/general/browser_datachoices_notification.js b/browser/base/content/test/general/browser_datachoices_notification.js deleted file mode 100644 index 360728b4c..000000000 --- a/browser/base/content/test/general/browser_datachoices_notification.js +++ /dev/null @@ -1,221 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -"use strict"; - -// Pass an empty scope object to the import to prevent "leaked window property" -// errors in tests. -var Preferences = Cu.import("resource://gre/modules/Preferences.jsm", {}).Preferences; -var TelemetryReportingPolicy = - Cu.import("resource://gre/modules/TelemetryReportingPolicy.jsm", {}).TelemetryReportingPolicy; - -const PREF_BRANCH = "datareporting.policy."; -const PREF_BYPASS_NOTIFICATION = PREF_BRANCH + "dataSubmissionPolicyBypassNotification"; -const PREF_CURRENT_POLICY_VERSION = PREF_BRANCH + "currentPolicyVersion"; -const PREF_ACCEPTED_POLICY_VERSION = PREF_BRANCH + "dataSubmissionPolicyAcceptedVersion"; -const PREF_ACCEPTED_POLICY_DATE = PREF_BRANCH + "dataSubmissionPolicyNotifiedTime"; - -const TEST_POLICY_VERSION = 37; - -function fakeShowPolicyTimeout(set, clear) { - let reportingPolicy = - Cu.import("resource://gre/modules/TelemetryReportingPolicy.jsm", {}).Policy; - reportingPolicy.setShowInfobarTimeout = set; - reportingPolicy.clearShowInfobarTimeout = clear; -} - -function sendSessionRestoredNotification() { - let reportingPolicyImpl = - Cu.import("resource://gre/modules/TelemetryReportingPolicy.jsm", {}).TelemetryReportingPolicyImpl; - reportingPolicyImpl.observe(null, "sessionstore-windows-restored", null); -} - -/** - * Wait for a tick. - */ -function promiseNextTick() { - return new Promise(resolve => executeSoon(resolve)); -} - -/** - * Wait for a notification to be shown in a notification box. - * @param {Object} aNotificationBox The notification box. - * @return {Promise} Resolved when the notification is displayed. - */ -function promiseWaitForAlertActive(aNotificationBox) { - let deferred = PromiseUtils.defer(); - aNotificationBox.addEventListener("AlertActive", function onActive() { - aNotificationBox.removeEventListener("AlertActive", onActive, true); - deferred.resolve(); - }); - return deferred.promise; -} - -/** - * Wait for a notification to be closed. - * @param {Object} aNotification The notification. - * @return {Promise} Resolved when the notification is closed. - */ -function promiseWaitForNotificationClose(aNotification) { - let deferred = PromiseUtils.defer(); - waitForNotificationClose(aNotification, deferred.resolve); - return deferred.promise; -} - -function triggerInfoBar(expectedTimeoutMs) { - let showInfobarCallback = null; - let timeoutMs = null; - fakeShowPolicyTimeout((callback, timeout) => { - showInfobarCallback = callback; - timeoutMs = timeout; - }, () => {}); - sendSessionRestoredNotification(); - Assert.ok(!!showInfobarCallback, "Must have a timer callback."); - if (expectedTimeoutMs !== undefined) { - Assert.equal(timeoutMs, expectedTimeoutMs, "Timeout should match"); - } - showInfobarCallback(); -} - -var checkInfobarButton = Task.async(function* (aNotification) { - // Check that the button on the data choices infobar does the right thing. - let buttons = aNotification.getElementsByTagName("button"); - Assert.equal(buttons.length, 1, "There is 1 button in the data reporting notification."); - let button = buttons[0]; - - // Add an observer to ensure the "advanced" pane opened (but don't bother - // closing it - we close the entire window when done.) - let paneLoadedPromise = promiseTopicObserved("advanced-pane-loaded"); - - // Click on the button. - button.click(); - - // Wait for the preferences panel to open. - yield paneLoadedPromise; - yield promiseNextTick(); -}); - -add_task(function* setup() { - const bypassNotification = Preferences.get(PREF_BYPASS_NOTIFICATION, true); - const currentPolicyVersion = Preferences.get(PREF_CURRENT_POLICY_VERSION, 1); - - // Register a cleanup function to reset our preferences. - registerCleanupFunction(() => { - Preferences.set(PREF_BYPASS_NOTIFICATION, bypassNotification); - Preferences.set(PREF_CURRENT_POLICY_VERSION, currentPolicyVersion); - - return closeAllNotifications(); - }); - - // Don't skip the infobar visualisation. - Preferences.set(PREF_BYPASS_NOTIFICATION, false); - // Set the current policy version. - Preferences.set(PREF_CURRENT_POLICY_VERSION, TEST_POLICY_VERSION); -}); - -function clearAcceptedPolicy() { - // Reset the accepted policy. - Preferences.reset(PREF_ACCEPTED_POLICY_VERSION); - Preferences.reset(PREF_ACCEPTED_POLICY_DATE); -} - -add_task(function* test_single_window() { - clearAcceptedPolicy(); - - // Close all the notifications, then try to trigger the data choices infobar. - yield closeAllNotifications(); - - let notificationBox = document.getElementById("global-notificationbox"); - - // Make sure that we have a coherent initial state. - Assert.equal(Preferences.get(PREF_ACCEPTED_POLICY_VERSION, 0), 0, - "No version should be set on init."); - Assert.equal(Preferences.get(PREF_ACCEPTED_POLICY_DATE, 0), 0, - "No date should be set on init."); - Assert.ok(!TelemetryReportingPolicy.testIsUserNotified(), - "User not notified about datareporting policy."); - - let alertShownPromise = promiseWaitForAlertActive(notificationBox); - Assert.ok(!TelemetryReportingPolicy.canUpload(), - "User should not be allowed to upload."); - - // Wait for the infobar to be displayed. - triggerInfoBar(10 * 1000); - yield alertShownPromise; - - Assert.equal(notificationBox.allNotifications.length, 1, "Notification Displayed."); - Assert.ok(TelemetryReportingPolicy.canUpload(), "User should be allowed to upload now."); - - yield promiseNextTick(); - let promiseClosed = promiseWaitForNotificationClose(notificationBox.currentNotification); - yield checkInfobarButton(notificationBox.currentNotification); - yield promiseClosed; - - Assert.equal(notificationBox.allNotifications.length, 0, "No notifications remain."); - - // Check that we are still clear to upload and that the policy data is saved. - Assert.ok(TelemetryReportingPolicy.canUpload()); - Assert.equal(TelemetryReportingPolicy.testIsUserNotified(), true, - "User notified about datareporting policy."); - Assert.equal(Preferences.get(PREF_ACCEPTED_POLICY_VERSION, 0), TEST_POLICY_VERSION, - "Version pref set."); - Assert.greater(parseInt(Preferences.get(PREF_ACCEPTED_POLICY_DATE, null), 10), -1, - "Date pref set."); -}); - -add_task(function* test_multiple_windows() { - clearAcceptedPolicy(); - - // Close all the notifications, then try to trigger the data choices infobar. - yield closeAllNotifications(); - - // Ensure we see the notification on all windows and that action on one window - // results in dismiss on every window. - let otherWindow = yield BrowserTestUtils.openNewBrowserWindow(); - - // Get the notification box for both windows. - let notificationBoxes = [ - document.getElementById("global-notificationbox"), - otherWindow.document.getElementById("global-notificationbox") - ]; - - Assert.ok(notificationBoxes[1], "2nd window has a global notification box."); - - // Make sure that we have a coherent initial state. - Assert.equal(Preferences.get(PREF_ACCEPTED_POLICY_VERSION, 0), 0, "No version should be set on init."); - Assert.equal(Preferences.get(PREF_ACCEPTED_POLICY_DATE, 0), 0, "No date should be set on init."); - Assert.ok(!TelemetryReportingPolicy.testIsUserNotified(), "User not notified about datareporting policy."); - - let showAlertPromises = [ - promiseWaitForAlertActive(notificationBoxes[0]), - promiseWaitForAlertActive(notificationBoxes[1]) - ]; - - Assert.ok(!TelemetryReportingPolicy.canUpload(), - "User should not be allowed to upload."); - - // Wait for the infobars. - triggerInfoBar(10 * 1000); - yield Promise.all(showAlertPromises); - - // Both notification were displayed. Close one and check that both gets closed. - let closeAlertPromises = [ - promiseWaitForNotificationClose(notificationBoxes[0].currentNotification), - promiseWaitForNotificationClose(notificationBoxes[1].currentNotification) - ]; - notificationBoxes[0].currentNotification.close(); - yield Promise.all(closeAlertPromises); - - // Close the second window we opened. - yield BrowserTestUtils.closeWindow(otherWindow); - - // Check that we are clear to upload and that the policy data us saved. - Assert.ok(TelemetryReportingPolicy.canUpload(), "User should be allowed to upload now."); - Assert.equal(TelemetryReportingPolicy.testIsUserNotified(), true, - "User notified about datareporting policy."); - Assert.equal(Preferences.get(PREF_ACCEPTED_POLICY_VERSION, 0), TEST_POLICY_VERSION, - "Version pref set."); - Assert.greater(parseInt(Preferences.get(PREF_ACCEPTED_POLICY_DATE, null), 10), -1, - "Date pref set."); -}); diff --git a/browser/base/content/test/general/browser_decoderDoctor.js b/browser/base/content/test/general/browser_decoderDoctor.js deleted file mode 100644 index a37972160..000000000 --- a/browser/base/content/test/general/browser_decoderDoctor.js +++ /dev/null @@ -1,122 +0,0 @@ -"use strict"; - -function* test_decoder_doctor_notification(type, notificationMessage, options) { - yield BrowserTestUtils.withNewTab({ gBrowser }, function*(browser) { - let awaitNotificationBar = - BrowserTestUtils.waitForNotificationBar(gBrowser, browser, "decoder-doctor-notification"); - - yield ContentTask.spawn(browser, type, function*(aType) { - Services.obs.notifyObservers(content.window, - "decoder-doctor-notification", - JSON.stringify({type: aType, - isSolved: false, - decoderDoctorReportId: "test", - formats: "test"})); - }); - - let notification; - try { - notification = yield awaitNotificationBar; - } catch (ex) { - ok(false, ex); - return; - } - ok(notification, "Got decoder-doctor-notification notification"); - - is(notification.getAttribute("label"), notificationMessage, - "notification message should match expectation"); - let button = notification.childNodes[0]; - if (options && options.noLearnMoreButton) { - ok(!button, "There should not be a Learn More button"); - return; - } - - is(button.getAttribute("label"), gNavigatorBundle.getString("decoder.noCodecs.button"), - "notification button should be 'Learn more'"); - is(button.getAttribute("accesskey"), gNavigatorBundle.getString("decoder.noCodecs.accesskey"), - "notification button should have accesskey"); - - let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL"); - let url = baseURL + ((options && options.sumo) || - "fix-video-audio-problems-firefox-windows"); - let awaitNewTab = BrowserTestUtils.waitForNewTab(gBrowser, url); - button.click(); - let sumoTab = yield awaitNewTab; - yield BrowserTestUtils.removeTab(sumoTab); - }); -} - -add_task(function* test_adobe_cdm_not_found() { - // This is only sent on Windows. - if (AppConstants.platform != "win") { - return; - } - - let message; - if (AppConstants.isPlatformAndVersionAtMost("win", "5.9")) { - message = gNavigatorBundle.getFormattedString("emeNotifications.drmContentDisabled.message", [""]); - } else { - message = gNavigatorBundle.getString("decoder.noCodecs.message"); - } - - yield test_decoder_doctor_notification("adobe-cdm-not-found", message); -}); - -add_task(function* test_adobe_cdm_not_activated() { - // This is only sent on Windows. - if (AppConstants.platform != "win") { - return; - } - - let message; - if (AppConstants.isPlatformAndVersionAtMost("win", "5.9")) { - message = gNavigatorBundle.getString("decoder.noCodecsXP.message"); - } else { - message = gNavigatorBundle.getString("decoder.noCodecs.message"); - } - - yield test_decoder_doctor_notification("adobe-cdm-not-activated", message); -}); - -add_task(function* test_platform_decoder_not_found() { - // Not sent on Windows XP. - if (AppConstants.isPlatformAndVersionAtMost("win", "5.9")) { - return; - } - - let message; - let isLinux = AppConstants.platform == "linux"; - if (isLinux) { - message = gNavigatorBundle.getString("decoder.noCodecsLinux.message"); - } else { - message = gNavigatorBundle.getString("decoder.noHWAcceleration.message"); - } - - yield test_decoder_doctor_notification("platform-decoder-not-found", - message, - {noLearnMoreButton: isLinux}); -}); - -add_task(function* test_cannot_initialize_pulseaudio() { - // This is only sent on Linux. - if (AppConstants.platform != "linux") { - return; - } - - let message = gNavigatorBundle.getString("decoder.noPulseAudio.message"); - yield test_decoder_doctor_notification("cannot-initialize-pulseaudio", - message, - {sumo: "fix-common-audio-and-video-issues"}); -}); - -add_task(function* test_unsupported_libavcodec() { - // This is only sent on Linux. - if (AppConstants.platform != "linux") { - return; - } - - let message = gNavigatorBundle.getString("decoder.unsupportedLibavcodec.message"); - yield test_decoder_doctor_notification("unsupported-libavcodec", - message, - {noLearnMoreButton: true}); -}); diff --git a/browser/base/content/test/general/browser_devedition.js b/browser/base/content/test/general/browser_devedition.js deleted file mode 100644 index 06ee42e7e..000000000 --- a/browser/base/content/test/general/browser_devedition.js +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Testing changes for Developer Edition theme. - * A special stylesheet should be added to the browser.xul document - * when the firefox-devedition@mozilla.org lightweight theme - * is applied. - */ - -const PREF_LWTHEME_USED_THEMES = "lightweightThemes.usedThemes"; -const PREF_DEVTOOLS_THEME = "devtools.theme"; -const {LightweightThemeManager} = Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", {}); - -LightweightThemeManager.clearBuiltInThemes(); -LightweightThemeManager.addBuiltInTheme(dummyLightweightTheme("firefox-devedition@mozilla.org")); - -registerCleanupFunction(() => { - // Set preferences back to their original values - LightweightThemeManager.currentTheme = null; - Services.prefs.clearUserPref(PREF_DEVTOOLS_THEME); - Services.prefs.clearUserPref(PREF_LWTHEME_USED_THEMES); - - LightweightThemeManager.currentTheme = null; - LightweightThemeManager.clearBuiltInThemes(); -}); - -add_task(function* startTests() { - Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark"); - - info ("Setting the current theme to null"); - LightweightThemeManager.currentTheme = null; - ok (!DevEdition.isStyleSheetEnabled, "There is no devedition style sheet when no lw theme is applied."); - - info ("Adding a lightweight theme."); - LightweightThemeManager.currentTheme = dummyLightweightTheme("preview0"); - ok (!DevEdition.isStyleSheetEnabled, "The devedition stylesheet has been removed when a lightweight theme is applied."); - - info ("Applying the devedition lightweight theme."); - let onAttributeAdded = waitForBrightTitlebarAttribute(); - LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org"); - ok (DevEdition.isStyleSheetEnabled, "The devedition stylesheet has been added when the devedition lightweight theme is applied"); - yield onAttributeAdded; - is (document.documentElement.getAttribute("brighttitlebarforeground"), "true", - "The brighttitlebarforeground attribute is set on the window."); - - info ("Unapplying all themes."); - LightweightThemeManager.currentTheme = null; - ok (!DevEdition.isStyleSheetEnabled, "There is no devedition style sheet when no lw theme is applied."); - - info ("Applying the devedition lightweight theme."); - onAttributeAdded = waitForBrightTitlebarAttribute(); - LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org"); - ok (DevEdition.isStyleSheetEnabled, "The devedition stylesheet has been added when the devedition lightweight theme is applied"); - yield onAttributeAdded; - ok (document.documentElement.hasAttribute("brighttitlebarforeground"), - "The brighttitlebarforeground attribute is set on the window with dark devtools theme."); -}); - -add_task(function* testDevtoolsTheme() { - info ("Checking stylesheet and :root attributes based on devtools theme."); - Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "light"); - is (document.documentElement.getAttribute("devtoolstheme"), "light", - "The documentElement has an attribute based on devtools theme."); - ok (DevEdition.isStyleSheetEnabled, "The devedition stylesheet is still there with the light devtools theme."); - ok (!document.documentElement.hasAttribute("brighttitlebarforeground"), - "The brighttitlebarforeground attribute is not set on the window with light devtools theme."); - - Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark"); - is (document.documentElement.getAttribute("devtoolstheme"), "dark", - "The documentElement has an attribute based on devtools theme."); - ok (DevEdition.isStyleSheetEnabled, "The devedition stylesheet is still there with the dark devtools theme."); - is (document.documentElement.getAttribute("brighttitlebarforeground"), "true", - "The brighttitlebarforeground attribute is set on the window with dark devtools theme."); - - Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "foobar"); - is (document.documentElement.getAttribute("devtoolstheme"), "light", - "The documentElement has 'light' as a default for the devtoolstheme attribute"); - ok (DevEdition.isStyleSheetEnabled, "The devedition stylesheet is still there with the foobar devtools theme."); - ok (!document.documentElement.hasAttribute("brighttitlebarforeground"), - "The brighttitlebarforeground attribute is not set on the window with light devtools theme."); -}); - -function dummyLightweightTheme(id) { - return { - id: id, - name: id, - headerURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.header.png", - iconURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.icon.png", - textcolor: "red", - accentcolor: "blue" - }; -} - -add_task(function* testLightweightThemePreview() { - info ("Setting devedition to current and the previewing others"); - LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org"); - ok (DevEdition.isStyleSheetEnabled, "The devedition stylesheet is enabled."); - LightweightThemeManager.previewTheme(dummyLightweightTheme("preview0")); - ok (!DevEdition.isStyleSheetEnabled, "The devedition stylesheet is not enabled after a lightweight theme preview."); - LightweightThemeManager.resetPreview(); - LightweightThemeManager.previewTheme(dummyLightweightTheme("preview1")); - ok (!DevEdition.isStyleSheetEnabled, "The devedition stylesheet is not enabled after a second lightweight theme preview."); - LightweightThemeManager.resetPreview(); - ok (DevEdition.isStyleSheetEnabled, "The devedition stylesheet is enabled again after resetting the preview."); - LightweightThemeManager.currentTheme = null; - ok (!DevEdition.isStyleSheetEnabled, "The devedition stylesheet is gone after removing the current theme."); - - info ("Previewing the devedition theme"); - LightweightThemeManager.previewTheme(LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org")); - ok (DevEdition.isStyleSheetEnabled, "The devedition stylesheet is enabled."); - LightweightThemeManager.previewTheme(dummyLightweightTheme("preview2")); - LightweightThemeManager.resetPreview(); - ok (!DevEdition.isStyleSheetEnabled, "The devedition stylesheet is now disabled after resetting the preview."); -}); - -// Use a mutation observer to wait for the brighttitlebarforeground -// attribute to change. Using this instead of waiting for the load -// event on the DevEdition styleSheet. -function waitForBrightTitlebarAttribute() { - return new Promise((resolve, reject) => { - let mutationObserver = new MutationObserver(function (mutations) { - for (let mutation of mutations) { - if (mutation.attributeName == "brighttitlebarforeground") { - mutationObserver.disconnect(); - resolve(); - } - } - }); - mutationObserver.observe(document.documentElement, { attributes: true }); - }); -} diff --git a/browser/base/content/test/general/browser_discovery.js b/browser/base/content/test/general/browser_discovery.js deleted file mode 100644 index 23d44c6a9..000000000 --- a/browser/base/content/test/general/browser_discovery.js +++ /dev/null @@ -1,162 +0,0 @@ -var browser; - -function doc() { - return browser.contentDocument; -} - -function setHandlerFunc(aResultFunc) { - gBrowser.addEventListener("DOMLinkAdded", function (event) { - gBrowser.removeEventListener("DOMLinkAdded", arguments.callee, false); - executeSoon(aResultFunc); - }, false); -} - -function test() { - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - browser = gBrowser.selectedBrowser; - browser.addEventListener("load", function (event) { - event.currentTarget.removeEventListener("load", arguments.callee, true); - iconDiscovery(); - }, true); - var rootDir = getRootDirectory(gTestPath); - content.location = rootDir + "discovery.html"; -} - -var iconDiscoveryTests = [ - { text: "rel icon discovered" }, - { rel: "abcdefg icon qwerty", text: "rel may contain additional rels separated by spaces" }, - { rel: "ICON", text: "rel is case insensitive" }, - { rel: "shortcut-icon", pass: false, text: "rel shortcut-icon not discovered" }, - { href: "moz.png", text: "relative href works" }, - { href: "notthere.png", text: "404'd icon is removed properly" }, - { href: "data:image/x-icon,%00", type: "image/x-icon", text: "data: URIs work" }, - { type: "image/png; charset=utf-8", text: "type may have optional parameters (RFC2046)" } -]; - -function runIconDiscoveryTest() { - var testCase = iconDiscoveryTests[0]; - var head = doc().getElementById("linkparent"); - var hasSrc = gBrowser.getIcon() != null; - if (testCase.pass) - ok(hasSrc, testCase.text); - else - ok(!hasSrc, testCase.text); - - head.removeChild(head.getElementsByTagName('link')[0]); - iconDiscoveryTests.shift(); - iconDiscovery(); // Run the next test. -} - -function iconDiscovery() { - if (iconDiscoveryTests.length) { - setHandlerFunc(runIconDiscoveryTest); - gBrowser.setIcon(gBrowser.selectedTab, null, - Services.scriptSecurityManager.getSystemPrincipal()); - - var testCase = iconDiscoveryTests[0]; - var head = doc().getElementById("linkparent"); - var link = doc().createElement("link"); - - var rootDir = getRootDirectory(gTestPath); - var rel = testCase.rel || "icon"; - var href = testCase.href || rootDir + "moz.png"; - var type = testCase.type || "image/png"; - if (testCase.pass == undefined) - testCase.pass = true; - - link.rel = rel; - link.href = href; - link.type = type; - head.appendChild(link); - } else { - searchDiscovery(); - } -} - -var searchDiscoveryTests = [ - { text: "rel search discovered" }, - { rel: "SEARCH", text: "rel is case insensitive" }, - { rel: "-search-", pass: false, text: "rel -search- not discovered" }, - { rel: "foo bar baz search quux", text: "rel may contain additional rels separated by spaces" }, - { href: "https://not.mozilla.com", text: "HTTPS ok" }, - { href: "ftp://not.mozilla.com", text: "FTP ok" }, - { href: "data:text/foo,foo", pass: false, text: "data URI not permitted" }, - { href: "javascript:alert(0)", pass: false, text: "JS URI not permitted" }, - { type: "APPLICATION/OPENSEARCHDESCRIPTION+XML", text: "type is case insensitve" }, - { type: " application/opensearchdescription+xml ", text: "type may contain extra whitespace" }, - { type: "application/opensearchdescription+xml; charset=utf-8", text: "type may have optional parameters (RFC2046)" }, - { type: "aapplication/opensearchdescription+xml", pass: false, text: "type should not be loosely matched" }, - { rel: "search search search", count: 1, text: "only one engine should be added" } -]; - -function runSearchDiscoveryTest() { - var testCase = searchDiscoveryTests[0]; - var title = testCase.title || searchDiscoveryTests.length; - if (browser.engines) { - var hasEngine = (testCase.count) ? (browser.engines[0].title == title && - browser.engines.length == testCase.count) : - (browser.engines[0].title == title); - ok(hasEngine, testCase.text); - browser.engines = null; - } - else - ok(!testCase.pass, testCase.text); - - searchDiscoveryTests.shift(); - searchDiscovery(); // Run the next test. -} - -// This handler is called twice, once for each added link element. -// Only want to check once the second link element has been added. -var ranOnce = false; -function runMultipleEnginesTestAndFinalize() { - if (!ranOnce) { - ranOnce = true; - return; - } - ok(browser.engines, "has engines"); - is(browser.engines.length, 1, "only one engine"); - is(browser.engines[0].uri, "http://first.mozilla.com/search.xml", "first engine wins"); - - gBrowser.removeCurrentTab(); - finish(); -} - -function searchDiscovery() { - let head = doc().getElementById("linkparent"); - - if (searchDiscoveryTests.length) { - setHandlerFunc(runSearchDiscoveryTest); - let testCase = searchDiscoveryTests[0]; - let link = doc().createElement("link"); - - let rel = testCase.rel || "search"; - let href = testCase.href || "http://so.not.here.mozilla.com/search.xml"; - let type = testCase.type || "application/opensearchdescription+xml"; - let title = testCase.title || searchDiscoveryTests.length; - if (testCase.pass == undefined) - testCase.pass = true; - - link.rel = rel; - link.href = href; - link.type = type; - link.title = title; - head.appendChild(link); - } else { - setHandlerFunc(runMultipleEnginesTestAndFinalize); - setHandlerFunc(runMultipleEnginesTestAndFinalize); - // Test multiple engines with the same title - let link = doc().createElement("link"); - link.rel = "search"; - link.href = "http://first.mozilla.com/search.xml"; - link.type = "application/opensearchdescription+xml"; - link.title = "Test Engine"; - let link2 = link.cloneNode(false); - link2.href = "http://second.mozilla.com/search.xml"; - - head.appendChild(link); - head.appendChild(link2); - } -} diff --git a/browser/base/content/test/general/browser_documentnavigation.js b/browser/base/content/test/general/browser_documentnavigation.js deleted file mode 100644 index eb789d076..000000000 --- a/browser/base/content/test/general/browser_documentnavigation.js +++ /dev/null @@ -1,266 +0,0 @@ -/* - * This test checks that focus is adjusted properly in a browser when pressing F6 and Shift+F6. - * There are additional tests in dom/tests/mochitest/chrome/test_focus_docnav.xul which test - * non-browser cases. - */ - -var testPage1 = "data:text/html,<html id='html1'><body id='body1'><button id='button1'>Tab 1</button></body></html>"; -var testPage2 = "data:text/html,<html id='html2'><body id='body2'><button id='button2'>Tab 2</button></body></html>"; -var testPage3 = "data:text/html,<html id='html3'><body id='body3' contenteditable='true'><button id='button3'>Tab 3</button></body></html>"; - -var fm = Services.focus; - -function* expectFocusOnF6(backward, expectedDocument, expectedElement, onContent, desc) -{ - let focusChangedInChildResolver = null; - let focusPromise = onContent ? new Promise(resolve => focusChangedInChildResolver = resolve) : - BrowserTestUtils.waitForEvent(window, "focus", true); - - function focusChangedListener(msg) { - let expected = expectedDocument; - if (!expectedElement.startsWith("html")) { - expected += "," + expectedElement; - } - - is(msg.data.details, expected, desc + " child focus matches"); - focusChangedInChildResolver(); - } - - if (onContent) { - messageManager.addMessageListener("BrowserTest:FocusChanged", focusChangedListener); - - yield ContentTask.spawn(gBrowser.selectedBrowser, { expectedElementId: expectedElement }, function* (arg) { - let contentExpectedElement = content.document.getElementById(arg.expectedElementId); - if (!contentExpectedElement) { - // Element not found, so look in the child frames. - for (let f = 0; f < content.frames.length; f++) { - if (content.frames[f].document.getElementById(arg.expectedElementId)) { - contentExpectedElement = content.frames[f].document; - break; - } - } - } - else if (contentExpectedElement.localName == "html") { - contentExpectedElement = contentExpectedElement.ownerDocument; - } - - if (!contentExpectedElement) { - sendSyncMessage("BrowserTest:FocusChanged", - { details : "expected element " + arg.expectedElementId + " not found" }); - return; - } - - contentExpectedElement.addEventListener("focus", function focusReceived() { - contentExpectedElement.removeEventListener("focus", focusReceived, true); - - const contentFM = Components.classes["@mozilla.org/focus-manager;1"]. - getService(Components.interfaces.nsIFocusManager); - let details = contentFM.focusedWindow.document.documentElement.id; - if (contentFM.focusedElement) { - details += "," + contentFM.focusedElement.id; - } - - sendSyncMessage("BrowserTest:FocusChanged", { details : details }); - }, true); - }); - } - - EventUtils.synthesizeKey("VK_F6", { shiftKey: backward }); - yield focusPromise; - - if (typeof expectedElement == "string") { - expectedElement = fm.focusedWindow.document.getElementById(expectedElement); - } - - if (gMultiProcessBrowser && onContent) { - expectedDocument = "main-window"; - expectedElement = gBrowser.selectedBrowser; - } - - is(fm.focusedWindow.document.documentElement.id, expectedDocument, desc + " document matches"); - is(fm.focusedElement, expectedElement, desc + " element matches"); - - if (onContent) { - messageManager.removeMessageListener("BrowserTest:FocusChanged", focusChangedListener); - } -} - -// Load a page and navigate between it and the chrome window. -add_task(function* () -{ - let page1Promise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - gBrowser.selectedBrowser.loadURI(testPage1); - yield page1Promise; - - // When the urlbar is focused, pressing F6 should focus the root of the content page. - gURLBar.focus(); - yield* expectFocusOnF6(false, "html1", "html1", - true, "basic focus content page"); - - // When the content is focused, pressing F6 should focus the urlbar. - yield* expectFocusOnF6(false, "main-window", gURLBar.inputField, - false, "basic focus content page urlbar"); - - // When a button in content is focused, pressing F6 should focus the urlbar. - yield* expectFocusOnF6(false, "html1", "html1", - true, "basic focus content page with button focused"); - - yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* () { - return content.document.getElementById("button1").focus(); - }); - - yield* expectFocusOnF6(false, "main-window", gURLBar.inputField, - false, "basic focus content page with button focused urlbar"); - - // The document root should be focused, not the button - yield* expectFocusOnF6(false, "html1", "html1", - true, "basic focus again content page with button focused"); - - // Check to ensure that the root element is focused - yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* () { - Assert.ok(content.document.activeElement == content.document.documentElement, - "basic focus again content page with button focused child root is focused"); - }); -}); - -// Open a second tab. Document focus should skip the background tab. -add_task(function* () -{ - yield BrowserTestUtils.openNewForegroundTab(gBrowser, testPage2); - - yield* expectFocusOnF6(false, "main-window", gURLBar.inputField, - false, "basic focus content page and second tab urlbar"); - yield* expectFocusOnF6(false, "html2", "html2", - true, "basic focus content page with second tab"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -// Shift+F6 should navigate backwards. There's only one document here so the effect -// is the same. -add_task(function* () -{ - gURLBar.focus(); - yield* expectFocusOnF6(true, "html1", "html1", - true, "back focus content page"); - yield* expectFocusOnF6(true, "main-window", gURLBar.inputField, - false, "back focus content page urlbar"); -}); - -// Open the sidebar and navigate between the sidebar, content and top-level window -add_task(function* () -{ - let sidebar = document.getElementById("sidebar"); - - let loadPromise = BrowserTestUtils.waitForEvent(sidebar, "load", true); - SidebarUI.toggle('viewBookmarksSidebar'); - yield loadPromise; - - - gURLBar.focus(); - yield* expectFocusOnF6(false, "bookmarksPanel", - sidebar.contentDocument.getElementById("search-box").inputField, - false, "focus with sidebar open sidebar"); - yield* expectFocusOnF6(false, "html1", "html1", - true, "focus with sidebar open content"); - yield* expectFocusOnF6(false, "main-window", gURLBar.inputField, - false, "focus with sidebar urlbar"); - - // Now go backwards - yield* expectFocusOnF6(true, "html1", "html1", - true, "back focus with sidebar open content"); - yield* expectFocusOnF6(true, "bookmarksPanel", - sidebar.contentDocument.getElementById("search-box").inputField, - false, "back focus with sidebar open sidebar"); - yield* expectFocusOnF6(true, "main-window", gURLBar.inputField, - false, "back focus with sidebar urlbar"); - - SidebarUI.toggle('viewBookmarksSidebar'); -}); - -// Navigate when the downloads panel is open -add_task(function* () -{ - yield pushPrefs(["accessibility.tabfocus", 7]); - - let popupShownPromise = BrowserTestUtils.waitForEvent(document, "popupshown", true); - EventUtils.synthesizeMouseAtCenter(document.getElementById("downloads-button"), { }); - yield popupShownPromise; - - gURLBar.focus(); - yield* expectFocusOnF6(false, "main-window", document.getElementById("downloadsHistory"), - false, "focus with downloads panel open panel"); - yield* expectFocusOnF6(false, "html1", "html1", - true, "focus with downloads panel open"); - yield* expectFocusOnF6(false, "main-window", gURLBar.inputField, - false, "focus downloads panel open urlbar"); - - // Now go backwards - yield* expectFocusOnF6(true, "html1", "html1", - true, "back focus with downloads panel open"); - yield* expectFocusOnF6(true, "main-window", document.getElementById("downloadsHistory"), - false, "back focus with downloads panel open"); - yield* expectFocusOnF6(true, "main-window", gURLBar.inputField, - false, "back focus downloads panel open urlbar"); - - let downloadsPopup = document.getElementById("downloadsPanel"); - let popupHiddenPromise = BrowserTestUtils.waitForEvent(downloadsPopup, "popuphidden", true); - downloadsPopup.hidePopup(); - yield popupHiddenPromise; -}); - -// Navigation with a contenteditable body -add_task(function* () -{ - yield BrowserTestUtils.openNewForegroundTab(gBrowser, testPage3); - - // The body should be focused when it is editable, not the root. - gURLBar.focus(); - yield* expectFocusOnF6(false, "html3", "body3", - true, "focus with contenteditable body"); - yield* expectFocusOnF6(false, "main-window", gURLBar.inputField, - false, "focus with contenteditable body urlbar"); - - // Now go backwards - - yield* expectFocusOnF6(false, "html3", "body3", - true, "back focus with contenteditable body"); - yield* expectFocusOnF6(false, "main-window", gURLBar.inputField, - false, "back focus with contenteditable body urlbar"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -// Navigation with a frameset loaded -add_task(function* () -{ - yield BrowserTestUtils.openNewForegroundTab(gBrowser, - "http://mochi.test:8888/browser/browser/base/content/test/general/file_documentnavigation_frameset.html"); - - gURLBar.focus(); - yield* expectFocusOnF6(false, "htmlframe1", "htmlframe1", - true, "focus on frameset frame 0"); - yield* expectFocusOnF6(false, "htmlframe2", "htmlframe2", - true, "focus on frameset frame 1"); - yield* expectFocusOnF6(false, "htmlframe3", "htmlframe3", - true, "focus on frameset frame 2"); - yield* expectFocusOnF6(false, "htmlframe4", "htmlframe4", - true, "focus on frameset frame 3"); - yield* expectFocusOnF6(false, "main-window", gURLBar.inputField, - false, "focus on frameset frame urlbar"); - - yield* expectFocusOnF6(true, "htmlframe4", "htmlframe4", - true, "back focus on frameset frame 3"); - yield* expectFocusOnF6(true, "htmlframe3", "htmlframe3", - true, "back focus on frameset frame 2"); - yield* expectFocusOnF6(true, "htmlframe2", "htmlframe2", - true, "back focus on frameset frame 1"); - yield* expectFocusOnF6(true, "htmlframe1", "htmlframe1", - true, "back focus on frameset frame 0"); - yield* expectFocusOnF6(true, "main-window", gURLBar.inputField, - false, "back focus on frameset frame urlbar"); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - -// XXXndeakin add tests for browsers inside of panels diff --git a/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js b/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js deleted file mode 100644 index 054fb3cc0..000000000 --- a/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js +++ /dev/null @@ -1,221 +0,0 @@ -"use strict"; - -var gMessageManager; - -function frameScript() { - addMessageListener("Test:RequestFullscreen", () => { - content.document.body.requestFullscreen(); - }); - addMessageListener("Test:ExitFullscreen", () => { - content.document.exitFullscreen(); - }); - addMessageListener("Test:QueryFullscreenState", () => { - sendAsyncMessage("Test:FullscreenState", { - inDOMFullscreen: !!content.document.fullscreenElement, - inFullscreen: content.fullScreen - }); - }); - content.document.addEventListener("fullscreenchange", () => { - sendAsyncMessage("Test:FullscreenChanged", { - inDOMFullscreen: !!content.document.fullscreenElement, - inFullscreen: content.fullScreen - }); - }); - function waitUntilActive() { - let doc = content.document; - if (doc.docShell.isActive && doc.hasFocus()) { - sendAsyncMessage("Test:Activated"); - } else { - setTimeout(waitUntilActive, 10); - } - } - waitUntilActive(); -} - -function listenOneMessage(aMsg, aListener) { - function listener({ data }) { - gMessageManager.removeMessageListener(aMsg, listener); - aListener(data); - } - gMessageManager.addMessageListener(aMsg, listener); -} - -function listenOneEvent(aEvent, aListener) { - function listener(evt) { - removeEventListener(aEvent, listener); - aListener(evt); - } - addEventListener(aEvent, listener); -} - -function queryFullscreenState() { - return new Promise(resolve => { - listenOneMessage("Test:FullscreenState", resolve); - gMessageManager.sendAsyncMessage("Test:QueryFullscreenState"); - }); -} - -function captureUnexpectedFullscreenChange() { - ok(false, "catched an unexpected fullscreen change"); -} - -const FS_CHANGE_DOM = 1 << 0; -const FS_CHANGE_SIZE = 1 << 1; -const FS_CHANGE_BOTH = FS_CHANGE_DOM | FS_CHANGE_SIZE; - -function waitForFullscreenChanges(aFlags) { - return new Promise(resolve => { - let fullscreenData = null; - let sizemodeChanged = false; - function tryResolve() { - if ((!(aFlags & FS_CHANGE_DOM) || fullscreenData) && - (!(aFlags & FS_CHANGE_SIZE) || sizemodeChanged)) { - if (!fullscreenData) { - queryFullscreenState().then(resolve); - } else { - resolve(fullscreenData); - } - } - } - if (aFlags & FS_CHANGE_SIZE) { - listenOneEvent("sizemodechange", () => { - sizemodeChanged = true; - tryResolve(); - }); - } - if (aFlags & FS_CHANGE_DOM) { - gMessageManager.removeMessageListener( - "Test:FullscreenChanged", captureUnexpectedFullscreenChange); - listenOneMessage("Test:FullscreenChanged", data => { - gMessageManager.addMessageListener( - "Test:FullscreenChanged", captureUnexpectedFullscreenChange); - fullscreenData = data; - tryResolve(); - }); - } - }); -} - -var gTests = [ - { - desc: "document method", - affectsFullscreenMode: false, - exitFunc: () => { - gMessageManager.sendAsyncMessage("Test:ExitFullscreen"); - } - }, - { - desc: "escape key", - affectsFullscreenMode: false, - exitFunc: () => { - executeSoon(() => EventUtils.synthesizeKey("VK_ESCAPE", {})); - } - }, - { - desc: "F11 key", - affectsFullscreenMode: true, - exitFunc: function () { - executeSoon(() => EventUtils.synthesizeKey("VK_F11", {})); - } - } -]; - -function checkState(expectedStates, contentStates) { - is(contentStates.inDOMFullscreen, expectedStates.inDOMFullscreen, - "The DOM fullscreen state of the content should match"); - // TODO window.fullScreen is not updated as soon as the fullscreen - // state flips in child process, hence checking it could cause - // anonying intermittent failure. As we just want to confirm the - // fullscreen state of the browser window, we can just check the - // that on the chrome window below. - // is(contentStates.inFullscreen, expectedStates.inFullscreen, - // "The fullscreen state of the content should match"); - is(!!document.fullscreenElement, expectedStates.inDOMFullscreen, - "The DOM fullscreen state of the chrome should match"); - is(window.fullScreen, expectedStates.inFullscreen, - "The fullscreen state of the chrome should match"); -} - -const kPage = "http://example.org/browser/browser/" + - "base/content/test/general/dummy_page.html"; - -add_task(function* () { - yield pushPrefs( - ["full-screen-api.transition-duration.enter", "0 0"], - ["full-screen-api.transition-duration.leave", "0 0"]); - - let tab = gBrowser.addTab(kPage); - let browser = tab.linkedBrowser; - gBrowser.selectedTab = tab; - yield waitForDocLoadComplete(); - - registerCleanupFunction(() => { - if (browser.contentWindow.fullScreen) { - BrowserFullScreen(); - } - gBrowser.removeTab(tab); - }); - - gMessageManager = browser.messageManager; - gMessageManager.loadFrameScript( - "data:,(" + frameScript.toString() + ")();", false); - gMessageManager.addMessageListener( - "Test:FullscreenChanged", captureUnexpectedFullscreenChange); - - // Wait for the document being activated, so that - // fullscreen request won't be denied. - yield new Promise(resolve => listenOneMessage("Test:Activated", resolve)); - - for (let test of gTests) { - let contentStates; - info("Testing exit DOM fullscreen via " + test.desc); - - contentStates = yield queryFullscreenState(); - checkState({inDOMFullscreen: false, inFullscreen: false}, contentStates); - - /* DOM fullscreen without fullscreen mode */ - - info("> Enter DOM fullscreen"); - gMessageManager.sendAsyncMessage("Test:RequestFullscreen"); - contentStates = yield waitForFullscreenChanges(FS_CHANGE_BOTH); - checkState({inDOMFullscreen: true, inFullscreen: true}, contentStates); - - info("> Exit DOM fullscreen"); - test.exitFunc(); - contentStates = yield waitForFullscreenChanges(FS_CHANGE_BOTH); - checkState({inDOMFullscreen: false, inFullscreen: false}, contentStates); - - /* DOM fullscreen with fullscreen mode */ - - info("> Enter fullscreen mode"); - // Need to be asynchronous because sizemodechange event could be - // dispatched synchronously, which would cause the event listener - // miss that event and wait infinitely. - executeSoon(() => BrowserFullScreen()); - contentStates = yield waitForFullscreenChanges(FS_CHANGE_SIZE); - checkState({inDOMFullscreen: false, inFullscreen: true}, contentStates); - - info("> Enter DOM fullscreen in fullscreen mode"); - gMessageManager.sendAsyncMessage("Test:RequestFullscreen"); - contentStates = yield waitForFullscreenChanges(FS_CHANGE_DOM); - checkState({inDOMFullscreen: true, inFullscreen: true}, contentStates); - - info("> Exit DOM fullscreen in fullscreen mode"); - test.exitFunc(); - contentStates = yield waitForFullscreenChanges( - test.affectsFullscreenMode ? FS_CHANGE_BOTH : FS_CHANGE_DOM); - checkState({ - inDOMFullscreen: false, - inFullscreen: !test.affectsFullscreenMode - }, contentStates); - - /* Cleanup */ - - // Exit fullscreen mode if we are still in - if (window.fullScreen) { - info("> Cleanup"); - executeSoon(() => BrowserFullScreen()); - yield waitForFullscreenChanges(FS_CHANGE_SIZE); - } - } -}); diff --git a/browser/base/content/test/general/browser_double_close_tab.js b/browser/base/content/test/general/browser_double_close_tab.js deleted file mode 100644 index 29242c3f9..000000000 --- a/browser/base/content/test/general/browser_double_close_tab.js +++ /dev/null @@ -1,80 +0,0 @@ -"use strict"; -const TEST_PAGE = "http://mochi.test:8888/browser/browser/base/content/test/general/file_double_close_tab.html"; -var testTab; - -SpecialPowers.pushPrefEnv({"set": [["dom.require_user_interaction_for_beforeunload", false]]}); - -function waitForDialog(callback) { - function onTabModalDialogLoaded(node) { - Services.obs.removeObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded"); - callback(node); - } - - // Listen for the dialog being created - Services.obs.addObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded", false); -} - -function waitForDialogDestroyed(node, callback) { - // Now listen for the dialog going away again... - let observer = new MutationObserver(function(muts) { - if (!node.parentNode) { - ok(true, "Dialog is gone"); - done(); - } - }); - observer.observe(node.parentNode, {childList: true}); - let failureTimeout = setTimeout(function() { - ok(false, "Dialog should have been destroyed"); - done(); - }, 10000); - - function done() { - clearTimeout(failureTimeout); - observer.disconnect(); - observer = null; - callback(); - } -} - -add_task(function*() { - testTab = gBrowser.selectedTab = gBrowser.addTab(); - yield promiseTabLoadEvent(testTab, TEST_PAGE); - // XXXgijs the reason this has nesting and callbacks rather than promises is - // that DOM promises resolve on the next tick. So they're scheduled - // in an event queue. So when we spin a new event queue for a modal dialog... - // everything gets messed up and the promise's .then callbacks never get - // called, despite resolve() being called just fine. - yield new Promise(resolveOuter => { - waitForDialog(dialogNode => { - waitForDialogDestroyed(dialogNode, () => { - let doCompletion = () => setTimeout(resolveOuter, 0); - info("Now checking if dialog is destroyed"); - ok(!dialogNode.parentNode, "onbeforeunload dialog should be gone."); - if (dialogNode.parentNode) { - // Failed to remove onbeforeunload dialog, so do it ourselves: - let leaveBtn = dialogNode.ui.button0; - waitForDialogDestroyed(dialogNode, doCompletion); - EventUtils.synthesizeMouseAtCenter(leaveBtn, {}); - return; - } - doCompletion(); - }); - // Click again: - document.getAnonymousElementByAttribute(testTab, "anonid", "close-button").click(); - }); - // Click once: - document.getAnonymousElementByAttribute(testTab, "anonid", "close-button").click(); - }); - yield promiseWaitForCondition(() => !testTab.parentNode); - ok(!testTab.parentNode, "Tab should be closed completely"); -}); - -registerCleanupFunction(function() { - if (testTab.parentNode) { - // Remove the handler, or closing this tab will prove tricky: - try { - testTab.linkedBrowser.contentWindow.onbeforeunload = null; - } catch (ex) {} - gBrowser.removeTab(testTab); - } -}); diff --git a/browser/base/content/test/general/browser_drag.js b/browser/base/content/test/general/browser_drag.js deleted file mode 100644 index 64ad19bde..000000000 --- a/browser/base/content/test/general/browser_drag.js +++ /dev/null @@ -1,45 +0,0 @@ -function test() -{ - waitForExplicitFinish(); - - let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let EventUtils = {}; - scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils); - - // ---- Test dragging the proxy icon --- - var value = content.location.href; - var urlString = value + "\n" + content.document.title; - var htmlString = "<a href=\"" + value + "\">" + value + "</a>"; - var expected = [ [ - { type : "text/x-moz-url", - data : urlString }, - { type : "text/uri-list", - data : value }, - { type : "text/plain", - data : value }, - { type : "text/html", - data : htmlString } - ] ]; - // set the valid attribute so dropping is allowed - var oldstate = gURLBar.getAttribute("pageproxystate"); - gURLBar.setAttribute("pageproxystate", "valid"); - var dt = EventUtils.synthesizeDragStart(document.getElementById("identity-box"), expected); - is(dt, null, "drag on proxy icon"); - gURLBar.setAttribute("pageproxystate", oldstate); - // Now, the identity information panel is opened by the proxy icon click. - // We need to close it for next tests. - EventUtils.synthesizeKey("VK_ESCAPE", {}, window); - - // now test dragging onto a tab - var tab = gBrowser.addTab("about:blank", {skipAnimation: true}); - var browser = gBrowser.getBrowserForTab(tab); - - browser.addEventListener("load", function () { - is(browser.contentWindow.location, "http://mochi.test:8888/", "drop on tab"); - gBrowser.removeTab(tab); - finish(); - }, true); - - EventUtils.synthesizeDrop(tab, tab, [[{type: "text/uri-list", data: "http://mochi.test:8888/"}]], "copy", window); -} diff --git a/browser/base/content/test/general/browser_duplicateIDs.js b/browser/base/content/test/general/browser_duplicateIDs.js deleted file mode 100644 index 38fc17820..000000000 --- a/browser/base/content/test/general/browser_duplicateIDs.js +++ /dev/null @@ -1,8 +0,0 @@ -function test() { - var ids = {}; - Array.forEach(document.querySelectorAll("[id]"), function (node) { - var id = node.id; - ok(!(id in ids), id + " should be unique"); - ids[id] = null; - }); -} diff --git a/browser/base/content/test/general/browser_e10s_about_process.js b/browser/base/content/test/general/browser_e10s_about_process.js deleted file mode 100644 index 2b4816754..000000000 --- a/browser/base/content/test/general/browser_e10s_about_process.js +++ /dev/null @@ -1,114 +0,0 @@ -const CHROME_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; -const CONTENT_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT; - -const CHROME = { - id: "cb34538a-d9da-40f3-b61a-069f0b2cb9fb", - path: "test-chrome", - flags: 0, -} -const CANREMOTE = { - id: "2480d3e1-9ce4-4b84-8ae3-910b9a95cbb3", - path: "test-allowremote", - flags: Ci.nsIAboutModule.URI_CAN_LOAD_IN_CHILD, -} -const MUSTREMOTE = { - id: "f849cee5-e13e-44d2-981d-0fb3884aaead", - path: "test-mustremote", - flags: Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD, -} - -const TEST_MODULES = [ - CHROME, - CANREMOTE, - MUSTREMOTE -] - -function AboutModule() { -} - -AboutModule.prototype = { - newChannel: function(aURI, aLoadInfo) { - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; - }, - - getURIFlags: function(aURI) { - for (let module of TEST_MODULES) { - if (aURI.path.startsWith(module.path)) { - return module.flags; - } - } - - ok(false, "Called getURIFlags for an unknown page " + aURI.spec); - return 0; - }, - - getIndexedDBOriginPostfix: function(aURI) { - return null; - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]) -}; - -var AboutModuleFactory = { - createInstance: function(aOuter, aIID) { - if (aOuter) - throw Components.results.NS_ERROR_NO_AGGREGATION; - return new AboutModule().QueryInterface(aIID); - }, - - lockFactory: function(aLock) { - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]) -}; - -add_task(function* init() { - let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); - for (let module of TEST_MODULES) { - registrar.registerFactory(Components.ID(module.id), "", - "@mozilla.org/network/protocol/about;1?what=" + module.path, - AboutModuleFactory); - } -}); - -registerCleanupFunction(() => { - let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); - for (let module of TEST_MODULES) { - registrar.unregisterFactory(Components.ID(module.id), AboutModuleFactory); - } -}); - -function test_url(url, chromeResult, contentResult) { - is(E10SUtils.canLoadURIInProcess(url, CHROME_PROCESS), - chromeResult, "Check URL in chrome process."); - is(E10SUtils.canLoadURIInProcess(url, CONTENT_PROCESS), - contentResult, "Check URL in content process."); - - is(E10SUtils.canLoadURIInProcess(url + "#foo", CHROME_PROCESS), - chromeResult, "Check URL with ref in chrome process."); - is(E10SUtils.canLoadURIInProcess(url + "#foo", CONTENT_PROCESS), - contentResult, "Check URL with ref in content process."); - - is(E10SUtils.canLoadURIInProcess(url + "?foo", CHROME_PROCESS), - chromeResult, "Check URL with query in chrome process."); - is(E10SUtils.canLoadURIInProcess(url + "?foo", CONTENT_PROCESS), - contentResult, "Check URL with query in content process."); - - is(E10SUtils.canLoadURIInProcess(url + "?foo#bar", CHROME_PROCESS), - chromeResult, "Check URL with query and ref in chrome process."); - is(E10SUtils.canLoadURIInProcess(url + "?foo#bar", CONTENT_PROCESS), - contentResult, "Check URL with query and ref in content process."); -} - -add_task(function* test_chrome() { - test_url("about:" + CHROME.path, true, false); -}); - -add_task(function* test_any() { - test_url("about:" + CANREMOTE.path, true, true); -}); - -add_task(function* test_remote() { - test_url("about:" + MUSTREMOTE.path, false, true); -}); diff --git a/browser/base/content/test/general/browser_e10s_chrome_process.js b/browser/base/content/test/general/browser_e10s_chrome_process.js deleted file mode 100644 index 0726447ce..000000000 --- a/browser/base/content/test/general/browser_e10s_chrome_process.js +++ /dev/null @@ -1,150 +0,0 @@ -// Returns a function suitable for add_task which loads startURL, runs -// transitionTask and waits for endURL to load, checking that the URLs were -// loaded in the correct process. -function makeTest(name, startURL, startProcessIsRemote, endURL, endProcessIsRemote, transitionTask) { - return function*() { - info("Running test " + name + ", " + transitionTask.name); - let browser = gBrowser.selectedBrowser; - - // In non-e10s nothing should be remote - if (!gMultiProcessBrowser) { - startProcessIsRemote = false; - endProcessIsRemote = false; - } - - // Load the initial URL and make sure we are in the right initial process - info("Loading initial URL"); - browser.loadURI(startURL); - yield waitForDocLoadComplete(); - - is(browser.currentURI.spec, startURL, "Shouldn't have been redirected"); - is(browser.isRemoteBrowser, startProcessIsRemote, "Should be displayed in the right process"); - - let docLoadedPromise = waitForDocLoadComplete(); - let asyncTask = Task.async(transitionTask); - let expectSyncChange = yield asyncTask(browser, endURL); - if (expectSyncChange) { - is(browser.isRemoteBrowser, endProcessIsRemote, "Should have switched to the right process synchronously"); - } - yield docLoadedPromise; - - is(browser.currentURI.spec, endURL, "Should have made it to the final URL"); - is(browser.isRemoteBrowser, endProcessIsRemote, "Should be displayed in the right process"); - } -} - -const CHROME_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; -const CONTENT_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT; -const PATH = (getRootDirectory(gTestPath) + "test_process_flags_chrome.html").replace("chrome://mochitests", ""); - -const CHROME = "chrome://mochitests" + PATH; -const CANREMOTE = "chrome://mochitests-any" + PATH; -const MUSTREMOTE = "chrome://mochitests-content" + PATH; - -add_task(function* init() { - gBrowser.selectedTab = gBrowser.addTab("about:blank"); -}); - -registerCleanupFunction(() => { - gBrowser.removeCurrentTab(); -}); - -function test_url(url, chromeResult, contentResult) { - is(E10SUtils.canLoadURIInProcess(url, CHROME_PROCESS), - chromeResult, "Check URL in chrome process."); - is(E10SUtils.canLoadURIInProcess(url, CONTENT_PROCESS), - contentResult, "Check URL in content process."); - - is(E10SUtils.canLoadURIInProcess(url + "#foo", CHROME_PROCESS), - chromeResult, "Check URL with ref in chrome process."); - is(E10SUtils.canLoadURIInProcess(url + "#foo", CONTENT_PROCESS), - contentResult, "Check URL with ref in content process."); - - is(E10SUtils.canLoadURIInProcess(url + "?foo", CHROME_PROCESS), - chromeResult, "Check URL with query in chrome process."); - is(E10SUtils.canLoadURIInProcess(url + "?foo", CONTENT_PROCESS), - contentResult, "Check URL with query in content process."); - - is(E10SUtils.canLoadURIInProcess(url + "?foo#bar", CHROME_PROCESS), - chromeResult, "Check URL with query and ref in chrome process."); - is(E10SUtils.canLoadURIInProcess(url + "?foo#bar", CONTENT_PROCESS), - contentResult, "Check URL with query and ref in content process."); -} - -add_task(function* test_chrome() { - test_url(CHROME, true, false); -}); - -add_task(function* test_any() { - test_url(CANREMOTE, true, true); -}); - -add_task(function* test_remote() { - test_url(MUSTREMOTE, false, true); -}); - -// The set of page transitions -var TESTS = [ - [ - "chrome -> chrome", - CHROME, false, - CHROME, false, - ], - [ - "chrome -> canremote", - CHROME, false, - CANREMOTE, false, - ], - [ - "chrome -> mustremote", - CHROME, false, - MUSTREMOTE, true, - ], - [ - "remote -> chrome", - MUSTREMOTE, true, - CHROME, false, - ], - [ - "remote -> canremote", - MUSTREMOTE, true, - CANREMOTE, true, - ], - [ - "remote -> mustremote", - MUSTREMOTE, true, - MUSTREMOTE, true, - ], -]; - -// The different ways to transition from one page to another -var TRANSITIONS = [ -// Loads the new page by calling browser.loadURI directly -function* loadURI(browser, uri) { - info("Calling browser.loadURI"); - yield BrowserTestUtils.loadURI(browser, uri); - return true; -}, - -// Loads the new page by finding a link with the right href in the document and -// clicking it -function* clickLink(browser, uri) { - info("Clicking link"); - - function frame_script(frameUri) { - let link = content.document.querySelector("a[href='" + frameUri + "']"); - link.click(); - } - - browser.messageManager.loadFrameScript("data:,(" + frame_script.toString() + ")(" + JSON.stringify(uri) + ");", false); - - return false; -}, -]; - -// Creates a set of test tasks, one for each combination of TESTS and TRANSITIONS. -for (let test of TESTS) { - for (let transition of TRANSITIONS) { - add_task(makeTest(...test, transition)); - } -} diff --git a/browser/base/content/test/general/browser_e10s_javascript.js b/browser/base/content/test/general/browser_e10s_javascript.js deleted file mode 100644 index 90e847b09..000000000 --- a/browser/base/content/test/general/browser_e10s_javascript.js +++ /dev/null @@ -1,11 +0,0 @@ -const CHROME_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; -const CONTENT_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT; - -add_task(function*() { - let url = "javascript:dosomething()"; - - ok(E10SUtils.canLoadURIInProcess(url, CHROME_PROCESS), - "Check URL in chrome process."); - ok(E10SUtils.canLoadURIInProcess(url, CONTENT_PROCESS), - "Check URL in content process."); -}); diff --git a/browser/base/content/test/general/browser_e10s_switchbrowser.js b/browser/base/content/test/general/browser_e10s_switchbrowser.js deleted file mode 100644 index e6134f749..000000000 --- a/browser/base/content/test/general/browser_e10s_switchbrowser.js +++ /dev/null @@ -1,261 +0,0 @@ -requestLongerTimeout(2); - -const DUMMY_PATH = "browser/browser/base/content/test/general/dummy_page.html"; - -const gExpectedHistory = { - index: -1, - entries: [] -}; - -function get_remote_history(browser) { - function frame_script() { - let webNav = docShell.QueryInterface(Components.interfaces.nsIWebNavigation); - let sessionHistory = webNav.sessionHistory; - let result = { - index: sessionHistory.index, - entries: [] - }; - - for (let i = 0; i < sessionHistory.count; i++) { - let entry = sessionHistory.getEntryAtIndex(i, false); - result.entries.push({ - uri: entry.URI.spec, - title: entry.title - }); - } - - sendAsyncMessage("Test:History", result); - } - - return new Promise(resolve => { - browser.messageManager.addMessageListener("Test:History", function listener({data}) { - browser.messageManager.removeMessageListener("Test:History", listener); - resolve(data); - }); - - browser.messageManager.loadFrameScript("data:,(" + frame_script.toString() + ")();", true); - }); -} - -var check_history = Task.async(function*() { - let sessionHistory = yield get_remote_history(gBrowser.selectedBrowser); - - let count = sessionHistory.entries.length; - is(count, gExpectedHistory.entries.length, "Should have the right number of history entries"); - is(sessionHistory.index, gExpectedHistory.index, "Should have the right history index"); - - for (let i = 0; i < count; i++) { - let entry = sessionHistory.entries[i]; - is(entry.uri, gExpectedHistory.entries[i].uri, "Should have the right URI"); - is(entry.title, gExpectedHistory.entries[i].title, "Should have the right title"); - } -}); - -function clear_history() { - gExpectedHistory.index = -1; - gExpectedHistory.entries = []; -} - -// Waits for a load and updates the known history -var waitForLoad = Task.async(function*(uri) { - info("Loading " + uri); - // Longwinded but this ensures we don't just shortcut to LoadInNewProcess - gBrowser.selectedBrowser.webNavigation.loadURI(uri, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); - - yield waitForDocLoadComplete(); - gExpectedHistory.index++; - gExpectedHistory.entries.push({ - uri: gBrowser.currentURI.spec, - title: gBrowser.contentTitle - }); -}); - -// Waits for a load and updates the known history -var waitForLoadWithFlags = Task.async(function*(uri, flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE) { - info("Loading " + uri + " flags = " + flags); - gBrowser.selectedBrowser.loadURIWithFlags(uri, flags, null, null, null); - - yield waitForDocLoadComplete(); - if (!(flags & Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY)) { - - if (flags & Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY) { - gExpectedHistory.entries.pop(); - } - else { - gExpectedHistory.index++; - } - - gExpectedHistory.entries.push({ - uri: gBrowser.currentURI.spec, - title: gBrowser.contentTitle - }); - } -}); - -var back = Task.async(function*() { - info("Going back"); - gBrowser.goBack(); - yield waitForDocLoadComplete(); - gExpectedHistory.index--; -}); - -var forward = Task.async(function*() { - info("Going forward"); - gBrowser.goForward(); - yield waitForDocLoadComplete(); - gExpectedHistory.index++; -}); - -// Tests that navigating from a page that should be in the remote process and -// a page that should be in the main process works and retains history -add_task(function* test_navigation() { - let expectedRemote = gMultiProcessBrowser; - - info("1"); - // Create a tab and load a remote page in it - gBrowser.selectedTab = gBrowser.addTab("about:blank", {skipAnimation: true}); - let {permanentKey} = gBrowser.selectedBrowser; - yield waitForLoad("http://example.org/" + DUMMY_PATH); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - - info("2"); - // Load another page - yield waitForLoad("http://example.com/" + DUMMY_PATH); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - yield check_history(); - - info("3"); - // Load a non-remote page - yield waitForLoad("about:robots"); - is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - yield check_history(); - - info("4"); - // Load a remote page - yield waitForLoad("http://example.org/" + DUMMY_PATH); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - yield check_history(); - - info("5"); - yield back(); - is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - yield check_history(); - - info("6"); - yield back(); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - yield check_history(); - - info("7"); - yield forward(); - is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - yield check_history(); - - info("8"); - yield forward(); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - yield check_history(); - - info("9"); - yield back(); - is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - yield check_history(); - - info("10"); - // Load a new remote page, this should replace the last history entry - gExpectedHistory.entries.splice(gExpectedHistory.entries.length - 1, 1); - yield waitForLoad("http://example.com/" + DUMMY_PATH); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - yield check_history(); - - info("11"); - gBrowser.removeCurrentTab(); - clear_history(); -}); - -// Tests that calling gBrowser.loadURI or browser.loadURI to load a page in a -// different process updates the browser synchronously -add_task(function* test_synchronous() { - let expectedRemote = gMultiProcessBrowser; - - info("1"); - // Create a tab and load a remote page in it - gBrowser.selectedTab = gBrowser.addTab("about:blank", {skipAnimation: true}); - let {permanentKey} = gBrowser.selectedBrowser; - yield waitForLoad("http://example.org/" + DUMMY_PATH); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - - info("2"); - // Load another page - info("Loading about:robots"); - yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "about:robots"); - is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - - yield waitForDocLoadComplete(); - is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - - info("3"); - // Load the remote page again - info("Loading http://example.org/" + DUMMY_PATH); - yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "http://example.org/" + DUMMY_PATH); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - - yield waitForDocLoadComplete(); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same"); - - info("4"); - gBrowser.removeCurrentTab(); - clear_history(); -}); - -// Tests that load flags are correctly passed through to the child process with -// normal loads -add_task(function* test_loadflags() { - let expectedRemote = gMultiProcessBrowser; - - info("1"); - // Create a tab and load a remote page in it - gBrowser.selectedTab = gBrowser.addTab("about:blank", {skipAnimation: true}); - yield waitForLoadWithFlags("about:robots"); - is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct"); - yield check_history(); - - info("2"); - // Load a page in the remote process with some custom flags - yield waitForLoadWithFlags("http://example.com/" + DUMMY_PATH, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - yield check_history(); - - info("3"); - // Load a non-remote page - yield waitForLoadWithFlags("about:robots"); - is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct"); - yield check_history(); - - info("4"); - // Load another remote page - yield waitForLoadWithFlags("http://example.org/" + DUMMY_PATH, Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY); - is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct"); - yield check_history(); - - is(gExpectedHistory.entries.length, 2, "Should end with the right number of history entries"); - - info("5"); - gBrowser.removeCurrentTab(); - clear_history(); -}); diff --git a/browser/base/content/test/general/browser_favicon_change.js b/browser/base/content/test/general/browser_favicon_change.js deleted file mode 100644 index f6b0a2a42..000000000 --- a/browser/base/content/test/general/browser_favicon_change.js +++ /dev/null @@ -1,41 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -const TEST_URL = "http://mochi.test:8888/browser/browser/base/content/test/general/file_favicon_change.html" - -add_task(function*() { - let extraTab = gBrowser.selectedTab = gBrowser.addTab(); - extraTab.linkedBrowser.loadURI(TEST_URL); - let tabLoaded = BrowserTestUtils.browserLoaded(extraTab.linkedBrowser); - let expectedFavicon = "http://example.org/one-icon"; - let haveChanged = new Promise.defer(); - let observer = new MutationObserver(function(mutations) { - for (let mut of mutations) { - if (mut.attributeName != "image") { - continue; - } - let imageVal = extraTab.getAttribute("image").replace(/#.*$/, ""); - if (!imageVal) { - // The value gets removed because it doesn't load. - continue; - } - is(imageVal, expectedFavicon, "Favicon image should correspond to expected image."); - haveChanged.resolve(); - } - }); - observer.observe(extraTab, {attributes: true}); - yield tabLoaded; - yield haveChanged.promise; - haveChanged = new Promise.defer(); - expectedFavicon = "http://example.org/other-icon"; - ContentTask.spawn(extraTab.linkedBrowser, null, function() { - let ev = new content.CustomEvent("PleaseChangeFavicon", {}); - content.dispatchEvent(ev); - }); - yield haveChanged.promise; - observer.disconnect(); - gBrowser.removeTab(extraTab); -}); - diff --git a/browser/base/content/test/general/browser_favicon_change_not_in_document.js b/browser/base/content/test/general/browser_favicon_change_not_in_document.js deleted file mode 100644 index d14a1da32..000000000 --- a/browser/base/content/test/general/browser_favicon_change_not_in_document.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; - -const TEST_URL = "http://mochi.test:8888/browser/browser/base/content/test/general/file_favicon_change_not_in_document.html" - -add_task(function*() { - let extraTab = gBrowser.selectedTab = gBrowser.addTab(); - let tabLoaded = promiseTabLoaded(extraTab); - extraTab.linkedBrowser.loadURI(TEST_URL); - let expectedFavicon = "http://example.org/one-icon"; - let haveChanged = new Promise.defer(); - let observer = new MutationObserver(function(mutations) { - for (let mut of mutations) { - if (mut.attributeName != "image") { - continue; - } - let imageVal = extraTab.getAttribute("image").replace(/#.*$/, ""); - if (!imageVal) { - // The value gets removed because it doesn't load. - continue; - } - is(imageVal, expectedFavicon, "Favicon image should correspond to expected image."); - haveChanged.resolve(); - } - }); - observer.observe(extraTab, {attributes: true}); - yield tabLoaded; - expectedFavicon = "http://example.org/yet-another-icon"; - haveChanged = new Promise.defer(); - yield haveChanged.promise; - observer.disconnect(); - gBrowser.removeTab(extraTab); -}); - - diff --git a/browser/base/content/test/general/browser_feed_discovery.js b/browser/base/content/test/general/browser_feed_discovery.js deleted file mode 100644 index 73dcef755..000000000 --- a/browser/base/content/test/general/browser_feed_discovery.js +++ /dev/null @@ -1,33 +0,0 @@ -const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/feed_discovery.html" - -/** Test for Bug 377611 **/ - -add_task(function* () { - // Open a new tab. - gBrowser.selectedTab = gBrowser.addTab(URL); - registerCleanupFunction(() => gBrowser.removeCurrentTab()); - - let browser = gBrowser.selectedBrowser; - yield BrowserTestUtils.browserLoaded(browser); - - let discovered = browser.feeds; - ok(discovered.length > 0, "some feeds should be discovered"); - - let feeds = {}; - for (let aFeed of discovered) { - feeds[aFeed.href] = true; - } - - yield ContentTask.spawn(browser, feeds, function* (contentFeeds) { - for (let aLink of content.document.getElementsByTagName("link")) { - // ignore real stylesheets, and anything without an href property - if (aLink.type != "text/css" && aLink.href) { - if (/bogus/i.test(aLink.title)) { - ok(!contentFeeds[aLink.href], "don't discover " + aLink.href); - } else { - ok(contentFeeds[aLink.href], "should discover " + aLink.href); - } - } - } - }); -}) diff --git a/browser/base/content/test/general/browser_findbarClose.js b/browser/base/content/test/general/browser_findbarClose.js deleted file mode 100644 index 53503073c..000000000 --- a/browser/base/content/test/general/browser_findbarClose.js +++ /dev/null @@ -1,35 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Tests find bar auto-close behavior - -var newTab; - -add_task(function* findbar_test() { - waitForExplicitFinish(); - newTab = gBrowser.addTab("about:blank"); - - let promise = ContentTask.spawn(newTab.linkedBrowser, null, function* () { - yield ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", false); - }); - newTab.linkedBrowser.loadURI("http://example.com/browser/" + - "browser/base/content/test/general/test_bug628179.html"); - yield promise; - - gFindBar.open(); - - yield new ContentTask.spawn(newTab.linkedBrowser, null, function* () { - let iframe = content.document.getElementById("iframe"); - let awaitLoad = ContentTaskUtils.waitForEvent(iframe, "load", false); - iframe.src = "http://example.org/"; - yield awaitLoad; - }); - - ok(!gFindBar.hidden, "the Find bar isn't hidden after the location of a " + - "subdocument changes"); - - gFindBar.close(); - gBrowser.removeTab(newTab); - finish(); -}); - diff --git a/browser/base/content/test/general/browser_focusonkeydown.js b/browser/base/content/test/general/browser_focusonkeydown.js deleted file mode 100644 index 5b3337203..000000000 --- a/browser/base/content/test/general/browser_focusonkeydown.js +++ /dev/null @@ -1,26 +0,0 @@ -add_task(function *() -{ - let keyUps = 0; - - yield BrowserTestUtils.openNewForegroundTab(gBrowser, "data:text/html,<body>"); - - gURLBar.focus(); - - window.addEventListener("keyup", function countKeyUps(event) { - window.removeEventListener("keyup", countKeyUps, true); - if (event.originalTarget == gURLBar.inputField) { - keyUps++; - } - }, true); - - gURLBar.addEventListener("keydown", function redirectFocus(event) { - gURLBar.removeEventListener("keydown", redirectFocus, true); - gBrowser.selectedBrowser.focus(); - }, true); - - EventUtils.synthesizeKey("v", { }); - - is(keyUps, 1, "Key up fired at url bar"); - - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_fullscreen-window-open.js b/browser/base/content/test/general/browser_fullscreen-window-open.js deleted file mode 100644 index 2624b754a..000000000 --- a/browser/base/content/test/general/browser_fullscreen-window-open.js +++ /dev/null @@ -1,347 +0,0 @@ -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -Components.utils.import("resource://gre/modules/Services.jsm"); - -var Cc = Components.classes; -var Ci = Components.interfaces; - -const PREF_DISABLE_OPEN_NEW_WINDOW = "browser.link.open_newwindow.disabled_in_fullscreen"; -const isOSX = (Services.appinfo.OS === "Darwin"); - -const TEST_FILE = "file_fullscreen-window-open.html"; -const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", - "http://127.0.0.1:8888/"); - -function test () { - waitForExplicitFinish(); - - Services.prefs.setBoolPref(PREF_DISABLE_OPEN_NEW_WINDOW, true); - - let newTab = gBrowser.addTab(gHttpTestRoot + TEST_FILE); - gBrowser.selectedTab = newTab; - - whenTabLoaded(newTab, function () { - // Enter browser fullscreen mode. - BrowserFullScreen(); - - runNextTest(); - }); -} - -registerCleanupFunction(function() { - // Exit browser fullscreen mode. - BrowserFullScreen(); - - gBrowser.removeCurrentTab(); - - Services.prefs.clearUserPref(PREF_DISABLE_OPEN_NEW_WINDOW); -}); - -var gTests = [ - test_open, - test_open_with_size, - test_open_with_pos, - test_open_with_outerSize, - test_open_with_innerSize, - test_open_with_dialog, - test_open_when_open_new_window_by_pref, - test_open_with_pref_to_disable_in_fullscreen, - test_open_from_chrome, -]; - -function runNextTest () { - let testCase = gTests.shift(); - if (testCase) { - executeSoon(testCase); - } - else { - finish(); - } -} - - -// Test for window.open() with no feature. -function test_open() { - waitForTabOpen({ - message: { - title: "test_open", - param: "", - }, - finalizeFn: function () {}, - }); -} - -// Test for window.open() with width/height. -function test_open_with_size() { - waitForTabOpen({ - message: { - title: "test_open_with_size", - param: "width=400,height=400", - }, - finalizeFn: function () {}, - }); -} - -// Test for window.open() with top/left. -function test_open_with_pos() { - waitForTabOpen({ - message: { - title: "test_open_with_pos", - param: "top=200,left=200", - }, - finalizeFn: function () {}, - }); -} - -// Test for window.open() with outerWidth/Height. -function test_open_with_outerSize() { - let [outerWidth, outerHeight] = [window.outerWidth, window.outerHeight]; - waitForTabOpen({ - message: { - title: "test_open_with_outerSize", - param: "outerWidth=200,outerHeight=200", - }, - successFn: function () { - is(window.outerWidth, outerWidth, "Don't change window.outerWidth."); - is(window.outerHeight, outerHeight, "Don't change window.outerHeight."); - }, - finalizeFn: function () {}, - }); -} - -// Test for window.open() with innerWidth/Height. -function test_open_with_innerSize() { - let [innerWidth, innerHeight] = [window.innerWidth, window.innerHeight]; - waitForTabOpen({ - message: { - title: "test_open_with_innerSize", - param: "innerWidth=200,innerHeight=200", - }, - successFn: function () { - is(window.innerWidth, innerWidth, "Don't change window.innerWidth."); - is(window.innerHeight, innerHeight, "Don't change window.innerHeight."); - }, - finalizeFn: function () {}, - }); -} - -// Test for window.open() with dialog. -function test_open_with_dialog() { - waitForTabOpen({ - message: { - title: "test_open_with_dialog", - param: "dialog=yes", - }, - finalizeFn: function () {}, - }); -} - -// Test for window.open() -// when "browser.link.open_newwindow" is nsIBrowserDOMWindow.OPEN_NEWWINDOW -function test_open_when_open_new_window_by_pref() { - const PREF_NAME = "browser.link.open_newwindow"; - Services.prefs.setIntPref(PREF_NAME, Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW); - is(Services.prefs.getIntPref(PREF_NAME), Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW, - PREF_NAME + " is nsIBrowserDOMWindow.OPEN_NEWWINDOW at this time"); - - waitForTabOpen({ - message: { - title: "test_open_when_open_new_window_by_pref", - param: "width=400,height=400", - }, - finalizeFn: function () { - Services.prefs.clearUserPref(PREF_NAME); - }, - }); -} - -// Test for the pref, "browser.link.open_newwindow.disabled_in_fullscreen" -function test_open_with_pref_to_disable_in_fullscreen() { - Services.prefs.setBoolPref(PREF_DISABLE_OPEN_NEW_WINDOW, false); - - waitForWindowOpen({ - message: { - title: "test_open_with_pref_disabled_in_fullscreen", - param: "width=400,height=400", - }, - finalizeFn: function () { - Services.prefs.setBoolPref(PREF_DISABLE_OPEN_NEW_WINDOW, true); - }, - }); -} - - -// Test for window.open() called from chrome context. -function test_open_from_chrome() { - waitForWindowOpenFromChrome({ - message: { - title: "test_open_from_chrome", - param: "", - }, - finalizeFn: function () {} - }); -} - -function waitForTabOpen(aOptions) { - let message = aOptions.message; - - if (!message.title) { - ok(false, "Can't get message.title."); - aOptions.finalizeFn(); - runNextTest(); - return; - } - - info("Running test: " + message.title); - - let onTabOpen = function onTabOpen(aEvent) { - gBrowser.tabContainer.removeEventListener("TabOpen", onTabOpen, true); - - let tab = aEvent.target; - whenTabLoaded(tab, function () { - is(tab.linkedBrowser.contentTitle, message.title, - "Opened Tab is expected: " + message.title); - - if (aOptions.successFn) { - aOptions.successFn(); - } - - gBrowser.removeTab(tab); - finalize(); - }); - } - gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, true); - - let finalize = function () { - aOptions.finalizeFn(); - info("Finished: " + message.title); - runNextTest(); - }; - - const URI = "data:text/html;charset=utf-8,<!DOCTYPE html><html><head><title>"+ - message.title + - "<%2Ftitle><%2Fhead><body><%2Fbody><%2Fhtml>"; - - executeWindowOpenInContent({ - uri: URI, - title: message.title, - option: message.param, - }); -} - - -function waitForWindowOpen(aOptions) { - let message = aOptions.message; - let url = aOptions.url || "about:blank"; - - if (!message.title) { - ok(false, "Can't get message.title"); - aOptions.finalizeFn(); - runNextTest(); - return; - } - - info("Running test: " + message.title); - - let onFinalize = function () { - aOptions.finalizeFn(); - - info("Finished: " + message.title); - runNextTest(); - }; - - let listener = new WindowListener(message.title, getBrowserURL(), { - onSuccess: aOptions.successFn, - onFinalize: onFinalize, - }); - Services.wm.addListener(listener); - - executeWindowOpenInContent({ - uri: url, - title: message.title, - option: message.param, - }); -} - -function executeWindowOpenInContent(aParam) { - ContentTask.spawn(gBrowser.selectedBrowser, JSON.stringify(aParam), function* (dataTestParam) { - let testElm = content.document.getElementById("test"); - testElm.setAttribute("data-test-param", dataTestParam); - testElm.click(); - }); -} - -function waitForWindowOpenFromChrome(aOptions) { - let message = aOptions.message; - let url = aOptions.url || "about:blank"; - - if (!message.title) { - ok(false, "Can't get message.title"); - aOptions.finalizeFn(); - runNextTest(); - return; - } - - info("Running test: " + message.title); - - let onFinalize = function () { - aOptions.finalizeFn(); - - info("Finished: " + message.title); - runNextTest(); - }; - - let listener = new WindowListener(message.title, getBrowserURL(), { - onSuccess: aOptions.successFn, - onFinalize: onFinalize, - }); - Services.wm.addListener(listener); - - window.open(url, message.title, message.option); -} - -function WindowListener(aTitle, aUrl, aCallBackObj) { - this.test_title = aTitle; - this.test_url = aUrl; - this.callback_onSuccess = aCallBackObj.onSuccess; - this.callBack_onFinalize = aCallBackObj.onFinalize; -} -WindowListener.prototype = { - - test_title: null, - test_url: null, - callback_onSuccess: null, - callBack_onFinalize: null, - - onOpenWindow: function(aXULWindow) { - Services.wm.removeListener(this); - - let domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindow); - let onLoad = aEvent => { - is(domwindow.document.location.href, this.test_url, - "Opened Window is expected: "+ this.test_title); - if (this.callback_onSuccess) { - this.callback_onSuccess(); - } - - domwindow.removeEventListener("load", onLoad, true); - - // wait for trasition to fullscreen on OSX Lion later - if (isOSX) { - setTimeout(function() { - domwindow.close(); - executeSoon(this.callBack_onFinalize); - }.bind(this), 3000); - } - else { - domwindow.close(); - executeSoon(this.callBack_onFinalize); - } - }; - domwindow.addEventListener("load", onLoad, true); - }, - onCloseWindow: function(aXULWindow) {}, - onWindowTitleChange: function(aXULWindow, aNewTitle) {}, - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediatorListener, - Ci.nsISupports]), -}; diff --git a/browser/base/content/test/general/browser_fxa_migrate.js b/browser/base/content/test/general/browser_fxa_migrate.js deleted file mode 100644 index 2faf9fb10..000000000 --- a/browser/base/content/test/general/browser_fxa_migrate.js +++ /dev/null @@ -1,18 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -const STATE_CHANGED_TOPIC = "fxa-migration:state-changed"; -const NOTIFICATION_TITLE = "fxa-migration"; - -var imports = {}; -Cu.import("resource://services-sync/FxaMigrator.jsm", imports); - -add_task(function* test() { - // Fake the state where we saw an EOL notification. - Services.obs.notifyObservers(null, STATE_CHANGED_TOPIC, null); - - let notificationBox = document.getElementById("global-notificationbox"); - Assert.ok(notificationBox.allNotifications.some(n => { - return n.getAttribute("value") == NOTIFICATION_TITLE; - }), "Disconnect notification should be present"); -}); diff --git a/browser/base/content/test/general/browser_fxa_oauth.html b/browser/base/content/test/general/browser_fxa_oauth.html deleted file mode 100644 index b31e7ceb4..000000000 --- a/browser/base/content/test/general/browser_fxa_oauth.html +++ /dev/null @@ -1,30 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <title>fxa_oauth_test</title> -</head> -<body> -<script> - window.onload = function() { - var event = new window.CustomEvent("WebChannelMessageToChrome", { - // Note: This intentionally sends an object instead of a string, to ensure both work - // (see browser_fxa_oauth_with_keys.html for the other test) - detail: { - id: "oauth_client_id", - message: { - command: "oauth_complete", - data: { - state: "state", - code: "code1", - closeWindow: "signin", - }, - }, - }, - }); - - window.dispatchEvent(event); - }; -</script> -</body> -</html> diff --git a/browser/base/content/test/general/browser_fxa_oauth.js b/browser/base/content/test/general/browser_fxa_oauth.js deleted file mode 100644 index 1f688bfa8..000000000 --- a/browser/base/content/test/general/browser_fxa_oauth.js +++ /dev/null @@ -1,327 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: this.docShell is null"); - -Cu.import("resource://gre/modules/Promise.jsm"); -Cu.import("resource://gre/modules/Task.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsOAuthClient", - "resource://gre/modules/FxAccountsOAuthClient.jsm"); - -const HTTP_PATH = "http://example.com"; -const HTTP_ENDPOINT = "/browser/browser/base/content/test/general/browser_fxa_oauth.html"; -const HTTP_ENDPOINT_WITH_KEYS = "/browser/browser/base/content/test/general/browser_fxa_oauth_with_keys.html"; - -var gTests = [ - { - desc: "FxA OAuth - should open a new tab, complete OAuth flow", - run: function () { - return new Promise(function(resolve, reject) { - let tabOpened = false; - let properURL = "http://example.com/browser/browser/base/content/test/general/browser_fxa_oauth.html"; - let queryStrings = [ - "action=signin", - "client_id=client_id", - "scope=", - "state=state", - "webChannelId=oauth_client_id", - ]; - queryStrings.sort(); - - waitForTab(function (tab) { - Assert.ok("Tab successfully opened"); - Assert.ok(gBrowser.currentURI.spec.split("?")[0], properURL, "Check URL without params"); - let actualURL = new URL(gBrowser.currentURI.spec); - let actualQueryStrings = actualURL.search.substring(1).split("&"); - actualQueryStrings.sort(); - Assert.equal(actualQueryStrings.length, queryStrings.length, "Check number of params"); - - for (let i = 0; i < queryStrings.length; i++) { - Assert.equal(actualQueryStrings[i], queryStrings[i], "Check parameter " + i); - } - - tabOpened = true; - }); - - let client = new FxAccountsOAuthClient({ - parameters: { - state: "state", - client_id: "client_id", - oauth_uri: HTTP_PATH, - content_uri: HTTP_PATH, - }, - authorizationEndpoint: HTTP_ENDPOINT - }); - - client.onComplete = function(tokenData) { - Assert.ok(tabOpened); - Assert.equal(tokenData.code, "code1"); - Assert.equal(tokenData.state, "state"); - resolve(); - }; - - client.onError = reject; - - client.launchWebFlow(); - }); - } - }, - { - desc: "FxA OAuth - should open a new tab, complete OAuth flow when forcing auth", - run: function () { - return new Promise(function(resolve, reject) { - let tabOpened = false; - let properURL = "http://example.com/browser/browser/base/content/test/general/browser_fxa_oauth.html"; - let queryStrings = [ - "action=force_auth", - "client_id=client_id", - "scope=", - "state=state", - "webChannelId=oauth_client_id", - "email=test%40invalid.com", - ]; - queryStrings.sort(); - - waitForTab(function (tab) { - Assert.ok("Tab successfully opened"); - Assert.ok(gBrowser.currentURI.spec.split("?")[0], properURL, "Check URL without params"); - - let actualURL = new URL(gBrowser.currentURI.spec); - let actualQueryStrings = actualURL.search.substring(1).split("&"); - actualQueryStrings.sort(); - Assert.equal(actualQueryStrings.length, queryStrings.length, "Check number of params"); - - for (let i = 0; i < queryStrings.length; i++) { - Assert.equal(actualQueryStrings[i], queryStrings[i], "Check parameter " + i); - } - - tabOpened = true; - }); - - let client = new FxAccountsOAuthClient({ - parameters: { - state: "state", - client_id: "client_id", - oauth_uri: HTTP_PATH, - content_uri: HTTP_PATH, - action: "force_auth", - email: "test@invalid.com" - }, - authorizationEndpoint: HTTP_ENDPOINT - }); - - client.onComplete = function(tokenData) { - Assert.ok(tabOpened); - Assert.equal(tokenData.code, "code1"); - Assert.equal(tokenData.state, "state"); - resolve(); - }; - - client.onError = reject; - - client.launchWebFlow(); - }); - } - }, - { - desc: "FxA OAuth - should receive an error when there's a state mismatch", - run: function () { - return new Promise(function(resolve, reject) { - let tabOpened = false; - - waitForTab(function (tab) { - Assert.ok("Tab successfully opened"); - - // It should have passed in the expected non-matching state value. - let queryString = gBrowser.currentURI.spec.split("?")[1]; - Assert.ok(queryString.indexOf('state=different-state') >= 0); - - tabOpened = true; - }); - - let client = new FxAccountsOAuthClient({ - parameters: { - state: "different-state", - client_id: "client_id", - oauth_uri: HTTP_PATH, - content_uri: HTTP_PATH, - }, - authorizationEndpoint: HTTP_ENDPOINT - }); - - client.onComplete = reject; - - client.onError = function(err) { - Assert.ok(tabOpened); - Assert.equal(err.message, "OAuth flow failed. State doesn't match"); - resolve(); - }; - - client.launchWebFlow(); - }); - } - }, - { - desc: "FxA OAuth - should be able to request keys during OAuth flow", - run: function () { - return new Promise(function(resolve, reject) { - let tabOpened = false; - - waitForTab(function (tab) { - Assert.ok("Tab successfully opened"); - - // It should have asked for keys. - let queryString = gBrowser.currentURI.spec.split('?')[1]; - Assert.ok(queryString.indexOf('keys=true') >= 0); - - tabOpened = true; - }); - - let client = new FxAccountsOAuthClient({ - parameters: { - state: "state", - client_id: "client_id", - oauth_uri: HTTP_PATH, - content_uri: HTTP_PATH, - keys: true, - }, - authorizationEndpoint: HTTP_ENDPOINT_WITH_KEYS - }); - - client.onComplete = function(tokenData, keys) { - Assert.ok(tabOpened); - Assert.equal(tokenData.code, "code1"); - Assert.equal(tokenData.state, "state"); - Assert.deepEqual(keys.kAr, {k: "kAr"}); - Assert.deepEqual(keys.kBr, {k: "kBr"}); - resolve(); - }; - - client.onError = reject; - - client.launchWebFlow(); - }); - } - }, - { - desc: "FxA OAuth - should not receive keys if not explicitly requested", - run: function () { - return new Promise(function(resolve, reject) { - let tabOpened = false; - - waitForTab(function (tab) { - Assert.ok("Tab successfully opened"); - - // It should not have asked for keys. - let queryString = gBrowser.currentURI.spec.split('?')[1]; - Assert.ok(queryString.indexOf('keys=true') == -1); - - tabOpened = true; - }); - - let client = new FxAccountsOAuthClient({ - parameters: { - state: "state", - client_id: "client_id", - oauth_uri: HTTP_PATH, - content_uri: HTTP_PATH - }, - // This endpoint will cause the completion message to contain keys. - authorizationEndpoint: HTTP_ENDPOINT_WITH_KEYS - }); - - client.onComplete = function(tokenData, keys) { - Assert.ok(tabOpened); - Assert.equal(tokenData.code, "code1"); - Assert.equal(tokenData.state, "state"); - Assert.strictEqual(keys, undefined); - resolve(); - }; - - client.onError = reject; - - client.launchWebFlow(); - }); - } - }, - { - desc: "FxA OAuth - should receive an error if keys could not be obtained", - run: function () { - return new Promise(function(resolve, reject) { - let tabOpened = false; - - waitForTab(function (tab) { - Assert.ok("Tab successfully opened"); - - // It should have asked for keys. - let queryString = gBrowser.currentURI.spec.split('?')[1]; - Assert.ok(queryString.indexOf('keys=true') >= 0); - - tabOpened = true; - }); - - let client = new FxAccountsOAuthClient({ - parameters: { - state: "state", - client_id: "client_id", - oauth_uri: HTTP_PATH, - content_uri: HTTP_PATH, - keys: true, - }, - // This endpoint will cause the completion message not to contain keys. - authorizationEndpoint: HTTP_ENDPOINT - }); - - client.onComplete = reject; - - client.onError = function(err) { - Assert.ok(tabOpened); - Assert.equal(err.message, "OAuth flow failed. Keys were not returned"); - resolve(); - }; - - client.launchWebFlow(); - }); - } - } -]; // gTests - -function waitForTab(aCallback) { - let container = gBrowser.tabContainer; - container.addEventListener("TabOpen", function tabOpener(event) { - container.removeEventListener("TabOpen", tabOpener, false); - gBrowser.addEventListener("load", function listener() { - gBrowser.removeEventListener("load", listener, true); - let tab = event.target; - aCallback(tab); - }, true); - }, false); -} - -function test() { - waitForExplicitFinish(); - - Task.spawn(function* () { - const webchannelWhitelistPref = "webchannel.allowObject.urlWhitelist"; - let origWhitelist = Services.prefs.getCharPref(webchannelWhitelistPref); - let newWhitelist = origWhitelist + " http://example.com"; - Services.prefs.setCharPref(webchannelWhitelistPref, newWhitelist); - try { - for (let testCase of gTests) { - info("Running: " + testCase.desc); - yield testCase.run(); - } - } finally { - Services.prefs.clearUserPref(webchannelWhitelistPref); - } - }).then(finish, ex => { - Assert.ok(false, "Unexpected Exception: " + ex); - finish(); - }); -} diff --git a/browser/base/content/test/general/browser_fxa_oauth_with_keys.html b/browser/base/content/test/general/browser_fxa_oauth_with_keys.html deleted file mode 100644 index 2c28f7088..000000000 --- a/browser/base/content/test/general/browser_fxa_oauth_with_keys.html +++ /dev/null @@ -1,33 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <title>fxa_oauth_test</title> -</head> -<body> -<script> - window.onload = function() { - var event = new window.CustomEvent("WebChannelMessageToChrome", { - // Note: This intentionally sends a string instead of an object, to ensure both work - // (see browser_fxa_oauth.html for the other test) - detail: JSON.stringify({ - id: "oauth_client_id", - message: { - command: "oauth_complete", - data: { - state: "state", - code: "code1", - closeWindow: "signin", - // Keys normally contain more information, but this is enough - // to keep Loop's tests happy. - keys: { kAr: { k: 'kAr' }, kBr: { k: 'kBr' }}, - }, - }, - }), - }); - - window.dispatchEvent(event); - }; -</script> -</body> -</html> diff --git a/browser/base/content/test/general/browser_fxa_web_channel.html b/browser/base/content/test/general/browser_fxa_web_channel.html deleted file mode 100644 index be5631ff1..000000000 --- a/browser/base/content/test/general/browser_fxa_web_channel.html +++ /dev/null @@ -1,138 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <title>fxa_web_channel_test</title> -</head> -<body> -<script> - var webChannelId = "account_updates_test"; - - window.onload = function() { - var testName = window.location.search.replace(/^\?/, ""); - - switch (testName) { - case "profile_change": - test_profile_change(); - break; - case "login": - test_login(); - break; - case "can_link_account": - test_can_link_account(); - break; - case "logout": - test_logout(); - break; - case "delete": - test_delete(); - break; - } - }; - - function test_profile_change() { - var event = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: webChannelId, - message: { - command: "profile:change", - data: { - uid: "abc123", - }, - }, - }), - }); - - window.dispatchEvent(event); - } - - function test_login() { - var event = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: webChannelId, - message: { - command: "fxaccounts:login", - data: { - authAt: Date.now(), - email: "testuser@testuser.com", - keyFetchToken: 'key_fetch_token', - sessionToken: 'session_token', - uid: 'uid', - unwrapBKey: 'unwrap_b_key', - verified: true, - }, - messageId: 1, - }, - }), - }); - - window.dispatchEvent(event); - } - - function test_can_link_account() { - window.addEventListener("WebChannelMessageToContent", function (e) { - // echo any responses from the browser back to the tests on the - // fxaccounts_webchannel_response_echo WebChannel. The tests are - // listening for events and do the appropriate checks. - var event = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: 'fxaccounts_webchannel_response_echo', - message: e.detail.message, - }) - }); - - window.dispatchEvent(event); - }, true); - - var event = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: webChannelId, - message: { - command: "fxaccounts:can_link_account", - data: { - email: "testuser@testuser.com", - }, - messageId: 2, - }, - }), - }); - - window.dispatchEvent(event); - } - - function test_logout() { - var event = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: webChannelId, - message: { - command: "fxaccounts:logout", - data: { - uid: 'uid' - }, - messageId: 3, - }, - }), - }); - - window.dispatchEvent(event); - } - - function test_delete() { - var event = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: webChannelId, - message: { - command: "fxaccounts:delete", - data: { - uid: 'uid' - }, - messageId: 4, - }, - }), - }); - - window.dispatchEvent(event); - } -</script> -</body> -</html> diff --git a/browser/base/content/test/general/browser_fxa_web_channel.js b/browser/base/content/test/general/browser_fxa_web_channel.js deleted file mode 100644 index eb0167ffb..000000000 --- a/browser/base/content/test/general/browser_fxa_web_channel.js +++ /dev/null @@ -1,210 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -Cu.import("resource://gre/modules/Promise.jsm"); -Cu.import("resource://gre/modules/Task.jsm"); - -XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function () { - return Components.utils.import("resource://gre/modules/FxAccountsCommon.js", {}); -}); - -XPCOMUtils.defineLazyModuleGetter(this, "WebChannel", - "resource://gre/modules/WebChannel.jsm"); - -// FxAccountsWebChannel isn't explicitly exported by FxAccountsWebChannel.jsm -// but we can get it here via a backstage pass. -var {FxAccountsWebChannel} = Components.utils.import("resource://gre/modules/FxAccountsWebChannel.jsm", {}); - -const TEST_HTTP_PATH = "http://example.com"; -const TEST_BASE_URL = TEST_HTTP_PATH + "/browser/browser/base/content/test/general/browser_fxa_web_channel.html"; -const TEST_CHANNEL_ID = "account_updates_test"; - -var gTests = [ - { - desc: "FxA Web Channel - should receive message about profile changes", - run: function* () { - let client = new FxAccountsWebChannel({ - content_uri: TEST_HTTP_PATH, - channel_id: TEST_CHANNEL_ID, - }); - let promiseObserver = new Promise((resolve, reject) => { - makeObserver(FxAccountsCommon.ON_PROFILE_CHANGE_NOTIFICATION, function (subject, topic, data) { - Assert.equal(data, "abc123"); - client.tearDown(); - resolve(); - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser: gBrowser, - url: TEST_BASE_URL + "?profile_change" - }, function* () { - yield promiseObserver; - }); - } - }, - { - desc: "fxa web channel - login messages should notify the fxAccounts object", - run: function* () { - - let promiseLogin = new Promise((resolve, reject) => { - let login = (accountData) => { - Assert.equal(typeof accountData.authAt, 'number'); - Assert.equal(accountData.email, 'testuser@testuser.com'); - Assert.equal(accountData.keyFetchToken, 'key_fetch_token'); - Assert.equal(accountData.sessionToken, 'session_token'); - Assert.equal(accountData.uid, 'uid'); - Assert.equal(accountData.unwrapBKey, 'unwrap_b_key'); - Assert.equal(accountData.verified, true); - - client.tearDown(); - resolve(); - }; - - let client = new FxAccountsWebChannel({ - content_uri: TEST_HTTP_PATH, - channel_id: TEST_CHANNEL_ID, - helpers: { - login: login - } - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser: gBrowser, - url: TEST_BASE_URL + "?login" - }, function* () { - yield promiseLogin; - }); - } - }, - { - desc: "fxa web channel - can_link_account messages should respond", - run: function* () { - let properUrl = TEST_BASE_URL + "?can_link_account"; - - let promiseEcho = new Promise((resolve, reject) => { - - let webChannelOrigin = Services.io.newURI(properUrl, null, null); - // responses sent to content are echoed back over the - // `fxaccounts_webchannel_response_echo` channel. Ensure the - // fxaccounts:can_link_account message is responded to. - let echoWebChannel = new WebChannel('fxaccounts_webchannel_response_echo', webChannelOrigin); - echoWebChannel.listen((webChannelId, message, target) => { - Assert.equal(message.command, 'fxaccounts:can_link_account'); - Assert.equal(message.messageId, 2); - Assert.equal(message.data.ok, true); - - client.tearDown(); - echoWebChannel.stopListening(); - - resolve(); - }); - - let client = new FxAccountsWebChannel({ - content_uri: TEST_HTTP_PATH, - channel_id: TEST_CHANNEL_ID, - helpers: { - shouldAllowRelink(acctName) { - return acctName === 'testuser@testuser.com'; - } - } - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser: gBrowser, - url: properUrl - }, function* () { - yield promiseEcho; - }); - } - }, - { - desc: "fxa web channel - logout messages should notify the fxAccounts object", - run: function* () { - let promiseLogout = new Promise((resolve, reject) => { - let logout = (uid) => { - Assert.equal(uid, 'uid'); - - client.tearDown(); - resolve(); - }; - - let client = new FxAccountsWebChannel({ - content_uri: TEST_HTTP_PATH, - channel_id: TEST_CHANNEL_ID, - helpers: { - logout: logout - } - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser: gBrowser, - url: TEST_BASE_URL + "?logout" - }, function* () { - yield promiseLogout; - }); - } - }, - { - desc: "fxa web channel - delete messages should notify the fxAccounts object", - run: function* () { - let promiseDelete = new Promise((resolve, reject) => { - let logout = (uid) => { - Assert.equal(uid, 'uid'); - - client.tearDown(); - resolve(); - }; - - let client = new FxAccountsWebChannel({ - content_uri: TEST_HTTP_PATH, - channel_id: TEST_CHANNEL_ID, - helpers: { - logout: logout - } - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser: gBrowser, - url: TEST_BASE_URL + "?delete" - }, function* () { - yield promiseDelete; - }); - } - } -]; // gTests - -function makeObserver(aObserveTopic, aObserveFunc) { - let callback = function (aSubject, aTopic, aData) { - if (aTopic == aObserveTopic) { - removeMe(); - aObserveFunc(aSubject, aTopic, aData); - } - }; - - function removeMe() { - Services.obs.removeObserver(callback, aObserveTopic); - } - - Services.obs.addObserver(callback, aObserveTopic, false); - return removeMe; -} - -function test() { - waitForExplicitFinish(); - - Task.spawn(function* () { - for (let testCase of gTests) { - info("Running: " + testCase.desc); - yield testCase.run(); - } - }).then(finish, ex => { - Assert.ok(false, "Unexpected Exception: " + ex); - finish(); - }); -} diff --git a/browser/base/content/test/general/browser_fxaccounts.js b/browser/base/content/test/general/browser_fxaccounts.js deleted file mode 100644 index 0f68286dc..000000000 --- a/browser/base/content/test/general/browser_fxaccounts.js +++ /dev/null @@ -1,261 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -var {Log} = Cu.import("resource://gre/modules/Log.jsm", {}); -var {Task} = Cu.import("resource://gre/modules/Task.jsm", {}); -var {fxAccounts} = Cu.import("resource://gre/modules/FxAccounts.jsm", {}); -var FxAccountsCommon = {}; -Cu.import("resource://gre/modules/FxAccountsCommon.js", FxAccountsCommon); - -const TEST_ROOT = "http://example.com/browser/browser/base/content/test/general/"; - -// instrument gFxAccounts to send observer notifications when it's done -// what it does. -(function() { - let unstubs = {}; // The original functions we stub out. - - // The stub functions. - let stubs = { - updateAppMenuItem: function() { - return unstubs['updateAppMenuItem'].call(gFxAccounts).then(() => { - Services.obs.notifyObservers(null, "test:browser_fxaccounts:updateAppMenuItem", null); - }); - }, - // Opening preferences is trickier than it should be as leaks are reported - // due to the promises it fires off at load time and there's no clear way to - // know when they are done. - // So just ensure openPreferences is called rather than whether it opens. - openPreferences: function() { - Services.obs.notifyObservers(null, "test:browser_fxaccounts:openPreferences", null); - } - }; - - for (let name in stubs) { - unstubs[name] = gFxAccounts[name]; - gFxAccounts[name] = stubs[name]; - } - // and undo our damage at the end. - registerCleanupFunction(() => { - for (let name in unstubs) { - gFxAccounts[name] = unstubs[name]; - } - stubs = unstubs = null; - }); -})(); - -// Other setup/cleanup -var newTab; - -Services.prefs.setCharPref("identity.fxaccounts.remote.signup.uri", - TEST_ROOT + "accounts_testRemoteCommands.html"); - -registerCleanupFunction(() => { - Services.prefs.clearUserPref("identity.fxaccounts.remote.signup.uri"); - Services.prefs.clearUserPref("identity.fxaccounts.remote.profile.uri"); - gBrowser.removeTab(newTab); -}); - -add_task(function* initialize() { - // Set a new tab with something other than about:blank, so it doesn't get reused. - // We must wait for it to load or the promiseTabOpen() call in the next test - // gets confused. - newTab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false}); - yield promiseTabLoaded(newTab); -}); - -// The elements we care about. -var panelUILabel = document.getElementById("PanelUI-fxa-label"); -var panelUIStatus = document.getElementById("PanelUI-fxa-status"); -var panelUIFooter = document.getElementById("PanelUI-footer-fxa"); - -// The tests -add_task(function* test_nouser() { - let user = yield fxAccounts.getSignedInUser(); - Assert.strictEqual(user, null, "start with no user signed in"); - let promiseUpdateDone = promiseObserver("test:browser_fxaccounts:updateAppMenuItem"); - Services.obs.notifyObservers(null, this.FxAccountsCommon.ONLOGOUT_NOTIFICATION, null); - yield promiseUpdateDone; - - // Check the world - the FxA footer area is visible as it is offering a signin. - Assert.ok(isFooterVisible()) - - Assert.equal(panelUILabel.getAttribute("label"), panelUIStatus.getAttribute("defaultlabel")); - Assert.equal(panelUIStatus.getAttribute("tooltiptext"), panelUIStatus.getAttribute("signedinTooltiptext")); - Assert.ok(!panelUIFooter.hasAttribute("fxastatus"), "no fxsstatus when signed out"); - Assert.ok(!panelUIFooter.hasAttribute("fxaprofileimage"), "no fxaprofileimage when signed out"); - - let promisePreferencesOpened = promiseObserver("test:browser_fxaccounts:openPreferences"); - panelUIStatus.click(); - yield promisePreferencesOpened; -}); - -/* -XXX - Bug 1191162 - need a better hawk mock story or this will leak in debug builds. - -add_task(function* test_unverifiedUser() { - let promiseUpdateDone = promiseObserver("test:browser_fxaccounts:updateAppMenuItem"); - yield setSignedInUser(false); // this will fire the observer that does the update. - yield promiseUpdateDone; - - // Check the world. - Assert.ok(isFooterVisible()) - - Assert.equal(panelUILabel.getAttribute("label"), "foo@example.com"); - Assert.equal(panelUIStatus.getAttribute("tooltiptext"), - panelUIStatus.getAttribute("signedinTooltiptext")); - Assert.equal(panelUIFooter.getAttribute("fxastatus"), "signedin"); - let promisePreferencesOpened = promiseObserver("test:browser_fxaccounts:openPreferences"); - panelUIStatus.click(); - yield promisePreferencesOpened - yield signOut(); -}); -*/ - -add_task(function* test_verifiedUserEmptyProfile() { - // We see 2 updateAppMenuItem() calls - one for the signedInUser and one after - // we first fetch the profile. We want them both to fire or we aren't testing - // the state we think we are testing. - let promiseUpdateDone = promiseObserver("test:browser_fxaccounts:updateAppMenuItem", 2); - gFxAccounts._cachedProfile = null; - configureProfileURL({}); // successful but empty profile. - yield setSignedInUser(true); // this will fire the observer that does the update. - yield promiseUpdateDone; - - // Check the world. - Assert.ok(isFooterVisible()) - Assert.equal(panelUILabel.getAttribute("label"), "foo@example.com"); - Assert.equal(panelUIStatus.getAttribute("tooltiptext"), - panelUIStatus.getAttribute("signedinTooltiptext")); - Assert.equal(panelUIFooter.getAttribute("fxastatus"), "signedin"); - - let promisePreferencesOpened = promiseObserver("test:browser_fxaccounts:openPreferences"); - panelUIStatus.click(); - yield promisePreferencesOpened; - yield signOut(); -}); - -add_task(function* test_verifiedUserDisplayName() { - let promiseUpdateDone = promiseObserver("test:browser_fxaccounts:updateAppMenuItem", 2); - gFxAccounts._cachedProfile = null; - configureProfileURL({ displayName: "Test User Display Name" }); - yield setSignedInUser(true); // this will fire the observer that does the update. - yield promiseUpdateDone; - - Assert.ok(isFooterVisible()) - Assert.equal(panelUILabel.getAttribute("label"), "Test User Display Name"); - Assert.equal(panelUIStatus.getAttribute("tooltiptext"), - panelUIStatus.getAttribute("signedinTooltiptext")); - Assert.equal(panelUIFooter.getAttribute("fxastatus"), "signedin"); - yield signOut(); -}); - -add_task(function* test_verifiedUserProfileFailure() { - // profile failure means only one observer fires. - let promiseUpdateDone = promiseObserver("test:browser_fxaccounts:updateAppMenuItem", 1); - gFxAccounts._cachedProfile = null; - configureProfileURL(null, 500); - yield setSignedInUser(true); // this will fire the observer that does the update. - yield promiseUpdateDone; - - Assert.ok(isFooterVisible()) - Assert.equal(panelUILabel.getAttribute("label"), "foo@example.com"); - Assert.equal(panelUIStatus.getAttribute("tooltiptext"), - panelUIStatus.getAttribute("signedinTooltiptext")); - Assert.equal(panelUIFooter.getAttribute("fxastatus"), "signedin"); - yield signOut(); -}); - -// Helpers. -function isFooterVisible() { - let style = window.getComputedStyle(panelUIFooter); - return style.getPropertyValue("display") == "flex"; -} - -function configureProfileURL(profile, responseStatus = 200) { - let responseBody = profile ? JSON.stringify(profile) : ""; - let url = TEST_ROOT + "fxa_profile_handler.sjs?" + - "responseStatus=" + responseStatus + - "responseBody=" + responseBody + - // This is a bit cheeky - the FxA code will just append "/profile" - // to the preference value. We arrange for this to be seen by our - // .sjs as part of the query string. - "&path="; - - Services.prefs.setCharPref("identity.fxaccounts.remote.profile.uri", url); -} - -function promiseObserver(topic, count = 1) { - return new Promise(resolve => { - let obs = (aSubject, aTopic, aData) => { - if (--count == 0) { - Services.obs.removeObserver(obs, aTopic); - resolve(aSubject); - } - } - Services.obs.addObserver(obs, topic, false); - }); -} - -// Stolen from browser_aboutHome.js -function promiseWaitForEvent(node, type, capturing) { - return new Promise((resolve) => { - node.addEventListener(type, function listener(event) { - node.removeEventListener(type, listener, capturing); - resolve(event); - }, capturing); - }); -} - -var promiseTabOpen = Task.async(function*(urlBase) { - info("Waiting for tab to open..."); - let event = yield promiseWaitForEvent(gBrowser.tabContainer, "TabOpen", true); - let tab = event.target; - yield promiseTabLoadEvent(tab); - ok(tab.linkedBrowser.currentURI.spec.startsWith(urlBase), - "Got " + tab.linkedBrowser.currentURI.spec + ", expecting " + urlBase); - let whenUnloaded = promiseTabUnloaded(tab); - gBrowser.removeTab(tab); - yield whenUnloaded; -}); - -function promiseTabUnloaded(tab) -{ - return new Promise(resolve => { - info("Wait for tab to unload"); - function handle(event) { - tab.linkedBrowser.removeEventListener("unload", handle, true); - info("Got unload event"); - resolve(event); - } - tab.linkedBrowser.addEventListener("unload", handle, true, true); - }); -} - -// FxAccounts helpers. -function setSignedInUser(verified) { - let data = { - email: "foo@example.com", - uid: "1234@lcip.org", - assertion: "foobar", - sessionToken: "dead", - kA: "beef", - kB: "cafe", - verified: verified, - - oauthTokens: { - // a token for the profile server. - profile: "key value", - } - } - return fxAccounts.setSignedInUser(data); -} - -var signOut = Task.async(function* () { - // This test needs to make sure that any updates for the logout have - // completed before starting the next test, or we see the observer - // notifications get out of sync. - let promiseUpdateDone = promiseObserver("test:browser_fxaccounts:updateAppMenuItem"); - // we always want a "localOnly" signout here... - yield fxAccounts.signOut(true); - yield promiseUpdateDone; -}); diff --git a/browser/base/content/test/general/browser_gZipOfflineChild.js b/browser/base/content/test/general/browser_gZipOfflineChild.js deleted file mode 100644 index 09691bed8..000000000 --- a/browser/base/content/test/general/browser_gZipOfflineChild.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/test_offline_gzip.html" - -registerCleanupFunction(function() { - // Clean up after ourself - let uri = Services.io.newURI(URL, null, null); - let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); - Services.perms.removeFromPrincipal(principal, "offline-app"); - Services.prefs.clearUserPref("offline-apps.allow_by_default"); -}); - -var cacheCount = 0; -var intervalID = 0; - -// -// Handle "message" events which are posted from the iframe upon -// offline cache events. -// -function handleMessageEvents(event) { - cacheCount++; - switch (cacheCount) { - case 1: - // This is the initial caching off offline data. - is(event.data, "oncache", "Child was successfully cached."); - // Reload the frame; this will generate an error message - // in the case of bug 501422. - event.source.location.reload(); - // Use setInterval to repeatedly call a function which - // checks that one of two things has occurred: either - // the offline cache is udpated (which means our iframe - // successfully reloaded), or the string "error" appears - // in the iframe, as in the case of bug 501422. - intervalID = setInterval(function() { - // Sometimes document.body may not exist, and trying to access - // it will throw an exception, so handle this case. - try { - var bodyInnerHTML = event.source.document.body.innerHTML; - } - catch (e) { - bodyInnerHTML = ""; - } - if (cacheCount == 2 || bodyInnerHTML.includes("error")) { - clearInterval(intervalID); - is(cacheCount, 2, "frame not reloaded successfully"); - if (cacheCount != 2) { - finish(); - } - } - }, 100); - break; - case 2: - is(event.data, "onupdate", "Child was successfully updated."); - clearInterval(intervalID); - finish(); - break; - default: - // how'd we get here? - ok(false, "cacheCount not 1 or 2"); - } -} - -function test() { - waitForExplicitFinish(); - - Services.prefs.setBoolPref("offline-apps.allow_by_default", true); - - // Open a new tab. - gBrowser.selectedTab = gBrowser.addTab(URL); - registerCleanupFunction(() => gBrowser.removeCurrentTab()); - - BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => { - let window = gBrowser.selectedBrowser.contentWindow; - - window.addEventListener("message", handleMessageEvents, false); - }); -} diff --git a/browser/base/content/test/general/browser_gestureSupport.js b/browser/base/content/test/general/browser_gestureSupport.js deleted file mode 100644 index b31cad31d..000000000 --- a/browser/base/content/test/general/browser_gestureSupport.js +++ /dev/null @@ -1,670 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -// Simple gestures tests -// -// These tests require the ability to disable the fact that the -// Firefox chrome intentionally prevents "simple gesture" events from -// reaching web content. - -var test_utils; -var test_commandset; -var test_prefBranch = "browser.gesture."; - -function test() -{ - waitForExplicitFinish(); - - // Disable the default gestures support during the test - gGestureSupport.init(false); - - test_utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - - // Run the tests of "simple gesture" events generally - test_EnsureConstantsAreDisjoint(); - test_TestEventListeners(); - test_TestEventCreation(); - - // Reenable the default gestures support. The remaining tests target - // the Firefox gesture functionality. - gGestureSupport.init(true); - - // Test Firefox's gestures support. - test_commandset = document.getElementById("mainCommandSet"); - test_swipeGestures(); - test_latchedGesture("pinch", "out", "in", "MozMagnifyGesture"); - test_thresholdGesture("pinch", "out", "in", "MozMagnifyGesture"); - test_rotateGestures(); -} - -var test_eventCount = 0; -var test_expectedType; -var test_expectedDirection; -var test_expectedDelta; -var test_expectedModifiers; -var test_expectedClickCount; -var test_imageTab; - -function test_gestureListener(evt) -{ - is(evt.type, test_expectedType, - "evt.type (" + evt.type + ") does not match expected value"); - is(evt.target, test_utils.elementFromPoint(20, 20, false, false), - "evt.target (" + evt.target + ") does not match expected value"); - is(evt.clientX, 20, - "evt.clientX (" + evt.clientX + ") does not match expected value"); - is(evt.clientY, 20, - "evt.clientY (" + evt.clientY + ") does not match expected value"); - isnot(evt.screenX, 0, - "evt.screenX (" + evt.screenX + ") does not match expected value"); - isnot(evt.screenY, 0, - "evt.screenY (" + evt.screenY + ") does not match expected value"); - - is(evt.direction, test_expectedDirection, - "evt.direction (" + evt.direction + ") does not match expected value"); - is(evt.delta, test_expectedDelta, - "evt.delta (" + evt.delta + ") does not match expected value"); - - is(evt.shiftKey, (test_expectedModifiers & Components.interfaces.nsIDOMEvent.SHIFT_MASK) != 0, - "evt.shiftKey did not match expected value"); - is(evt.ctrlKey, (test_expectedModifiers & Components.interfaces.nsIDOMEvent.CONTROL_MASK) != 0, - "evt.ctrlKey did not match expected value"); - is(evt.altKey, (test_expectedModifiers & Components.interfaces.nsIDOMEvent.ALT_MASK) != 0, - "evt.altKey did not match expected value"); - is(evt.metaKey, (test_expectedModifiers & Components.interfaces.nsIDOMEvent.META_MASK) != 0, - "evt.metaKey did not match expected value"); - - if (evt.type == "MozTapGesture") { - is(evt.clickCount, test_expectedClickCount, "evt.clickCount does not match"); - } - - test_eventCount++; -} - -function test_helper1(type, direction, delta, modifiers) -{ - // Setup the expected values - test_expectedType = type; - test_expectedDirection = direction; - test_expectedDelta = delta; - test_expectedModifiers = modifiers; - - let expectedEventCount = test_eventCount + 1; - - document.addEventListener(type, test_gestureListener, true); - test_utils.sendSimpleGestureEvent(type, 20, 20, direction, delta, modifiers); - document.removeEventListener(type, test_gestureListener, true); - - is(expectedEventCount, test_eventCount, "Event (" + type + ") was never received by event listener"); -} - -function test_clicks(type, clicks) -{ - // Setup the expected values - test_expectedType = type; - test_expectedDirection = 0; - test_expectedDelta = 0; - test_expectedModifiers = 0; - test_expectedClickCount = clicks; - - let expectedEventCount = test_eventCount + 1; - - document.addEventListener(type, test_gestureListener, true); - test_utils.sendSimpleGestureEvent(type, 20, 20, 0, 0, 0, clicks); - document.removeEventListener(type, test_gestureListener, true); - - is(expectedEventCount, test_eventCount, "Event (" + type + ") was never received by event listener"); -} - -function test_TestEventListeners() -{ - let e = test_helper1; // easier to type this name - - // Swipe gesture animation events - e("MozSwipeGestureStart", 0, -0.7, 0); - e("MozSwipeGestureUpdate", 0, -0.4, 0); - e("MozSwipeGestureEnd", 0, 0, 0); - e("MozSwipeGestureStart", 0, 0.6, 0); - e("MozSwipeGestureUpdate", 0, 0.3, 0); - e("MozSwipeGestureEnd", 0, 1, 0); - - // Swipe gesture event - e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_LEFT, 0.0, 0); - e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_RIGHT, 0.0, 0); - e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_UP, 0.0, 0); - e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_DOWN, 0.0, 0); - e("MozSwipeGesture", - SimpleGestureEvent.DIRECTION_UP | SimpleGestureEvent.DIRECTION_LEFT, 0.0, 0); - e("MozSwipeGesture", - SimpleGestureEvent.DIRECTION_DOWN | SimpleGestureEvent.DIRECTION_RIGHT, 0.0, 0); - e("MozSwipeGesture", - SimpleGestureEvent.DIRECTION_UP | SimpleGestureEvent.DIRECTION_RIGHT, 0.0, 0); - e("MozSwipeGesture", - SimpleGestureEvent.DIRECTION_DOWN | SimpleGestureEvent.DIRECTION_LEFT, 0.0, 0); - - // magnify gesture events - e("MozMagnifyGestureStart", 0, 50.0, 0); - e("MozMagnifyGestureUpdate", 0, -25.0, 0); - e("MozMagnifyGestureUpdate", 0, 5.0, 0); - e("MozMagnifyGesture", 0, 30.0, 0); - - // rotate gesture events - e("MozRotateGestureStart", SimpleGestureEvent.ROTATION_CLOCKWISE, 33.0, 0); - e("MozRotateGestureUpdate", SimpleGestureEvent.ROTATION_COUNTERCLOCKWISE, -13.0, 0); - e("MozRotateGestureUpdate", SimpleGestureEvent.ROTATION_CLOCKWISE, 13.0, 0); - e("MozRotateGesture", SimpleGestureEvent.ROTATION_CLOCKWISE, 33.0, 0); - - // Tap and presstap gesture events - test_clicks("MozTapGesture", 1); - test_clicks("MozTapGesture", 2); - test_clicks("MozTapGesture", 3); - test_clicks("MozPressTapGesture", 1); - - // simple delivery test for edgeui gestures - e("MozEdgeUIStarted", 0, 0, 0); - e("MozEdgeUICanceled", 0, 0, 0); - e("MozEdgeUICompleted", 0, 0, 0); - - // event.shiftKey - let modifier = Components.interfaces.nsIDOMEvent.SHIFT_MASK; - e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_RIGHT, 0, modifier); - - // event.metaKey - modifier = Components.interfaces.nsIDOMEvent.META_MASK; - e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_RIGHT, 0, modifier); - - // event.altKey - modifier = Components.interfaces.nsIDOMEvent.ALT_MASK; - e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_RIGHT, 0, modifier); - - // event.ctrlKey - modifier = Components.interfaces.nsIDOMEvent.CONTROL_MASK; - e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_RIGHT, 0, modifier); -} - -function test_eventDispatchListener(evt) -{ - test_eventCount++; - evt.stopPropagation(); -} - -function test_helper2(type, direction, delta, altKey, ctrlKey, shiftKey, metaKey) -{ - let event = null; - let successful; - - try { - event = document.createEvent("SimpleGestureEvent"); - successful = true; - } - catch (ex) { - successful = false; - } - ok(successful, "Unable to create SimpleGestureEvent"); - - try { - event.initSimpleGestureEvent(type, true, true, window, 1, - 10, 10, 10, 10, - ctrlKey, altKey, shiftKey, metaKey, - 1, window, - 0, direction, delta, 0); - successful = true; - } - catch (ex) { - successful = false; - } - ok(successful, "event.initSimpleGestureEvent should not fail"); - - // Make sure the event fields match the expected values - is(event.type, type, "Mismatch on evt.type"); - is(event.direction, direction, "Mismatch on evt.direction"); - is(event.delta, delta, "Mismatch on evt.delta"); - is(event.altKey, altKey, "Mismatch on evt.altKey"); - is(event.ctrlKey, ctrlKey, "Mismatch on evt.ctrlKey"); - is(event.shiftKey, shiftKey, "Mismatch on evt.shiftKey"); - is(event.metaKey, metaKey, "Mismatch on evt.metaKey"); - is(event.view, window, "Mismatch on evt.view"); - is(event.detail, 1, "Mismatch on evt.detail"); - is(event.clientX, 10, "Mismatch on evt.clientX"); - is(event.clientY, 10, "Mismatch on evt.clientY"); - is(event.screenX, 10, "Mismatch on evt.screenX"); - is(event.screenY, 10, "Mismatch on evt.screenY"); - is(event.button, 1, "Mismatch on evt.button"); - is(event.relatedTarget, window, "Mismatch on evt.relatedTarget"); - - // Test event dispatch - let expectedEventCount = test_eventCount + 1; - document.addEventListener(type, test_eventDispatchListener, true); - document.dispatchEvent(event); - document.removeEventListener(type, test_eventDispatchListener, true); - is(expectedEventCount, test_eventCount, "Dispatched event was never received by listener"); -} - -function test_TestEventCreation() -{ - // Event creation - test_helper2("MozMagnifyGesture", SimpleGestureEvent.DIRECTION_RIGHT, 20.0, - true, false, true, false); - test_helper2("MozMagnifyGesture", SimpleGestureEvent.DIRECTION_LEFT, -20.0, - false, true, false, true); -} - -function test_EnsureConstantsAreDisjoint() -{ - let up = SimpleGestureEvent.DIRECTION_UP; - let down = SimpleGestureEvent.DIRECTION_DOWN; - let left = SimpleGestureEvent.DIRECTION_LEFT; - let right = SimpleGestureEvent.DIRECTION_RIGHT; - - let clockwise = SimpleGestureEvent.ROTATION_CLOCKWISE; - let cclockwise = SimpleGestureEvent.ROTATION_COUNTERCLOCKWISE; - - ok(up ^ down, "DIRECTION_UP and DIRECTION_DOWN are not bitwise disjoint"); - ok(up ^ left, "DIRECTION_UP and DIRECTION_LEFT are not bitwise disjoint"); - ok(up ^ right, "DIRECTION_UP and DIRECTION_RIGHT are not bitwise disjoint"); - ok(down ^ left, "DIRECTION_DOWN and DIRECTION_LEFT are not bitwise disjoint"); - ok(down ^ right, "DIRECTION_DOWN and DIRECTION_RIGHT are not bitwise disjoint"); - ok(left ^ right, "DIRECTION_LEFT and DIRECTION_RIGHT are not bitwise disjoint"); - ok(clockwise ^ cclockwise, "ROTATION_CLOCKWISE and ROTATION_COUNTERCLOCKWISE are not bitwise disjoint"); -} - -// Helper for test of latched event processing. Emits the actual -// gesture events to test whether the commands associated with the -// gesture will only trigger once for each direction of movement. -function test_emitLatchedEvents(eventPrefix, initialDelta, cmd) -{ - let cumulativeDelta = 0; - let isIncreasing = initialDelta > 0; - - let expect = {}; - // Reset the call counters and initialize expected values - for (let dir in cmd) - cmd[dir].callCount = expect[dir] = 0; - - let check = (aDir, aMsg) => ok(cmd[aDir].callCount == expect[aDir], aMsg); - let checkBoth = function(aNum, aInc, aDec) { - let prefix = "Step " + aNum + ": "; - check("inc", prefix + aInc); - check("dec", prefix + aDec); - }; - - // Send the "Start" event. - test_utils.sendSimpleGestureEvent(eventPrefix + "Start", 0, 0, 0, initialDelta, 0); - cumulativeDelta += initialDelta; - if (isIncreasing) { - expect.inc++; - checkBoth(1, "Increasing command was not triggered", "Decreasing command was triggered"); - } else { - expect.dec++; - checkBoth(1, "Increasing command was triggered", "Decreasing command was not triggered"); - } - - // Send random values in the same direction and ensure neither - // command triggers. - for (let i = 0; i < 5; i++) { - let delta = Math.random() * (isIncreasing ? 100 : -100); - test_utils.sendSimpleGestureEvent(eventPrefix + "Update", 0, 0, 0, delta, 0); - cumulativeDelta += delta; - checkBoth(2, "Increasing command was triggered", "Decreasing command was triggered"); - } - - // Now go back in the opposite direction. - test_utils.sendSimpleGestureEvent(eventPrefix + "Update", 0, 0, 0, - - initialDelta, 0); - cumulativeDelta += - initialDelta; - if (isIncreasing) { - expect.dec++; - checkBoth(3, "Increasing command was triggered", "Decreasing command was not triggered"); - } else { - expect.inc++; - checkBoth(3, "Increasing command was not triggered", "Decreasing command was triggered"); - } - - // Send random values in the opposite direction and ensure neither - // command triggers. - for (let i = 0; i < 5; i++) { - let delta = Math.random() * (isIncreasing ? -100 : 100); - test_utils.sendSimpleGestureEvent(eventPrefix + "Update", 0, 0, 0, delta, 0); - cumulativeDelta += delta; - checkBoth(4, "Increasing command was triggered", "Decreasing command was triggered"); - } - - // Go back to the original direction. The original command should trigger. - test_utils.sendSimpleGestureEvent(eventPrefix + "Update", 0, 0, 0, - initialDelta, 0); - cumulativeDelta += initialDelta; - if (isIncreasing) { - expect.inc++; - checkBoth(5, "Increasing command was not triggered", "Decreasing command was triggered"); - } else { - expect.dec++; - checkBoth(5, "Increasing command was triggered", "Decreasing command was not triggered"); - } - - // Send the wrap-up event. No commands should be triggered. - test_utils.sendSimpleGestureEvent(eventPrefix, 0, 0, 0, cumulativeDelta, 0); - checkBoth(6, "Increasing command was triggered", "Decreasing command was triggered"); -} - -function test_addCommand(prefName, id) -{ - let cmd = test_commandset.appendChild(document.createElement("command")); - cmd.setAttribute("id", id); - cmd.setAttribute("oncommand", "this.callCount++;"); - - cmd.origPrefName = prefName; - cmd.origPrefValue = gPrefService.getCharPref(prefName); - gPrefService.setCharPref(prefName, id); - - return cmd; -} - -function test_removeCommand(cmd) -{ - gPrefService.setCharPref(cmd.origPrefName, cmd.origPrefValue); - test_commandset.removeChild(cmd); -} - -// Test whether latched events are only called once per direction of motion. -function test_latchedGesture(gesture, inc, dec, eventPrefix) -{ - let branch = test_prefBranch + gesture + "."; - - // Put the gesture into latched mode. - let oldLatchedValue = gPrefService.getBoolPref(branch + "latched"); - gPrefService.setBoolPref(branch + "latched", true); - - // Install the test commands for increasing and decreasing motion. - let cmd = { - inc: test_addCommand(branch + inc, "test:incMotion"), - dec: test_addCommand(branch + dec, "test:decMotion"), - }; - - // Test the gestures in each direction. - test_emitLatchedEvents(eventPrefix, 500, cmd); - test_emitLatchedEvents(eventPrefix, -500, cmd); - - // Restore the gesture to its original configuration. - gPrefService.setBoolPref(branch + "latched", oldLatchedValue); - for (let dir in cmd) - test_removeCommand(cmd[dir]); -} - -// Test whether non-latched events are triggered upon sufficient motion. -function test_thresholdGesture(gesture, inc, dec, eventPrefix) -{ - let branch = test_prefBranch + gesture + "."; - - // Disable latched mode for this gesture. - let oldLatchedValue = gPrefService.getBoolPref(branch + "latched"); - gPrefService.setBoolPref(branch + "latched", false); - - // Set the triggering threshold value to 50. - let oldThresholdValue = gPrefService.getIntPref(branch + "threshold"); - gPrefService.setIntPref(branch + "threshold", 50); - - // Install the test commands for increasing and decreasing motion. - let cmdInc = test_addCommand(branch + inc, "test:incMotion"); - let cmdDec = test_addCommand(branch + dec, "test:decMotion"); - - // Send the start event but stop short of triggering threshold. - cmdInc.callCount = cmdDec.callCount = 0; - test_utils.sendSimpleGestureEvent(eventPrefix + "Start", 0, 0, 0, 49.5, 0); - ok(cmdInc.callCount == 0, "Increasing command was triggered"); - ok(cmdDec.callCount == 0, "Decreasing command was triggered"); - - // Now trigger the threshold. - cmdInc.callCount = cmdDec.callCount = 0; - test_utils.sendSimpleGestureEvent(eventPrefix + "Update", 0, 0, 0, 1, 0); - ok(cmdInc.callCount == 1, "Increasing command was not triggered"); - ok(cmdDec.callCount == 0, "Decreasing command was triggered"); - - // The tracking counter should go to zero. Go back the other way and - // stop short of triggering the threshold. - cmdInc.callCount = cmdDec.callCount = 0; - test_utils.sendSimpleGestureEvent(eventPrefix + "Update", 0, 0, 0, -49.5, 0); - ok(cmdInc.callCount == 0, "Increasing command was triggered"); - ok(cmdDec.callCount == 0, "Decreasing command was triggered"); - - // Now cross the threshold and trigger the decreasing command. - cmdInc.callCount = cmdDec.callCount = 0; - test_utils.sendSimpleGestureEvent(eventPrefix + "Update", 0, 0, 0, -1.5, 0); - ok(cmdInc.callCount == 0, "Increasing command was triggered"); - ok(cmdDec.callCount == 1, "Decreasing command was not triggered"); - - // Send the wrap-up event. No commands should trigger. - cmdInc.callCount = cmdDec.callCount = 0; - test_utils.sendSimpleGestureEvent(eventPrefix, 0, 0, 0, -0.5, 0); - ok(cmdInc.callCount == 0, "Increasing command was triggered"); - ok(cmdDec.callCount == 0, "Decreasing command was triggered"); - - // Restore the gesture to its original configuration. - gPrefService.setBoolPref(branch + "latched", oldLatchedValue); - gPrefService.setIntPref(branch + "threshold", oldThresholdValue); - test_removeCommand(cmdInc); - test_removeCommand(cmdDec); -} - -function test_swipeGestures() -{ - // easier to type names for the direction constants - let up = SimpleGestureEvent.DIRECTION_UP; - let down = SimpleGestureEvent.DIRECTION_DOWN; - let left = SimpleGestureEvent.DIRECTION_LEFT; - let right = SimpleGestureEvent.DIRECTION_RIGHT; - - let branch = test_prefBranch + "swipe."; - - // Install the test commands for the swipe gestures. - let cmdUp = test_addCommand(branch + "up", "test:swipeUp"); - let cmdDown = test_addCommand(branch + "down", "test:swipeDown"); - let cmdLeft = test_addCommand(branch + "left", "test:swipeLeft"); - let cmdRight = test_addCommand(branch + "right", "test:swipeRight"); - - function resetCounts() { - cmdUp.callCount = 0; - cmdDown.callCount = 0; - cmdLeft.callCount = 0; - cmdRight.callCount = 0; - } - - // UP - resetCounts(); - test_utils.sendSimpleGestureEvent("MozSwipeGesture", 0, 0, up, 0, 0); - ok(cmdUp.callCount == 1, "Step 1: Up command was not triggered"); - ok(cmdDown.callCount == 0, "Step 1: Down command was triggered"); - ok(cmdLeft.callCount == 0, "Step 1: Left command was triggered"); - ok(cmdRight.callCount == 0, "Step 1: Right command was triggered"); - - // DOWN - resetCounts(); - test_utils.sendSimpleGestureEvent("MozSwipeGesture", 0, 0, down, 0, 0); - ok(cmdUp.callCount == 0, "Step 2: Up command was triggered"); - ok(cmdDown.callCount == 1, "Step 2: Down command was not triggered"); - ok(cmdLeft.callCount == 0, "Step 2: Left command was triggered"); - ok(cmdRight.callCount == 0, "Step 2: Right command was triggered"); - - // LEFT - resetCounts(); - test_utils.sendSimpleGestureEvent("MozSwipeGesture", 0, 0, left, 0, 0); - ok(cmdUp.callCount == 0, "Step 3: Up command was triggered"); - ok(cmdDown.callCount == 0, "Step 3: Down command was triggered"); - ok(cmdLeft.callCount == 1, "Step 3: Left command was not triggered"); - ok(cmdRight.callCount == 0, "Step 3: Right command was triggered"); - - // RIGHT - resetCounts(); - test_utils.sendSimpleGestureEvent("MozSwipeGesture", 0, 0, right, 0, 0); - ok(cmdUp.callCount == 0, "Step 4: Up command was triggered"); - ok(cmdDown.callCount == 0, "Step 4: Down command was triggered"); - ok(cmdLeft.callCount == 0, "Step 4: Left command was triggered"); - ok(cmdRight.callCount == 1, "Step 4: Right command was not triggered"); - - // Make sure combinations do not trigger events. - let combos = [ up | left, up | right, down | left, down | right]; - for (let i = 0; i < combos.length; i++) { - resetCounts(); - test_utils.sendSimpleGestureEvent("MozSwipeGesture", 0, 0, combos[i], 0, 0); - ok(cmdUp.callCount == 0, "Step 5-"+i+": Up command was triggered"); - ok(cmdDown.callCount == 0, "Step 5-"+i+": Down command was triggered"); - ok(cmdLeft.callCount == 0, "Step 5-"+i+": Left command was triggered"); - ok(cmdRight.callCount == 0, "Step 5-"+i+": Right command was triggered"); - } - - // Remove the test commands. - test_removeCommand(cmdUp); - test_removeCommand(cmdDown); - test_removeCommand(cmdLeft); - test_removeCommand(cmdRight); -} - - -function test_rotateHelperGetImageRotation(aImageElement) -{ - // Get the true image rotation from the transform matrix, bounded - // to 0 <= result < 360 - let transformValue = content.window.getComputedStyle(aImageElement, null) - .transform; - if (transformValue == "none") - return 0; - - transformValue = transformValue.split("(")[1] - .split(")")[0] - .split(","); - var rotation = Math.round(Math.atan2(transformValue[1], transformValue[0]) * - (180 / Math.PI)); - return (rotation < 0 ? rotation + 360 : rotation); -} - -function test_rotateHelperOneGesture(aImageElement, aCurrentRotation, - aDirection, aAmount, aStop) -{ - if (aAmount <= 0 || aAmount > 90) // Bound to 0 < aAmount <= 90 - return; - - // easier to type names for the direction constants - let clockwise = SimpleGestureEvent.ROTATION_CLOCKWISE; - - let delta = aAmount * (aDirection == clockwise ? 1 : -1); - - // Kill transition time on image so test isn't wrong and doesn't take 10 seconds - aImageElement.style.transitionDuration = "0s"; - - // Start the gesture, perform an update, and force flush - test_utils.sendSimpleGestureEvent("MozRotateGestureStart", 0, 0, aDirection, .001, 0); - test_utils.sendSimpleGestureEvent("MozRotateGestureUpdate", 0, 0, aDirection, delta, 0); - aImageElement.clientTop; - - // If stop, check intermediate - if (aStop) { - // Send near-zero-delta to stop, and force flush - test_utils.sendSimpleGestureEvent("MozRotateGestureUpdate", 0, 0, aDirection, .001, 0); - aImageElement.clientTop; - - let stopExpectedRotation = (aCurrentRotation + delta) % 360; - if (stopExpectedRotation < 0) - stopExpectedRotation += 360; - - is(stopExpectedRotation, test_rotateHelperGetImageRotation(aImageElement), - "Image rotation at gesture stop/hold: expected=" + stopExpectedRotation + - ", observed=" + test_rotateHelperGetImageRotation(aImageElement) + - ", init=" + aCurrentRotation + - ", amt=" + aAmount + - ", dir=" + (aDirection == clockwise ? "cl" : "ccl")); - } - // End it and force flush - test_utils.sendSimpleGestureEvent("MozRotateGesture", 0, 0, aDirection, 0, 0); - aImageElement.clientTop; - - let finalExpectedRotation; - - if (aAmount < 45 && aStop) { - // Rotate a bit, then stop. Expect no change at end of gesture. - finalExpectedRotation = aCurrentRotation; - } - else { - // Either not stopping (expect 90 degree change in aDirection), OR - // stopping but after 45, (expect 90 degree change in aDirection) - finalExpectedRotation = (aCurrentRotation + - (aDirection == clockwise ? 1 : -1) * 90) % 360; - if (finalExpectedRotation < 0) - finalExpectedRotation += 360; - } - - is(finalExpectedRotation, test_rotateHelperGetImageRotation(aImageElement), - "Image rotation gesture end: expected=" + finalExpectedRotation + - ", observed=" + test_rotateHelperGetImageRotation(aImageElement) + - ", init=" + aCurrentRotation + - ", amt=" + aAmount + - ", dir=" + (aDirection == clockwise ? "cl" : "ccl")); -} - -function test_rotateGesturesOnTab() -{ - gBrowser.selectedBrowser.removeEventListener("load", test_rotateGesturesOnTab, true); - - if (!(content.document instanceof ImageDocument)) { - ok(false, "Image document failed to open for rotation testing"); - gBrowser.removeTab(test_imageTab); - finish(); - return; - } - - // easier to type names for the direction constants - let cl = SimpleGestureEvent.ROTATION_CLOCKWISE; - let ccl = SimpleGestureEvent.ROTATION_COUNTERCLOCKWISE; - - let imgElem = content.document.body && - content.document.body.firstElementChild; - - if (!imgElem) { - ok(false, "Could not get image element on ImageDocument for rotation!"); - gBrowser.removeTab(test_imageTab); - finish(); - return; - } - - // Quick function to normalize rotation to 0 <= r < 360 - var normRot = function(rotation) { - rotation = rotation % 360; - if (rotation < 0) - rotation += 360; - return rotation; - } - - for (var initRot = 0; initRot < 360; initRot += 90) { - // Test each case: at each 90 degree snap; cl/ccl; - // amount more or less than 45; stop and hold or don't (32 total tests) - // The amount added to the initRot is where it is expected to be - test_rotateHelperOneGesture(imgElem, normRot(initRot + 0), cl, 35, true ); - test_rotateHelperOneGesture(imgElem, normRot(initRot + 0), cl, 35, false); - test_rotateHelperOneGesture(imgElem, normRot(initRot + 90), cl, 55, true ); - test_rotateHelperOneGesture(imgElem, normRot(initRot + 180), cl, 55, false); - test_rotateHelperOneGesture(imgElem, normRot(initRot + 270), ccl, 35, true ); - test_rotateHelperOneGesture(imgElem, normRot(initRot + 270), ccl, 35, false); - test_rotateHelperOneGesture(imgElem, normRot(initRot + 180), ccl, 55, true ); - test_rotateHelperOneGesture(imgElem, normRot(initRot + 90), ccl, 55, false); - - // Manually rotate it 90 degrees clockwise to prepare for next iteration, - // and force flush - test_utils.sendSimpleGestureEvent("MozRotateGestureStart", 0, 0, cl, .001, 0); - test_utils.sendSimpleGestureEvent("MozRotateGestureUpdate", 0, 0, cl, 90, 0); - test_utils.sendSimpleGestureEvent("MozRotateGestureUpdate", 0, 0, cl, .001, 0); - test_utils.sendSimpleGestureEvent("MozRotateGesture", 0, 0, cl, 0, 0); - imgElem.clientTop; - } - - gBrowser.removeTab(test_imageTab); - test_imageTab = null; - finish(); -} - -function test_rotateGestures() -{ - test_imageTab = gBrowser.addTab("chrome://branding/content/about-logo.png"); - gBrowser.selectedTab = test_imageTab; - - gBrowser.selectedBrowser.addEventListener("load", test_rotateGesturesOnTab, true); -} diff --git a/browser/base/content/test/general/browser_getshortcutoruri.js b/browser/base/content/test/general/browser_getshortcutoruri.js deleted file mode 100644 index 9ebf8e9ca..000000000 --- a/browser/base/content/test/general/browser_getshortcutoruri.js +++ /dev/null @@ -1,143 +0,0 @@ -function getPostDataString(aIS) { - if (!aIS) - return null; - - var sis = Cc["@mozilla.org/scriptableinputstream;1"]. - createInstance(Ci.nsIScriptableInputStream); - sis.init(aIS); - var dataLines = sis.read(aIS.available()).split("\n"); - - // only want the last line - return dataLines[dataLines.length-1]; -} - -function keywordResult(aURL, aPostData, aIsUnsafe) { - this.url = aURL; - this.postData = aPostData; - this.isUnsafe = aIsUnsafe; -} - -function keyWordData() {} -keyWordData.prototype = { - init: function(aKeyWord, aURL, aPostData, aSearchWord) { - this.keyword = aKeyWord; - this.uri = makeURI(aURL); - this.postData = aPostData; - this.searchWord = aSearchWord; - - this.method = (this.postData ? "POST" : "GET"); - } -} - -function bmKeywordData(aKeyWord, aURL, aPostData, aSearchWord) { - this.init(aKeyWord, aURL, aPostData, aSearchWord); -} -bmKeywordData.prototype = new keyWordData(); - -function searchKeywordData(aKeyWord, aURL, aPostData, aSearchWord) { - this.init(aKeyWord, aURL, aPostData, aSearchWord); -} -searchKeywordData.prototype = new keyWordData(); - -var testData = [ - [new bmKeywordData("bmget", "http://bmget/search=%s", null, "foo"), - new keywordResult("http://bmget/search=foo", null)], - - [new bmKeywordData("bmpost", "http://bmpost/", "search=%s", "foo2"), - new keywordResult("http://bmpost/", "search=foo2")], - - [new bmKeywordData("bmpostget", "http://bmpostget/search1=%s", "search2=%s", "foo3"), - new keywordResult("http://bmpostget/search1=foo3", "search2=foo3")], - - [new bmKeywordData("bmget-nosearch", "http://bmget-nosearch/", null, ""), - new keywordResult("http://bmget-nosearch/", null)], - - [new searchKeywordData("searchget", "http://searchget/?search={searchTerms}", null, "foo4"), - new keywordResult("http://searchget/?search=foo4", null, true)], - - [new searchKeywordData("searchpost", "http://searchpost/", "search={searchTerms}", "foo5"), - new keywordResult("http://searchpost/", "search=foo5", true)], - - [new searchKeywordData("searchpostget", "http://searchpostget/?search1={searchTerms}", "search2={searchTerms}", "foo6"), - new keywordResult("http://searchpostget/?search1=foo6", "search2=foo6", true)], - - // Bookmark keywords that don't take parameters should not be activated if a - // parameter is passed (bug 420328). - [new bmKeywordData("bmget-noparam", "http://bmget-noparam/", null, "foo7"), - new keywordResult(null, null, true)], - [new bmKeywordData("bmpost-noparam", "http://bmpost-noparam/", "not_a=param", "foo8"), - new keywordResult(null, null, true)], - - // Test escaping (%s = escaped, %S = raw) - // UTF-8 default - [new bmKeywordData("bmget-escaping", "http://bmget/?esc=%s&raw=%S", null, "foé"), - new keywordResult("http://bmget/?esc=fo%C3%A9&raw=foé", null)], - // Explicitly-defined ISO-8859-1 - [new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "foé"), - new keywordResult("http://bmget/?esc=fo%E9&raw=foé", null)], - - // Bug 359809: Test escaping +, /, and @ - // UTF-8 default - [new bmKeywordData("bmget-escaping", "http://bmget/?esc=%s&raw=%S", null, "+/@"), - new keywordResult("http://bmget/?esc=%2B%2F%40&raw=+/@", null)], - // Explicitly-defined ISO-8859-1 - [new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "+/@"), - new keywordResult("http://bmget/?esc=%2B%2F%40&raw=+/@", null)], - - // Test using a non-bmKeywordData object, to test the behavior of - // getShortcutOrURIAndPostData for non-keywords (setupKeywords only adds keywords for - // bmKeywordData objects) - [{keyword: "http://gavinsharp.com"}, - new keywordResult(null, null, true)] -]; - -add_task(function* test_getshortcutoruri() { - yield setupKeywords(); - - for (let item of testData) { - let [data, result] = item; - - let query = data.keyword; - if (data.searchWord) - query += " " + data.searchWord; - let returnedData = yield getShortcutOrURIAndPostData(query); - // null result.url means we should expect the same query we sent in - let expected = result.url || query; - is(returnedData.url, expected, "got correct URL for " + data.keyword); - is(getPostDataString(returnedData.postData), result.postData, "got correct postData for " + data.keyword); - is(returnedData.mayInheritPrincipal, !result.isUnsafe, "got correct mayInheritPrincipal for " + data.keyword); - } - - yield cleanupKeywords(); -}); - -var folder = null; -var gAddedEngines = []; - -function* setupKeywords() { - folder = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid, - type: PlacesUtils.bookmarks.TYPE_FOLDER, - title: "keyword-test" }); - for (let item of testData) { - let data = item[0]; - if (data instanceof bmKeywordData) { - yield PlacesUtils.bookmarks.insert({ url: data.uri, parentGuid: folder.guid }); - yield PlacesUtils.keywords.insert({ keyword: data.keyword, url: data.uri.spec, postData: data.postData }); - } - - if (data instanceof searchKeywordData) { - Services.search.addEngineWithDetails(data.keyword, "", data.keyword, "", data.method, data.uri.spec); - let addedEngine = Services.search.getEngineByName(data.keyword); - if (data.postData) { - let [paramName, paramValue] = data.postData.split("="); - addedEngine.addParam(paramName, paramValue, null); - } - gAddedEngines.push(addedEngine); - } - } -} - -function* cleanupKeywords() { - PlacesUtils.bookmarks.remove(folder); - gAddedEngines.map(Services.search.removeEngine); -} diff --git a/browser/base/content/test/general/browser_hide_removing.js b/browser/base/content/test/general/browser_hide_removing.js deleted file mode 100644 index be62e2d89..000000000 --- a/browser/base/content/test/general/browser_hide_removing.js +++ /dev/null @@ -1,39 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -// Bug 587922: tabs don't get removed if they're hidden - -function test() { - waitForExplicitFinish(); - - // Add a tab that will get removed and hidden - let testTab = gBrowser.addTab("about:blank", {skipAnimation: true}); - is(gBrowser.visibleTabs.length, 2, "just added a tab, so 2 tabs"); - gBrowser.selectedTab = testTab; - - let numVisBeforeHide, numVisAfterHide; - gBrowser.tabContainer.addEventListener("TabSelect", function() { - gBrowser.tabContainer.removeEventListener("TabSelect", arguments.callee, false); - - // While the next tab is being selected, hide the removing tab - numVisBeforeHide = gBrowser.visibleTabs.length; - gBrowser.hideTab(testTab); - numVisAfterHide = gBrowser.visibleTabs.length; - }, false); - gBrowser.removeTab(testTab, {animate: true}); - - // Make sure the tab gets removed at the end of the animation by polling - (function checkRemoved() { - return setTimeout(function() { - if (gBrowser.tabs.length != 1) { - checkRemoved(); - return; - } - - is(numVisBeforeHide, 1, "animated remove has in 1 tab left"); - is(numVisAfterHide, 1, "hiding a removing tab is also has 1 tab"); - finish(); - }, 50); - })(); -} diff --git a/browser/base/content/test/general/browser_homeDrop.js b/browser/base/content/test/general/browser_homeDrop.js deleted file mode 100644 index 6e87963d5..000000000 --- a/browser/base/content/test/general/browser_homeDrop.js +++ /dev/null @@ -1,90 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -add_task(function*() { - let HOMEPAGE_PREF = "browser.startup.homepage"; - - let homepageStr = Cc["@mozilla.org/supports-string;1"] - .createInstance(Ci.nsISupportsString); - homepageStr.data = "about:mozilla"; - yield pushPrefs([HOMEPAGE_PREF, homepageStr, Ci.nsISupportsString]); - - let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let EventUtils = {}; - scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils); - - // Since synthesizeDrop triggers the srcElement, need to use another button. - let dragSrcElement = document.getElementById("downloads-button"); - ok(dragSrcElement, "Downloads button exists"); - let homeButton = document.getElementById("home-button"); - ok(homeButton, "home button present"); - - function* drop(dragData, homepage) { - let setHomepageDialogPromise = BrowserTestUtils.domWindowOpened(); - - EventUtils.synthesizeDrop(dragSrcElement, homeButton, dragData, "copy", window); - - let setHomepageDialog = yield setHomepageDialogPromise; - ok(true, "dialog appeared in response to home button drop"); - yield BrowserTestUtils.waitForEvent(setHomepageDialog, "load", false); - - let setHomepagePromise = new Promise(function(resolve) { - let observer = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), - observe: function(subject, topic, data) { - is(topic, "nsPref:changed", "observed correct topic"); - is(data, HOMEPAGE_PREF, "observed correct data"); - let modified = Services.prefs.getComplexValue(HOMEPAGE_PREF, - Ci.nsISupportsString); - is(modified.data, homepage, "homepage is set correctly"); - Services.prefs.removeObserver(HOMEPAGE_PREF, observer); - - Services.prefs.setComplexValue(HOMEPAGE_PREF, - Ci.nsISupportsString, homepageStr); - - resolve(); - } - }; - Services.prefs.addObserver(HOMEPAGE_PREF, observer, false); - }); - - setHomepageDialog.document.documentElement.acceptDialog(); - - yield setHomepagePromise; - } - - function dropInvalidURI() { - return new Promise(resolve => { - let consoleListener = { - observe: function (m) { - if (m.message.includes("NS_ERROR_DOM_BAD_URI")) { - ok(true, "drop was blocked"); - resolve(); - } - } - }; - Services.console.registerListener(consoleListener); - registerCleanupFunction(function () { - Services.console.unregisterListener(consoleListener); - }); - - executeSoon(function () { - info("Attempting second drop, of a javascript: URI"); - // The drop handler throws an exception when dragging URIs that inherit - // principal, e.g. javascript: - expectUncaughtException(); - EventUtils.synthesizeDrop(dragSrcElement, homeButton, [[{type: "text/plain", data: "javascript:8888"}]], "copy", window); - }); - }); - } - - yield* drop([[{type: "text/plain", - data: "http://mochi.test:8888/"}]], - "http://mochi.test:8888/"); - yield* drop([[{type: "text/plain", - data: "http://mochi.test:8888/\nhttp://mochi.test:8888/b\nhttp://mochi.test:8888/c"}]], - "http://mochi.test:8888/|http://mochi.test:8888/b|http://mochi.test:8888/c"); - yield dropInvalidURI(); -}); - diff --git a/browser/base/content/test/general/browser_identity_UI.js b/browser/base/content/test/general/browser_identity_UI.js deleted file mode 100644 index 5aacb2e79..000000000 --- a/browser/base/content/test/general/browser_identity_UI.js +++ /dev/null @@ -1,146 +0,0 @@ -/* Tests for correct behaviour of getEffectiveHost on identity handler */ - -function test() { - waitForExplicitFinish(); - requestLongerTimeout(2); - - ok(gIdentityHandler, "gIdentityHandler should exist"); - - BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", true).then(() => { - gBrowser.selectedBrowser.addEventListener("load", checkResult, true); - nextTest(); - }); -} - -// Greek IDN for 'example.test'. -var idnDomain = "\u03C0\u03B1\u03C1\u03AC\u03B4\u03B5\u03B9\u03B3\u03BC\u03B1.\u03B4\u03BF\u03BA\u03B9\u03BC\u03AE"; -var tests = [ - { - name: "normal domain", - location: "http://test1.example.org/", - effectiveHost: "test1.example.org" - }, - { - name: "view-source", - location: "view-source:http://example.com/", - effectiveHost: null - }, - { - name: "normal HTTPS", - location: "https://example.com/", - effectiveHost: "example.com", - isHTTPS: true - }, - { - name: "IDN subdomain", - location: "http://sub1." + idnDomain + "/", - effectiveHost: "sub1." + idnDomain - }, - { - name: "subdomain with port", - location: "http://sub1.test1.example.org:8000/", - effectiveHost: "sub1.test1.example.org" - }, - { - name: "subdomain HTTPS", - location: "https://test1.example.com/", - effectiveHost: "test1.example.com", - isHTTPS: true - }, - { - name: "view-source HTTPS", - location: "view-source:https://example.com/", - effectiveHost: null, - isHTTPS: true - }, - { - name: "IP address", - location: "http://127.0.0.1:8888/", - effectiveHost: "127.0.0.1" - }, -] - -var gCurrentTest, gCurrentTestIndex = -1, gTestDesc, gPopupHidden; -// Go through the tests in both directions, to add additional coverage for -// transitions between different states. -var gForward = true; -var gCheckETLD = false; -function nextTest() { - if (!gCheckETLD) { - if (gForward) - gCurrentTestIndex++; - else - gCurrentTestIndex--; - - if (gCurrentTestIndex == tests.length) { - // Went too far, reverse - gCurrentTestIndex--; - gForward = false; - } - - if (gCurrentTestIndex == -1) { - gBrowser.selectedBrowser.removeEventListener("load", checkResult, true); - gBrowser.removeCurrentTab(); - finish(); - return; - } - - gCurrentTest = tests[gCurrentTestIndex]; - gTestDesc = "#" + gCurrentTestIndex + " (" + gCurrentTest.name + ")"; - if (!gForward) - gTestDesc += " (second time)"; - if (gCurrentTest.isHTTPS) { - gCheckETLD = true; - } - - // Navigate to the next page, which will cause checkResult to fire. - let spec = gBrowser.selectedBrowser.currentURI.spec; - if (spec == "about:blank" || spec == gCurrentTest.location) { - BrowserTestUtils.loadURI(gBrowser.selectedBrowser, gCurrentTest.location); - } else { - // Open the Control Center and make sure it closes after nav (Bug 1207542). - let popupShown = promisePopupShown(gIdentityHandler._identityPopup); - gPopupHidden = promisePopupHidden(gIdentityHandler._identityPopup); - gIdentityHandler._identityBox.click(); - info("Waiting for the Control Center to be shown"); - popupShown.then(() => { - is_element_visible(gIdentityHandler._identityPopup, "Control Center is visible"); - // Show the subview, which is an easy way in automation to reproduce - // Bug 1207542, where the CC wouldn't close on navigation. - gBrowser.ownerDocument.querySelector("#identity-popup-security-expander").click(); - BrowserTestUtils.loadURI(gBrowser.selectedBrowser, gCurrentTest.location); - }); - } - } else { - gCheckETLD = false; - gTestDesc = "#" + gCurrentTestIndex + " (" + gCurrentTest.name + " without eTLD in identity icon label)"; - if (!gForward) - gTestDesc += " (second time)"; - gBrowser.selectedBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE | - Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY); - } -} - -function checkResult() { - // Sanity check other values, and the value of gIdentityHandler.getEffectiveHost() - is(gIdentityHandler._uri.spec, gCurrentTest.location, "location matches for test " + gTestDesc); - // getEffectiveHost can't be called for all modes - if (gCurrentTest.effectiveHost === null) { - let identityBox = document.getElementById("identity-box"); - ok(identityBox.className == "unknownIdentity" || - identityBox.className == "chromeUI", "mode matched"); - } else { - is(gIdentityHandler.getEffectiveHost(), gCurrentTest.effectiveHost, "effectiveHost matches for test " + gTestDesc); - } - - if (gPopupHidden) { - info("Waiting for the Control Center to hide"); - gPopupHidden.then(() => { - gPopupHidden = null; - is_element_hidden(gIdentityHandler._identityPopup, "control center is hidden"); - executeSoon(nextTest); - }); - } else { - executeSoon(nextTest); - } -} diff --git a/browser/base/content/test/general/browser_insecureLoginForms.js b/browser/base/content/test/general/browser_insecureLoginForms.js deleted file mode 100644 index 72db7dbe6..000000000 --- a/browser/base/content/test/general/browser_insecureLoginForms.js +++ /dev/null @@ -1,162 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Load directly from the browser-chrome support files of login tests. -const TEST_URL_PATH = "/browser/toolkit/components/passwordmgr/test/browser/"; - -/** - * Waits for the given number of occurrences of InsecureLoginFormsStateChange - * on the given browser element. - */ -function waitForInsecureLoginFormsStateChange(browser, count) { - return BrowserTestUtils.waitForEvent(browser, "InsecureLoginFormsStateChange", - false, () => --count == 0); -} - -/** - * Checks the insecure login forms logic for the identity block. - */ -add_task(function* test_simple() { - yield new Promise(resolve => SpecialPowers.pushPrefEnv({ - "set": [["security.insecure_password.ui.enabled", true]], - }, resolve)); - - for (let [origin, expectWarning] of [ - ["http://example.com", true], - ["http://127.0.0.1", false], - ["https://example.com", false], - ]) { - let testUrlPath = origin + TEST_URL_PATH; - let tab = gBrowser.addTab(testUrlPath + "form_basic.html"); - let browser = tab.linkedBrowser; - yield Promise.all([ - BrowserTestUtils.switchTab(gBrowser, tab), - BrowserTestUtils.browserLoaded(browser), - // One event is triggered by pageshow and one by DOMFormHasPassword. - waitForInsecureLoginFormsStateChange(browser, 2), - ]); - - let { gIdentityHandler } = gBrowser.ownerGlobal; - gIdentityHandler._identityBox.click(); - document.getElementById("identity-popup-security-expander").click(); - - if (expectWarning) { - is_element_visible(document.getElementById("connection-icon")); - let connectionIconImage = gBrowser.ownerGlobal - .getComputedStyle(document.getElementById("connection-icon"), "") - .getPropertyValue("list-style-image"); - let securityViewBG = gBrowser.ownerGlobal - .getComputedStyle(document.getElementById("identity-popup-securityView"), "") - .getPropertyValue("background-image"); - let securityContentBG = gBrowser.ownerGlobal - .getComputedStyle(document.getElementById("identity-popup-security-content"), "") - .getPropertyValue("background-image"); - is(connectionIconImage, - "url(\"chrome://browser/skin/connection-mixed-active-loaded.svg#icon\")", - "Using expected icon image in the identity block"); - is(securityViewBG, - "url(\"chrome://browser/skin/controlcenter/mcb-disabled.svg\")", - "Using expected icon image in the Control Center main view"); - is(securityContentBG, - "url(\"chrome://browser/skin/controlcenter/mcb-disabled.svg\")", - "Using expected icon image in the Control Center subview"); - is(Array.filter(document.querySelectorAll("[observes=identity-popup-insecure-login-forms-learn-more]"), - element => !is_hidden(element)).length, 1, - "The 'Learn more' link should be visible once."); - } - - // Messages should be visible when the scheme is HTTP, and invisible when - // the scheme is HTTPS. - is(Array.every(document.querySelectorAll("[when-loginforms=insecure]"), - element => !is_hidden(element)), - expectWarning, - "The relevant messages should be visible or hidden."); - - gIdentityHandler._identityPopup.hidden = true; - gBrowser.removeTab(tab); - } -}); - -/** - * Checks that the insecure login forms logic does not regress mixed content - * blocking messages when mixed active content is loaded. - */ -add_task(function* test_mixedcontent() { - yield new Promise(resolve => SpecialPowers.pushPrefEnv({ - "set": [["security.mixed_content.block_active_content", false]], - }, resolve)); - - // Load the page with the subframe in a new tab. - let testUrlPath = "://example.com" + TEST_URL_PATH; - let tab = gBrowser.addTab("https" + testUrlPath + "insecure_test.html"); - let browser = tab.linkedBrowser; - yield Promise.all([ - BrowserTestUtils.switchTab(gBrowser, tab), - BrowserTestUtils.browserLoaded(browser), - // Two events are triggered by pageshow and one by DOMFormHasPassword. - waitForInsecureLoginFormsStateChange(browser, 3), - ]); - - assertMixedContentBlockingState(browser, { activeLoaded: true, - activeBlocked: false, - passiveLoaded: false }); - - gBrowser.removeTab(tab); -}); - -/** - * Checks that insecure window.opener does not trigger a warning. - */ -add_task(function* test_ignoring_window_opener() { - let newTabURL = "https://example.com" + TEST_URL_PATH + "form_basic.html"; - let path = getRootDirectory(gTestPath) - .replace("chrome://mochitests/content", "http://example.com"); - let url = path + "insecure_opener.html"; - - yield BrowserTestUtils.withNewTab(url, function*(browser) { - // Clicking the link will spawn a new tab. - let loaded = BrowserTestUtils.waitForNewTab(gBrowser, newTabURL); - yield ContentTask.spawn(browser, {}, function() { - content.document.getElementById("link").click(); - }); - let tab = yield loaded; - browser = tab.linkedBrowser; - yield waitForInsecureLoginFormsStateChange(browser, 2); - - // Open the identity popup. - let { gIdentityHandler } = gBrowser.ownerGlobal; - gIdentityHandler._identityBox.click(); - document.getElementById("identity-popup-security-expander").click(); - - ok(is_visible(document.getElementById("connection-icon")), - "Connection icon is visible"); - - // Assert that the identity indicators are still "secure". - let connectionIconImage = gBrowser.ownerGlobal - .getComputedStyle(document.getElementById("connection-icon")) - .getPropertyValue("list-style-image"); - let securityViewBG = gBrowser.ownerGlobal - .getComputedStyle(document.getElementById("identity-popup-securityView")) - .getPropertyValue("background-image"); - let securityContentBG = gBrowser.ownerGlobal - .getComputedStyle(document.getElementById("identity-popup-security-content")) - .getPropertyValue("background-image"); - is(connectionIconImage, - "url(\"chrome://browser/skin/connection-secure.svg\")", - "Using expected icon image in the identity block"); - is(securityViewBG, - "url(\"chrome://browser/skin/controlcenter/connection.svg#connection-secure\")", - "Using expected icon image in the Control Center main view"); - is(securityContentBG, - "url(\"chrome://browser/skin/controlcenter/connection.svg#connection-secure\")", - "Using expected icon image in the Control Center subview"); - - ok(Array.every(document.querySelectorAll("[when-loginforms=insecure]"), - element => is_hidden(element)), - "All messages should be hidden."); - - gIdentityHandler._identityPopup.hidden = true; - - yield BrowserTestUtils.removeTab(tab); - }); -}); diff --git a/browser/base/content/test/general/browser_invalid_uri_back_forward_manipulation.js b/browser/base/content/test/general/browser_invalid_uri_back_forward_manipulation.js deleted file mode 100644 index 8e69e781b..000000000 --- a/browser/base/content/test/general/browser_invalid_uri_back_forward_manipulation.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; - - -/** - * Verify that loading an invalid URI does not clobber a previously-loaded page's history - * entry, but that the invalid URI gets its own history entry instead. We're checking this - * using nsIWebNavigation's canGoBack, as well as actually going back and then checking - * canGoForward. - */ -add_task(function* checkBackFromInvalidURI() { - yield pushPrefs(["keyword.enabled", false]); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots", true); - gURLBar.value = "::2600"; - gURLBar.focus(); - - let promiseErrorPageLoaded = new Promise(resolve => { - tab.linkedBrowser.addEventListener("DOMContentLoaded", function onLoad() { - tab.linkedBrowser.removeEventListener("DOMContentLoaded", onLoad, false, true); - resolve(); - }, false, true); - }); - EventUtils.synthesizeKey("VK_RETURN", {}); - yield promiseErrorPageLoaded; - - ok(gBrowser.webNavigation.canGoBack, "Should be able to go back"); - if (gBrowser.webNavigation.canGoBack) { - // Can't use DOMContentLoaded here because the page is bfcached. Can't use pageshow for - // the error page because it doesn't seem to fire for those. - let promiseOtherPageLoaded = BrowserTestUtils.waitForEvent(tab.linkedBrowser, "pageshow", false, - // Be paranoid we *are* actually seeing this other page load, not some kind of race - // for if/when we do start firing pageshow for the error page... - function(e) { return gBrowser.currentURI.spec == "about:robots" } - ); - gBrowser.goBack(); - yield promiseOtherPageLoaded; - ok(gBrowser.webNavigation.canGoForward, "Should be able to go forward from previous page."); - } - yield BrowserTestUtils.removeTab(tab); -}); diff --git a/browser/base/content/test/general/browser_keywordBookmarklets.js b/browser/base/content/test/general/browser_keywordBookmarklets.js deleted file mode 100644 index 5e94733fe..000000000 --- a/browser/base/content/test/general/browser_keywordBookmarklets.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict" - -add_task(function* test_keyword_bookmarklet() { - let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid, - title: "bookmarklet", - url: "javascript:'1';" }); - let tab = gBrowser.selectedTab = gBrowser.addTab(); - registerCleanupFunction (function* () { - gBrowser.removeTab(tab); - yield PlacesUtils.bookmarks.remove(bm); - }); - yield promisePageShow(); - let originalPrincipal = gBrowser.contentPrincipal; - - function getPrincipalURI() { - return ContentTask.spawn(tab.linkedBrowser, null, function() { - return content.document.nodePrincipal.URI.spec; - }); - } - - let originalPrincipalURI = yield getPrincipalURI(); - - yield PlacesUtils.keywords.insert({ keyword: "bm", url: "javascript:'1';" }) - - // Enter bookmarklet keyword in the URL bar - gURLBar.value = "bm"; - gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); - - yield promisePageShow(); - - let newPrincipalURI = yield getPrincipalURI(); - is(newPrincipalURI, originalPrincipalURI, "content has the same principal"); - - // In e10s, null principals don't round-trip so the same null principal sent - // from the child will be a new null principal. Verify that this is the - // case. - if (tab.linkedBrowser.isRemoteBrowser) { - ok(originalPrincipal.isNullPrincipal && gBrowser.contentPrincipal.isNullPrincipal, - "both principals should be null principals in the parent"); - } else { - ok(gBrowser.contentPrincipal.equals(originalPrincipal), - "javascript bookmarklet should inherit principal"); - } -}); - -function* promisePageShow() { - return new Promise(resolve => { - gBrowser.selectedBrowser.addEventListener("pageshow", function listen() { - gBrowser.selectedBrowser.removeEventListener("pageshow", listen); - resolve(); - }); - }); -} diff --git a/browser/base/content/test/general/browser_keywordSearch.js b/browser/base/content/test/general/browser_keywordSearch.js deleted file mode 100644 index cf8bd0c0e..000000000 --- a/browser/base/content/test/general/browser_keywordSearch.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - **/ - -var gTests = [ - { - name: "normal search (search service)", - testText: "test search", - searchURL: Services.search.defaultEngine.getSubmission("test search", null, "keyword").uri.spec - }, - { - name: "?-prefixed search (search service)", - testText: "? foo ", - searchURL: Services.search.defaultEngine.getSubmission("foo", null, "keyword").uri.spec - } -]; - -function test() { - waitForExplicitFinish(); - - let windowObserver = { - observe: function(aSubject, aTopic, aData) { - if (aTopic == "domwindowopened") { - ok(false, "Alert window opened"); - let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); - win.addEventListener("load", function() { - win.removeEventListener("load", arguments.callee, false); - win.close(); - }, false); - executeSoon(finish); - } - } - }; - - Services.ww.registerNotification(windowObserver); - - let tab = gBrowser.selectedTab = gBrowser.addTab(); - - let listener = { - onStateChange: function onLocationChange(webProgress, req, flags, status) { - // Only care about document starts - let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT | - Ci.nsIWebProgressListener.STATE_START; - if (!(flags & docStart)) - return; - - info("received document start"); - - ok(req instanceof Ci.nsIChannel, "req is a channel"); - is(req.originalURI.spec, gCurrTest.searchURL, "search URL was loaded"); - info("Actual URI: " + req.URI.spec); - - req.cancel(Components.results.NS_ERROR_FAILURE); - - executeSoon(nextTest); - } - }; - gBrowser.addProgressListener(listener); - - registerCleanupFunction(function () { - Services.ww.unregisterNotification(windowObserver); - - gBrowser.removeProgressListener(listener); - gBrowser.removeTab(tab); - }); - - nextTest(); -} - -var gCurrTest; -function nextTest() { - if (gTests.length) { - gCurrTest = gTests.shift(); - doTest(); - } else { - finish(); - } -} - -function doTest() { - info("Running test: " + gCurrTest.name); - - // Simulate a user entering search terms - gURLBar.value = gCurrTest.testText; - gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); -} diff --git a/browser/base/content/test/general/browser_keywordSearch_postData.js b/browser/base/content/test/general/browser_keywordSearch_postData.js deleted file mode 100644 index 3f700fa58..000000000 --- a/browser/base/content/test/general/browser_keywordSearch_postData.js +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - **/ - -var gTests = [ - { - name: "normal search (search service)", - testText: "test search", - expectText: "test+search" - }, - { - name: "?-prefixed search (search service)", - testText: "? foo ", - expectText: "foo" - } -]; - -function test() { - waitForExplicitFinish(); - - let tab = gBrowser.selectedTab = gBrowser.addTab(); - - let searchObserver = function search_observer(aSubject, aTopic, aData) { - let engine = aSubject.QueryInterface(Ci.nsISearchEngine); - info("Observer: " + aData + " for " + engine.name); - - if (aData != "engine-added") - return; - - if (engine.name != "POST Search") - return; - - Services.search.defaultEngine = engine; - - registerCleanupFunction(function () { - Services.search.removeEngine(engine); - }); - - // ready to execute the tests! - executeSoon(nextTest); - }; - - Services.obs.addObserver(searchObserver, "browser-search-engine-modified", false); - - registerCleanupFunction(function () { - gBrowser.removeTab(tab); - - Services.obs.removeObserver(searchObserver, "browser-search-engine-modified"); - }); - - Services.search.addEngine("http://test:80/browser/browser/base/content/test/general/POSTSearchEngine.xml", - null, null, false); -} - -var gCurrTest; -function nextTest() { - if (gTests.length) { - gCurrTest = gTests.shift(); - doTest(); - } else { - finish(); - } -} - -function doTest() { - info("Running test: " + gCurrTest.name); - - waitForLoad(function () { - let loadedText = gBrowser.contentDocument.body.textContent; - ok(loadedText, "search page loaded"); - let needle = "searchterms=" + gCurrTest.expectText; - is(loadedText, needle, "The query POST data should be returned in the response"); - nextTest(); - }); - - // Simulate a user entering search terms - gURLBar.value = gCurrTest.testText; - gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); -} - - -function waitForLoad(cb) { - let browser = gBrowser.selectedBrowser; - browser.addEventListener("load", function listener() { - if (browser.currentURI.spec == "about:blank") - return; - info("Page loaded: " + browser.currentURI.spec); - browser.removeEventListener("load", listener, true); - - cb(); - }, true); -} diff --git a/browser/base/content/test/general/browser_lastAccessedTab.js b/browser/base/content/test/general/browser_lastAccessedTab.js deleted file mode 100644 index 57bd330ae..000000000 --- a/browser/base/content/test/general/browser_lastAccessedTab.js +++ /dev/null @@ -1,47 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -// gBrowser.selectedTab.lastAccessed and Date.now() called from this test can't -// run concurrently, and therefore don't always match exactly. -const CURRENT_TIME_TOLERANCE_MS = 15; - -function isCurrent(tab, msg) { - const DIFF = Math.abs(Date.now() - tab.lastAccessed); - ok(DIFF <= CURRENT_TIME_TOLERANCE_MS, msg + " (difference: " + DIFF + ")"); -} - -function nextStep(fn) { - setTimeout(fn, CURRENT_TIME_TOLERANCE_MS + 10); -} - -var originalTab; -var newTab; - -function test() { - waitForExplicitFinish(); - - originalTab = gBrowser.selectedTab; - nextStep(step2); -} - -function step2() { - isCurrent(originalTab, "selected tab has the current timestamp"); - newTab = gBrowser.addTab("about:blank", {skipAnimation: true}); - nextStep(step3); -} - -function step3() { - ok(newTab.lastAccessed < Date.now(), "new tab hasn't been selected so far"); - gBrowser.selectedTab = newTab; - isCurrent(newTab, "new tab has the current timestamp after being selected"); - nextStep(step4); -} - -function step4() { - ok(originalTab.lastAccessed < Date.now(), - "original tab has old timestamp after being deselected"); - isCurrent(newTab, "new tab has the current timestamp since it's still selected"); - - gBrowser.removeTab(newTab); - finish(); -} diff --git a/browser/base/content/test/general/browser_mcb_redirect.js b/browser/base/content/test/general/browser_mcb_redirect.js deleted file mode 100644 index 41b4e9468..000000000 --- a/browser/base/content/test/general/browser_mcb_redirect.js +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Description of the Tests for - * - Bug 418354 - Call Mixed content blocking on redirects - * - * Single redirect script tests - * 1. Load a script over https inside an https page - * - the server responds with a 302 redirect to a >> HTTP << script - * - the doorhanger should appear! - * - * 2. Load a script over https inside an http page - * - the server responds with a 302 redirect to a >> HTTP << script - * - the doorhanger should not appear! - * - * Single redirect image tests - * 3. Load an image over https inside an https page - * - the server responds with a 302 redirect to a >> HTTP << image - * - the image should not load - * - * 4. Load an image over https inside an http page - * - the server responds with a 302 redirect to a >> HTTP << image - * - the image should load and get cached - * - * Single redirect cached image tests - * 5. Using offline mode to ensure we hit the cache, load a cached image over - * https inside an http page - * - the server would have responded with a 302 redirect to a >> HTTP << - * image, but instead we try to use the cached image. - * - the image should load - * - * 6. Using offline mode to ensure we hit the cache, load a cached image over - * https inside an https page - * - the server would have responded with a 302 redirect to a >> HTTP << - * image, but instead we try to use the cached image. - * - the image should not load - * - * Double redirect image test - * 7. Load an image over https inside an http page - * - the server responds with a 302 redirect to a >> HTTP << server - * - the HTTP server responds with a 302 redirect to a >> HTTPS << image - * - the image should load and get cached - * - * Double redirect cached image tests - * 8. Using offline mode to ensure we hit the cache, load a cached image over - * https inside an http page - * - the image would have gone through two redirects: HTTPS->HTTP->HTTPS, - * but instead we try to use the cached image. - * - the image should load - * - * 9. Using offline mode to ensure we hit the cache, load a cached image over - * https inside an https page - * - the image would have gone through two redirects: HTTPS->HTTP->HTTPS, - * but instead we try to use the cached image. - * - the image should not load - */ - -const PREF_ACTIVE = "security.mixed_content.block_active_content"; -const PREF_DISPLAY = "security.mixed_content.block_display_content"; -const gHttpsTestRoot = "https://example.com/browser/browser/base/content/test/general/"; -const gHttpTestRoot = "http://example.com/browser/browser/base/content/test/general/"; - -var origBlockActive; -var origBlockDisplay; -var gTestBrowser = null; - -// ------------------------ Helper Functions --------------------- - -registerCleanupFunction(function() { - // Set preferences back to their original values - Services.prefs.setBoolPref(PREF_ACTIVE, origBlockActive); - Services.prefs.setBoolPref(PREF_DISPLAY, origBlockDisplay); - - // Make sure we are online again - Services.io.offline = false; -}); - -function cleanUpAfterTests() { - gBrowser.removeCurrentTab(); - window.focus(); - finish(); -} - -function waitForCondition(condition, nextTest, errorMsg, okMsg) { - var tries = 0; - var interval = setInterval(function() { - if (tries >= 30) { - ok(false, errorMsg); - moveOn(); - } - if (condition()) { - ok(true, okMsg) - moveOn(); - } - tries++; - }, 500); - var moveOn = function() { - clearInterval(interval); nextTest(); - }; -} - -// ------------------------ Test 1 ------------------------------ - -function test1() { - gTestBrowser.addEventListener("load", checkUIForTest1, true); - var url = gHttpsTestRoot + "test_mcb_redirect.html" - gTestBrowser.contentWindow.location = url; -} - -function checkUIForTest1() { - gTestBrowser.removeEventListener("load", checkUIForTest1, true); - - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); - - var expected = "script blocked"; - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test2, "Error: Waited too long for status in Test 1!", - "OK: Expected result in innerHTML for Test1!"); -} - -// ------------------------ Test 2 ------------------------------ - -function test2() { - gTestBrowser.addEventListener("load", checkUIForTest2, true); - var url = gHttpTestRoot + "test_mcb_redirect.html" - gTestBrowser.contentWindow.location = url; -} - -function checkUIForTest2() { - gTestBrowser.removeEventListener("load", checkUIForTest2, true); - - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: false, passiveLoaded: false}); - - var expected = "script executed"; - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test3, "Error: Waited too long for status in Test 2!", - "OK: Expected result in innerHTML for Test2!"); -} - -// ------------------------ Test 3 ------------------------------ -// HTTPS page loading insecure image -function test3() { - gTestBrowser.addEventListener("load", checkLoadEventForTest3, true); - var url = gHttpsTestRoot + "test_mcb_redirect_image.html" - gTestBrowser.contentWindow.location = url; -} - -function checkLoadEventForTest3() { - gTestBrowser.removeEventListener("load", checkLoadEventForTest3, true); - - var expected = "image blocked" - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test4, "Error: Waited too long for status in Test 3!", - "OK: Expected result in innerHTML for Test3!"); -} - -// ------------------------ Test 4 ------------------------------ -// HTTP page loading insecure image -function test4() { - gTestBrowser.addEventListener("load", checkLoadEventForTest4, true); - var url = gHttpTestRoot + "test_mcb_redirect_image.html" - gTestBrowser.contentWindow.location = url; -} - -function checkLoadEventForTest4() { - gTestBrowser.removeEventListener("load", checkLoadEventForTest4, true); - - var expected = "image loaded" - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test5, "Error: Waited too long for status in Test 4!", - "OK: Expected result in innerHTML for Test4!"); -} - -// ------------------------ Test 5 ------------------------------ -// HTTP page laoding insecure cached image -// Assuming test 4 succeeded, the image has already been loaded once -// and hence should be cached per the sjs cache-control header -// Going into offline mode to ensure we are loading from the cache. -function test5() { - gTestBrowser.addEventListener("load", checkLoadEventForTest5, true); - // Go into offline mode - Services.io.offline = true; - var url = gHttpTestRoot + "test_mcb_redirect_image.html" - gTestBrowser.contentWindow.location = url; -} - -function checkLoadEventForTest5() { - gTestBrowser.removeEventListener("load", checkLoadEventForTest5, true); - - var expected = "image loaded" - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test6, "Error: Waited too long for status in Test 5!", - "OK: Expected result in innerHTML for Test5!"); - // Go back online - Services.io.offline = false; -} - -// ------------------------ Test 6 ------------------------------ -// HTTPS page loading insecure cached image -// Assuming test 4 succeeded, the image has already been loaded once -// and hence should be cached per the sjs cache-control header -// Going into offline mode to ensure we are loading from the cache. -function test6() { - gTestBrowser.addEventListener("load", checkLoadEventForTest6, true); - // Go into offline mode - Services.io.offline = true; - var url = gHttpsTestRoot + "test_mcb_redirect_image.html" - gTestBrowser.contentWindow.location = url; -} - -function checkLoadEventForTest6() { - gTestBrowser.removeEventListener("load", checkLoadEventForTest6, true); - - var expected = "image blocked" - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test7, "Error: Waited too long for status in Test 6!", - "OK: Expected result in innerHTML for Test6!"); - // Go back online - Services.io.offline = false; -} - -// ------------------------ Test 7 ------------------------------ -// HTTP page loading insecure image that went through a double redirect -function test7() { - gTestBrowser.addEventListener("load", checkLoadEventForTest7, true); - var url = gHttpTestRoot + "test_mcb_double_redirect_image.html" - gTestBrowser.contentWindow.location = url; -} - -function checkLoadEventForTest7() { - gTestBrowser.removeEventListener("load", checkLoadEventForTest7, true); - - var expected = "image loaded" - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test8, "Error: Waited too long for status in Test 7!", - "OK: Expected result in innerHTML for Test7!"); -} - -// ------------------------ Test 8 ------------------------------ -// HTTP page loading insecure cached image that went through a double redirect -// Assuming test 7 succeeded, the image has already been loaded once -// and hence should be cached per the sjs cache-control header -// Going into offline mode to ensure we are loading from the cache. -function test8() { - gTestBrowser.addEventListener("load", checkLoadEventForTest8, true); - // Go into offline mode - Services.io.offline = true; - var url = gHttpTestRoot + "test_mcb_double_redirect_image.html" - gTestBrowser.contentWindow.location = url; -} - -function checkLoadEventForTest8() { - gTestBrowser.removeEventListener("load", checkLoadEventForTest8, true); - - var expected = "image loaded" - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - test9, "Error: Waited too long for status in Test 8!", - "OK: Expected result in innerHTML for Test8!"); - // Go back online - Services.io.offline = false; -} - -// ------------------------ Test 9 ------------------------------ -// HTTPS page loading insecure cached image that went through a double redirect -// Assuming test 7 succeeded, the image has already been loaded once -// and hence should be cached per the sjs cache-control header -// Going into offline mode to ensure we are loading from the cache. -function test9() { - gTestBrowser.addEventListener("load", checkLoadEventForTest9, true); - // Go into offline mode - Services.io.offline = true; - var url = gHttpsTestRoot + "test_mcb_double_redirect_image.html" - gTestBrowser.contentWindow.location = url; -} - -function checkLoadEventForTest9() { - gTestBrowser.removeEventListener("load", checkLoadEventForTest9, true); - - var expected = "image blocked" - waitForCondition( - () => content.document.getElementById('mctestdiv').innerHTML == expected, - cleanUpAfterTests, "Error: Waited too long for status in Test 9!", - "OK: Expected result in innerHTML for Test9!"); - // Go back online - Services.io.offline = false; -} - -// ------------------------ SETUP ------------------------------ - -function test() { - // Performing async calls, e.g. 'onload', we have to wait till all of them finished - waitForExplicitFinish(); - - // Store original preferences so we can restore settings after testing - origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE); - origBlockDisplay = Services.prefs.getBoolPref(PREF_DISPLAY); - Services.prefs.setBoolPref(PREF_ACTIVE, true); - Services.prefs.setBoolPref(PREF_DISPLAY, true); - - pushPrefs(["dom.ipc.processCount", 1]).then(() => { - var newTab = gBrowser.addTab(); - gBrowser.selectedTab = newTab; - gTestBrowser = gBrowser.selectedBrowser; - newTab.linkedBrowser.stop(); - - executeSoon(test1); - }); -} diff --git a/browser/base/content/test/general/browser_menuButtonBadgeManager.js b/browser/base/content/test/general/browser_menuButtonBadgeManager.js deleted file mode 100644 index 9afe39ab7..000000000 --- a/browser/base/content/test/general/browser_menuButtonBadgeManager.js +++ /dev/null @@ -1,46 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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 menuButton = document.getElementById("PanelUI-menu-button"); - -add_task(function* testButtonActivities() { - is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status"); - is(menuButton.hasAttribute("badge"), false, "Should not have the badge attribute set"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_FXA, "fxa-needs-authentication"); - is(menuButton.getAttribute("badge-status"), "fxa-needs-authentication", "Should have fxa-needs-authentication badge status"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE, "update-succeeded"); - is(menuButton.getAttribute("badge-status"), "update-succeeded", "Should have update-succeeded badge status (update > fxa)"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE, "update-failed"); - is(menuButton.getAttribute("badge-status"), "update-failed", "Should have update-failed badge status"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_DOWNLOAD, "download-severe"); - is(menuButton.getAttribute("badge-status"), "download-severe", "Should have download-severe badge status"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_DOWNLOAD, "download-warning"); - is(menuButton.getAttribute("badge-status"), "download-warning", "Should have download-warning badge status"); - - gMenuButtonBadgeManager.addBadge("unknownbadge", "attr"); - is(menuButton.getAttribute("badge-status"), "download-warning", "Should not have changed badge status"); - - gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_DOWNLOAD); - is(menuButton.getAttribute("badge-status"), "update-failed", "Should have update-failed badge status"); - - gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE); - is(menuButton.getAttribute("badge-status"), "fxa-needs-authentication", "Should have fxa-needs-authentication badge status"); - - gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_FXA); - is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status"); - - yield PanelUI.show(); - is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status (Hamburger menu opened)"); - PanelUI.hide(); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_FXA, "fxa-needs-authentication"); - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE, "update-succeeded"); - gMenuButtonBadgeManager.clearBadges(); - is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status (clearBadges called)"); -}); diff --git a/browser/base/content/test/general/browser_menuButtonFitts.js b/browser/base/content/test/general/browser_menuButtonFitts.js deleted file mode 100644 index e2541b925..000000000 --- a/browser/base/content/test/general/browser_menuButtonFitts.js +++ /dev/null @@ -1,32 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -function test () { - waitForExplicitFinish(); - window.maximize(); - - // Find where the nav-bar is vertically. - var navBar = document.getElementById("nav-bar"); - var boundingRect = navBar.getBoundingClientRect(); - var yPixel = boundingRect.top + Math.floor(boundingRect.height / 2); - var xPixel = boundingRect.width - 1; // Use the last pixel of the screen since it is maximized. - - function onPopupHidden() { - PanelUI.panel.removeEventListener("popuphidden", onPopupHidden); - window.restore(); - finish(); - } - function onPopupShown() { - PanelUI.panel.removeEventListener("popupshown", onPopupShown); - ok(true, "Clicking at the far edge of the window opened the menu popup."); - PanelUI.panel.addEventListener("popuphidden", onPopupHidden); - PanelUI.hide(); - } - registerCleanupFunction(function() { - PanelUI.panel.removeEventListener("popupshown", onPopupShown); - PanelUI.panel.removeEventListener("popuphidden", onPopupHidden); - }); - PanelUI.panel.addEventListener("popupshown", onPopupShown); - EventUtils.synthesizeMouseAtPoint(xPixel, yPixel, {}, window); -} diff --git a/browser/base/content/test/general/browser_middleMouse_noJSPaste.js b/browser/base/content/test/general/browser_middleMouse_noJSPaste.js deleted file mode 100644 index fa0c26f78..000000000 --- a/browser/base/content/test/general/browser_middleMouse_noJSPaste.js +++ /dev/null @@ -1,34 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -const middleMousePastePref = "middlemouse.contentLoadURL"; -const autoScrollPref = "general.autoScroll"; - -add_task(function* () { - yield pushPrefs([middleMousePastePref, true], [autoScrollPref, false]); - - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser); - - let url = "javascript:http://www.example.com/"; - yield new Promise((resolve, reject) => { - SimpleTest.waitForClipboard(url, () => { - Components.classes["@mozilla.org/widget/clipboardhelper;1"] - .getService(Components.interfaces.nsIClipboardHelper) - .copyString(url); - }, resolve, () => { - ok(false, "Clipboard copy failed"); - reject(); - }); - }); - - let middlePagePromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser); - - // Middle click on the content area - info("Middle clicking"); - yield BrowserTestUtils.synthesizeMouse(null, 10, 10, {button: 1}, gBrowser.selectedBrowser); - yield middlePagePromise; - - is(gBrowser.currentURI.spec, url.replace(/^javascript:/, ""), "url loaded by middle click doesn't include JS"); - - gBrowser.removeTab(tab); -}); diff --git a/browser/base/content/test/general/browser_minimize.js b/browser/base/content/test/general/browser_minimize.js deleted file mode 100644 index 1d761c0da..000000000 --- a/browser/base/content/test/general/browser_minimize.js +++ /dev/null @@ -1,18 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -add_task(function *() { - registerCleanupFunction(function() { - window.restore(); - }); - function waitForActive() { return gBrowser.selectedTab.linkedBrowser.docShellIsActive; } - function waitForInactive() { return !gBrowser.selectedTab.linkedBrowser.docShellIsActive; } - yield promiseWaitForCondition(waitForActive); - is(gBrowser.selectedTab.linkedBrowser.docShellIsActive, true, "Docshell should be active"); - window.minimize(); - yield promiseWaitForCondition(waitForInactive); - is(gBrowser.selectedTab.linkedBrowser.docShellIsActive, false, "Docshell should be Inactive"); - window.restore(); - yield promiseWaitForCondition(waitForActive); - is(gBrowser.selectedTab.linkedBrowser.docShellIsActive, true, "Docshell should be active again"); -}); diff --git a/browser/base/content/test/general/browser_misused_characters_in_strings.js b/browser/base/content/test/general/browser_misused_characters_in_strings.js deleted file mode 100644 index fe8022662..000000000 --- a/browser/base/content/test/general/browser_misused_characters_in_strings.js +++ /dev/null @@ -1,244 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* This list allows pre-existing or 'unfixable' issues to remain, while we - * detect newly occurring issues in shipping files. It is a list of objects - * specifying conditions under which an error should be ignored. - * - * As each issue is found in the whitelist, it is removed from the list. At - * the end of the test, there is an assertion that all items have been - * removed from the whitelist, thus ensuring there are no stale entries. */ -let gWhitelist = [{ - file: "search.properties", - key: "searchForSomethingWith", - type: "single-quote" - }, { - file: "netError.dtd", - key: "certerror.introPara", - type: "single-quote" - }, { - file: "netError.dtd", - key: "weakCryptoAdvanced.longDesc", - type: "single-quote" - }, { - file: "netError.dtd", - key: "weakCryptoAdvanced.override", - type: "single-quote" - }, { - file: "netError.dtd", - key: "inadequateSecurityError.longDesc", - type: "single-quote" - }, { - file: "netError.dtd", - key: "certerror.wrongSystemTime", - type: "single-quote" - }, { - file: "phishing-afterload-warning-message.dtd", - key: "safeb.blocked.malwarePage.shortDesc", - type: "single-quote" - }, { - file: "phishing-afterload-warning-message.dtd", - key: "safeb.blocked.unwantedPage.shortDesc", - type: "single-quote" - }, { - file: "phishing-afterload-warning-message.dtd", - key: "safeb.blocked.phishingPage.shortDesc2", - type: "single-quote" - }, { - file: "mathfont.properties", - key: "operator.\\u002E\\u002E\\u002E.postfix", - type: "ellipsis" - }, { - file: "layout_errors.properties", - key: "ImageMapRectBoundsError", - type: "double-quote" - }, { - file: "layout_errors.properties", - key: "ImageMapCircleWrongNumberOfCoords", - type: "double-quote" - }, { - file: "layout_errors.properties", - key: "ImageMapCircleNegativeRadius", - type: "double-quote" - }, { - file: "layout_errors.properties", - key: "ImageMapPolyWrongNumberOfCoords", - type: "double-quote" - }, { - file: "layout_errors.properties", - key: "ImageMapPolyOddNumberOfCoords", - type: "double-quote" - }, { - file: "xbl.properties", - key: "CommandNotInChrome", - type: "double-quote" - }, { - file: "dom.properties", - key: "PatternAttributeCompileFailure", - type: "single-quote" - }, { - file: "pipnss.properties", - key: "certErrorMismatchSingle2", - type: "double-quote" - }, { - file: "pipnss.properties", - key: "certErrorCodePrefix2", - type: "double-quote" - }, { - file: "aboutSupport.dtd", - key: "aboutSupport.pageSubtitle", - type: "single-quote" - }, { - file: "aboutSupport.dtd", - key: "aboutSupport.userJSDescription", - type: "single-quote" - }, { - file: "netError.dtd", - key: "inadequateSecurityError.longDesc", - type: "single-quote" - }, { - file: "netErrorApp.dtd", - key: "securityOverride.warningContent", - type: "single-quote" - }, { - file: "pocket.properties", - key: "tos", - type: "double-quote" - }, { - file: "pocket.properties", - key: "tos", - type: "apostrophe" - }, { - file: "aboutNetworking.dtd", - key: "aboutNetworking.logTutorial", - type: "single-quote" - } -]; - -var moduleLocation = gTestPath.replace(/\/[^\/]*$/i, "/parsingTestHelpers.jsm"); -var {generateURIsFromDirTree} = Cu.import(moduleLocation, {}); - -/** - * Check if an error should be ignored due to matching one of the whitelist - * objects defined in gWhitelist. - * - * @param filepath The URI spec of the locale file - * @param key The key of the entity that is being checked - * @param type The type of error that has been found - * @return true if the error should be ignored, false otherwise. - */ -function ignoredError(filepath, key, type) { - for (let index in gWhitelist) { - let whitelistItem = gWhitelist[index]; - if (filepath.endsWith(whitelistItem.file) && - key == whitelistItem.key && - type == whitelistItem.type) { - gWhitelist.splice(index, 1); - return true; - } - } - return false; -} - -function fetchFile(uri) { - return new Promise((resolve, reject) => { - let xhr = new XMLHttpRequest(); - xhr.open("GET", uri, true); - xhr.onreadystatechange = function() { - if (this.readyState != this.DONE) { - return; - } - try { - resolve(this.responseText); - } catch (ex) { - ok(false, `Script error reading ${uri}: ${ex}`); - resolve(""); - } - }; - xhr.onerror = error => { - ok(false, `XHR error reading ${uri}: ${error}`); - resolve(""); - }; - xhr.send(null); - }); -} - -function testForError(filepath, key, str, pattern, type, helpText) { - if (str.match(pattern) && - !ignoredError(filepath, key, type)) { - ok(false, `${filepath} with key=${key} has a misused ${type}. ${helpText}`); - } -} - -function testForErrors(filepath, key, str) { - testForError(filepath, key, str, /\w'\w/, "apostrophe", "Strings with apostrophes should use foo\u2019s instead of foo's."); - testForError(filepath, key, str, /\w\u2018\w/, "incorrect-apostrophe", "Strings with apostrophes should use foo\u2019s instead of foo\u2018s."); - testForError(filepath, key, str, /'.+'/, "single-quote", "Single-quoted strings should use Unicode \u2018foo\u2019 instead of 'foo'."); - testForError(filepath, key, str, /"/, "double-quote", "Double-quoted strings should use Unicode \u201cfoo\u201d instead of \"foo\"."); - testForError(filepath, key, str, /\.\.\./, "ellipsis", "Strings with an ellipsis should use the Unicode \u2026 character instead of three periods."); -} - -function* getAllTheFiles(extension) { - let appDirGreD = Services.dirsvc.get("GreD", Ci.nsIFile); - let appDirXCurProcD = Services.dirsvc.get("XCurProcD", Ci.nsIFile); - if (appDirGreD.contains(appDirXCurProcD)) { - return yield generateURIsFromDirTree(appDirGreD, [extension]); - } - if (appDirXCurProcD.contains(appDirGreD)) { - return yield generateURIsFromDirTree(appDirXCurProcD, [extension]); - } - let urisGreD = yield generateURIsFromDirTree(appDirGreD, [extension]); - let urisXCurProcD = yield generateURIsFromDirTree(appDirXCurProcD, [extension]); - return Array.from(new Set(urisGreD.concat(appDirXCurProcD))); -} - -add_task(function* checkAllTheProperties() { - // This asynchronously produces a list of URLs (sadly, mostly sync on our - // test infrastructure because it runs against jarfiles there, and - // our zipreader APIs are all sync) - let uris = yield getAllTheFiles(".properties"); - ok(uris.length, `Found ${uris.length} .properties files to scan for misused characters`); - - for (let uri of uris) { - let bundle = new StringBundle(uri.spec); - let entities = bundle.getAll(); - for (let entity of entities) { - testForErrors(uri.spec, entity.key, entity.value); - } - } -}); - -var checkDTD = Task.async(function* (aURISpec) { - let rawContents = yield fetchFile(aURISpec); - // The regular expression below is adapted from: - // https://hg.mozilla.org/mozilla-central/file/68c0b7d6f16ce5bb023e08050102b5f2fe4aacd8/python/compare-locales/compare_locales/parser.py#l233 - let entities = rawContents.match(/<!ENTITY\s+([\w\.]*)\s+("[^"]*"|'[^']*')\s*>/g); - if (!entities) { - // Some files, such as requestAutocomplete.dtd, have no entities defined. - return; - } - for (let entity of entities) { - let [, key, str] = entity.match(/<!ENTITY\s+([\w\.]*)\s+("[^"]*"|'[^']*')\s*>/); - // The matched string includes the enclosing quotation marks, - // we need to slice them off. - str = str.slice(1, -1); - testForErrors(aURISpec, key, str); - } -}); - -add_task(function* checkAllTheDTDs() { - let uris = yield getAllTheFiles(".dtd"); - ok(uris.length, `Found ${uris.length} .dtd files to scan for misused characters`); - for (let uri of uris) { - yield checkDTD(uri.spec); - } - - // This support DTD file supplies a string with a newline to make sure - // the regex in checkDTD works correctly for that case. - let dtdLocation = gTestPath.replace(/\/[^\/]*$/i, "/bug1262648_string_with_newlines.dtd"); - yield checkDTD(dtdLocation); -}); - -add_task(function* ensureWhiteListIsEmpty() { - is(gWhitelist.length, 0, "No remaining whitelist entries exist"); -}); diff --git a/browser/base/content/test/general/browser_mixedContentFramesOnHttp.js b/browser/base/content/test/general/browser_mixedContentFramesOnHttp.js deleted file mode 100644 index ac19efd05..000000000 --- a/browser/base/content/test/general/browser_mixedContentFramesOnHttp.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - * - * Test for Bug 1182551 - - * - * This test has a top level HTTP page with an HTTPS iframe. The HTTPS iframe - * includes an HTTP image. We check that the top level security state is - * STATE_IS_INSECURE. The mixed content from the iframe shouldn't "upgrade" - * the HTTP top level page to broken HTTPS. - */ - -const gHttpTestUrl = "http://example.com/browser/browser/base/content/test/general/file_mixedContentFramesOnHttp.html"; - -var gTestBrowser = null; - -add_task(function *() { - yield new Promise(resolve => { - SpecialPowers.pushPrefEnv({ - "set": [ - ["security.mixed_content.block_active_content", true], - ["security.mixed_content.block_display_content", false] - ] - }, resolve); - }); - let url = gHttpTestUrl - yield BrowserTestUtils.withNewTab({gBrowser, url}, function*() { - gTestBrowser = gBrowser.selectedBrowser; - // check security state is insecure - isSecurityState("insecure"); - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: false, passiveLoaded: true}); - }); -}); - diff --git a/browser/base/content/test/general/browser_mixedContentFromOnunload.js b/browser/base/content/test/general/browser_mixedContentFromOnunload.js deleted file mode 100644 index 9b39776f4..000000000 --- a/browser/base/content/test/general/browser_mixedContentFromOnunload.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - * - * Tests for Bug 947079 - Fix bug in nsSecureBrowserUIImpl that sets the wrong - * security state on a page because of a subresource load that is not on the - * same page. - */ - -// We use different domains for each test and for navigation within each test -const gHttpTestRoot1 = "http://example.com/browser/browser/base/content/test/general/"; -const gHttpsTestRoot1 = "https://test1.example.com/browser/browser/base/content/test/general/"; -const gHttpTestRoot2 = "http://example.net/browser/browser/base/content/test/general/"; -const gHttpsTestRoot2 = "https://test2.example.com/browser/browser/base/content/test/general/"; - -var gTestBrowser = null; -add_task(function *() { - let url = gHttpTestRoot1 + "file_mixedContentFromOnunload.html"; - yield BrowserTestUtils.withNewTab({gBrowser, url}, function*() { - yield new Promise(resolve => { - SpecialPowers.pushPrefEnv({ - "set": [ - ["security.mixed_content.block_active_content", true], - ["security.mixed_content.block_display_content", false] - ] - }, resolve); - }); - gTestBrowser = gBrowser.selectedBrowser; - // Navigation from an http page to a https page with no mixed content - // The http page loads an http image on unload - url = gHttpsTestRoot1 + "file_mixedContentFromOnunload_test1.html"; - yield BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); - // check security state. Since current url is https and doesn't have any - // mixed content resources, we expect it to be secure. - isSecurityState("secure"); - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: false, passiveLoaded: false}); - // Navigation from an http page to a https page that has mixed display content - // The https page loads an http image on unload - url = gHttpTestRoot2 + "file_mixedContentFromOnunload.html"; - yield BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); - url = gHttpsTestRoot2 + "file_mixedContentFromOnunload_test2.html"; - yield BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); - isSecurityState("broken"); - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: false, passiveLoaded: true}); - }); -}); diff --git a/browser/base/content/test/general/browser_mixed_content_cert_override.js b/browser/base/content/test/general/browser_mixed_content_cert_override.js deleted file mode 100644 index 037fce5d2..000000000 --- a/browser/base/content/test/general/browser_mixed_content_cert_override.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Bug 1253771 - check mixed content blocking in combination with overriden certificates - */ - -"use strict"; - -const MIXED_CONTENT_URL = "https://self-signed.example.com/browser/browser/base/content/test/general/test-mixedcontent-securityerrors.html"; - -function getConnectionState() { - return document.getElementById("identity-popup").getAttribute("connection"); -} - -function getPopupContentVerifier() { - return document.getElementById("identity-popup-content-verifier"); -} - -function getConnectionIcon() { - return window.getComputedStyle(document.getElementById("connection-icon")).listStyleImage; -} - -function checkIdentityPopup(icon) { - gIdentityHandler.refreshIdentityPopup(); - is(getConnectionIcon(), `url("chrome://browser/skin/${icon}")`); - is(getConnectionState(), "secure-cert-user-overridden"); - isnot(getPopupContentVerifier().style.display, "none", "Overridden certificate warning is shown"); - ok(getPopupContentVerifier().textContent.includes("security exception"), "Text shows overridden certificate warning."); -} - -add_task(function* () { - yield BrowserTestUtils.openNewForegroundTab(gBrowser); - - // check that a warning is shown when loading a page with mixed content and an overridden certificate - yield loadBadCertPage(MIXED_CONTENT_URL); - checkIdentityPopup("connection-mixed-passive-loaded.svg#icon"); - - // check that the crossed out icon is shown when disabling mixed content protection - gIdentityHandler.disableMixedContentProtection(); - yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - - checkIdentityPopup("connection-mixed-active-loaded.svg#icon"); - - // check that a warning is shown even without mixed content - yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://self-signed.example.com"); - yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - checkIdentityPopup("connection-mixed-passive-loaded.svg#icon"); - - // remove cert exception - let certOverrideService = Cc["@mozilla.org/security/certoverride;1"] - .getService(Ci.nsICertOverrideService); - certOverrideService.clearValidityOverride("self-signed.example.com", -1); - - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); - diff --git a/browser/base/content/test/general/browser_mixedcontent_securityflags.js b/browser/base/content/test/general/browser_mixedcontent_securityflags.js deleted file mode 100644 index 1c2614b86..000000000 --- a/browser/base/content/test/general/browser_mixedcontent_securityflags.js +++ /dev/null @@ -1,70 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -// The test loads a web page with mixed active and mixed display content and -// makes sure that the mixed content flags on the docshell are set correctly. -// * Using default about:config prefs (mixed active blocked, mixed display -// loaded) we load the page and check the flags. -// * We change the about:config prefs (mixed active blocked, mixed display -// blocked), reload the page, and check the flags again. -// * We override protection so all mixed content can load and check the -// flags again. - -const TEST_URI = "https://example.com/browser/browser/base/content/test/general/test-mixedcontent-securityerrors.html"; -const PREF_DISPLAY = "security.mixed_content.block_display_content"; -const PREF_ACTIVE = "security.mixed_content.block_active_content"; -var gTestBrowser = null; - -registerCleanupFunction(function() { - // Set preferences back to their original values - Services.prefs.clearUserPref(PREF_DISPLAY); - Services.prefs.clearUserPref(PREF_ACTIVE); - gBrowser.removeCurrentTab(); -}); - -add_task(function* blockMixedActiveContentTest() { - // Turn on mixed active blocking and mixed display loading and load the page. - Services.prefs.setBoolPref(PREF_DISPLAY, false); - Services.prefs.setBoolPref(PREF_ACTIVE, true); - - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI); - gTestBrowser = gBrowser.getBrowserForTab(tab); - - yield ContentTask.spawn(gTestBrowser, null, function() { - is(docShell.hasMixedDisplayContentBlocked, false, "hasMixedDisplayContentBlocked flag has been set"); - is(docShell.hasMixedActiveContentBlocked, true, "hasMixedActiveContentBlocked flag has been set"); - is(docShell.hasMixedDisplayContentLoaded, true, "hasMixedDisplayContentLoaded flag has been set"); - is(docShell.hasMixedActiveContentLoaded, false, "hasMixedActiveContentLoaded flag has been set"); - }); - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: true}); - - // Turn on mixed active and mixed display blocking and reload the page. - Services.prefs.setBoolPref(PREF_DISPLAY, true); - Services.prefs.setBoolPref(PREF_ACTIVE, true); - - gBrowser.reload(); - yield BrowserTestUtils.browserLoaded(gTestBrowser); - - yield ContentTask.spawn(gTestBrowser, null, function() { - is(docShell.hasMixedDisplayContentBlocked, true, "hasMixedDisplayContentBlocked flag has been set"); - is(docShell.hasMixedActiveContentBlocked, true, "hasMixedActiveContentBlocked flag has been set"); - is(docShell.hasMixedDisplayContentLoaded, false, "hasMixedDisplayContentLoaded flag has been set"); - is(docShell.hasMixedActiveContentLoaded, false, "hasMixedActiveContentLoaded flag has been set"); - }); - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: false, activeBlocked: true, passiveLoaded: false}); -}); - -add_task(function* overrideMCB() { - // Disable mixed content blocking (reloads page) and retest - let {gIdentityHandler} = gTestBrowser.ownerGlobal; - gIdentityHandler.disableMixedContentProtection(); - yield BrowserTestUtils.browserLoaded(gTestBrowser); - - yield ContentTask.spawn(gTestBrowser, null, function() { - is(docShell.hasMixedDisplayContentLoaded, true, "hasMixedDisplayContentLoaded flag has not been set"); - is(docShell.hasMixedActiveContentLoaded, true, "hasMixedActiveContentLoaded flag has not been set"); - is(docShell.hasMixedDisplayContentBlocked, false, "second hasMixedDisplayContentBlocked flag has been set"); - is(docShell.hasMixedActiveContentBlocked, false, "second hasMixedActiveContentBlocked flag has been set"); - }); - assertMixedContentBlockingState(gTestBrowser, {activeLoaded: true, activeBlocked: false, passiveLoaded: true}); -}); diff --git a/browser/base/content/test/general/browser_modifiedclick_inherit_principal.js b/browser/base/content/test/general/browser_modifiedclick_inherit_principal.js deleted file mode 100644 index 3b5a5a149..000000000 --- a/browser/base/content/test/general/browser_modifiedclick_inherit_principal.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; - -const kURL = - "http://example.com/browser/browser/base/content/test/general/dummy_page.html"; - "data:text/html,<a href=''>Middle-click me</a>"; - -/* - * Check that when manually opening content JS links in new tabs/windows, - * we use the correct principal, and we don't clear the URL bar. - */ -add_task(function* () { - yield BrowserTestUtils.withNewTab(kURL, function* (browser) { - let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser); - yield ContentTask.spawn(browser, null, function* () { - let a = content.document.createElement("a"); - a.href = "javascript:document.write('spoof'); void(0);"; - a.textContent = "Some link"; - content.document.body.appendChild(a); - }); - info("Added element"); - yield BrowserTestUtils.synthesizeMouseAtCenter("a", {button: 1}, browser); - let newTab = yield newTabPromise; - is(newTab.linkedBrowser.contentPrincipal.origin, "http://example.com", - "Principal should be for example.com"); - yield BrowserTestUtils.switchTab(gBrowser, newTab); - info(gURLBar.value); - isnot(gURLBar.value, "", "URL bar should not be empty."); - yield BrowserTestUtils.removeTab(newTab); - }); -}); diff --git a/browser/base/content/test/general/browser_newTabDrop.js b/browser/base/content/test/general/browser_newTabDrop.js deleted file mode 100644 index 03c90df3f..000000000 --- a/browser/base/content/test/general/browser_newTabDrop.js +++ /dev/null @@ -1,99 +0,0 @@ -registerCleanupFunction(function* cleanup() { - while (gBrowser.tabs.length > 1) { - yield BrowserTestUtils.removeTab(gBrowser.tabs[gBrowser.tabs.length - 1]); - } - Services.search.currentEngine = originalEngine; - let engine = Services.search.getEngineByName("MozSearch"); - Services.search.removeEngine(engine); -}); - -let originalEngine; -add_task(function* test_setup() { - // Stop search-engine loads from hitting the network - Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET", - "http://example.com/?q={searchTerms}"); - let engine = Services.search.getEngineByName("MozSearch"); - originalEngine = Services.search.currentEngine; - Services.search.currentEngine = engine; -}); - -// New Tab Button opens any link. -add_task(function*() { yield dropText("mochi.test/first", 1); }); -add_task(function*() { yield dropText("javascript:'bad'", 1); }); -add_task(function*() { yield dropText("jAvascript:'bad'", 1); }); -add_task(function*() { yield dropText("mochi.test/second", 1); }); -add_task(function*() { yield dropText("data:text/html,bad", 1); }); -add_task(function*() { yield dropText("mochi.test/third", 1); }); - -// Single text/plain item, with multiple links. -add_task(function*() { yield dropText("mochi.test/1\nmochi.test/2", 2); }); -add_task(function*() { yield dropText("javascript:'bad1'\nmochi.test/3", 2); }); -add_task(function*() { yield dropText("mochi.test/4\ndata:text/html,bad1", 2); }); - -// Multiple text/plain items, with single and multiple links. -add_task(function*() { - yield drop([[{type: "text/plain", - data: "mochi.test/5"}], - [{type: "text/plain", - data: "mochi.test/6\nmochi.test/7"}]], 3); -}); - -// Single text/x-moz-url item, with multiple links. -// "text/x-moz-url" has titles in even-numbered lines. -add_task(function*() { - yield drop([[{type: "text/x-moz-url", - data: "mochi.test/8\nTITLE8\nmochi.test/9\nTITLE9"}]], 2); -}); - -// Single item with multiple types. -add_task(function*() { - yield drop([[{type: "text/plain", - data: "mochi.test/10"}, - {type: "text/x-moz-url", - data: "mochi.test/11\nTITLE11"}]], 1); -}); - -function dropText(text, expectedTabOpenCount=0) { - return drop([[{type: "text/plain", data: text}]], expectedTabOpenCount); -} - -function* drop(dragData, expectedTabOpenCount=0) { - let dragDataString = JSON.stringify(dragData); - info(`Starting test for datagData:${dragDataString}; expectedTabOpenCount:${expectedTabOpenCount}`); - let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let EventUtils = {}; - scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils); - - // Since synthesizeDrop triggers the srcElement, need to use another button. - let dragSrcElement = document.getElementById("downloads-button"); - ok(dragSrcElement, "Downloads button exists"); - let newTabButton = document.getElementById("new-tab-button"); - ok(newTabButton, "New Tab button exists"); - - let awaitDrop = BrowserTestUtils.waitForEvent(newTabButton, "drop"); - let actualTabOpenCount = 0; - let openedTabs = []; - let checkCount = function(event) { - openedTabs.push(event.target); - actualTabOpenCount++; - return actualTabOpenCount == expectedTabOpenCount; - }; - let awaitTabOpen = expectedTabOpenCount && BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen", false, checkCount); - - EventUtils.synthesizeDrop(dragSrcElement, newTabButton, dragData, "link", window); - - let tabsOpened = false; - if (awaitTabOpen) { - yield awaitTabOpen; - info("Got TabOpen event"); - tabsOpened = true; - for (let tab of openedTabs) { - yield BrowserTestUtils.removeTab(tab); - } - } - is(tabsOpened, !!expectedTabOpenCount, `Tabs for ${dragDataString} should only open if any of dropped items are valid`); - - yield awaitDrop; - ok(true, "Got drop event"); -} diff --git a/browser/base/content/test/general/browser_newWindowDrop.js b/browser/base/content/test/general/browser_newWindowDrop.js deleted file mode 100644 index f404d4eed..000000000 --- a/browser/base/content/test/general/browser_newWindowDrop.js +++ /dev/null @@ -1,120 +0,0 @@ -registerCleanupFunction(function* cleanup() { - Services.search.currentEngine = originalEngine; - let engine = Services.search.getEngineByName("MozSearch"); - Services.search.removeEngine(engine); -}); - -let originalEngine; -add_task(function* test_setup() { - // Opening multiple windows on debug build takes too long time. - requestLongerTimeout(10); - - // Stop search-engine loads from hitting the network - Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET", - "http://example.com/?q={searchTerms}"); - let engine = Services.search.getEngineByName("MozSearch"); - originalEngine = Services.search.currentEngine; - Services.search.currentEngine = engine; - - // Move New Window button to nav bar, to make it possible to drag and drop. - let {CustomizableUI} = Cu.import("resource:///modules/CustomizableUI.jsm", {}); - let origPlacement = CustomizableUI.getPlacementOfWidget("new-window-button"); - if (!origPlacement || origPlacement.area != CustomizableUI.AREA_NAVBAR) { - CustomizableUI.addWidgetToArea("new-window-button", - CustomizableUI.AREA_NAVBAR, - 0); - CustomizableUI.ensureWidgetPlacedInWindow("new-window-button", window); - registerCleanupFunction(function () { - CustomizableUI.reset(); - }); - } -}); - -// New Window Button opens any link. -add_task(function*() { yield dropText("mochi.test/first", 1); }); -add_task(function*() { yield dropText("javascript:'bad'", 1); }); -add_task(function*() { yield dropText("jAvascript:'bad'", 1); }); -add_task(function*() { yield dropText("mochi.test/second", 1); }); -add_task(function*() { yield dropText("data:text/html,bad", 1); }); -add_task(function*() { yield dropText("mochi.test/third", 1); }); - -// Single text/plain item, with multiple links. -add_task(function*() { yield dropText("mochi.test/1\nmochi.test/2", 2); }); -add_task(function*() { yield dropText("javascript:'bad1'\nmochi.test/3", 2); }); -add_task(function*() { yield dropText("mochi.test/4\ndata:text/html,bad1", 2); }); - -// Multiple text/plain items, with single and multiple links. -add_task(function*() { - yield drop([[{type: "text/plain", - data: "mochi.test/5"}], - [{type: "text/plain", - data: "mochi.test/6\nmochi.test/7"}]], 3); -}); - -// Single text/x-moz-url item, with multiple links. -// "text/x-moz-url" has titles in even-numbered lines. -add_task(function*() { - yield drop([[{type: "text/x-moz-url", - data: "mochi.test/8\nTITLE8\nmochi.test/9\nTITLE9"}]], 2); -}); - -// Single item with multiple types. -add_task(function*() { - yield drop([[{type: "text/plain", - data: "mochi.test/10"}, - {type: "text/x-moz-url", - data: "mochi.test/11\nTITLE11"}]], 1); -}); - -function dropText(text, expectedWindowOpenCount=0) { - return drop([[{type: "text/plain", data: text}]], expectedWindowOpenCount); -} - -function* drop(dragData, expectedWindowOpenCount=0) { - let dragDataString = JSON.stringify(dragData); - info(`Starting test for datagData:${dragDataString}; expectedWindowOpenCount:${expectedWindowOpenCount}`); - let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let EventUtils = {}; - scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils); - - // Since synthesizeDrop triggers the srcElement, need to use another button. - let dragSrcElement = document.getElementById("downloads-button"); - ok(dragSrcElement, "Downloads button exists"); - let newWindowButton = document.getElementById("new-window-button"); - ok(newWindowButton, "New Window button exists"); - - let tmp = {}; - Cu.import("resource://testing-common/TestUtils.jsm", tmp); - - let awaitDrop = BrowserTestUtils.waitForEvent(newWindowButton, "drop"); - let actualWindowOpenCount = 0; - let openedWindows = []; - let checkCount = function(window) { - // Add observer as soon as domWindow is opened to avoid missing the topic. - let awaitStartup = tmp.TestUtils.topicObserved("browser-delayed-startup-finished", - subject => subject == window); - openedWindows.push([window, awaitStartup]); - actualWindowOpenCount++; - return actualWindowOpenCount == expectedWindowOpenCount; - }; - let awaitWindowOpen = expectedWindowOpenCount && BrowserTestUtils.domWindowOpened(null, checkCount); - - EventUtils.synthesizeDrop(dragSrcElement, newWindowButton, dragData, "link", window); - - let windowsOpened = false; - if (awaitWindowOpen) { - yield awaitWindowOpen; - info("Got Window opened"); - windowsOpened = true; - for (let [window, awaitStartup] of openedWindows.reverse()) { - // Wait for startup before closing, to properly close the browser window. - yield awaitStartup; - yield BrowserTestUtils.closeWindow(window); - } - } - is(windowsOpened, !!expectedWindowOpenCount, `Windows for ${dragDataString} should only open if any of dropped items are valid`); - - yield awaitDrop; - ok(true, "Got drop event"); -} diff --git a/browser/base/content/test/general/browser_newwindow_focus.js b/browser/base/content/test/general/browser_newwindow_focus.js deleted file mode 100644 index 7880db0bd..000000000 --- a/browser/base/content/test/general/browser_newwindow_focus.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; - -/** - * These tests are for the auto-focus behaviour on the initial browser - * when a window is opened from content. - */ - -const PAGE = `data:text/html,<a id="target" href="%23" onclick="window.open('http://www.example.com', '_blank', 'width=100,height=100');">Click me</a>`; - -/** - * Returns a Promise that resolves when a new window has - * opened, and the "load" event has fired in that window. - * We can't use BrowserTestUtils.domWindowOpened directly, - * because by the time the "then" on the Promise runs, - * DOMContentLoaded and load may have already run in the new - * window. However, we want to be very explicit about what - * events we're waiting for, and not rely on a quirk of our - * Promises infrastructure. - */ -function promiseNewWindow() { - return new Promise((resolve) => { - let observer = (subject, topic, data) => { - if (topic == "domwindowopened") { - Services.ww.unregisterNotification(observer); - let win = subject.QueryInterface(Ci.nsIDOMWindow); - win.addEventListener("load", function onLoad() { - win.removeEventListener("load", onLoad); - resolve(win); - }); - } - }; - - Services.ww.registerNotification(observer); - }); -} - -/** - * Test that when a new window is opened from content, focus moves - * to the initial browser in that window once the window has finished - * painting. - */ -add_task(function* test_focus_browser() { - yield BrowserTestUtils.withNewTab({ - url: PAGE, - gBrowser, - }, function*(browser) { - let newWinPromise = promiseNewWindow(); - let delayedStartupPromise = BrowserTestUtils.waitForNewWindow(); - - yield BrowserTestUtils.synthesizeMouseAtCenter("#target", {}, browser); - let newWin = yield newWinPromise; - yield BrowserTestUtils.contentPainted(newWin.gBrowser.selectedBrowser); - yield delayedStartupPromise; - - let focusedElement = - Services.focus.getFocusedElementForWindow(newWin, false, {}); - - Assert.equal(focusedElement, newWin.gBrowser.selectedBrowser, - "Initial browser should be focused"); - - yield BrowserTestUtils.closeWindow(newWin); - }); -}); - -/** - * Test that when a new window is opened from content and focus - * shifts in that window before the content has a chance to paint - * that we _don't_ steal focus once content has painted. - */ -add_task(function* test_no_steal_focus() { - yield BrowserTestUtils.withNewTab({ - url: PAGE, - gBrowser, - }, function*(browser) { - let newWinPromise = promiseNewWindow(); - let delayedStartupPromise = BrowserTestUtils.waitForNewWindow(); - - yield BrowserTestUtils.synthesizeMouseAtCenter("#target", {}, browser); - let newWin = yield newWinPromise; - - // Because we're switching focus, we shouldn't steal it once - // content paints. - newWin.gURLBar.focus(); - - yield BrowserTestUtils.contentPainted(newWin.gBrowser.selectedBrowser); - yield delayedStartupPromise; - - let focusedElement = - Services.focus.getFocusedElementForWindow(newWin, false, {}); - - Assert.equal(focusedElement, newWin.gURLBar.inputField, - "URLBar should be focused"); - - yield BrowserTestUtils.closeWindow(newWin); - }); -}); diff --git a/browser/base/content/test/general/browser_no_mcb_on_http_site.js b/browser/base/content/test/general/browser_no_mcb_on_http_site.js deleted file mode 100644 index 45fd67379..000000000 --- a/browser/base/content/test/general/browser_no_mcb_on_http_site.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Description of the Tests for - * - Bug 909920 - Mixed content warning should not show on a HTTP site - * - * Description of the tests: - * Test 1: - * 1) Load an http page - * 2) The page includes a css file using https - * 3) The css file loads an |IMAGE| << over http - * - * Test 2: - * 1) Load an http page - * 2) The page includes a css file using https - * 3) The css file loads a |FONT| over http - * - * Test 3: - * 1) Load an http page - * 2) The page includes a css file using https - * 3) The css file imports (@import) another css file using http - * 3) The imported css file loads a |FONT| over http -* - * Since the top-domain is >> NOT << served using https, the MCB - * should >> NOT << trigger a warning. - */ - -const PREF_ACTIVE = "security.mixed_content.block_active_content"; -const PREF_DISPLAY = "security.mixed_content.block_display_content"; - -const gHttpTestRoot = "http://example.com/browser/browser/base/content/test/general/"; - -var gTestBrowser = null; - -function cleanUpAfterTests() { - gBrowser.removeCurrentTab(); - window.focus(); -} - -add_task(function* init() { - yield SpecialPowers.pushPrefEnv({ set: [[ PREF_ACTIVE, true ], - [ PREF_DISPLAY, true ]] }); - let url = gHttpTestRoot + "test_no_mcb_on_http_site_img.html"; - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, url) - gTestBrowser = tab.linkedBrowser; -}); - -// ------------- TEST 1 ----------------------------------------- - -add_task(function* test1() { - let expected = "Verifying MCB does not trigger warning/error for an http page "; - expected += "with https css that includes http image"; - - yield ContentTask.spawn(gTestBrowser, expected, function* (condition) { - yield ContentTaskUtils.waitForCondition( - () => content.document.getElementById("testDiv").innerHTML == condition, - "Waited too long for status in Test 1!"); - }); - - // Explicit OKs needed because the harness requires at least one call to ok. - ok(true, "test 1 passed"); - - // set up test 2 - let url = gHttpTestRoot + "test_no_mcb_on_http_site_font.html"; - BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -// ------------- TEST 2 ----------------------------------------- - -add_task(function* test2() { - let expected = "Verifying MCB does not trigger warning/error for an http page "; - expected += "with https css that includes http font"; - - yield ContentTask.spawn(gTestBrowser, expected, function* (condition) { - yield ContentTaskUtils.waitForCondition( - () => content.document.getElementById("testDiv").innerHTML == condition, - "Waited too long for status in Test 2!"); - }); - - ok(true, "test 2 passed"); - - // set up test 3 - let url = gHttpTestRoot + "test_no_mcb_on_http_site_font2.html"; - BrowserTestUtils.loadURI(gTestBrowser, url); - yield BrowserTestUtils.browserLoaded(gTestBrowser); -}); - -// ------------- TEST 3 ----------------------------------------- - -add_task(function* test3() { - let expected = "Verifying MCB does not trigger warning/error for an http page " - expected += "with https css that imports another http css which includes http font"; - - yield ContentTask.spawn(gTestBrowser, expected, function* (condition) { - yield ContentTaskUtils.waitForCondition( - () => content.document.getElementById("testDiv").innerHTML == condition, - "Waited too long for status in Test 3!"); - }); - - ok(true, "test3 passed"); -}); - -// ------------------------------------------------------ - -add_task(function* cleanup() { - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); diff --git a/browser/base/content/test/general/browser_offlineQuotaNotification.js b/browser/base/content/test/general/browser_offlineQuotaNotification.js deleted file mode 100644 index e56bfe9a8..000000000 --- a/browser/base/content/test/general/browser_offlineQuotaNotification.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// Test offline quota warnings - must be run as a mochitest-browser test or -// else the test runner gets in the way of notifications due to bug 857897. - -const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/offlineQuotaNotification.html"; - -registerCleanupFunction(function() { - // Clean up after ourself - let uri = Services.io.newURI(URL, null, null); - let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); - Services.perms.removeFromPrincipal(principal, "offline-app"); - Services.prefs.clearUserPref("offline-apps.quota.warn"); - Services.prefs.clearUserPref("offline-apps.allow_by_default"); - let {OfflineAppCacheHelper} = Components.utils.import("resource:///modules/offlineAppCache.jsm", {}); - OfflineAppCacheHelper.clear(); -}); - -// Same as the other one, but for in-content preferences -function checkInContentPreferences(win) { - let doc = win.document; - let sel = doc.getElementById("categories").selectedItems[0].id; - let tab = doc.getElementById("advancedPrefs").selectedTab.id; - is(gBrowser.currentURI.spec, "about:preferences#advanced", "about:preferences loaded"); - is(sel, "category-advanced", "Advanced pane was selected"); - is(tab, "networkTab", "Network tab is selected"); - // all good, we are done. - win.close(); - finish(); -} - -function test() { - waitForExplicitFinish(); - - Services.prefs.setBoolPref("offline-apps.allow_by_default", false); - - // Open a new tab. - gBrowser.selectedTab = gBrowser.addTab(URL); - registerCleanupFunction(() => gBrowser.removeCurrentTab()); - - - Promise.all([ - // Wait for a notification that asks whether to allow offline storage. - promiseNotification(), - // Wait for the tab to load. - BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser), - ]).then(() => { - info("Loaded page, adding onCached handler"); - // Need a promise to keep track of when we've added our handler. - let mm = gBrowser.selectedBrowser.messageManager; - let onCachedAttached = BrowserTestUtils.waitForMessage(mm, "Test:OnCachedAttached"); - let gotCached = ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - return new Promise(resolve => { - content.window.applicationCache.oncached = function() { - setTimeout(resolve, 0); - }; - sendAsyncMessage("Test:OnCachedAttached"); - }); - }); - gotCached.then(function() { - // We got cached - now we should have provoked the quota warning. - let notification = PopupNotifications.getNotification('offline-app-usage'); - ok(notification, "have offline-app-usage notification"); - // select the default action - this should cause the preferences - // tab to open - which we track via an "Initialized" event. - PopupNotifications.panel.firstElementChild.button.click(); - let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab); - newTabBrowser.addEventListener("Initialized", function PrefInit() { - newTabBrowser.removeEventListener("Initialized", PrefInit, true); - executeSoon(function() { - checkInContentPreferences(newTabBrowser.contentWindow); - }) - }, true); - }); - onCachedAttached.then(function() { - Services.prefs.setIntPref("offline-apps.quota.warn", 1); - - // Click the notification panel's "Allow" button. This should kick - // off updates which will call our oncached handler above. - PopupNotifications.panel.firstElementChild.button.click(); - }); - }); -} - -function promiseNotification() { - return new Promise(resolve => { - PopupNotifications.panel.addEventListener("popupshown", function onShown() { - PopupNotifications.panel.removeEventListener("popupshown", onShown); - resolve(); - }); - }); -} diff --git a/browser/base/content/test/general/browser_overflowScroll.js b/browser/base/content/test/general/browser_overflowScroll.js deleted file mode 100644 index 56932fae2..000000000 --- a/browser/base/content/test/general/browser_overflowScroll.js +++ /dev/null @@ -1,91 +0,0 @@ -var tabstrip = gBrowser.tabContainer.mTabstrip; -var scrollbox = tabstrip._scrollbox; -var originalSmoothScroll = tabstrip.smoothScroll; -var tabs = gBrowser.tabs; - -var rect = ele => ele.getBoundingClientRect(); -var width = ele => rect(ele).width; -var left = ele => rect(ele).left; -var right = ele => rect(ele).right; -var isLeft = (ele, msg) => is(left(ele) + tabstrip._tabMarginLeft, left(scrollbox), msg); -var isRight = (ele, msg) => is(right(ele) - tabstrip._tabMarginRight, right(scrollbox), msg); -var elementFromPoint = x => tabstrip._elementFromPoint(x); -var nextLeftElement = () => elementFromPoint(left(scrollbox) - 1); -var nextRightElement = () => elementFromPoint(right(scrollbox) + 1); -var firstScrollable = () => tabs[gBrowser._numPinnedTabs]; - -function test() { - requestLongerTimeout(2); - waitForExplicitFinish(); - - // If the previous (or more) test finished with cleaning up the tabs, - // there may be some pending animations. That can cause a failure of - // this tests, so, we should test this in another stack. - setTimeout(doTest, 0); -} - -function doTest() { - tabstrip.smoothScroll = false; - - var tabMinWidth = parseInt(getComputedStyle(gBrowser.selectedTab, null).minWidth); - var tabCountForOverflow = Math.ceil(width(tabstrip) / tabMinWidth * 3); - while (tabs.length < tabCountForOverflow) - gBrowser.addTab("about:blank", {skipAnimation: true}); - gBrowser.pinTab(tabs[0]); - - tabstrip.addEventListener("overflow", runOverflowTests, false); -} - -function runOverflowTests(aEvent) { - if (aEvent.detail != 1) - return; - - tabstrip.removeEventListener("overflow", runOverflowTests, false); - - var upButton = tabstrip._scrollButtonUp; - var downButton = tabstrip._scrollButtonDown; - var element; - - gBrowser.selectedTab = firstScrollable(); - ok(left(scrollbox) <= left(firstScrollable()), "Selecting the first tab scrolls it into view " + - "(" + left(scrollbox) + " <= " + left(firstScrollable()) + ")"); - - element = nextRightElement(); - EventUtils.synthesizeMouseAtCenter(downButton, {}); - isRight(element, "Scrolled one tab to the right with a single click"); - - gBrowser.selectedTab = tabs[tabs.length - 1]; - ok(right(gBrowser.selectedTab) <= right(scrollbox), "Selecting the last tab scrolls it into view " + - "(" + right(gBrowser.selectedTab) + " <= " + right(scrollbox) + ")"); - - element = nextLeftElement(); - EventUtils.synthesizeMouse(upButton, 1, 1, {}); - isLeft(element, "Scrolled one tab to the left with a single click"); - - let elementPoint = left(scrollbox) - width(scrollbox); - element = elementFromPoint(elementPoint); - if (elementPoint == right(element)) { - element = element.nextSibling; - } - EventUtils.synthesizeMouse(upButton, 1, 1, {clickCount: 2}); - isLeft(element, "Scrolled one page of tabs with a double click"); - - EventUtils.synthesizeMouse(upButton, 1, 1, {clickCount: 3}); - var firstScrollableLeft = left(firstScrollable()); - ok(left(scrollbox) <= firstScrollableLeft, "Scrolled to the start with a triple click " + - "(" + left(scrollbox) + " <= " + firstScrollableLeft + ")"); - - for (var i = 2; i; i--) - EventUtils.synthesizeWheel(scrollbox, 1, 1, { deltaX: -1.0, deltaMode: WheelEvent.DOM_DELTA_LINE }); - is(left(firstScrollable()), firstScrollableLeft, "Remained at the start with the mouse wheel"); - - element = nextRightElement(); - EventUtils.synthesizeWheel(scrollbox, 1, 1, { deltaX: 1.0, deltaMode: WheelEvent.DOM_DELTA_LINE}); - isRight(element, "Scrolled one tab to the right with the mouse wheel"); - - while (tabs.length > 1) - gBrowser.removeTab(tabs[0]); - - tabstrip.smoothScroll = originalSmoothScroll; - finish(); -} diff --git a/browser/base/content/test/general/browser_pageInfo.js b/browser/base/content/test/general/browser_pageInfo.js deleted file mode 100644 index 90fe2e17f..000000000 --- a/browser/base/content/test/general/browser_pageInfo.js +++ /dev/null @@ -1,38 +0,0 @@ -function test() { - waitForExplicitFinish(); - - var pageInfo; - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function loadListener() { - gBrowser.selectedBrowser.removeEventListener("load", loadListener, true); - - Services.obs.addObserver(observer, "page-info-dialog-loaded", false); - pageInfo = BrowserPageInfo(); - }, true); - content.location = - "https://example.com/browser/browser/base/content/test/general/feed_tab.html"; - - function observer(win, topic, data) { - Services.obs.removeObserver(observer, "page-info-dialog-loaded"); - pageInfo.onFinished.push(handlePageInfo); - } - - function handlePageInfo() { - ok(pageInfo.document.getElementById("feedTab"), "Feed tab"); - let feedListbox = pageInfo.document.getElementById("feedListbox"); - ok(feedListbox, "Feed list"); - - var feedRowsNum = feedListbox.getRowCount(); - is(feedRowsNum, 3, "Number of feeds listed"); - - for (var i = 0; i < feedRowsNum; i++) { - let feedItem = feedListbox.getItemAtIndex(i); - is(feedItem.getAttribute("name"), i + 1, "Feed name"); - } - - pageInfo.close(); - gBrowser.removeCurrentTab(); - finish(); - } -} diff --git a/browser/base/content/test/general/browser_page_style_menu.js b/browser/base/content/test/general/browser_page_style_menu.js deleted file mode 100644 index cb080d52a..000000000 --- a/browser/base/content/test/general/browser_page_style_menu.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; - -/** - * Stylesheets are updated for a browser after the pageshow event. - * This helper function returns a Promise that waits for that pageshow - * event, and then resolves on the next tick to ensure that gPageStyleMenu - * has had a chance to update the stylesheets. - * - * @param browser - * The <xul:browser> to wait for. - * @return Promise - */ -function promiseStylesheetsUpdated(browser) { - return ContentTask.spawn(browser, { PAGE }, function*(args) { - return new Promise((resolve) => { - addEventListener("pageshow", function onPageShow(e) { - if (e.target.location == args.PAGE) { - removeEventListener("pageshow", onPageShow); - content.setTimeout(resolve, 0); - } - }); - }) - }); -} - -const PAGE = "http://example.com/browser/browser/base/content/test/general/page_style_sample.html"; - -/* - * Test that the right stylesheets do (and others don't) show up - * in the page style menu. - */ -add_task(function*() { - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", false); - let browser = tab.linkedBrowser; - yield BrowserTestUtils.loadURI(browser, PAGE); - yield promiseStylesheetsUpdated(browser); - - let menupopup = document.getElementById("pageStyleMenu").menupopup; - gPageStyleMenu.fillPopup(menupopup); - - var items = []; - var current = menupopup.getElementsByTagName("menuseparator")[0]; - while (current.nextSibling) { - current = current.nextSibling; - items.push(current); - } - - items = items.map(el => ({ - label: el.getAttribute("label"), - checked: el.getAttribute("checked") == "true", - })); - - let validLinks = yield ContentTask.spawn(gBrowser.selectedBrowser, items, function(contentItems) { - let contentValidLinks = 0; - Array.forEach(content.document.querySelectorAll("link, style"), function (el) { - var title = el.getAttribute("title"); - var rel = el.getAttribute("rel"); - var media = el.getAttribute("media"); - var idstring = el.nodeName + " " + (title ? title : "without title and") + - " with rel=\"" + rel + "\"" + - (media ? " and media=\"" + media + "\"" : ""); - - var item = contentItems.filter(aItem => aItem.label == title); - var found = item.length == 1; - var checked = found && item[0].checked; - - switch (el.getAttribute("data-state")) { - case "0": - ok(!found, idstring + " should not show up in page style menu"); - break; - case "0-todo": - contentValidLinks++; - todo(!found, idstring + " should not show up in page style menu"); - ok(!checked, idstring + " should not be selected"); - break; - case "1": - contentValidLinks++; - ok(found, idstring + " should show up in page style menu"); - ok(!checked, idstring + " should not be selected"); - break; - case "2": - contentValidLinks++; - ok(found, idstring + " should show up in page style menu"); - ok(checked, idstring + " should be selected"); - break; - default: - throw "data-state attribute is missing or has invalid value"; - } - }); - return contentValidLinks; - }); - - ok(items.length, "At least one item in the menu"); - is(items.length, validLinks, "all valid links found"); - - yield BrowserTestUtils.removeTab(tab); -}); diff --git a/browser/base/content/test/general/browser_page_style_menu_update.js b/browser/base/content/test/general/browser_page_style_menu_update.js deleted file mode 100644 index a0c741e48..000000000 --- a/browser/base/content/test/general/browser_page_style_menu_update.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; - -const PAGE = "http://example.com/browser/browser/base/content/test/general/page_style_sample.html"; - -/** - * Stylesheets are updated for a browser after the pageshow event. - * This helper function returns a Promise that waits for that pageshow - * event, and then resolves on the next tick to ensure that gPageStyleMenu - * has had a chance to update the stylesheets. - * - * @param browser - * The <xul:browser> to wait for. - * @return Promise - */ -function promiseStylesheetsUpdated(browser) { - return ContentTask.spawn(browser, { PAGE }, function*(args) { - return new Promise((resolve) => { - addEventListener("pageshow", function onPageShow(e) { - if (e.target.location == args.PAGE) { - removeEventListener("pageshow", onPageShow); - content.setTimeout(resolve, 0); - } - }); - }) - }); -} - -/** - * Tests that the Page Style menu shows the currently - * selected Page Style after a new one has been selected. - */ -add_task(function*() { - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", false); - let browser = tab.linkedBrowser; - - yield BrowserTestUtils.loadURI(browser, PAGE); - yield promiseStylesheetsUpdated(browser); - - let menupopup = document.getElementById("pageStyleMenu").menupopup; - gPageStyleMenu.fillPopup(menupopup); - - // page_style_sample.html should default us to selecting the stylesheet - // with the title "6" first. - let selected = menupopup.querySelector("menuitem[checked='true']"); - is(selected.getAttribute("label"), "6", "Should have '6' stylesheet selected by default"); - - // Now select stylesheet "1" - let target = menupopup.querySelector("menuitem[label='1']"); - target.click(); - - // Now we need to wait for the content process to send its stylesheet - // update for the selected tab to the parent. Because messages are - // guaranteed to be sent in order, we'll make sure we do the check - // after the parent has been updated by yielding until the child - // has finished running a ContentTask for us. - yield ContentTask.spawn(browser, {}, function*() { - dump('\nJust wasting some time.\n'); - }); - - gPageStyleMenu.fillPopup(menupopup); - // gPageStyleMenu empties out the menu between opens, so we need - // to get a new reference to the selected menuitem - selected = menupopup.querySelector("menuitem[checked='true']"); - is(selected.getAttribute("label"), "1", "Should now have stylesheet 1 selected"); - - yield BrowserTestUtils.removeTab(tab); -}); diff --git a/browser/base/content/test/general/browser_pageinfo_svg_image.js b/browser/base/content/test/general/browser_pageinfo_svg_image.js deleted file mode 100644 index 02514d79f..000000000 --- a/browser/base/content/test/general/browser_pageinfo_svg_image.js +++ /dev/null @@ -1,38 +0,0 @@ -function test() { - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function loadListener() { - gBrowser.selectedBrowser.removeEventListener("load", loadListener, true); - var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec, - "mediaTab"); - - pageInfo.addEventListener("load", function loadListener2() { - pageInfo.removeEventListener("load", loadListener2, true); - pageInfo.onFinished.push(function() { - executeSoon(function() { - var imageTree = pageInfo.document.getElementById("imagetree"); - var imageRowsNum = imageTree.view.rowCount; - - ok(imageTree, "Image tree is null (media tab is broken)"); - - is(imageRowsNum, 1, "should have one image"); - - // Only bother running this if we've got the right number of rows. - if (imageRowsNum == 1) { - is(imageTree.view.getCellText(0, imageTree.columns[0]), - "https://example.com/browser/browser/base/content/test/general/title_test.svg", - "The URL should be the svg image."); - } - - pageInfo.close(); - gBrowser.removeCurrentTab(); - finish(); - }); - }); - }, true); - }, true); - - content.location = - "https://example.com/browser/browser/base/content/test/general/svg_image.html"; -} diff --git a/browser/base/content/test/general/browser_parsable_css.js b/browser/base/content/test/general/browser_parsable_css.js deleted file mode 100644 index 72954d2e5..000000000 --- a/browser/base/content/test/general/browser_parsable_css.js +++ /dev/null @@ -1,376 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* This list allows pre-existing or 'unfixable' CSS issues to remain, while we - * detect newly occurring issues in shipping CSS. It is a list of objects - * specifying conditions under which an error should be ignored. - * - * Every property of the objects in it needs to consist of a regular expression - * matching the offending error. If an object has multiple regex criteria, they - * ALL need to match an error in order for that error not to cause a test - * failure. */ -let whitelist = [ - // CodeMirror is imported as-is, see bug 1004423. - {sourceName: /codemirror\.css$/i, - isFromDevTools: true}, - // The debugger uses cross-browser CSS. - {sourceName: /devtools\/client\/debugger\/new\/styles.css/i, - isFromDevTools: true}, - // PDFjs is futureproofing its pseudoselectors, and those rules are dropped. - {sourceName: /web\/viewer\.css$/i, - errorMessage: /Unknown pseudo-class.*(fullscreen|selection)/i, - isFromDevTools: false}, - // Tracked in bug 1004428. - {sourceName: /aboutaccounts\/(main|normalize)\.css$/i, - isFromDevTools: false}, - // Highlighter CSS uses a UA-only pseudo-class, see bug 985597. - {sourceName: /highlighters\.css$/i, - errorMessage: /Unknown pseudo-class.*moz-native-anonymous/i, - isFromDevTools: true}, - // Responsive Design Mode CSS uses a UA-only pseudo-class, see Bug 1241714. - {sourceName: /responsive-ua\.css$/i, - errorMessage: /Unknown pseudo-class.*moz-dropdown-list/i, - isFromDevTools: true}, - - {sourceName: /\b(contenteditable|EditorOverride|svg|forms|html|mathml|ua)\.css$/i, - errorMessage: /Unknown pseudo-class.*-moz-/i, - isFromDevTools: false}, - {sourceName: /\b(html|mathml|ua)\.css$/i, - errorMessage: /Unknown property.*-moz-/i, - isFromDevTools: false}, - // Reserved to UA sheets unless layout.css.overflow-clip-box.enabled flipped to true. - {sourceName: /res\/forms\.css$/i, - errorMessage: /Unknown property.*overflow-clip-box/i, - isFromDevTools: false}, - {sourceName: /res\/(ua|html)\.css$/i, - errorMessage: /Unknown pseudo-class .*\bfullscreen\b/i, - isFromDevTools: false}, - {sourceName: /skin\/timepicker\.css$/i, - errorMessage: /Error in parsing.*mask/i, - isFromDevTools: false}, -]; - -// Platform can be "linux", "macosx" or "win". If omitted, the exception applies to all platforms. -let allowedImageReferences = [ - // Bug 1302691 - {file: "chrome://devtools/skin/images/dock-bottom-minimize@2x.png", - from: "chrome://devtools/skin/toolbox.css", - isFromDevTools: true}, - {file: "chrome://devtools/skin/images/dock-bottom-maximize@2x.png", - from: "chrome://devtools/skin/toolbox.css", - isFromDevTools: true}, -]; - -var moduleLocation = gTestPath.replace(/\/[^\/]*$/i, "/parsingTestHelpers.jsm"); -var {generateURIsFromDirTree} = Cu.import(moduleLocation, {}); - -// Add suffix to stylesheets' URI so that we always load them here and -// have them parsed. Add a random number so that even if we run this -// test multiple times, it would be unlikely to affect each other. -const kPathSuffix = "?always-parse-css-" + Math.random(); - -/** - * Check if an error should be ignored due to matching one of the whitelist - * objects defined in whitelist - * - * @param aErrorObject the error to check - * @return true if the error should be ignored, false otherwise. - */ -function ignoredError(aErrorObject) { - for (let whitelistItem of whitelist) { - let matches = true; - for (let prop of ["sourceName", "errorMessage"]) { - if (whitelistItem.hasOwnProperty(prop) && - !whitelistItem[prop].test(aErrorObject[prop] || "")) { - matches = false; - break; - } - } - if (matches) { - whitelistItem.used = true; - return true; - } - } - return false; -} - -function once(target, name) { - return new Promise((resolve, reject) => { - let cb = () => { - target.removeEventListener(name, cb); - resolve(); - }; - target.addEventListener(name, cb); - }); -} - -function fetchFile(uri) { - return new Promise((resolve, reject) => { - let xhr = new XMLHttpRequest(); - xhr.responseType = "text"; - xhr.open("GET", uri, true); - xhr.onreadystatechange = function() { - if (this.readyState != this.DONE) { - return; - } - try { - resolve(this.responseText); - } catch (ex) { - ok(false, `Script error reading ${uri}: ${ex}`); - resolve(""); - } - }; - xhr.onerror = error => { - ok(false, `XHR error reading ${uri}: ${error}`); - resolve(""); - }; - xhr.send(null); - }); -} - -var gChromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"] - .getService(Ci.nsIChromeRegistry); -var gChromeMap = new Map(); - -function getBaseUriForChromeUri(chromeUri) { - let chromeFile = chromeUri + "gobbledygooknonexistentfile.reallynothere"; - let uri = Services.io.newURI(chromeFile, null, null); - let fileUri = gChromeReg.convertChromeURL(uri); - return fileUri.resolve("."); -} - -function parseManifest(manifestUri) { - return fetchFile(manifestUri.spec).then(data => { - for (let line of data.split('\n')) { - let [type, ...argv] = line.split(/\s+/); - let component; - if (type == "content" || type == "skin") { - [component] = argv; - } else { - // skip unrelated lines - continue; - } - let chromeUri = `chrome://${component}/${type}/`; - gChromeMap.set(getBaseUriForChromeUri(chromeUri), chromeUri); - } - }); -} - -function convertToChromeUri(fileUri) { - let baseUri = fileUri.spec; - let path = ""; - while (true) { - let slashPos = baseUri.lastIndexOf("/", baseUri.length - 2); - if (slashPos < 0) { - info(`File not accessible from chrome protocol: ${fileUri.path}`); - return fileUri; - } - path = baseUri.slice(slashPos + 1) + path; - baseUri = baseUri.slice(0, slashPos + 1); - if (gChromeMap.has(baseUri)) { - let chromeBaseUri = gChromeMap.get(baseUri); - let chromeUri = `${chromeBaseUri}${path}`; - return Services.io.newURI(chromeUri, null, null); - } - } -} - -function messageIsCSSError(msg) { - // Only care about CSS errors generated by our iframe: - if ((msg instanceof Ci.nsIScriptError) && - msg.category.includes("CSS") && - msg.sourceName.endsWith(kPathSuffix)) { - let sourceName = msg.sourceName.slice(0, -kPathSuffix.length); - let msgInfo = { sourceName, errorMessage: msg.errorMessage }; - // Check if this error is whitelisted in whitelist - if (!ignoredError(msgInfo)) { - ok(false, `Got error message for ${sourceName}: ${msg.errorMessage}`); - return true; - } - info(`Ignored error for ${sourceName} because of filter.`); - } - return false; -} - -let imageURIsToReferencesMap = new Map(); - -function processCSSRules(sheet) { - for (let rule of sheet.cssRules) { - if (rule instanceof CSSMediaRule) { - processCSSRules(rule); - continue; - } - if (!(rule instanceof CSSStyleRule)) - continue; - - // Extract urls from the css text. - // Note: CSSStyleRule.cssText always has double quotes around URLs even - // when the original CSS file didn't. - let urls = rule.cssText.match(/url\("[^"]*"\)/g); - if (!urls) - continue; - - for (let url of urls) { - // Remove the url(" prefix and the ") suffix. - url = url.replace(/url\("(.*)"\)/, "$1"); - if (url.startsWith("data:")) - continue; - - // Make the url absolute and remove the ref. - let baseURI = Services.io.newURI(rule.parentStyleSheet.href, null, null); - url = Services.io.newURI(url, null, baseURI).specIgnoringRef; - - // Store the image url along with the css file referencing it. - let baseUrl = baseURI.spec.split("?always-parse-css")[0]; - if (!imageURIsToReferencesMap.has(url)) { - imageURIsToReferencesMap.set(url, new Set([baseUrl])); - } else { - imageURIsToReferencesMap.get(url).add(baseUrl); - } - } - } -} - -function chromeFileExists(aURI) -{ - let available = 0; - try { - let channel = NetUtil.newChannel({uri: aURI, loadUsingSystemPrincipal: true}); - let stream = channel.open(); - let sstream = Cc["@mozilla.org/scriptableinputstream;1"] - .createInstance(Ci.nsIScriptableInputStream); - sstream.init(stream); - available = sstream.available(); - sstream.close(); - } catch (e) { - if (e.result != Components.results.NS_ERROR_FILE_NOT_FOUND) { - dump("Checking " + aURI + ": " + e + "\n"); - Cu.reportError(e); - } - } - return available > 0; -} - -add_task(function* checkAllTheCSS() { - let appDir = Services.dirsvc.get("GreD", Ci.nsIFile); - // This asynchronously produces a list of URLs (sadly, mostly sync on our - // test infrastructure because it runs against jarfiles there, and - // our zipreader APIs are all sync) - let uris = yield generateURIsFromDirTree(appDir, [".css", ".manifest"]); - - // Create a clean iframe to load all the files into. This needs to live at a - // chrome URI so that it's allowed to load and parse any styles. - let testFile = getRootDirectory(gTestPath) + "dummy_page.html"; - let windowless = Services.appShell.createWindowlessBrowser(); - let iframe = windowless.document.createElementNS("http://www.w3.org/1999/xhtml", "html:iframe"); - windowless.document.documentElement.appendChild(iframe); - let iframeLoaded = once(iframe, 'load'); - iframe.contentWindow.location = testFile; - yield iframeLoaded; - let doc = iframe.contentWindow.document; - - // Parse and remove all manifests from the list. - // NOTE that this must be done before filtering out devtools paths - // so that all chrome paths can be recorded. - let manifestPromises = []; - uris = uris.filter(uri => { - if (uri.path.endsWith(".manifest")) { - manifestPromises.push(parseManifest(uri)); - return false; - } - return true; - }); - // Wait for all manifest to be parsed - yield Promise.all(manifestPromises); - - // We build a list of promises that get resolved when their respective - // files have loaded and produced no errors. - let allPromises = []; - - // filter out either the devtools paths or the non-devtools paths: - let isDevtools = SimpleTest.harnessParameters.subsuite == "devtools"; - let devtoolsPathBits = ["webide", "devtools"]; - uris = uris.filter(uri => isDevtools == devtoolsPathBits.some(path => uri.spec.includes(path))); - - for (let uri of uris) { - let linkEl = doc.createElement("link"); - linkEl.setAttribute("rel", "stylesheet"); - let promiseForThisSpec = Promise.defer(); - let onLoad = (e) => { - processCSSRules(linkEl.sheet); - promiseForThisSpec.resolve(); - linkEl.removeEventListener("load", onLoad); - linkEl.removeEventListener("error", onError); - }; - let onError = (e) => { - ok(false, "Loading " + linkEl.getAttribute("href") + " threw an error!"); - promiseForThisSpec.resolve(); - linkEl.removeEventListener("load", onLoad); - linkEl.removeEventListener("error", onError); - }; - linkEl.addEventListener("load", onLoad); - linkEl.addEventListener("error", onError); - linkEl.setAttribute("type", "text/css"); - let chromeUri = convertToChromeUri(uri); - linkEl.setAttribute("href", chromeUri.spec + kPathSuffix); - allPromises.push(promiseForThisSpec.promise); - doc.head.appendChild(linkEl); - } - - // Wait for all the files to have actually loaded: - yield Promise.all(allPromises); - - // Check if all the files referenced from CSS actually exist. - for (let [image, references] of imageURIsToReferencesMap) { - if (!chromeFileExists(image)) { - for (let ref of references) { - let ignored = false; - for (let item of allowedImageReferences) { - if (image.endsWith(item.file) && ref.endsWith(item.from) && - isDevtools == item.isFromDevTools && - (!item.platforms || item.platforms.includes(AppConstants.platform))) { - item.used = true; - ignored = true; - break; - } - } - if (!ignored) - ok(false, "missing " + image + " referenced from " + ref); - } - } - } - - let messages = Services.console.getMessageArray(); - // Count errors (the test output will list actual issues for us, as well - // as the ok(false) in messageIsCSSError. - let errors = messages.filter(messageIsCSSError); - is(errors.length, 0, "All the styles (" + allPromises.length + ") loaded without errors."); - - // Confirm that all whitelist rules have been used. - for (let item of whitelist) { - if (!item.used && isDevtools == item.isFromDevTools) { - ok(false, "Unused whitelist item. " + - (item.sourceName ? " sourceName: " + item.sourceName : "") + - (item.errorMessage ? " errorMessage: " + item.errorMessage : "")); - } - } - - // Confirm that all file whitelist rules have been used. - for (let item of allowedImageReferences) { - if (!item.used && isDevtools == item.isFromDevTools && - (!item.platforms || item.platforms.includes(AppConstants.platform))) { - ok(false, "Unused file whitelist item. " + - " file: " + item.file + - " from: " + item.from); - } - } - - // Clean up to avoid leaks: - iframe.remove(); - doc.head.innerHTML = ''; - doc = null; - iframe = null; - windowless.close(); - windowless = null; - imageURIsToReferencesMap = null; -}); diff --git a/browser/base/content/test/general/browser_parsable_script.js b/browser/base/content/test/general/browser_parsable_script.js deleted file mode 100644 index 50333dd65..000000000 --- a/browser/base/content/test/general/browser_parsable_script.js +++ /dev/null @@ -1,132 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* This list allows pre-existing or 'unfixable' JS issues to remain, while we - * detect newly occurring issues in shipping JS. It is a list of regexes - * matching files which have errors: - */ -const kWhitelist = new Set([ - /defaults\/profile\/prefs.js$/, - /browser\/content\/browser\/places\/controller.js$/, -]); - - -var moduleLocation = gTestPath.replace(/\/[^\/]*$/i, "/parsingTestHelpers.jsm"); -var {generateURIsFromDirTree} = Cu.import(moduleLocation, {}); - -// Normally we would use reflect.jsm to get Reflect.parse. However, if -// we do that, then all the AST data is allocated in reflect.jsm's -// zone. That exposes a bug in our GC. The GC collects reflect.jsm's -// zone but not the zone in which our test code lives (since no new -// data is being allocated in it). The cross-compartment wrappers in -// our zone that point to the AST data never get collected, and so the -// AST data itself is never collected. We need to GC both zones at -// once to fix the problem. -const init = Components.classes["@mozilla.org/jsreflect;1"].createInstance(); -init(); - -/** - * Check if an error should be ignored due to matching one of the whitelist - * objects defined in kWhitelist - * - * @param uri the uri to check against the whitelist - * @return true if the uri should be skipped, false otherwise. - */ -function uriIsWhiteListed(uri) { - for (let whitelistItem of kWhitelist) { - if (whitelistItem.test(uri.spec)) { - return true; - } - } - return false; -} - -function parsePromise(uri) { - let promise = new Promise((resolve, reject) => { - let xhr = new XMLHttpRequest(); - xhr.open("GET", uri, true); - xhr.onreadystatechange = function() { - if (this.readyState == this.DONE) { - let scriptText = this.responseText; - try { - info("Checking " + uri); - Reflect.parse(scriptText); - resolve(true); - } catch (ex) { - let errorMsg = "Script error reading " + uri + ": " + ex; - ok(false, errorMsg); - resolve(false); - } - } - }; - xhr.onerror = (error) => { - ok(false, "XHR error reading " + uri + ": " + error); - resolve(false); - }; - xhr.overrideMimeType("application/javascript"); - xhr.send(null); - }); - return promise; -} - -add_task(function* checkAllTheJS() { - // In debug builds, even on a fast machine, collecting the file list may take - // more than 30 seconds, and parsing all files may take four more minutes. - // For this reason, this test must be explictly requested in debug builds by - // using the "--setpref parse=<filter>" argument to mach. You can specify: - // - A case-sensitive substring of the file name to test (slow). - // - A single absolute URI printed out by a previous run (fast). - // - An empty string to run the test on all files (slowest). - let parseRequested = Services.prefs.prefHasUserValue("parse"); - let parseValue = parseRequested && Services.prefs.getCharPref("parse"); - if (SpecialPowers.isDebugBuild) { - if (!parseRequested) { - ok(true, "Test disabled on debug build. To run, execute: ./mach" + - " mochitest-browser --setpref parse=<case_sensitive_filter>" + - " browser/base/content/test/general/browser_parsable_script.js"); - return; - } - // Request a 15 minutes timeout (30 seconds * 30) for debug builds. - requestLongerTimeout(30); - } - - let uris; - // If an absolute URI is specified on the command line, use it immediately. - if (parseValue && parseValue.includes(":")) { - uris = [NetUtil.newURI(parseValue)]; - } else { - let appDir = Services.dirsvc.get("XCurProcD", Ci.nsIFile); - // This asynchronously produces a list of URLs (sadly, mostly sync on our - // test infrastructure because it runs against jarfiles there, and - // our zipreader APIs are all sync) - let startTimeMs = Date.now(); - info("Collecting URIs"); - uris = yield generateURIsFromDirTree(appDir, [".js", ".jsm"]); - info("Collected URIs in " + (Date.now() - startTimeMs) + "ms"); - - // Apply the filter specified on the command line, if any. - if (parseValue) { - uris = uris.filter(uri => { - if (uri.spec.includes(parseValue)) { - return true; - } - info("Not checking filtered out " + uri.spec); - return false; - }); - } - } - - // We create an array of promises so we can parallelize all our parsing - // and file loading activity: - let allPromises = []; - for (let uri of uris) { - if (uriIsWhiteListed(uri)) { - info("Not checking whitelisted " + uri.spec); - continue; - } - allPromises.push(parsePromise(uri.spec)); - } - - let promiseResults = yield Promise.all(allPromises); - is(promiseResults.filter((x) => !x).length, 0, "There should be 0 parsing errors"); -}); diff --git a/browser/base/content/test/general/browser_permissions.js b/browser/base/content/test/general/browser_permissions.js deleted file mode 100644 index 721a669d2..000000000 --- a/browser/base/content/test/general/browser_permissions.js +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Test the Permissions section in the Control Center. - */ - -var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; -const PERMISSIONS_PAGE = "http://example.com/browser/browser/base/content/test/general/permissions.html"; -var {SitePermissions} = Cu.import("resource:///modules/SitePermissions.jsm", {}); - -registerCleanupFunction(function() { - SitePermissions.remove(gBrowser.currentURI, "cookie"); - SitePermissions.remove(gBrowser.currentURI, "geo"); - SitePermissions.remove(gBrowser.currentURI, "camera"); - SitePermissions.remove(gBrowser.currentURI, "microphone"); - - while (gBrowser.tabs.length > 1) { - gBrowser.removeCurrentTab(); - } -}); - -function* openIdentityPopup() { - let {gIdentityHandler} = gBrowser.ownerGlobal; - let promise = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown"); - gIdentityHandler._identityBox.click(); - return promise; -} - -function* closeIdentityPopup() { - let {gIdentityHandler} = gBrowser.ownerGlobal; - let promise = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popuphidden"); - gIdentityHandler._identityPopup.hidePopup(); - return promise; -} - -add_task(function* testMainViewVisible() { - let tab = gBrowser.selectedTab = gBrowser.addTab(); - yield promiseTabLoadEvent(tab, PERMISSIONS_PAGE); - - let permissionsList = document.getElementById("identity-popup-permission-list"); - let emptyLabel = permissionsList.nextSibling.nextSibling; - - yield openIdentityPopup(); - - ok(!is_hidden(emptyLabel), "List of permissions is empty"); - - yield closeIdentityPopup(); - - SitePermissions.set(gBrowser.currentURI, "camera", SitePermissions.ALLOW); - - yield openIdentityPopup(); - - ok(is_hidden(emptyLabel), "List of permissions is not empty"); - - let labelText = SitePermissions.getPermissionLabel("camera"); - let labels = permissionsList.querySelectorAll(".identity-popup-permission-label"); - is(labels.length, 1, "One permission visible in main view"); - is(labels[0].textContent, labelText, "Correct value"); - - let img = permissionsList.querySelector("image.identity-popup-permission-icon"); - ok(img, "There is an image for the permissions"); - ok(img.classList.contains("camera-icon"), "proper class is in image class"); - - yield closeIdentityPopup(); - - SitePermissions.remove(gBrowser.currentURI, "camera"); - - yield openIdentityPopup(); - - ok(!is_hidden(emptyLabel), "List of permissions is empty"); - - yield closeIdentityPopup(); -}); - -add_task(function* testIdentityIcon() { - let {gIdentityHandler} = gBrowser.ownerGlobal; - let tab = gBrowser.selectedTab = gBrowser.addTab(); - yield promiseTabLoadEvent(tab, PERMISSIONS_PAGE); - - SitePermissions.set(gBrowser.currentURI, "geo", SitePermissions.ALLOW); - - ok(gIdentityHandler._identityBox.classList.contains("grantedPermissions"), - "identity-box signals granted permissions"); - - SitePermissions.remove(gBrowser.currentURI, "geo"); - - ok(!gIdentityHandler._identityBox.classList.contains("grantedPermissions"), - "identity-box doesn't signal granted permissions"); - - SitePermissions.set(gBrowser.currentURI, "camera", SitePermissions.BLOCK); - - ok(!gIdentityHandler._identityBox.classList.contains("grantedPermissions"), - "identity-box doesn't signal granted permissions"); - - SitePermissions.set(gBrowser.currentURI, "cookie", SitePermissions.SESSION); - - ok(gIdentityHandler._identityBox.classList.contains("grantedPermissions"), - "identity-box signals granted permissions"); - - SitePermissions.remove(gBrowser.currentURI, "geo"); - SitePermissions.remove(gBrowser.currentURI, "camera"); - SitePermissions.remove(gBrowser.currentURI, "cookie"); -}); - -add_task(function* testCancelPermission() { - let tab = gBrowser.selectedTab = gBrowser.addTab(); - yield promiseTabLoadEvent(tab, PERMISSIONS_PAGE); - - let permissionsList = document.getElementById("identity-popup-permission-list"); - let emptyLabel = permissionsList.nextSibling.nextSibling; - - SitePermissions.set(gBrowser.currentURI, "geo", SitePermissions.ALLOW); - SitePermissions.set(gBrowser.currentURI, "camera", SitePermissions.BLOCK); - - yield openIdentityPopup(); - - ok(is_hidden(emptyLabel), "List of permissions is not empty"); - - let cancelButtons = permissionsList - .querySelectorAll(".identity-popup-permission-remove-button"); - - cancelButtons[0].click(); - let labels = permissionsList.querySelectorAll(".identity-popup-permission-label"); - is(labels.length, 1, "One permission should be removed"); - cancelButtons[1].click(); - labels = permissionsList.querySelectorAll(".identity-popup-permission-label"); - is(labels.length, 0, "One permission should be removed"); - - yield closeIdentityPopup(); -}); - -add_task(function* testPermissionHints() { - let tab = gBrowser.selectedTab = gBrowser.addTab(); - yield promiseTabLoadEvent(tab, PERMISSIONS_PAGE); - - let permissionsList = document.getElementById("identity-popup-permission-list"); - let emptyHint = document.getElementById("identity-popup-permission-empty-hint"); - let reloadHint = document.getElementById("identity-popup-permission-reload-hint"); - - yield openIdentityPopup(); - - ok(!is_hidden(emptyHint), "Empty hint is visible"); - ok(is_hidden(reloadHint), "Reload hint is hidden"); - - yield closeIdentityPopup(); - - SitePermissions.set(gBrowser.currentURI, "geo", SitePermissions.ALLOW); - SitePermissions.set(gBrowser.currentURI, "camera", SitePermissions.BLOCK); - - yield openIdentityPopup(); - - ok(is_hidden(emptyHint), "Empty hint is hidden"); - ok(is_hidden(reloadHint), "Reload hint is hidden"); - - let cancelButtons = permissionsList - .querySelectorAll(".identity-popup-permission-remove-button"); - SitePermissions.remove(gBrowser.currentURI, "camera"); - - cancelButtons[0].click(); - ok(is_hidden(emptyHint), "Empty hint is hidden"); - ok(!is_hidden(reloadHint), "Reload hint is visible"); - - cancelButtons[1].click(); - ok(is_hidden(emptyHint), "Empty hint is hidden"); - ok(!is_hidden(reloadHint), "Reload hint is visible"); - - yield closeIdentityPopup(); - yield promiseTabLoadEvent(tab, PERMISSIONS_PAGE); - yield openIdentityPopup(); - - ok(!is_hidden(emptyHint), "Empty hint is visible after reloading"); - ok(is_hidden(reloadHint), "Reload hint is hidden after reloading"); - - yield closeIdentityPopup(); -}); - -add_task(function* testPermissionIcons() { - let {gIdentityHandler} = gBrowser.ownerGlobal; - let tab = gBrowser.selectedTab = gBrowser.addTab(); - yield promiseTabLoadEvent(tab, PERMISSIONS_PAGE); - - SitePermissions.set(gBrowser.currentURI, "camera", SitePermissions.ALLOW); - SitePermissions.set(gBrowser.currentURI, "geo", SitePermissions.BLOCK); - SitePermissions.set(gBrowser.currentURI, "microphone", SitePermissions.SESSION); - - let geoIcon = gIdentityHandler._identityBox - .querySelector(".blocked-permission-icon[data-permission-id='geo']"); - ok(geoIcon.hasAttribute("showing"), "blocked permission icon is shown"); - - let cameraIcon = gIdentityHandler._identityBox - .querySelector(".blocked-permission-icon[data-permission-id='camera']"); - ok(!cameraIcon.hasAttribute("showing"), - "allowed permission icon is not shown"); - - let microphoneIcon = gIdentityHandler._identityBox - .querySelector(".blocked-permission-icon[data-permission-id='microphone']"); - ok(!microphoneIcon.hasAttribute("showing"), - "allowed permission icon is not shown"); - - SitePermissions.remove(gBrowser.currentURI, "geo"); - - ok(!geoIcon.hasAttribute("showing"), - "blocked permission icon is not shown after reset"); -}); diff --git a/browser/base/content/test/general/browser_pinnedTabs.js b/browser/base/content/test/general/browser_pinnedTabs.js deleted file mode 100644 index e0ddb5072..000000000 --- a/browser/base/content/test/general/browser_pinnedTabs.js +++ /dev/null @@ -1,75 +0,0 @@ -var tabs; - -function index(tab) { - return Array.indexOf(gBrowser.tabs, tab); -} - -function indexTest(tab, expectedIndex, msg) { - var diag = "tab " + tab + " should be at index " + expectedIndex; - if (msg) - msg = msg + " (" + diag + ")"; - else - msg = diag; - is(index(tabs[tab]), expectedIndex, msg); -} - -function PinUnpinHandler(tab, eventName) { - this.eventCount = 0; - var self = this; - tab.addEventListener(eventName, function() { - tab.removeEventListener(eventName, arguments.callee, true); - - self.eventCount++; - }, true); - gBrowser.tabContainer.addEventListener(eventName, function(e) { - gBrowser.tabContainer.removeEventListener(eventName, arguments.callee, true); - - if (e.originalTarget == tab) { - self.eventCount++; - } - }, true); -} - -function test() { - tabs = [gBrowser.selectedTab, gBrowser.addTab(), gBrowser.addTab(), gBrowser.addTab()]; - indexTest(0, 0); - indexTest(1, 1); - indexTest(2, 2); - indexTest(3, 3); - - var eh = new PinUnpinHandler(tabs[3], "TabPinned"); - gBrowser.pinTab(tabs[3]); - is(eh.eventCount, 2, "TabPinned event should be fired"); - indexTest(0, 1); - indexTest(1, 2); - indexTest(2, 3); - indexTest(3, 0); - - eh = new PinUnpinHandler(tabs[1], "TabPinned"); - gBrowser.pinTab(tabs[1]); - is(eh.eventCount, 2, "TabPinned event should be fired"); - indexTest(0, 2); - indexTest(1, 1); - indexTest(2, 3); - indexTest(3, 0); - - gBrowser.moveTabTo(tabs[3], 3); - indexTest(3, 1, "shouldn't be able to mix a pinned tab into normal tabs"); - - gBrowser.moveTabTo(tabs[2], 0); - indexTest(2, 2, "shouldn't be able to mix a normal tab into pinned tabs"); - - eh = new PinUnpinHandler(tabs[1], "TabUnpinned"); - gBrowser.unpinTab(tabs[1]); - is(eh.eventCount, 2, "TabUnpinned event should be fired"); - indexTest(1, 1, "unpinning a tab should move a tab to the start of normal tabs"); - - eh = new PinUnpinHandler(tabs[3], "TabUnpinned"); - gBrowser.unpinTab(tabs[3]); - is(eh.eventCount, 2, "TabUnpinned event should be fired"); - indexTest(3, 0, "unpinning a tab should move a tab to the start of normal tabs"); - - gBrowser.removeTab(tabs[1]); - gBrowser.removeTab(tabs[2]); - gBrowser.removeTab(tabs[3]); -} diff --git a/browser/base/content/test/general/browser_plainTextLinks.js b/browser/base/content/test/general/browser_plainTextLinks.js deleted file mode 100644 index 7a304fce0..000000000 --- a/browser/base/content/test/general/browser_plainTextLinks.js +++ /dev/null @@ -1,146 +0,0 @@ -function testExpected(expected, msg) { - is(document.getElementById("context-openlinkincurrent").hidden, expected, msg); -} - -function testLinkExpected(expected, msg) { - is(gContextMenu.linkURL, expected, msg); -} - -add_task(function *() { - const url = "data:text/html;charset=UTF-8,Test For Non-Hyperlinked url selection"; - yield BrowserTestUtils.openNewForegroundTab(gBrowser, url); - - yield SimpleTest.promiseFocus(gBrowser.selectedBrowser.contentWindowAsCPOW); - - // Initial setup of the content area. - yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* (arg) { - let doc = content.document; - let range = doc.createRange(); - let selection = content.getSelection(); - - let mainDiv = doc.createElement("div"); - let div = doc.createElement("div"); - let div2 = doc.createElement("div"); - let span1 = doc.createElement("span"); - let span2 = doc.createElement("span"); - let span3 = doc.createElement("span"); - let span4 = doc.createElement("span"); - let p1 = doc.createElement("p"); - let p2 = doc.createElement("p"); - span1.textContent = "http://index."; - span2.textContent = "example.com example.com"; - span3.textContent = " - Test"; - span4.innerHTML = "<a href='http://www.example.com'>http://www.example.com/example</a>"; - p1.textContent = "mailto:test.com ftp.example.com"; - p2.textContent = "example.com -"; - div.appendChild(span1); - div.appendChild(span2); - div.appendChild(span3); - div.appendChild(span4); - div.appendChild(p1); - div.appendChild(p2); - let p3 = doc.createElement("p"); - p3.textContent = "main.example.com"; - div2.appendChild(p3); - mainDiv.appendChild(div); - mainDiv.appendChild(div2); - doc.body.appendChild(mainDiv); - - function setSelection(el1, el2, index1, index2) { - while (el1.nodeType != el1.TEXT_NODE) - el1 = el1.firstChild; - while (el2.nodeType != el1.TEXT_NODE) - el2 = el2.firstChild; - - selection.removeAllRanges(); - range.setStart(el1, index1); - range.setEnd(el2, index2); - selection.addRange(range); - - return range; - } - - // Each of these tests creates a selection and returns a range within it. - content.tests = [ - () => setSelection(span1.firstChild, span2.firstChild, 0, 11), - () => setSelection(span1.firstChild, span2.firstChild, 7, 11), - () => setSelection(span1.firstChild, span2.firstChild, 8, 11), - () => setSelection(span2.firstChild, span2.firstChild, 0, 11), - () => setSelection(span2.firstChild, span2.firstChild, 11, 23), - () => setSelection(span2.firstChild, span2.firstChild, 0, 10), - () => setSelection(span2.firstChild, span3.firstChild, 12, 7), - () => setSelection(span2.firstChild, span2.firstChild, 12, 19), - () => setSelection(p1.firstChild, p1.firstChild, 0, 15), - () => setSelection(p1.firstChild, p1.firstChild, 16, 31), - () => setSelection(p2.firstChild, p2.firstChild, 0, 14), - () => { - selection.selectAllChildren(div2); - return selection.getRangeAt(0); - }, - () => { - selection.selectAllChildren(span4); - return selection.getRangeAt(0); - }, - () => { - mainDiv.innerHTML = "(open-suse.ru)"; - return setSelection(mainDiv, mainDiv, 1, 13); - }, - () => setSelection(mainDiv, mainDiv, 1, 14) - ]; - }); - - let checks = [ - () => testExpected(false, "The link context menu should show for http://www.example.com"), - () => testExpected(false, "The link context menu should show for www.example.com"), - () => testExpected(true, "The link context menu should not show for ww.example.com"), - () => { - testExpected(false, "The link context menu should show for example.com"); - testLinkExpected("http://example.com/", "url for example.com selection should not prepend www"); - }, - () => testExpected(false, "The link context menu should show for example.com"), - () => testExpected(true, "Link options should not show for selection that's not at a word boundary"), - () => testExpected(true, "Link options should not show for selection that has whitespace"), - () => testExpected(true, "Link options should not show unless a url is selected"), - () => testExpected(true, "Link options should not show for mailto: links"), - () => { - testExpected(false, "Link options should show for ftp.example.com"); - testLinkExpected("http://ftp.example.com/", "ftp.example.com should be preceeded with http://"); - }, - () => testExpected(false, "Link options should show for www.example.com "), - () => testExpected(false, "Link options should show for triple-click selections"), - () => testLinkExpected("http://www.example.com/", "Linkified text should open the correct link"), - () => { - testExpected(false, "Link options should show for open-suse.ru"); - testLinkExpected("http://open-suse.ru/", "Linkified text should open the correct link"); - }, - () => testExpected(true, "Link options should not show for 'open-suse.ru)'") - ]; - - let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - - for (let testid = 0; testid < checks.length; testid++) { - let menuPosition = yield ContentTask.spawn(gBrowser.selectedBrowser, { testid: testid }, function* (arg) { - let range = content.tests[arg.testid](); - - // Get the range of the selection and determine its coordinates. These - // coordinates will be returned to the parent process and the context menu - // will be opened at that location. - let rangeRect = range.getBoundingClientRect(); - return [rangeRect.x + 3, rangeRect.y + 3]; - }); - - let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown"); - yield BrowserTestUtils.synthesizeMouseAtPoint(menuPosition[0], menuPosition[1], - { type: "contextmenu", button: 2 }, gBrowser.selectedBrowser); - yield popupShownPromise; - - checks[testid](); - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden"); - contentAreaContextMenu.hidePopup(); - yield popupHiddenPromise; - } - - gBrowser.removeCurrentTab(); -}); - diff --git a/browser/base/content/test/general/browser_printpreview.js b/browser/base/content/test/general/browser_printpreview.js deleted file mode 100644 index c38fc18be..000000000 --- a/browser/base/content/test/general/browser_printpreview.js +++ /dev/null @@ -1,74 +0,0 @@ -let ourTab; - -function test() { - waitForExplicitFinish(); - - BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home", true).then(function(tab) { - ourTab = tab; - ok(!gInPrintPreviewMode, - "Should NOT be in print preview mode at starting this tests"); - // Skip access key test on platforms which don't support access key. - if (!/Win|Linux/.test(navigator.platform)) { - openPrintPreview(testClosePrintPreviewWithEscKey); - } else { - openPrintPreview(testClosePrintPreviewWithAccessKey); - } - }); -} - -function tidyUp() { - BrowserTestUtils.removeTab(ourTab).then(finish); -} - -function testClosePrintPreviewWithAccessKey() { - EventUtils.synthesizeKey("c", { altKey: true }); - checkPrintPreviewClosed(function (aSucceeded) { - ok(aSucceeded, - "print preview mode should be finished by access key"); - openPrintPreview(testClosePrintPreviewWithEscKey); - }); -} - -function testClosePrintPreviewWithEscKey() { - EventUtils.synthesizeKey("VK_ESCAPE", {}); - checkPrintPreviewClosed(function (aSucceeded) { - ok(aSucceeded, - "print preview mode should be finished by Esc key press"); - openPrintPreview(testClosePrintPreviewWithClosingWindowShortcutKey); - }); -} - -function testClosePrintPreviewWithClosingWindowShortcutKey() { - EventUtils.synthesizeKey("w", { accelKey: true }); - checkPrintPreviewClosed(function (aSucceeded) { - ok(aSucceeded, - "print preview mode should be finished by closing window shortcut key"); - tidyUp(); - }); -} - -function openPrintPreview(aCallback) { - document.getElementById("cmd_printPreview").doCommand(); - executeSoon(function () { - if (gInPrintPreviewMode) { - executeSoon(aCallback); - return; - } - executeSoon(arguments.callee); - }); -} - -function checkPrintPreviewClosed(aCallback) { - let count = 0; - executeSoon(function () { - if (!gInPrintPreviewMode) { - executeSoon(function () { aCallback(count < 1000); }); - return; - } - if (++count == 1000) { - // The test might fail. - PrintUtils.exitPrintPreview(); - } - executeSoon(arguments.callee); - }); -} diff --git a/browser/base/content/test/general/browser_private_browsing_window.js b/browser/base/content/test/general/browser_private_browsing_window.js deleted file mode 100644 index 607a34060..000000000 --- a/browser/base/content/test/general/browser_private_browsing_window.js +++ /dev/null @@ -1,65 +0,0 @@ -// Make sure that we can open private browsing windows - -function test() { - waitForExplicitFinish(); - var nonPrivateWin = OpenBrowserWindow(); - ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow() should open a normal window"); - nonPrivateWin.close(); - - var privateWin = OpenBrowserWindow({private: true}); - ok(PrivateBrowsingUtils.isWindowPrivate(privateWin), "OpenBrowserWindow({private: true}) should open a private window"); - - nonPrivateWin = OpenBrowserWindow({private: false}); - ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow({private: false}) should open a normal window"); - nonPrivateWin.close(); - - whenDelayedStartupFinished(privateWin, function() { - nonPrivateWin = privateWin.OpenBrowserWindow({private: false}); - ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "privateWin.OpenBrowserWindow({private: false}) should open a normal window"); - - nonPrivateWin.close(); - - [ - { normal: "menu_newNavigator", private: "menu_newPrivateWindow", accesskey: true }, - { normal: "appmenu_newNavigator", private: "appmenu_newPrivateWindow", accesskey: false }, - ].forEach(function(menu) { - let newWindow = privateWin.document.getElementById(menu.normal); - let newPrivateWindow = privateWin.document.getElementById(menu.private); - if (newWindow && newPrivateWindow) { - ok(!newPrivateWindow.hidden, "New Private Window menu item should be hidden"); - isnot(newWindow.label, newPrivateWindow.label, "New Window's label shouldn't be overwritten"); - if (menu.accesskey) { - isnot(newWindow.accessKey, newPrivateWindow.accessKey, "New Window's accessKey shouldn't be overwritten"); - } - isnot(newWindow.command, newPrivateWindow.command, "New Window's command shouldn't be overwritten"); - } - }); - - privateWin.close(); - - Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true); - privateWin = OpenBrowserWindow({private: true}); - whenDelayedStartupFinished(privateWin, function() { - [ - { normal: "menu_newNavigator", private: "menu_newPrivateWindow", accessKey: true }, - { normal: "appmenu_newNavigator", private: "appmenu_newPrivateWindow", accessKey: false }, - ].forEach(function(menu) { - let newWindow = privateWin.document.getElementById(menu.normal); - let newPrivateWindow = privateWin.document.getElementById(menu.private); - if (newWindow && newPrivateWindow) { - ok(newPrivateWindow.hidden, "New Private Window menu item should be hidden"); - is(newWindow.label, newPrivateWindow.label, "New Window's label should be overwritten"); - if (menu.accesskey) { - is(newWindow.accessKey, newPrivateWindow.accessKey, "New Window's accessKey should be overwritten"); - } - is(newWindow.command, newPrivateWindow.command, "New Window's command should be overwritten"); - } - }); - - privateWin.close(); - Services.prefs.clearUserPref("browser.privatebrowsing.autostart"); - finish(); - }); - }); -} - diff --git a/browser/base/content/test/general/browser_private_no_prompt.js b/browser/base/content/test/general/browser_private_no_prompt.js deleted file mode 100644 index c6c580f80..000000000 --- a/browser/base/content/test/general/browser_private_no_prompt.js +++ /dev/null @@ -1,12 +0,0 @@ -function test() { - waitForExplicitFinish(); - var privateWin = OpenBrowserWindow({private: true}); - - whenDelayedStartupFinished(privateWin, function () { - privateWin.BrowserOpenTab(); - privateWin.BrowserTryToCloseWindow(); - ok(true, "didn't prompt"); - - executeSoon(finish); - }); -} diff --git a/browser/base/content/test/general/browser_purgehistory_clears_sh.js b/browser/base/content/test/general/browser_purgehistory_clears_sh.js deleted file mode 100644 index 1a1e6554d..000000000 --- a/browser/base/content/test/general/browser_purgehistory_clears_sh.js +++ /dev/null @@ -1,60 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -const url = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; - -add_task(function* purgeHistoryTest() { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url, - }, function* purgeHistoryTestInner(browser) { - let backButton = browser.ownerDocument.getElementById("Browser:Back"); - let forwardButton = browser.ownerDocument.getElementById("Browser:Forward"); - - ok(!browser.webNavigation.canGoBack, - "Initial value for webNavigation.canGoBack"); - ok(!browser.webNavigation.canGoForward, - "Initial value for webNavigation.canGoBack"); - ok(backButton.hasAttribute("disabled"), "Back button is disabled"); - ok(forwardButton.hasAttribute("disabled"), "Forward button is disabled"); - - yield ContentTask.spawn(browser, null, function*() { - let startHistory = content.history.length; - content.history.pushState({}, ""); - content.history.pushState({}, ""); - content.history.back(); - let newHistory = content.history.length; - Assert.equal(startHistory, 1, "Initial SHistory size"); - Assert.equal(newHistory, 3, "New SHistory size"); - }); - - ok(browser.webNavigation.canGoBack, true, - "New value for webNavigation.canGoBack"); - ok(browser.webNavigation.canGoForward, true, - "New value for webNavigation.canGoForward"); - ok(!backButton.hasAttribute("disabled"), "Back button was enabled"); - ok(!forwardButton.hasAttribute("disabled"), "Forward button was enabled"); - - - let tmp = {}; - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://browser/content/sanitize.js", tmp); - - let {Sanitizer} = tmp; - let sanitizer = new Sanitizer(); - - yield sanitizer.sanitize(["history"]); - - yield ContentTask.spawn(browser, null, function*() { - Assert.equal(content.history.length, 1, "SHistory correctly cleared"); - }); - - ok(!browser.webNavigation.canGoBack, - "webNavigation.canGoBack correctly cleared"); - ok(!browser.webNavigation.canGoForward, - "webNavigation.canGoForward correctly cleared"); - ok(backButton.hasAttribute("disabled"), "Back button was disabled"); - ok(forwardButton.hasAttribute("disabled"), "Forward button was disabled"); - }); -}); diff --git a/browser/base/content/test/general/browser_refreshBlocker.js b/browser/base/content/test/general/browser_refreshBlocker.js deleted file mode 100644 index ee274f2c2..000000000 --- a/browser/base/content/test/general/browser_refreshBlocker.js +++ /dev/null @@ -1,135 +0,0 @@ -"use strict"; - -const META_PAGE = "http://example.org/browser/browser/base/content/test/general/refresh_meta.sjs" -const HEADER_PAGE = "http://example.org/browser/browser/base/content/test/general/refresh_header.sjs" -const TARGET_PAGE = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; -const PREF = "accessibility.blockautorefresh"; - -/** - * Goes into the content, and simulates a meta-refresh header at a very - * low level, and checks to see if it was blocked. This will always cancel - * the refresh, regardless of whether or not the refresh was blocked. - * - * @param browser (<xul:browser>) - * The browser to test for refreshing. - * @param expectRefresh (bool) - * Whether or not we expect the refresh attempt to succeed. - * @returns Promise - */ -function* attemptFakeRefresh(browser, expectRefresh) { - yield ContentTask.spawn(browser, expectRefresh, function*(contentExpectRefresh) { - let URI = docShell.QueryInterface(Ci.nsIWebNavigation).currentURI; - let refresher = docShell.QueryInterface(Ci.nsIRefreshURI); - refresher.refreshURI(URI, 0, false, true); - - Assert.equal(refresher.refreshPending, contentExpectRefresh, - "Got the right refreshPending state"); - - if (refresher.refreshPending) { - // Cancel the pending refresh - refresher.cancelRefreshURITimers(); - } - - // The RefreshBlocker will wait until onLocationChange has - // been fired before it will show any notifications (see bug - // 1246291), so we cause this to occur manually here. - content.location = URI.spec + "#foo"; - }); -} - -/** - * Tests that we can enable the blocking pref and block a refresh - * from occurring while showing a notification bar. Also tests that - * when we disable the pref, that refreshes can go through again. - */ -add_task(function* test_can_enable_and_block() { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: TARGET_PAGE, - }, function*(browser) { - // By default, we should be able to reload the page. - yield attemptFakeRefresh(browser, true); - - yield pushPrefs(["accessibility.blockautorefresh", true]); - - let notificationPromise = - BrowserTestUtils.waitForNotificationBar(gBrowser, browser, - "refresh-blocked"); - - yield attemptFakeRefresh(browser, false); - - yield notificationPromise; - - yield pushPrefs(["accessibility.blockautorefresh", false]); - - // Page reloads should go through again. - yield attemptFakeRefresh(browser, true); - }); -}); - -/** - * Attempts a "real" refresh by opening a tab, and then sending it to - * an SJS page that will attempt to cause a refresh. This will also pass - * a delay amount to the SJS page. The refresh should be blocked, and - * the notification should be shown. Once shown, the "Allow" button will - * be clicked, and the refresh will go through. Finally, the helper will - * close the tab and resolve the Promise. - * - * @param refreshPage (string) - * The SJS page to use. Use META_PAGE for the <meta> tag refresh - * case. Use HEADER_PAGE for the HTTP header case. - * @param delay (int) - * The amount, in ms, for the page to wait before attempting the - * refresh. - * - * @returns Promise - */ -function* testRealRefresh(refreshPage, delay) { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: "about:blank", - }, function*(browser) { - yield pushPrefs(["accessibility.blockautorefresh", true]); - - browser.loadURI(refreshPage + "?p=" + TARGET_PAGE + "&d=" + delay); - yield BrowserTestUtils.browserLoaded(browser); - - // Once browserLoaded resolves, all nsIWebProgressListener callbacks - // should have fired, so the notification should be visible. - let notificationBox = gBrowser.getNotificationBox(browser); - let notification = notificationBox.currentNotification; - - ok(notification, "Notification should be visible"); - is(notification.value, "refresh-blocked", - "Should be showing the right notification"); - - // Then click the button to allow the refresh. - let buttons = notification.querySelectorAll(".notification-button"); - is(buttons.length, 1, "Should have one button."); - - // Prepare a Promise that should resolve when the refresh goes through - let refreshPromise = BrowserTestUtils.browserLoaded(browser); - buttons[0].click(); - - yield refreshPromise; - }); -} - -/** - * Tests the meta-tag case for both short and longer delay times. - */ -add_task(function* test_can_allow_refresh() { - yield testRealRefresh(META_PAGE, 0); - yield testRealRefresh(META_PAGE, 100); - yield testRealRefresh(META_PAGE, 500); -}); - -/** - * Tests that when a HTTP header case for both short and longer - * delay times. - */ -add_task(function* test_can_block_refresh_from_header() { - yield testRealRefresh(HEADER_PAGE, 0); - yield testRealRefresh(HEADER_PAGE, 100); - yield testRealRefresh(HEADER_PAGE, 500); -}); diff --git a/browser/base/content/test/general/browser_registerProtocolHandler_notification.html b/browser/base/content/test/general/browser_registerProtocolHandler_notification.html deleted file mode 100644 index 241b03b95..000000000 --- a/browser/base/content/test/general/browser_registerProtocolHandler_notification.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> -<html> - <head> - <title>Protocol registrar page</title> - <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> - <meta content="utf-8" http-equiv="encoding"> - </head> - <body> - <script type="text/javascript"> - navigator.registerProtocolHandler("testprotocol", - "https://example.com/foobar?uri=%s", - "Test Protocol"); - </script> - </body> -</html> diff --git a/browser/base/content/test/general/browser_registerProtocolHandler_notification.js b/browser/base/content/test/general/browser_registerProtocolHandler_notification.js deleted file mode 100644 index b30ece0f6..000000000 --- a/browser/base/content/test/general/browser_registerProtocolHandler_notification.js +++ /dev/null @@ -1,43 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - waitForExplicitFinish(); - let notificationValue = "Protocol Registration: testprotocol"; - let testURI = "http://example.com/browser/" + - "browser/base/content/test/general/browser_registerProtocolHandler_notification.html"; - - waitForCondition(function() { - // Do not start until the notification is up - let notificationBox = window.gBrowser.getNotificationBox(); - let notification = notificationBox.getNotificationWithValue(notificationValue); - return notification; - }, - function() { - - let notificationBox = window.gBrowser.getNotificationBox(); - let notification = notificationBox.getNotificationWithValue(notificationValue); - ok(notification, "Notification box should be displayed"); - if (notification == null) { - finish(); - return; - } - is(notification.type, "info", "We expect this notification to have the type of 'info'."); - isnot(notification.image, null, "We expect this notification to have an icon."); - - let buttons = notification.getElementsByClassName("notification-button-default"); - is(buttons.length, 1, "We expect see one default button."); - - buttons = notification.getElementsByClassName("notification-button"); - is(buttons.length, 1, "We expect see one button."); - - let button = buttons[0]; - isnot(button.label, null, "We expect the add button to have a label."); - todo_isnot(button.accesskey, null, "We expect the add button to have a accesskey."); - - finish(); - }, "Still can not get notification after retry 100 times.", 100); - - window.gBrowser.selectedBrowser.loadURI(testURI); -} diff --git a/browser/base/content/test/general/browser_relatedTabs.js b/browser/base/content/test/general/browser_relatedTabs.js deleted file mode 100644 index 97cf51d84..000000000 --- a/browser/base/content/test/general/browser_relatedTabs.js +++ /dev/null @@ -1,51 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -add_task(function*() { - is(gBrowser.tabs.length, 1, "one tab is open initially"); - - // Add several new tabs in sequence, interrupted by selecting a - // different tab, moving a tab around and closing a tab, - // returning a list of opened tabs for verifying the expected order. - // The new tab behaviour is documented in bug 465673 - let tabs = []; - function addTab(aURL, aReferrer) { - let tab = gBrowser.addTab(aURL, {referrerURI: aReferrer}); - tabs.push(tab); - return BrowserTestUtils.browserLoaded(tab.linkedBrowser); - } - - yield addTab("http://mochi.test:8888/#0"); - gBrowser.selectedTab = tabs[0]; - yield addTab("http://mochi.test:8888/#1"); - yield addTab("http://mochi.test:8888/#2", gBrowser.currentURI); - yield addTab("http://mochi.test:8888/#3", gBrowser.currentURI); - gBrowser.selectedTab = tabs[tabs.length - 1]; - gBrowser.selectedTab = tabs[0]; - yield addTab("http://mochi.test:8888/#4", gBrowser.currentURI); - gBrowser.selectedTab = tabs[3]; - yield addTab("http://mochi.test:8888/#5", gBrowser.currentURI); - gBrowser.removeTab(tabs.pop()); - yield addTab("about:blank", gBrowser.currentURI); - gBrowser.moveTabTo(gBrowser.selectedTab, 1); - yield addTab("http://mochi.test:8888/#6", gBrowser.currentURI); - yield addTab(); - yield addTab("http://mochi.test:8888/#7"); - - function testPosition(tabNum, expectedPosition, msg) { - is(Array.indexOf(gBrowser.tabs, tabs[tabNum]), expectedPosition, msg); - } - - testPosition(0, 3, "tab without referrer was opened to the far right"); - testPosition(1, 7, "tab without referrer was opened to the far right"); - testPosition(2, 5, "tab with referrer opened immediately to the right"); - testPosition(3, 1, "next tab with referrer opened further to the right"); - testPosition(4, 4, "tab selection changed, tab opens immediately to the right"); - testPosition(5, 6, "blank tab with referrer opens to the right of 3rd original tab where removed tab was"); - testPosition(6, 2, "tab has moved, new tab opens immediately to the right"); - testPosition(7, 8, "blank tab without referrer opens at the end"); - testPosition(8, 9, "tab without referrer opens at the end"); - - tabs.forEach(gBrowser.removeTab, gBrowser); -}); diff --git a/browser/base/content/test/general/browser_remoteTroubleshoot.js b/browser/base/content/test/general/browser_remoteTroubleshoot.js deleted file mode 100644 index 5c939dbd0..000000000 --- a/browser/base/content/test/general/browser_remoteTroubleshoot.js +++ /dev/null @@ -1,93 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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 {WebChannel} = Cu.import("resource://gre/modules/WebChannel.jsm", {}); - -const TEST_URL_TAIL = "example.com/browser/browser/base/content/test/general/test_remoteTroubleshoot.html" -const TEST_URI_GOOD = Services.io.newURI("https://" + TEST_URL_TAIL, null, null); -const TEST_URI_BAD = Services.io.newURI("http://" + TEST_URL_TAIL, null, null); -const TEST_URI_GOOD_OBJECT = Services.io.newURI("https://" + TEST_URL_TAIL + "?object", null, null); - -// Creates a one-shot web-channel for the test data to be sent back from the test page. -function promiseChannelResponse(channelID, originOrPermission) { - return new Promise((resolve, reject) => { - let channel = new WebChannel(channelID, originOrPermission); - channel.listen((id, data, target) => { - channel.stopListening(); - resolve(data); - }); - }); -} - -// Loads the specified URI in a new tab and waits for it to send us data on our -// test web-channel and resolves with that data. -function promiseNewChannelResponse(uri) { - let channelPromise = promiseChannelResponse("test-remote-troubleshooting-backchannel", - uri); - let tab = gBrowser.loadOneTab(uri.spec, { inBackground: false }); - return promiseTabLoaded(tab).then( - () => channelPromise - ).then(data => { - gBrowser.removeTab(tab); - return data; - }); -} - -add_task(function*() { - // We haven't set a permission yet - so even the "good" URI should fail. - let got = yield promiseNewChannelResponse(TEST_URI_GOOD); - // Should have no data. - Assert.ok(got.message === undefined, "should have failed to get any data"); - - // Add a permission manager entry for our URI. - Services.perms.add(TEST_URI_GOOD, - "remote-troubleshooting", - Services.perms.ALLOW_ACTION); - registerCleanupFunction(() => { - Services.perms.remove(TEST_URI_GOOD, "remote-troubleshooting"); - }); - - // Try again - now we are expecting a response with the actual data. - got = yield promiseNewChannelResponse(TEST_URI_GOOD); - - // Check some keys we expect to always get. - Assert.ok(got.message.extensions, "should have extensions"); - Assert.ok(got.message.graphics, "should have graphics"); - - // Check we have channel and build ID info: - Assert.equal(got.message.application.buildID, Services.appinfo.appBuildID, - "should have correct build ID"); - - let updateChannel = null; - try { - updateChannel = Cu.import("resource://gre/modules/UpdateUtils.jsm", {}).UpdateUtils.UpdateChannel; - } catch (ex) {} - if (!updateChannel) { - Assert.ok(!('updateChannel' in got.message.application), - "should not have update channel where not available."); - } else { - Assert.equal(got.message.application.updateChannel, updateChannel, - "should have correct update channel."); - } - - - // And check some keys we know we decline to return. - Assert.ok(!got.message.modifiedPreferences, "should not have a modifiedPreferences key"); - Assert.ok(!got.message.crashes, "should not have crash info"); - - // Now a http:// URI - should get nothing even with the permission setup. - got = yield promiseNewChannelResponse(TEST_URI_BAD); - Assert.ok(got.message === undefined, "should have failed to get any data"); - - // Check that the page can send an object as well if it's in the whitelist - let webchannelWhitelistPref = "webchannel.allowObject.urlWhitelist"; - let origWhitelist = Services.prefs.getCharPref(webchannelWhitelistPref); - let newWhitelist = origWhitelist + " https://example.com"; - Services.prefs.setCharPref(webchannelWhitelistPref, newWhitelist); - registerCleanupFunction(() => { - Services.prefs.clearUserPref(webchannelWhitelistPref); - }); - got = yield promiseNewChannelResponse(TEST_URI_GOOD_OBJECT); - Assert.ok(got.message, "should have gotten some data back"); -}); diff --git a/browser/base/content/test/general/browser_remoteWebNavigation_postdata.js b/browser/base/content/test/general/browser_remoteWebNavigation_postdata.js deleted file mode 100644 index 451323f50..000000000 --- a/browser/base/content/test/general/browser_remoteWebNavigation_postdata.js +++ /dev/null @@ -1,50 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -Cu.import("resource://gre/modules/BrowserUtils.jsm"); -Cu.import("resource://gre/modules/Promise.jsm"); - -function makeInputStream(aString) { - let stream = Cc["@mozilla.org/io/string-input-stream;1"] - .createInstance(Ci.nsIStringInputStream); - stream.data = aString; - return stream; // XPConnect will QI this to nsIInputStream for us. -} - -add_task(function* test_remoteWebNavigation_postdata() { - let obj = {}; - Cu.import("resource://testing-common/httpd.js", obj); - Cu.import("resource://services-common/utils.js", obj); - - let server = new obj.HttpServer(); - server.start(-1); - - let loadDeferred = Promise.defer(); - - server.registerPathHandler("/test", (request, response) => { - let body = obj.CommonUtils.readBytesFromInputStream(request.bodyInputStream); - is(body, "success", "request body is correct"); - is(request.method, "POST", "request was a post"); - response.write("Received from POST: " + body); - loadDeferred.resolve(); - }); - - let i = server.identity; - let path = i.primaryScheme + "://" + i.primaryHost + ":" + i.primaryPort + "/test"; - - let postdata = - "Content-Length: 7\r\n" + - "Content-Type: application/x-www-form-urlencoded\r\n" + - "\r\n" + - "success"; - - openUILinkIn(path, "tab", null, makeInputStream(postdata)); - - yield loadDeferred.promise; - yield BrowserTestUtils.removeTab(gBrowser.selectedTab); - - let serverStoppedDeferred = Promise.defer(); - server.stop(function() { serverStoppedDeferred.resolve(); }); - yield serverStoppedDeferred.promise; -}); diff --git a/browser/base/content/test/general/browser_removeTabsToTheEnd.js b/browser/base/content/test/general/browser_removeTabsToTheEnd.js deleted file mode 100644 index 351085d74..000000000 --- a/browser/base/content/test/general/browser_removeTabsToTheEnd.js +++ /dev/null @@ -1,24 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - // Add two new tabs after the original tab. Pin the first one. - let originalTab = gBrowser.selectedTab; - let newTab1 = gBrowser.addTab(); - gBrowser.addTab(); - gBrowser.pinTab(newTab1); - - // Check that there is only one closable tab from originalTab to the end - is(gBrowser.getTabsToTheEndFrom(originalTab).length, 1, - "One unpinned tab to the right"); - - // Remove tabs to the end - gBrowser.removeTabsToTheEndFrom(originalTab); - is(gBrowser.tabs.length, 2, "Length is 2"); - is(gBrowser.tabs[1], originalTab, "Starting tab is not removed"); - is(gBrowser.tabs[0], newTab1, "Pinned tab is not removed"); - - // Remove pinned tab - gBrowser.removeTab(newTab1); -} diff --git a/browser/base/content/test/general/browser_restore_isAppTab.js b/browser/base/content/test/general/browser_restore_isAppTab.js deleted file mode 100644 index e20974d80..000000000 --- a/browser/base/content/test/general/browser_restore_isAppTab.js +++ /dev/null @@ -1,160 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); - -const DUMMY = "http://example.com/browser/browser/base/content/test/general/dummy_page.html"; - -function getMinidumpDirectory() { - let dir = Services.dirsvc.get('ProfD', Ci.nsIFile); - dir.append("minidumps"); - return dir; -} - -// This observer is needed so we can clean up all evidence of the crash so -// the testrunner thinks things are peachy. -var CrashObserver = { - observe: function(subject, topic, data) { - is(topic, 'ipc:content-shutdown', 'Received correct observer topic.'); - ok(subject instanceof Ci.nsIPropertyBag2, - 'Subject implements nsIPropertyBag2.'); - // we might see this called as the process terminates due to previous tests. - // We are only looking for "abnormal" exits... - if (!subject.hasKey("abnormal")) { - info("This is a normal termination and isn't the one we are looking for..."); - return; - } - - let dumpID; - if ('nsICrashReporter' in Ci) { - dumpID = subject.getPropertyAsAString('dumpID'); - ok(dumpID, "dumpID is present and not an empty string"); - } - - if (dumpID) { - let minidumpDirectory = getMinidumpDirectory(); - let file = minidumpDirectory.clone(); - file.append(dumpID + '.dmp'); - file.remove(true); - file = minidumpDirectory.clone(); - file.append(dumpID + '.extra'); - file.remove(true); - } - } -} -Services.obs.addObserver(CrashObserver, 'ipc:content-shutdown', false); - -registerCleanupFunction(() => { - Services.obs.removeObserver(CrashObserver, 'ipc:content-shutdown'); -}); - -function frameScript() { - addMessageListener("Test:GetIsAppTab", function() { - sendAsyncMessage("Test:IsAppTab", { isAppTab: docShell.isAppTab }); - }); - - addMessageListener("Test:Crash", function() { - privateNoteIntentionalCrash(); - Components.utils.import("resource://gre/modules/ctypes.jsm"); - let zero = new ctypes.intptr_t(8); - let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t)); - badptr.contents - }); -} - -function loadFrameScript(browser) { - browser.messageManager.loadFrameScript("data:,(" + frameScript.toString() + ")();", true); -} - -function isBrowserAppTab(browser) { - return new Promise(resolve => { - function listener({ data }) { - browser.messageManager.removeMessageListener("Test:IsAppTab", listener); - resolve(data.isAppTab); - } - // It looks like same-process messages may be reordered by the message - // manager, so we need to wait one tick before sending the message. - executeSoon(function () { - browser.messageManager.addMessageListener("Test:IsAppTab", listener); - browser.messageManager.sendAsyncMessage("Test:GetIsAppTab"); - }); - }); -} - -// Restarts the child process by crashing it then reloading the tab -var restart = Task.async(function*(browser) { - // If the tab isn't remote this would crash the main process so skip it - if (!browser.isRemoteBrowser) - return; - - // Make sure the main process has all of the current tab state before crashing - yield TabStateFlusher.flush(browser); - - browser.messageManager.sendAsyncMessage("Test:Crash"); - yield promiseWaitForEvent(browser, "AboutTabCrashedLoad", false, true); - - let tab = gBrowser.getTabForBrowser(browser); - SessionStore.reviveCrashedTab(tab); - - yield promiseTabLoaded(tab); -}); - -add_task(function* navigate() { - let tab = gBrowser.addTab("about:robots"); - let browser = tab.linkedBrowser; - gBrowser.selectedTab = tab; - yield waitForDocLoadComplete(); - loadFrameScript(browser); - let isAppTab = yield isBrowserAppTab(browser); - ok(!isAppTab, "Docshell shouldn't think it is an app tab"); - - gBrowser.pinTab(tab); - isAppTab = yield isBrowserAppTab(browser); - ok(isAppTab, "Docshell should think it is an app tab"); - - gBrowser.loadURI(DUMMY); - yield waitForDocLoadComplete(); - loadFrameScript(browser); - isAppTab = yield isBrowserAppTab(browser); - ok(isAppTab, "Docshell should think it is an app tab"); - - gBrowser.unpinTab(tab); - isAppTab = yield isBrowserAppTab(browser); - ok(!isAppTab, "Docshell shouldn't think it is an app tab"); - - gBrowser.pinTab(tab); - isAppTab = yield isBrowserAppTab(browser); - ok(isAppTab, "Docshell should think it is an app tab"); - - gBrowser.loadURI("about:robots"); - yield waitForDocLoadComplete(); - loadFrameScript(browser); - isAppTab = yield isBrowserAppTab(browser); - ok(isAppTab, "Docshell should think it is an app tab"); - - gBrowser.removeCurrentTab(); -}); - -add_task(function* crash() { - if (!gMultiProcessBrowser || !("nsICrashReporter" in Ci)) - return; - - let tab = gBrowser.addTab(DUMMY); - let browser = tab.linkedBrowser; - gBrowser.selectedTab = tab; - yield waitForDocLoadComplete(); - loadFrameScript(browser); - let isAppTab = yield isBrowserAppTab(browser); - ok(!isAppTab, "Docshell shouldn't think it is an app tab"); - - gBrowser.pinTab(tab); - isAppTab = yield isBrowserAppTab(browser); - ok(isAppTab, "Docshell should think it is an app tab"); - - yield restart(browser); - loadFrameScript(browser); - isAppTab = yield isBrowserAppTab(browser); - ok(isAppTab, "Docshell should think it is an app tab"); - - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_sanitize-passwordDisabledHosts.js b/browser/base/content/test/general/browser_sanitize-passwordDisabledHosts.js deleted file mode 100644 index 4f4f5c398..000000000 --- a/browser/base/content/test/general/browser_sanitize-passwordDisabledHosts.js +++ /dev/null @@ -1,39 +0,0 @@ -// Bug 474792 - Clear "Never remember passwords for this site" when -// clearing site-specific settings in Clear Recent History dialog - -var tempScope = {}; -Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://browser/content/sanitize.js", tempScope); -var Sanitizer = tempScope.Sanitizer; - -add_task(function*() { - var pwmgr = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager); - - // Add a disabled host - pwmgr.setLoginSavingEnabled("http://example.com", false); - // Sanity check - is(pwmgr.getLoginSavingEnabled("http://example.com"), false, - "example.com should be disabled for password saving since we haven't cleared that yet."); - - // Set up the sanitizer to just clear siteSettings - let s = new Sanitizer(); - s.ignoreTimespan = false; - s.prefDomain = "privacy.cpd."; - var itemPrefs = gPrefService.getBranch(s.prefDomain); - itemPrefs.setBoolPref("history", false); - itemPrefs.setBoolPref("downloads", false); - itemPrefs.setBoolPref("cache", false); - itemPrefs.setBoolPref("cookies", false); - itemPrefs.setBoolPref("formdata", false); - itemPrefs.setBoolPref("offlineApps", false); - itemPrefs.setBoolPref("passwords", false); - itemPrefs.setBoolPref("sessions", false); - itemPrefs.setBoolPref("siteSettings", true); - - // Clear it - yield s.sanitize(); - - // Make sure it's gone - is(pwmgr.getLoginSavingEnabled("http://example.com"), true, - "example.com should be enabled for password saving again now that we've cleared."); -}); diff --git a/browser/base/content/test/general/browser_sanitize-sitepermissions.js b/browser/base/content/test/general/browser_sanitize-sitepermissions.js deleted file mode 100644 index 1b43d62fc..000000000 --- a/browser/base/content/test/general/browser_sanitize-sitepermissions.js +++ /dev/null @@ -1,52 +0,0 @@ -// Bug 380852 - Delete permission manager entries in Clear Recent History - -var tempScope = {}; -Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://browser/content/sanitize.js", tempScope); -var Sanitizer = tempScope.Sanitizer; - -function countPermissions() { - let result = 0; - let enumerator = Services.perms.enumerator; - while (enumerator.hasMoreElements()) { - result++; - enumerator.getNext(); - } - return result; -} - -add_task(function* test() { - // sanitize before we start so we have a good baseline. - // Set up the sanitizer to just clear siteSettings - let s = new Sanitizer(); - s.ignoreTimespan = false; - s.prefDomain = "privacy.cpd."; - var itemPrefs = gPrefService.getBranch(s.prefDomain); - itemPrefs.setBoolPref("history", false); - itemPrefs.setBoolPref("downloads", false); - itemPrefs.setBoolPref("cache", false); - itemPrefs.setBoolPref("cookies", false); - itemPrefs.setBoolPref("formdata", false); - itemPrefs.setBoolPref("offlineApps", false); - itemPrefs.setBoolPref("passwords", false); - itemPrefs.setBoolPref("sessions", false); - itemPrefs.setBoolPref("siteSettings", true); - s.sanitize(); - - // Count how many permissions we start with - some are defaults that - // will not be sanitized. - let numAtStart = countPermissions(); - - // Add a permission entry - var pm = Services.perms; - pm.add(makeURI("http://example.com"), "testing", pm.ALLOW_ACTION); - - // Sanity check - ok(pm.enumerator.hasMoreElements(), "Permission manager should have elements, since we just added one"); - - // Clear it - yield s.sanitize(); - - // Make sure it's gone - is(numAtStart, countPermissions(), "Permission manager should have the same count it started with"); -}); diff --git a/browser/base/content/test/general/browser_sanitize-timespans.js b/browser/base/content/test/general/browser_sanitize-timespans.js deleted file mode 100644 index 3712c5e1c..000000000 --- a/browser/base/content/test/general/browser_sanitize-timespans.js +++ /dev/null @@ -1,733 +0,0 @@ -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -requestLongerTimeout(2); - -// Bug 453440 - Test the timespan-based logic of the sanitizer code -var now_mSec = Date.now(); -var now_uSec = now_mSec * 1000; - -const kMsecPerMin = 60 * 1000; -const kUsecPerMin = 60 * 1000000; - -var tempScope = {}; -Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://browser/content/sanitize.js", tempScope); -var Sanitizer = tempScope.Sanitizer; - -var FormHistory = (Components.utils.import("resource://gre/modules/FormHistory.jsm", {})).FormHistory; -var Downloads = (Components.utils.import("resource://gre/modules/Downloads.jsm", {})).Downloads; - -function promiseFormHistoryRemoved() { - let deferred = Promise.defer(); - Services.obs.addObserver(function onfh() { - Services.obs.removeObserver(onfh, "satchel-storage-changed", false); - deferred.resolve(); - }, "satchel-storage-changed", false); - return deferred.promise; -} - -function promiseDownloadRemoved(list) { - let deferred = Promise.defer(); - - let view = { - onDownloadRemoved: function(download) { - list.removeView(view); - deferred.resolve(); - } - }; - - list.addView(view); - - return deferred.promise; -} - -add_task(function* test() { - yield setupDownloads(); - yield setupFormHistory(); - yield setupHistory(); - yield onHistoryReady(); -}); - -function countEntries(name, message, check) { - let deferred = Promise.defer(); - - var obj = {}; - if (name !== null) - obj.fieldname = name; - - let count; - FormHistory.count(obj, { handleResult: result => count = result, - handleError: function (error) { - deferred.reject(error) - throw new Error("Error occurred searching form history: " + error); - }, - handleCompletion: function (reason) { - if (!reason) { - check(count, message); - deferred.resolve(); - } - }, - }); - - return deferred.promise; -} - -function* onHistoryReady() { - var hoursSinceMidnight = new Date().getHours(); - var minutesSinceMidnight = hoursSinceMidnight * 60 + new Date().getMinutes(); - - // Should test cookies here, but nsICookieManager/nsICookieService - // doesn't let us fake creation times. bug 463127 - - let s = new Sanitizer(); - s.ignoreTimespan = false; - s.prefDomain = "privacy.cpd."; - var itemPrefs = gPrefService.getBranch(s.prefDomain); - itemPrefs.setBoolPref("history", true); - itemPrefs.setBoolPref("downloads", true); - itemPrefs.setBoolPref("cache", false); - itemPrefs.setBoolPref("cookies", false); - itemPrefs.setBoolPref("formdata", true); - itemPrefs.setBoolPref("offlineApps", false); - itemPrefs.setBoolPref("passwords", false); - itemPrefs.setBoolPref("sessions", false); - itemPrefs.setBoolPref("siteSettings", false); - - let publicList = yield Downloads.getList(Downloads.PUBLIC); - let downloadPromise = promiseDownloadRemoved(publicList); - let formHistoryPromise = promiseFormHistoryRemoved(); - - // Clear 10 minutes ago - s.range = [now_uSec - 10*60*1000000, now_uSec]; - yield s.sanitize(); - s.range = null; - - yield formHistoryPromise; - yield downloadPromise; - - ok(!(yield promiseIsURIVisited(makeURI("http://10minutes.com"))), - "Pretend visit to 10minutes.com should now be deleted"); - ok((yield promiseIsURIVisited(makeURI("http://1hour.com"))), - "Pretend visit to 1hour.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://1hour10minutes.com"))), - "Pretend visit to 1hour10minutes.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://2hour.com"))), - "Pretend visit to 2hour.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://2hour10minutes.com"))), - "Pretend visit to 2hour10minutes.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://4hour.com"))), - "Pretend visit to 4hour.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))), - "Pretend visit to 4hour10minutes.com should should still exist"); - if (minutesSinceMidnight > 10) { - ok((yield promiseIsURIVisited(makeURI("http://today.com"))), - "Pretend visit to today.com should still exist"); - } - ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))), - "Pretend visit to before-today.com should still exist"); - - let checkZero = function(num, message) { is(num, 0, message); } - let checkOne = function(num, message) { is(num, 1, message); } - - yield countEntries("10minutes", "10minutes form entry should be deleted", checkZero); - yield countEntries("1hour", "1hour form entry should still exist", checkOne); - yield countEntries("1hour10minutes", "1hour10minutes form entry should still exist", checkOne); - yield countEntries("2hour", "2hour form entry should still exist", checkOne); - yield countEntries("2hour10minutes", "2hour10minutes form entry should still exist", checkOne); - yield countEntries("4hour", "4hour form entry should still exist", checkOne); - yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne); - if (minutesSinceMidnight > 10) - yield countEntries("today", "today form entry should still exist", checkOne); - yield countEntries("b4today", "b4today form entry should still exist", checkOne); - - ok(!(yield downloadExists(publicList, "fakefile-10-minutes")), "10 minute download should now be deleted"); - ok((yield downloadExists(publicList, "fakefile-1-hour")), "<1 hour download should still be present"); - ok((yield downloadExists(publicList, "fakefile-1-hour-10-minutes")), "1 hour 10 minute download should still be present"); - ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-2-hour")), "<2 hour old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute download should still be present"); - ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present"); - - if (minutesSinceMidnight > 10) - ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present"); - - downloadPromise = promiseDownloadRemoved(publicList); - formHistoryPromise = promiseFormHistoryRemoved(); - - // Clear 1 hour - Sanitizer.prefs.setIntPref("timeSpan", 1); - yield s.sanitize(); - - yield formHistoryPromise; - yield downloadPromise; - - ok(!(yield promiseIsURIVisited(makeURI("http://1hour.com"))), - "Pretend visit to 1hour.com should now be deleted"); - ok((yield promiseIsURIVisited(makeURI("http://1hour10minutes.com"))), - "Pretend visit to 1hour10minutes.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://2hour.com"))), - "Pretend visit to 2hour.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://2hour10minutes.com"))), - "Pretend visit to 2hour10minutes.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://4hour.com"))), - "Pretend visit to 4hour.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))), - "Pretend visit to 4hour10minutes.com should should still exist"); - if (hoursSinceMidnight > 1) { - ok((yield promiseIsURIVisited(makeURI("http://today.com"))), - "Pretend visit to today.com should still exist"); - } - ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))), - "Pretend visit to before-today.com should still exist"); - - yield countEntries("1hour", "1hour form entry should be deleted", checkZero); - yield countEntries("1hour10minutes", "1hour10minutes form entry should still exist", checkOne); - yield countEntries("2hour", "2hour form entry should still exist", checkOne); - yield countEntries("2hour10minutes", "2hour10minutes form entry should still exist", checkOne); - yield countEntries("4hour", "4hour form entry should still exist", checkOne); - yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne); - if (hoursSinceMidnight > 1) - yield countEntries("today", "today form entry should still exist", checkOne); - yield countEntries("b4today", "b4today form entry should still exist", checkOne); - - ok(!(yield downloadExists(publicList, "fakefile-1-hour")), "<1 hour download should now be deleted"); - ok((yield downloadExists(publicList, "fakefile-1-hour-10-minutes")), "1 hour 10 minute download should still be present"); - ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-2-hour")), "<2 hour old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute download should still be present"); - ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present"); - - if (hoursSinceMidnight > 1) - ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present"); - - downloadPromise = promiseDownloadRemoved(publicList); - formHistoryPromise = promiseFormHistoryRemoved(); - - // Clear 1 hour 10 minutes - s.range = [now_uSec - 70*60*1000000, now_uSec]; - yield s.sanitize(); - s.range = null; - - yield formHistoryPromise; - yield downloadPromise; - - ok(!(yield promiseIsURIVisited(makeURI("http://1hour10minutes.com"))), - "Pretend visit to 1hour10minutes.com should now be deleted"); - ok((yield promiseIsURIVisited(makeURI("http://2hour.com"))), - "Pretend visit to 2hour.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://2hour10minutes.com"))), - "Pretend visit to 2hour10minutes.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://4hour.com"))), - "Pretend visit to 4hour.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))), - "Pretend visit to 4hour10minutes.com should should still exist"); - if (minutesSinceMidnight > 70) { - ok((yield promiseIsURIVisited(makeURI("http://today.com"))), - "Pretend visit to today.com should still exist"); - } - ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))), - "Pretend visit to before-today.com should still exist"); - - yield countEntries("1hour10minutes", "1hour10minutes form entry should be deleted", checkZero); - yield countEntries("2hour", "2hour form entry should still exist", checkOne); - yield countEntries("2hour10minutes", "2hour10minutes form entry should still exist", checkOne); - yield countEntries("4hour", "4hour form entry should still exist", checkOne); - yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne); - if (minutesSinceMidnight > 70) - yield countEntries("today", "today form entry should still exist", checkOne); - yield countEntries("b4today", "b4today form entry should still exist", checkOne); - - ok(!(yield downloadExists(publicList, "fakefile-1-hour-10-minutes")), "1 hour 10 minute old download should now be deleted"); - ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-2-hour")), "<2 hour old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute download should still be present"); - ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present"); - if (minutesSinceMidnight > 70) - ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present"); - - downloadPromise = promiseDownloadRemoved(publicList); - formHistoryPromise = promiseFormHistoryRemoved(); - - // Clear 2 hours - Sanitizer.prefs.setIntPref("timeSpan", 2); - yield s.sanitize(); - - yield formHistoryPromise; - yield downloadPromise; - - ok(!(yield promiseIsURIVisited(makeURI("http://2hour.com"))), - "Pretend visit to 2hour.com should now be deleted"); - ok((yield promiseIsURIVisited(makeURI("http://2hour10minutes.com"))), - "Pretend visit to 2hour10minutes.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://4hour.com"))), - "Pretend visit to 4hour.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))), - "Pretend visit to 4hour10minutes.com should should still exist"); - if (hoursSinceMidnight > 2) { - ok((yield promiseIsURIVisited(makeURI("http://today.com"))), - "Pretend visit to today.com should still exist"); - } - ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))), - "Pretend visit to before-today.com should still exist"); - - yield countEntries("2hour", "2hour form entry should be deleted", checkZero); - yield countEntries("2hour10minutes", "2hour10minutes form entry should still exist", checkOne); - yield countEntries("4hour", "4hour form entry should still exist", checkOne); - yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne); - if (hoursSinceMidnight > 2) - yield countEntries("today", "today form entry should still exist", checkOne); - yield countEntries("b4today", "b4today form entry should still exist", checkOne); - - ok(!(yield downloadExists(publicList, "fakefile-2-hour")), "<2 hour old download should now be deleted"); - ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute download should still be present"); - ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present"); - if (hoursSinceMidnight > 2) - ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present"); - - downloadPromise = promiseDownloadRemoved(publicList); - formHistoryPromise = promiseFormHistoryRemoved(); - - // Clear 2 hours 10 minutes - s.range = [now_uSec - 130*60*1000000, now_uSec]; - yield s.sanitize(); - s.range = null; - - yield formHistoryPromise; - yield downloadPromise; - - ok(!(yield promiseIsURIVisited(makeURI("http://2hour10minutes.com"))), - "Pretend visit to 2hour10minutes.com should now be deleted"); - ok((yield promiseIsURIVisited(makeURI("http://4hour.com"))), - "Pretend visit to 4hour.com should should still exist"); - ok((yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))), - "Pretend visit to 4hour10minutes.com should should still exist"); - if (minutesSinceMidnight > 130) { - ok((yield promiseIsURIVisited(makeURI("http://today.com"))), - "Pretend visit to today.com should still exist"); - } - ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))), - "Pretend visit to before-today.com should still exist"); - - yield countEntries("2hour10minutes", "2hour10minutes form entry should be deleted", checkZero); - yield countEntries("4hour", "4hour form entry should still exist", checkOne); - yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne); - if (minutesSinceMidnight > 130) - yield countEntries("today", "today form entry should still exist", checkOne); - yield countEntries("b4today", "b4today form entry should still exist", checkOne); - - ok(!(yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute old download should now be deleted"); - ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present"); - ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present"); - ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present"); - if (minutesSinceMidnight > 130) - ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present"); - - downloadPromise = promiseDownloadRemoved(publicList); - formHistoryPromise = promiseFormHistoryRemoved(); - - // Clear 4 hours - Sanitizer.prefs.setIntPref("timeSpan", 3); - yield s.sanitize(); - - yield formHistoryPromise; - yield downloadPromise; - - ok(!(yield promiseIsURIVisited(makeURI("http://4hour.com"))), - "Pretend visit to 4hour.com should now be deleted"); - ok((yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))), - "Pretend visit to 4hour10minutes.com should should still exist"); - if (hoursSinceMidnight > 4) { - ok((yield promiseIsURIVisited(makeURI("http://today.com"))), - "Pretend visit to today.com should still exist"); - } - ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))), - "Pretend visit to before-today.com should still exist"); - - yield countEntries("4hour", "4hour form entry should be deleted", checkZero); - yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne); - if (hoursSinceMidnight > 4) - yield countEntries("today", "today form entry should still exist", checkOne); - yield countEntries("b4today", "b4today form entry should still exist", checkOne); - - ok(!(yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should now be deleted"); - ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present"); - ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present"); - if (hoursSinceMidnight > 4) - ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present"); - - downloadPromise = promiseDownloadRemoved(publicList); - formHistoryPromise = promiseFormHistoryRemoved(); - - // Clear 4 hours 10 minutes - s.range = [now_uSec - 250*60*1000000, now_uSec]; - yield s.sanitize(); - s.range = null; - - yield formHistoryPromise; - yield downloadPromise; - - ok(!(yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))), - "Pretend visit to 4hour10minutes.com should now be deleted"); - if (minutesSinceMidnight > 250) { - ok((yield promiseIsURIVisited(makeURI("http://today.com"))), - "Pretend visit to today.com should still exist"); - } - ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))), - "Pretend visit to before-today.com should still exist"); - - yield countEntries("4hour10minutes", "4hour10minutes form entry should be deleted", checkZero); - if (minutesSinceMidnight > 250) - yield countEntries("today", "today form entry should still exist", checkOne); - yield countEntries("b4today", "b4today form entry should still exist", checkOne); - - ok(!(yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should now be deleted"); - ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present"); - if (minutesSinceMidnight > 250) - ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present"); - - // The 'Today' download might have been already deleted, in which case we - // should not wait for a download removal notification. - if (minutesSinceMidnight > 250) { - downloadPromise = promiseDownloadRemoved(publicList); - } else { - downloadPromise = Promise.resolve(); - } - formHistoryPromise = promiseFormHistoryRemoved(); - - // Clear Today - Sanitizer.prefs.setIntPref("timeSpan", 4); - yield s.sanitize(); - - yield formHistoryPromise; - yield downloadPromise; - - // Be careful. If we add our objectss just before midnight, and sanitize - // runs immediately after, they won't be expired. This is expected, but - // we should not test in that case. We cannot just test for opposite - // condition because we could cross midnight just one moment after we - // cache our time, then we would have an even worse random failure. - var today = isToday(new Date(now_mSec)); - if (today) { - ok(!(yield promiseIsURIVisited(makeURI("http://today.com"))), - "Pretend visit to today.com should now be deleted"); - - yield countEntries("today", "today form entry should be deleted", checkZero); - ok(!(yield downloadExists(publicList, "fakefile-today")), "'Today' download should now be deleted"); - } - - ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))), - "Pretend visit to before-today.com should still exist"); - yield countEntries("b4today", "b4today form entry should still exist", checkOne); - ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present"); - - downloadPromise = promiseDownloadRemoved(publicList); - formHistoryPromise = promiseFormHistoryRemoved(); - - // Choose everything - Sanitizer.prefs.setIntPref("timeSpan", 0); - yield s.sanitize(); - - yield formHistoryPromise; - yield downloadPromise; - - ok(!(yield promiseIsURIVisited(makeURI("http://before-today.com"))), - "Pretend visit to before-today.com should now be deleted"); - - yield countEntries("b4today", "b4today form entry should be deleted", checkZero); - - ok(!(yield downloadExists(publicList, "fakefile-old")), "Year old download should now be deleted"); -} - -function setupHistory() { - let deferred = Promise.defer(); - - let places = []; - - function addPlace(aURI, aTitle, aVisitDate) { - places.push({ - uri: aURI, - title: aTitle, - visits: [{ - visitDate: aVisitDate, - transitionType: Ci.nsINavHistoryService.TRANSITION_LINK - }] - }); - } - - addPlace(makeURI("http://10minutes.com/"), "10 minutes ago", now_uSec - 10 * kUsecPerMin); - addPlace(makeURI("http://1hour.com/"), "Less than 1 hour ago", now_uSec - 45 * kUsecPerMin); - addPlace(makeURI("http://1hour10minutes.com/"), "1 hour 10 minutes ago", now_uSec - 70 * kUsecPerMin); - addPlace(makeURI("http://2hour.com/"), "Less than 2 hours ago", now_uSec - 90 * kUsecPerMin); - addPlace(makeURI("http://2hour10minutes.com/"), "2 hours 10 minutes ago", now_uSec - 130 * kUsecPerMin); - addPlace(makeURI("http://4hour.com/"), "Less than 4 hours ago", now_uSec - 180 * kUsecPerMin); - addPlace(makeURI("http://4hour10minutes.com/"), "4 hours 10 minutesago", now_uSec - 250 * kUsecPerMin); - - let today = new Date(); - today.setHours(0); - today.setMinutes(0); - today.setSeconds(1); - addPlace(makeURI("http://today.com/"), "Today", today.getTime() * 1000); - - let lastYear = new Date(); - lastYear.setFullYear(lastYear.getFullYear() - 1); - addPlace(makeURI("http://before-today.com/"), "Before Today", lastYear.getTime() * 1000); - PlacesUtils.asyncHistory.updatePlaces(places, { - handleError: () => ok(false, "Unexpected error in adding visit."), - handleResult: () => { }, - handleCompletion: () => deferred.resolve() - }); - - return deferred.promise; -} - -function* setupFormHistory() { - - function searchEntries(terms, params) { - let deferred = Promise.defer(); - - let results = []; - FormHistory.search(terms, params, { handleResult: result => results.push(result), - handleError: function (error) { - deferred.reject(error); - throw new Error("Error occurred searching form history: " + error); - }, - handleCompletion: function (reason) { deferred.resolve(results); } - }); - return deferred.promise; - } - - function update(changes) - { - let deferred = Promise.defer(); - FormHistory.update(changes, { handleError: function (error) { - deferred.reject(error); - throw new Error("Error occurred searching form history: " + error); - }, - handleCompletion: function (reason) { deferred.resolve(); } - }); - return deferred.promise; - } - - // Make sure we've got a clean DB to start with, then add the entries we'll be testing. - yield update( - [{ - op: "remove" - }, - { - op : "add", - fieldname : "10minutes", - value : "10m" - }, { - op : "add", - fieldname : "1hour", - value : "1h" - }, { - op : "add", - fieldname : "1hour10minutes", - value : "1h10m" - }, { - op : "add", - fieldname : "2hour", - value : "2h" - }, { - op : "add", - fieldname : "2hour10minutes", - value : "2h10m" - }, { - op : "add", - fieldname : "4hour", - value : "4h" - }, { - op : "add", - fieldname : "4hour10minutes", - value : "4h10m" - }, { - op : "add", - fieldname : "today", - value : "1d" - }, { - op : "add", - fieldname : "b4today", - value : "1y" - }]); - - // Artifically age the entries to the proper vintage. - let timestamp = now_uSec - 10 * kUsecPerMin; - let results = yield searchEntries(["guid"], { fieldname: "10minutes" }); - yield update({ op: "update", firstUsed: timestamp, guid: results[0].guid }); - - timestamp = now_uSec - 45 * kUsecPerMin; - results = yield searchEntries(["guid"], { fieldname: "1hour" }); - yield update({ op: "update", firstUsed: timestamp, guid: results[0].guid }); - - timestamp = now_uSec - 70 * kUsecPerMin; - results = yield searchEntries(["guid"], { fieldname: "1hour10minutes" }); - yield update({ op: "update", firstUsed: timestamp, guid: results[0].guid }); - - timestamp = now_uSec - 90 * kUsecPerMin; - results = yield searchEntries(["guid"], { fieldname: "2hour" }); - yield update({ op: "update", firstUsed: timestamp, guid: results[0].guid }); - - timestamp = now_uSec - 130 * kUsecPerMin; - results = yield searchEntries(["guid"], { fieldname: "2hour10minutes" }); - yield update({ op: "update", firstUsed: timestamp, guid: results[0].guid }); - - timestamp = now_uSec - 180 * kUsecPerMin; - results = yield searchEntries(["guid"], { fieldname: "4hour" }); - yield update({ op: "update", firstUsed: timestamp, guid: results[0].guid }); - - timestamp = now_uSec - 250 * kUsecPerMin; - results = yield searchEntries(["guid"], { fieldname: "4hour10minutes" }); - yield update({ op: "update", firstUsed: timestamp, guid: results[0].guid }); - - let today = new Date(); - today.setHours(0); - today.setMinutes(0); - today.setSeconds(1); - timestamp = today.getTime() * 1000; - results = yield searchEntries(["guid"], { fieldname: "today" }); - yield update({ op: "update", firstUsed: timestamp, guid: results[0].guid }); - - let lastYear = new Date(); - lastYear.setFullYear(lastYear.getFullYear() - 1); - timestamp = lastYear.getTime() * 1000; - results = yield searchEntries(["guid"], { fieldname: "b4today" }); - yield update({ op: "update", firstUsed: timestamp, guid: results[0].guid }); - - var checks = 0; - let checkOne = function(num, message) { is(num, 1, message); checks++; } - - // Sanity check. - yield countEntries("10minutes", "Checking for 10minutes form history entry creation", checkOne); - yield countEntries("1hour", "Checking for 1hour form history entry creation", checkOne); - yield countEntries("1hour10minutes", "Checking for 1hour10minutes form history entry creation", checkOne); - yield countEntries("2hour", "Checking for 2hour form history entry creation", checkOne); - yield countEntries("2hour10minutes", "Checking for 2hour10minutes form history entry creation", checkOne); - yield countEntries("4hour", "Checking for 4hour form history entry creation", checkOne); - yield countEntries("4hour10minutes", "Checking for 4hour10minutes form history entry creation", checkOne); - yield countEntries("today", "Checking for today form history entry creation", checkOne); - yield countEntries("b4today", "Checking for b4today form history entry creation", checkOne); - is(checks, 9, "9 checks made"); -} - -function* setupDownloads() { - - let publicList = yield Downloads.getList(Downloads.PUBLIC); - - let download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169", - target: "fakefile-10-minutes" - }); - download.startTime = new Date(now_mSec - 10 * kMsecPerMin), // 10 minutes ago - download.canceled = true; - yield publicList.add(download); - - download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440", - target: "fakefile-1-hour" - }); - download.startTime = new Date(now_mSec - 45 * kMsecPerMin), // 45 minutes ago - download.canceled = true; - yield publicList.add(download); - - download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169", - target: "fakefile-1-hour-10-minutes" - }); - download.startTime = new Date(now_mSec - 70 * kMsecPerMin), // 70 minutes ago - download.canceled = true; - yield publicList.add(download); - - download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440", - target: "fakefile-2-hour" - }); - download.startTime = new Date(now_mSec - 90 * kMsecPerMin), // 90 minutes ago - download.canceled = true; - yield publicList.add(download); - - download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169", - target: "fakefile-2-hour-10-minutes" - }); - download.startTime = new Date(now_mSec - 130 * kMsecPerMin), // 130 minutes ago - download.canceled = true; - yield publicList.add(download); - - download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440", - target: "fakefile-4-hour" - }); - download.startTime = new Date(now_mSec - 180 * kMsecPerMin), // 180 minutes ago - download.canceled = true; - yield publicList.add(download); - - download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169", - target: "fakefile-4-hour-10-minutes" - }); - download.startTime = new Date(now_mSec - 250 * kMsecPerMin), // 250 minutes ago - download.canceled = true; - yield publicList.add(download); - - // Add "today" download - let today = new Date(); - today.setHours(0); - today.setMinutes(0); - today.setSeconds(1); - - download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440", - target: "fakefile-today" - }); - download.startTime = today, // 12:00:01 AM this morning - download.canceled = true; - yield publicList.add(download); - - // Add "before today" download - let lastYear = new Date(); - lastYear.setFullYear(lastYear.getFullYear() - 1); - - download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440", - target: "fakefile-old" - }); - download.startTime = lastYear, - download.canceled = true; - yield publicList.add(download); - - // Confirm everything worked - let downloads = yield publicList.getAll(); - is(downloads.length, 9, "9 Pretend downloads added"); - - ok((yield downloadExists(publicList, "fakefile-old")), "Pretend download for everything case should exist"); - ok((yield downloadExists(publicList, "fakefile-10-minutes")), "Pretend download for 10-minutes case should exist"); - ok((yield downloadExists(publicList, "fakefile-1-hour")), "Pretend download for 1-hour case should exist"); - ok((yield downloadExists(publicList, "fakefile-1-hour-10-minutes")), "Pretend download for 1-hour-10-minutes case should exist"); - ok((yield downloadExists(publicList, "fakefile-2-hour")), "Pretend download for 2-hour case should exist"); - ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "Pretend download for 2-hour-10-minutes case should exist"); - ok((yield downloadExists(publicList, "fakefile-4-hour")), "Pretend download for 4-hour case should exist"); - ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "Pretend download for 4-hour-10-minutes case should exist"); - ok((yield downloadExists(publicList, "fakefile-today")), "Pretend download for Today case should exist"); -} - -/** - * Checks to see if the downloads with the specified id exists. - * - * @param aID - * The ids of the downloads to check. - */ -let downloadExists = Task.async(function* (list, path) { - let listArray = yield list.getAll(); - return listArray.some(i => i.target.path == path); -}); - -function isToday(aDate) { - return aDate.getDate() == new Date().getDate(); -} diff --git a/browser/base/content/test/general/browser_sanitizeDialog.js b/browser/base/content/test/general/browser_sanitizeDialog.js deleted file mode 100644 index 50546be45..000000000 --- a/browser/base/content/test/general/browser_sanitizeDialog.js +++ /dev/null @@ -1,1027 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/** - * Tests the sanitize dialog (a.k.a. the clear recent history dialog). - * See bug 480169. - * - * The purpose of this test is not to fully flex the sanitize timespan code; - * browser/base/content/test/general/browser_sanitize-timespans.js does that. This - * test checks the UI of the dialog and makes sure it's correctly connected to - * the sanitize timespan code. - * - * Some of this code, especially the history creation parts, was taken from - * browser/base/content/test/general/browser_sanitize-timespans.js. - */ - -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -var {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInfo.jsm", {}); - -XPCOMUtils.defineLazyModuleGetter(this, "FormHistory", - "resource://gre/modules/FormHistory.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Downloads", - "resource://gre/modules/Downloads.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Timer", - "resource://gre/modules/Timer.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils", - "resource://testing-common/PlacesTestUtils.jsm"); - -var tempScope = {}; -Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", tempScope); -var Sanitizer = tempScope.Sanitizer; - -const kMsecPerMin = 60 * 1000; -const kUsecPerMin = 60 * 1000000; - -add_task(function* init() { - requestLongerTimeout(3); - yield blankSlate(); - registerCleanupFunction(function* () { - yield blankSlate(); - yield PlacesTestUtils.promiseAsyncUpdates(); - }); -}); - -/** - * Initializes the dialog to its default state. - */ -add_task(function* default_state() { - let wh = new WindowHelper(); - wh.onload = function () { - // Select "Last Hour" - this.selectDuration(Sanitizer.TIMESPAN_HOUR); - // Hide details - if (!this.getItemList().collapsed) - this.toggleDetails(); - this.acceptDialog(); - }; - wh.open(); - yield wh.promiseClosed; -}); - -/** - * Cancels the dialog, makes sure history not cleared. - */ -add_task(function* test_cancel() { - // Add history (within the past hour) - let uris = []; - let places = []; - let pURI; - for (let i = 0; i < 30; i++) { - pURI = makeURI("http://" + i + "-minutes-ago.com/"); - places.push({uri: pURI, visitDate: visitTimeForMinutesAgo(i)}); - uris.push(pURI); - } - yield PlacesTestUtils.addVisits(places); - - let wh = new WindowHelper(); - wh.onload = function () { - this.selectDuration(Sanitizer.TIMESPAN_HOUR); - this.checkPrefCheckbox("history", false); - this.checkDetails(false); - - // Show details - this.toggleDetails(); - this.checkDetails(true); - - // Hide details - this.toggleDetails(); - this.checkDetails(false); - this.cancelDialog(); - }; - wh.onunload = function* () { - yield promiseHistoryClearedState(uris, false); - yield blankSlate(); - yield promiseHistoryClearedState(uris, true); - }; - wh.open(); - yield wh.promiseClosed; -}); - -/** - * Ensures that the combined history-downloads checkbox clears both history - * visits and downloads when checked; the dialog respects simple timespan. - */ -add_task(function* test_history_downloads_checked() { - // Add downloads (within the past hour). - let downloadIDs = []; - for (let i = 0; i < 5; i++) { - yield addDownloadWithMinutesAgo(downloadIDs, i); - } - // Add downloads (over an hour ago). - let olderDownloadIDs = []; - for (let i = 0; i < 5; i++) { - yield addDownloadWithMinutesAgo(olderDownloadIDs, 61 + i); - } - - // Add history (within the past hour). - let uris = []; - let places = []; - let pURI; - for (let i = 0; i < 30; i++) { - pURI = makeURI("http://" + i + "-minutes-ago.com/"); - places.push({uri: pURI, visitDate: visitTimeForMinutesAgo(i)}); - uris.push(pURI); - } - // Add history (over an hour ago). - let olderURIs = []; - for (let i = 0; i < 5; i++) { - pURI = makeURI("http://" + (61 + i) + "-minutes-ago.com/"); - places.push({uri: pURI, visitDate: visitTimeForMinutesAgo(61 + i)}); - olderURIs.push(pURI); - } - let promiseSanitized = promiseSanitizationComplete(); - - yield PlacesTestUtils.addVisits(places); - - let wh = new WindowHelper(); - wh.onload = function () { - this.selectDuration(Sanitizer.TIMESPAN_HOUR); - this.checkPrefCheckbox("history", true); - this.acceptDialog(); - }; - wh.onunload = function* () { - intPrefIs("sanitize.timeSpan", Sanitizer.TIMESPAN_HOUR, - "timeSpan pref should be hour after accepting dialog with " + - "hour selected"); - boolPrefIs("cpd.history", true, - "history pref should be true after accepting dialog with " + - "history checkbox checked"); - boolPrefIs("cpd.downloads", true, - "downloads pref should be true after accepting dialog with " + - "history checkbox checked"); - - yield promiseSanitized; - - // History visits and downloads within one hour should be cleared. - yield promiseHistoryClearedState(uris, true); - yield ensureDownloadsClearedState(downloadIDs, true); - - // Visits and downloads > 1 hour should still exist. - yield promiseHistoryClearedState(olderURIs, false); - yield ensureDownloadsClearedState(olderDownloadIDs, false); - - // OK, done, cleanup after ourselves. - yield blankSlate(); - yield promiseHistoryClearedState(olderURIs, true); - yield ensureDownloadsClearedState(olderDownloadIDs, true); - }; - wh.open(); - yield wh.promiseClosed; -}); - -/** - * Ensures that the combined history-downloads checkbox removes neither - * history visits nor downloads when not checked. - */ -add_task(function* test_history_downloads_unchecked() { - // Add form entries - let formEntries = []; - - for (let i = 0; i < 5; i++) { - formEntries.push((yield promiseAddFormEntryWithMinutesAgo(i))); - } - - - // Add downloads (within the past hour). - let downloadIDs = []; - for (let i = 0; i < 5; i++) { - yield addDownloadWithMinutesAgo(downloadIDs, i); - } - - // Add history, downloads, form entries (within the past hour). - let uris = []; - let places = []; - let pURI; - for (let i = 0; i < 5; i++) { - pURI = makeURI("http://" + i + "-minutes-ago.com/"); - places.push({uri: pURI, visitDate: visitTimeForMinutesAgo(i)}); - uris.push(pURI); - } - - yield PlacesTestUtils.addVisits(places); - let wh = new WindowHelper(); - wh.onload = function () { - is(this.isWarningPanelVisible(), false, - "Warning panel should be hidden after previously accepting dialog " + - "with a predefined timespan"); - this.selectDuration(Sanitizer.TIMESPAN_HOUR); - - // Remove only form entries, leave history (including downloads). - this.checkPrefCheckbox("history", false); - this.checkPrefCheckbox("formdata", true); - this.acceptDialog(); - }; - wh.onunload = function* () { - intPrefIs("sanitize.timeSpan", Sanitizer.TIMESPAN_HOUR, - "timeSpan pref should be hour after accepting dialog with " + - "hour selected"); - boolPrefIs("cpd.history", false, - "history pref should be false after accepting dialog with " + - "history checkbox unchecked"); - boolPrefIs("cpd.downloads", false, - "downloads pref should be false after accepting dialog with " + - "history checkbox unchecked"); - - // Of the three only form entries should be cleared. - yield promiseHistoryClearedState(uris, false); - yield ensureDownloadsClearedState(downloadIDs, false); - - for (let entry of formEntries) { - let exists = yield formNameExists(entry); - is(exists, false, "form entry " + entry + " should no longer exist"); - } - - // OK, done, cleanup after ourselves. - yield blankSlate(); - yield promiseHistoryClearedState(uris, true); - yield ensureDownloadsClearedState(downloadIDs, true); - }; - wh.open(); - yield wh.promiseClosed; -}); - -/** - * Ensures that the "Everything" duration option works. - */ -add_task(function* test_everything() { - // Add history. - let uris = []; - let places = []; - let pURI; - // within past hour, within past two hours, within past four hours and - // outside past four hours - [10, 70, 130, 250].forEach(function(aValue) { - pURI = makeURI("http://" + aValue + "-minutes-ago.com/"); - places.push({uri: pURI, visitDate: visitTimeForMinutesAgo(aValue)}); - uris.push(pURI); - }); - - let promiseSanitized = promiseSanitizationComplete(); - - yield PlacesTestUtils.addVisits(places); - let wh = new WindowHelper(); - wh.onload = function () { - is(this.isWarningPanelVisible(), false, - "Warning panel should be hidden after previously accepting dialog " + - "with a predefined timespan"); - this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING); - this.checkPrefCheckbox("history", true); - this.checkDetails(true); - - // Hide details - this.toggleDetails(); - this.checkDetails(false); - - // Show details - this.toggleDetails(); - this.checkDetails(true); - - this.acceptDialog(); - }; - wh.onunload = function* () { - yield promiseSanitized; - intPrefIs("sanitize.timeSpan", Sanitizer.TIMESPAN_EVERYTHING, - "timeSpan pref should be everything after accepting dialog " + - "with everything selected"); - - yield promiseHistoryClearedState(uris, true); - }; - wh.open(); - yield wh.promiseClosed; -}); - -/** - * Ensures that the "Everything" warning is visible on dialog open after - * the previous test. - */ -add_task(function* test_everything_warning() { - // Add history. - let uris = []; - let places = []; - let pURI; - // within past hour, within past two hours, within past four hours and - // outside past four hours - [10, 70, 130, 250].forEach(function(aValue) { - pURI = makeURI("http://" + aValue + "-minutes-ago.com/"); - places.push({uri: pURI, visitDate: visitTimeForMinutesAgo(aValue)}); - uris.push(pURI); - }); - - let promiseSanitized = promiseSanitizationComplete(); - - yield PlacesTestUtils.addVisits(places); - let wh = new WindowHelper(); - wh.onload = function () { - is(this.isWarningPanelVisible(), true, - "Warning panel should be visible after previously accepting dialog " + - "with clearing everything"); - this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING); - this.checkPrefCheckbox("history", true); - this.acceptDialog(); - }; - wh.onunload = function* () { - intPrefIs("sanitize.timeSpan", Sanitizer.TIMESPAN_EVERYTHING, - "timeSpan pref should be everything after accepting dialog " + - "with everything selected"); - - yield promiseSanitized; - - yield promiseHistoryClearedState(uris, true); - }; - wh.open(); - yield wh.promiseClosed; -}); - -/** - * The next three tests checks that when a certain history item cannot be - * cleared then the checkbox should be both disabled and unchecked. - * In addition, we ensure that this behavior does not modify the preferences. - */ -add_task(function* test_cannot_clear_history() { - // Add form entries - let formEntries = [ (yield promiseAddFormEntryWithMinutesAgo(10)) ]; - - let promiseSanitized = promiseSanitizationComplete(); - - // Add history. - let pURI = makeURI("http://" + 10 + "-minutes-ago.com/"); - yield PlacesTestUtils.addVisits({uri: pURI, visitDate: visitTimeForMinutesAgo(10)}); - let uris = [ pURI ]; - - let wh = new WindowHelper(); - wh.onload = function() { - // Check that the relevant checkboxes are enabled - var cb = this.win.document.querySelectorAll( - "#itemList > [preference='privacy.cpd.formdata']"); - ok(cb.length == 1 && !cb[0].disabled, "There is formdata, checkbox to " + - "clear formdata should be enabled."); - - cb = this.win.document.querySelectorAll( - "#itemList > [preference='privacy.cpd.history']"); - ok(cb.length == 1 && !cb[0].disabled, "There is history, checkbox to " + - "clear history should be enabled."); - - this.checkAllCheckboxes(); - this.acceptDialog(); - }; - wh.onunload = function* () { - yield promiseSanitized; - - yield promiseHistoryClearedState(uris, true); - - let exists = yield formNameExists(formEntries[0]); - is(exists, false, "form entry " + formEntries[0] + " should no longer exist"); - }; - wh.open(); - yield wh.promiseClosed; -}); - -add_task(function* test_no_formdata_history_to_clear() { - let promiseSanitized = promiseSanitizationComplete(); - let wh = new WindowHelper(); - wh.onload = function() { - boolPrefIs("cpd.history", true, - "history pref should be true after accepting dialog with " + - "history checkbox checked"); - boolPrefIs("cpd.formdata", true, - "formdata pref should be true after accepting dialog with " + - "formdata checkbox checked"); - - var cb = this.win.document.querySelectorAll( - "#itemList > [preference='privacy.cpd.history']"); - ok(cb.length == 1 && !cb[0].disabled && cb[0].checked, - "There is no history, but history checkbox should always be enabled " + - "and will be checked from previous preference."); - - this.acceptDialog(); - } - wh.open(); - yield wh.promiseClosed; - yield promiseSanitized; -}); - -add_task(function* test_form_entries() { - let formEntry = (yield promiseAddFormEntryWithMinutesAgo(10)); - - let promiseSanitized = promiseSanitizationComplete(); - - let wh = new WindowHelper(); - wh.onload = function() { - boolPrefIs("cpd.formdata", true, - "formdata pref should persist previous value after accepting " + - "dialog where you could not clear formdata."); - - var cb = this.win.document.querySelectorAll( - "#itemList > [preference='privacy.cpd.formdata']"); - - info("There exists formEntries so the checkbox should be in sync with the pref."); - is(cb.length, 1, "There is only one checkbox for form data"); - ok(!cb[0].disabled, "The checkbox is enabled"); - ok(cb[0].checked, "The checkbox is checked"); - - this.acceptDialog(); - }; - wh.onunload = function* () { - yield promiseSanitized; - let exists = yield formNameExists(formEntry); - is(exists, false, "form entry " + formEntry + " should no longer exist"); - }; - wh.open(); - yield wh.promiseClosed; -}); - - -/** - * Ensure that toggling details persists - * across dialog openings. - */ -add_task(function* test_toggling_details_persists() { - { - let wh = new WindowHelper(); - wh.onload = function () { - // Check all items and select "Everything" - this.checkAllCheckboxes(); - this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING); - - // Hide details - this.toggleDetails(); - this.checkDetails(false); - this.acceptDialog(); - }; - wh.open(); - yield wh.promiseClosed; - } - { - let wh = new WindowHelper(); - wh.onload = function () { - // Details should remain closed because all items are checked. - this.checkDetails(false); - - // Uncheck history. - this.checkPrefCheckbox("history", false); - this.acceptDialog(); - }; - wh.open(); - yield wh.promiseClosed; - } - { - let wh = new WindowHelper(); - wh.onload = function () { - // Details should be open because not all items are checked. - this.checkDetails(true); - - // Modify the Site Preferences item state (bug 527820) - this.checkAllCheckboxes(); - this.checkPrefCheckbox("siteSettings", false); - this.acceptDialog(); - }; - wh.open(); - yield wh.promiseClosed; - } - { - let wh = new WindowHelper(); - wh.onload = function () { - // Details should be open because not all items are checked. - this.checkDetails(true); - - // Hide details - this.toggleDetails(); - this.checkDetails(false); - this.cancelDialog(); - }; - wh.open(); - yield wh.promiseClosed; - } - { - let wh = new WindowHelper(); - wh.onload = function () { - // Details should be open because not all items are checked. - this.checkDetails(true); - - // Select another duration - this.selectDuration(Sanitizer.TIMESPAN_HOUR); - // Hide details - this.toggleDetails(); - this.checkDetails(false); - this.acceptDialog(); - }; - wh.open(); - yield wh.promiseClosed; - } - { - let wh = new WindowHelper(); - wh.onload = function () { - // Details should not be open because "Last Hour" is selected - this.checkDetails(false); - - this.cancelDialog(); - }; - wh.open(); - yield wh.promiseClosed; - } - { - let wh = new WindowHelper(); - wh.onload = function () { - // Details should have remained closed - this.checkDetails(false); - - // Show details - this.toggleDetails(); - this.checkDetails(true); - this.cancelDialog(); - }; - wh.open(); - yield wh.promiseClosed; - } -}); - -// Test for offline cache deletion -add_task(function* test_offline_cache() { - // Prepare stuff, we will work with www.example.com - var URL = "http://www.example.com"; - var URI = makeURI(URL); - var principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(URI); - - // Give www.example.com privileges to store offline data - Services.perms.addFromPrincipal(principal, "offline-app", Ci.nsIPermissionManager.ALLOW_ACTION); - Services.perms.addFromPrincipal(principal, "offline-app", Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN); - - // Store something to the offline cache - var appcacheserv = Cc["@mozilla.org/network/application-cache-service;1"] - .getService(Ci.nsIApplicationCacheService); - var appcachegroupid = appcacheserv.buildGroupIDForInfo(makeURI(URL + "/manifest"), LoadContextInfo.default); - var appcache = appcacheserv.createApplicationCache(appcachegroupid); - var storage = Services.cache2.appCacheStorage(LoadContextInfo.default, appcache); - - // Open the dialog - let wh = new WindowHelper(); - wh.onload = function () { - this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING); - // Show details - this.toggleDetails(); - // Clear only offlineApps - this.uncheckAllCheckboxes(); - this.checkPrefCheckbox("offlineApps", true); - this.acceptDialog(); - }; - wh.onunload = function () { - // Check if the cache has been deleted - var size = -1; - var visitor = { - onCacheStorageInfo: function (aEntryCount, aConsumption, aCapacity, aDiskDirectory) - { - size = aConsumption; - } - }; - storage.asyncVisitStorage(visitor, false); - // Offline cache visit happens synchronously, since it's forwarded to the old code - is(size, 0, "offline application cache entries evicted"); - }; - - var cacheListener = { - onCacheEntryCheck: function() { return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; }, - onCacheEntryAvailable: function (entry, isnew, unused, status) { - is(status, Cr.NS_OK); - var stream = entry.openOutputStream(0); - var content = "content"; - stream.write(content, content.length); - stream.close(); - entry.close(); - wh.open(); - } - }; - - storage.asyncOpenURI(makeURI(URL), "", Ci.nsICacheStorage.OPEN_TRUNCATE, cacheListener); - yield wh.promiseClosed; -}); - -// Test for offline apps permission deletion -add_task(function* test_offline_apps_permissions() { - // Prepare stuff, we will work with www.example.com - var URL = "http://www.example.com"; - var URI = makeURI(URL); - var principal = Services.scriptSecurityManager.createCodebasePrincipal(URI, {}); - - let promiseSanitized = promiseSanitizationComplete(); - - // Open the dialog - let wh = new WindowHelper(); - wh.onload = function () { - this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING); - // Show details - this.toggleDetails(); - // Clear only offlineApps - this.uncheckAllCheckboxes(); - this.checkPrefCheckbox("siteSettings", true); - this.acceptDialog(); - }; - wh.onunload = function* () { - yield promiseSanitized; - - // Check all has been deleted (privileges, data, cache) - is(Services.perms.testPermissionFromPrincipal(principal, "offline-app"), 0, "offline-app permissions removed"); - }; - wh.open(); - yield wh.promiseClosed; -}); - -var now_mSec = Date.now(); -var now_uSec = now_mSec * 1000; - -/** - * This wraps the dialog and provides some convenience methods for interacting - * with it. - * - * @param aWin - * The dialog's nsIDOMWindow - */ -function WindowHelper(aWin) { - this.win = aWin; - this.promiseClosed = new Promise(resolve => { this._resolveClosed = resolve }); -} - -WindowHelper.prototype = { - /** - * "Presses" the dialog's OK button. - */ - acceptDialog: function () { - is(this.win.document.documentElement.getButton("accept").disabled, false, - "Dialog's OK button should not be disabled"); - this.win.document.documentElement.acceptDialog(); - }, - - /** - * "Presses" the dialog's Cancel button. - */ - cancelDialog: function () { - this.win.document.documentElement.cancelDialog(); - }, - - /** - * Ensures that the details progressive disclosure button and the item list - * hidden by it match up. Also makes sure the height of the dialog is - * sufficient for the item list and warning panel. - * - * @param aShouldBeShown - * True if you expect the details to be shown and false if hidden - */ - checkDetails: function (aShouldBeShown) { - let button = this.getDetailsButton(); - let list = this.getItemList(); - let hidden = list.hidden || list.collapsed; - is(hidden, !aShouldBeShown, - "Details should be " + (aShouldBeShown ? "shown" : "hidden") + - " but were actually " + (hidden ? "hidden" : "shown")); - let dir = hidden ? "down" : "up"; - is(button.className, "expander-" + dir, - "Details button should be " + dir + " because item list is " + - (hidden ? "" : "not ") + "hidden"); - let height = 0; - if (!hidden) { - ok(list.boxObject.height > 30, "listbox has sufficient size") - height += list.boxObject.height; - } - if (this.isWarningPanelVisible()) - height += this.getWarningPanel().boxObject.height; - ok(height < this.win.innerHeight, - "Window should be tall enough to fit warning panel and item list"); - }, - - /** - * (Un)checks a history scope checkbox (browser & download history, - * form history, etc.). - * - * @param aPrefName - * The final portion of the checkbox's privacy.cpd.* preference name - * @param aCheckState - * True if the checkbox should be checked, false otherwise - */ - checkPrefCheckbox: function (aPrefName, aCheckState) { - var pref = "privacy.cpd." + aPrefName; - var cb = this.win.document.querySelectorAll( - "#itemList > [preference='" + pref + "']"); - is(cb.length, 1, "found checkbox for " + pref + " preference"); - if (cb[0].checked != aCheckState) - cb[0].click(); - }, - - /** - * Makes sure all the checkboxes are checked. - */ - _checkAllCheckboxesCustom: function (check) { - var cb = this.win.document.querySelectorAll("#itemList > [preference]"); - ok(cb.length > 1, "found checkboxes for preferences"); - for (var i = 0; i < cb.length; ++i) { - var pref = this.win.document.getElementById(cb[i].getAttribute("preference")); - if (!!pref.value ^ check) - cb[i].click(); - } - }, - - checkAllCheckboxes: function () { - this._checkAllCheckboxesCustom(true); - }, - - uncheckAllCheckboxes: function () { - this._checkAllCheckboxesCustom(false); - }, - - /** - * @return The details progressive disclosure button - */ - getDetailsButton: function () { - return this.win.document.getElementById("detailsExpander"); - }, - - /** - * @return The dialog's duration dropdown - */ - getDurationDropdown: function () { - return this.win.document.getElementById("sanitizeDurationChoice"); - }, - - /** - * @return The item list hidden by the details progressive disclosure button - */ - getItemList: function () { - return this.win.document.getElementById("itemList"); - }, - - /** - * @return The clear-everything warning box - */ - getWarningPanel: function () { - return this.win.document.getElementById("sanitizeEverythingWarningBox"); - }, - - /** - * @return True if the "Everything" warning panel is visible (as opposed to - * the tree) - */ - isWarningPanelVisible: function () { - return !this.getWarningPanel().hidden; - }, - - /** - * Opens the clear recent history dialog. Before calling this, set - * this.onload to a function to execute onload. It should close the dialog - * when done so that the tests may continue. Set this.onunload to a function - * to execute onunload. this.onunload is optional. If it returns true, the - * caller is expected to call waitForAsyncUpdates at some point; if false is - * returned, waitForAsyncUpdates is called automatically. - */ - open: function () { - let wh = this; - - function windowObserver(aSubject, aTopic, aData) { - if (aTopic != "domwindowopened") - return; - - Services.ww.unregisterNotification(windowObserver); - - var loaded = false; - let win = aSubject.QueryInterface(Ci.nsIDOMWindow); - - win.addEventListener("load", function onload(event) { - win.removeEventListener("load", onload, false); - - if (win.name !== "SanitizeDialog") - return; - - wh.win = win; - loaded = true; - executeSoon(() => wh.onload()); - }, false); - - win.addEventListener("unload", function onunload(event) { - if (win.name !== "SanitizeDialog") { - win.removeEventListener("unload", onunload, false); - return; - } - - // Why is unload fired before load? - if (!loaded) - return; - - win.removeEventListener("unload", onunload, false); - wh.win = win; - - // Some exceptions that reach here don't reach the test harness, but - // ok()/is() do... - Task.spawn(function* () { - if (wh.onunload) { - yield wh.onunload(); - } - yield PlacesTestUtils.promiseAsyncUpdates(); - wh._resolveClosed(); - }); - }, false); - } - Services.ww.registerNotification(windowObserver); - Services.ww.openWindow(null, - "chrome://browser/content/sanitize.xul", - "SanitizeDialog", - "chrome,titlebar,dialog,centerscreen,modal", - null); - }, - - /** - * Selects a duration in the duration dropdown. - * - * @param aDurVal - * One of the Sanitizer.TIMESPAN_* values - */ - selectDuration: function (aDurVal) { - this.getDurationDropdown().value = aDurVal; - if (aDurVal === Sanitizer.TIMESPAN_EVERYTHING) { - is(this.isWarningPanelVisible(), true, - "Warning panel should be visible for TIMESPAN_EVERYTHING"); - } - else { - is(this.isWarningPanelVisible(), false, - "Warning panel should not be visible for non-TIMESPAN_EVERYTHING"); - } - }, - - /** - * Toggles the details progressive disclosure button. - */ - toggleDetails: function () { - this.getDetailsButton().click(); - } -}; - -function promiseSanitizationComplete() { - return promiseTopicObserved("sanitizer-sanitization-complete"); -} - -/** - * Adds a download to history. - * - * @param aMinutesAgo - * The download will be downloaded this many minutes ago - */ -function* addDownloadWithMinutesAgo(aExpectedPathList, aMinutesAgo) { - let publicList = yield Downloads.getList(Downloads.PUBLIC); - - let name = "fakefile-" + aMinutesAgo + "-minutes-ago"; - let download = yield Downloads.createDownload({ - source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169", - target: name - }); - download.startTime = new Date(now_mSec - (aMinutesAgo * kMsecPerMin)); - download.canceled = true; - publicList.add(download); - - ok((yield downloadExists(name)), - "Sanity check: download " + name + - " should exist after creating it"); - - aExpectedPathList.push(name); -} - -/** - * Adds a form entry to history. - * - * @param aMinutesAgo - * The entry will be added this many minutes ago - */ -function promiseAddFormEntryWithMinutesAgo(aMinutesAgo) { - let name = aMinutesAgo + "-minutes-ago"; - - // Artifically age the entry to the proper vintage. - let timestamp = now_uSec - (aMinutesAgo * kUsecPerMin); - - return new Promise((resolve, reject) => - FormHistory.update({ op: "add", fieldname: name, value: "dummy", firstUsed: timestamp }, - { handleError: function (error) { - reject(); - throw new Error("Error occurred updating form history: " + error); - }, - handleCompletion: function (reason) { - resolve(name); - } - }) - ) -} - -/** - * Checks if a form entry exists. - */ -function formNameExists(name) -{ - return new Promise((resolve, reject) => { - let count = 0; - FormHistory.count({ fieldname: name }, - { handleResult: result => count = result, - handleError: function (error) { - reject(error); - throw new Error("Error occurred searching form history: " + error); - }, - handleCompletion: function (reason) { - if (!reason) { - resolve(count); - } - } - }); - }); -} - -/** - * Removes all history visits, downloads, and form entries. - */ -function* blankSlate() { - let publicList = yield Downloads.getList(Downloads.PUBLIC); - let downloads = yield publicList.getAll(); - for (let download of downloads) { - yield publicList.remove(download); - yield download.finalize(true); - } - - yield new Promise((resolve, reject) => { - FormHistory.update({op: "remove"}, { - handleCompletion(reason) { - if (!reason) { - resolve(); - } - }, - handleError(error) { - reject(error); - throw new Error("Error occurred updating form history: " + error); - } - }); - }); - - yield PlacesTestUtils.clearHistory(); -} - -/** - * Ensures that the given pref is the expected value. - * - * @param aPrefName - * The pref's sub-branch under the privacy branch - * @param aExpectedVal - * The pref's expected value - * @param aMsg - * Passed to is() - */ -function boolPrefIs(aPrefName, aExpectedVal, aMsg) { - is(gPrefService.getBoolPref("privacy." + aPrefName), aExpectedVal, aMsg); -} - -/** - * Checks to see if the download with the specified path exists. - * - * @param aPath - * The path of the download to check - * @return True if the download exists, false otherwise - */ -function* downloadExists(aPath) { - let publicList = yield Downloads.getList(Downloads.PUBLIC); - let listArray = yield publicList.getAll(); - return listArray.some(i => i.target.path == aPath); -} - -/** - * Ensures that the specified downloads are either cleared or not. - * - * @param aDownloadIDs - * Array of download database IDs - * @param aShouldBeCleared - * True if each download should be cleared, false otherwise - */ -function* ensureDownloadsClearedState(aDownloadIDs, aShouldBeCleared) { - let niceStr = aShouldBeCleared ? "no longer" : "still"; - for (let id of aDownloadIDs) { - is((yield downloadExists(id)), !aShouldBeCleared, - "download " + id + " should " + niceStr + " exist"); - } -} - -/** - * Ensures that the given pref is the expected value. - * - * @param aPrefName - * The pref's sub-branch under the privacy branch - * @param aExpectedVal - * The pref's expected value - * @param aMsg - * Passed to is() - */ -function intPrefIs(aPrefName, aExpectedVal, aMsg) { - is(gPrefService.getIntPref("privacy." + aPrefName), aExpectedVal, aMsg); -} - -/** - * Creates a visit time. - * - * @param aMinutesAgo - * The visit will be visited this many minutes ago - */ -function visitTimeForMinutesAgo(aMinutesAgo) { - return now_uSec - aMinutesAgo * kUsecPerMin; -} diff --git a/browser/base/content/test/general/browser_save_link-perwindowpb.js b/browser/base/content/test/general/browser_save_link-perwindowpb.js deleted file mode 100644 index 5c99ba32a..000000000 --- a/browser/base/content/test/general/browser_save_link-perwindowpb.js +++ /dev/null @@ -1,199 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -var MockFilePicker = SpecialPowers.MockFilePicker; -MockFilePicker.init(window); - -// Trigger a save of a link in public mode, then trigger an identical save -// in private mode and ensure that the second request is differentiated from -// the first by checking that cookies set by the first response are not sent -// during the second request. -function triggerSave(aWindow, aCallback) { - info("started triggerSave"); - var fileName; - let testBrowser = aWindow.gBrowser.selectedBrowser; - // This page sets a cookie if and only if a cookie does not exist yet - let testURI = "http://mochi.test:8888/browser/browser/base/content/test/general/bug792517-2.html"; - testBrowser.loadURI(testURI); - BrowserTestUtils.browserLoaded(testBrowser, false, testURI) - .then(() => { - waitForFocus(function () { - info("register to handle popupshown"); - aWindow.document.addEventListener("popupshown", contextMenuOpened, false); - - BrowserTestUtils.synthesizeMouseAtCenter("#fff", {type: "contextmenu", button: 2}, testBrowser); - info("right clicked!"); - }, aWindow); - }); - - function contextMenuOpened(event) { - info("contextMenuOpened"); - aWindow.document.removeEventListener("popupshown", contextMenuOpened); - - // Create the folder the link will be saved into. - var destDir = createTemporarySaveDirectory(); - var destFile = destDir.clone(); - - MockFilePicker.displayDirectory = destDir; - MockFilePicker.showCallback = function(fp) { - info("showCallback"); - fileName = fp.defaultString; - info("fileName: " + fileName); - destFile.append (fileName); - MockFilePicker.returnFiles = [destFile]; - MockFilePicker.filterIndex = 1; // kSaveAsType_URL - info("done showCallback"); - }; - - mockTransferCallback = function(downloadSuccess) { - info("mockTransferCallback"); - onTransferComplete(aWindow, downloadSuccess, destDir); - destDir.remove(true); - ok(!destDir.exists(), "Destination dir should be removed"); - ok(!destFile.exists(), "Destination file should be removed"); - mockTransferCallback = null; - info("done mockTransferCallback"); - } - - // Select "Save Link As" option from context menu - var saveLinkCommand = aWindow.document.getElementById("context-savelink"); - info("saveLinkCommand: " + saveLinkCommand); - saveLinkCommand.doCommand(); - - event.target.hidePopup(); - info("popup hidden"); - } - - function onTransferComplete(aWindow2, downloadSuccess, destDir) { - ok(downloadSuccess, "Link should have been downloaded successfully"); - aWindow2.close(); - - executeSoon(() => aCallback()); - } -} - -function test() { - info("Start the test"); - waitForExplicitFinish(); - - var gNumSet = 0; - function testOnWindow(options, callback) { - info("testOnWindow(" + options + ")"); - var win = OpenBrowserWindow(options); - info("got " + win); - whenDelayedStartupFinished(win, () => callback(win)); - } - - function whenDelayedStartupFinished(aWindow, aCallback) { - info("whenDelayedStartupFinished"); - Services.obs.addObserver(function obs(aSubject, aTopic) { - info("whenDelayedStartupFinished, got topic: " + aTopic + ", got subject: " + aSubject + ", waiting for " + aWindow); - if (aWindow == aSubject) { - Services.obs.removeObserver(obs, aTopic); - executeSoon(aCallback); - info("whenDelayedStartupFinished found our window"); - } - }, "browser-delayed-startup-finished", false); - } - - mockTransferRegisterer.register(); - - registerCleanupFunction(function () { - info("Running the cleanup code"); - mockTransferRegisterer.unregister(); - MockFilePicker.cleanup(); - Services.obs.removeObserver(observer, "http-on-modify-request"); - Services.obs.removeObserver(observer, "http-on-examine-response"); - info("Finished running the cleanup code"); - }); - - function observer(subject, topic, state) { - info("observer called with " + topic); - if (topic == "http-on-modify-request") { - onModifyRequest(subject); - } else if (topic == "http-on-examine-response") { - onExamineResponse(subject); - } - } - - function onExamineResponse(subject) { - let channel = subject.QueryInterface(Ci.nsIHttpChannel); - info("onExamineResponse with " + channel.URI.spec); - if (channel.URI.spec != "http://mochi.test:8888/browser/browser/base/content/test/general/bug792517.sjs") { - info("returning"); - return; - } - try { - let cookies = channel.getResponseHeader("set-cookie"); - // From browser/base/content/test/general/bug792715.sjs, we receive a Set-Cookie - // header with foopy=1 when there are no cookies for that domain. - is(cookies, "foopy=1", "Cookie should be foopy=1"); - gNumSet += 1; - info("gNumSet = " + gNumSet); - } catch (ex) { - if (ex.result == Cr.NS_ERROR_NOT_AVAILABLE) { - info("onExamineResponse caught NOTAVAIL" + ex); - } else { - info("ionExamineResponse caught " + ex); - } - } - } - - function onModifyRequest(subject) { - let channel = subject.QueryInterface(Ci.nsIHttpChannel); - info("onModifyRequest with " + channel.URI.spec); - if (channel.URI.spec != "http://mochi.test:8888/browser/browser/base/content/test/general/bug792517.sjs") { - return; - } - try { - let cookies = channel.getRequestHeader("cookie"); - info("cookies: " + cookies); - // From browser/base/content/test/general/bug792715.sjs, we should never send a - // cookie because we are making only 2 requests: one in public mode, and - // one in private mode. - throw "We should never send a cookie in this test"; - } catch (ex) { - if (ex.result == Cr.NS_ERROR_NOT_AVAILABLE) { - info("onModifyRequest caught NOTAVAIL" + ex); - } else { - info("ionModifyRequest caught " + ex); - } - } - } - - Services.obs.addObserver(observer, "http-on-modify-request", false); - Services.obs.addObserver(observer, "http-on-examine-response", false); - - testOnWindow(undefined, function(win) { - // The first save from a regular window sets a cookie. - triggerSave(win, function() { - is(gNumSet, 1, "1 cookie should be set"); - - // The second save from a private window also sets a cookie. - testOnWindow({private: true}, function(win2) { - triggerSave(win2, function() { - is(gNumSet, 2, "2 cookies should be set"); - finish(); - }); - }); - }); - }); -} - -Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js", - this); - -function createTemporarySaveDirectory() { - var saveDir = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties) - .get("TmpD", Ci.nsIFile); - saveDir.append("testsavedir"); - if (!saveDir.exists()) { - info("create testsavedir!"); - saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755); - } - info("return from createTempSaveDir: " + saveDir.path); - return saveDir; -} diff --git a/browser/base/content/test/general/browser_save_link_when_window_navigates.js b/browser/base/content/test/general/browser_save_link_when_window_navigates.js deleted file mode 100644 index 2fd10b00e..000000000 --- a/browser/base/content/test/general/browser_save_link_when_window_navigates.js +++ /dev/null @@ -1,173 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -var MockFilePicker = SpecialPowers.MockFilePicker; -MockFilePicker.init(window); - -const SAVE_PER_SITE_PREF = "browser.download.lastDir.savePerSite"; -const ALWAYS_DOWNLOAD_DIR_PREF = "browser.download.useDownloadDir"; -const UCT_URI = "chrome://mozapps/content/downloads/unknownContentType.xul"; - -Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js", - this); - -function createTemporarySaveDirectory() { - var saveDir = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties) - .get("TmpD", Ci.nsIFile); - saveDir.append("testsavedir"); - if (!saveDir.exists()) { - info("create testsavedir!"); - saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755); - } - info("return from createTempSaveDir: " + saveDir.path); - return saveDir; -} - -function triggerSave(aWindow, aCallback) { - info("started triggerSave, persite downloads: " + (Services.prefs.getBoolPref(SAVE_PER_SITE_PREF) ? "on" : "off")); - var fileName; - let testBrowser = aWindow.gBrowser.selectedBrowser; - let testURI = "http://mochi.test:8888/browser/browser/base/content/test/general/navigating_window_with_download.html"; - windowObserver.setCallback(onUCTDialog); - testBrowser.loadURI(testURI); - - // Create the folder the link will be saved into. - var destDir = createTemporarySaveDirectory(); - var destFile = destDir.clone(); - - MockFilePicker.displayDirectory = destDir; - MockFilePicker.showCallback = function(fp) { - info("showCallback"); - fileName = fp.defaultString; - info("fileName: " + fileName); - destFile.append (fileName); - MockFilePicker.returnFiles = [destFile]; - MockFilePicker.filterIndex = 1; // kSaveAsType_URL - info("done showCallback"); - }; - - mockTransferCallback = function(downloadSuccess) { - info("mockTransferCallback"); - onTransferComplete(aWindow, downloadSuccess, destDir); - destDir.remove(true); - ok(!destDir.exists(), "Destination dir should be removed"); - ok(!destFile.exists(), "Destination file should be removed"); - mockTransferCallback = null; - info("done mockTransferCallback"); - } - - function onUCTDialog(dialog) { - function doLoad() { - content.document.querySelector('iframe').remove(); - } - testBrowser.messageManager.loadFrameScript("data:,(" + doLoad.toString() + ")()", false); - executeSoon(continueDownloading); - } - - function continueDownloading() { - let windows = Services.wm.getEnumerator(""); - while (windows.hasMoreElements()) { - let win = windows.getNext(); - if (win.location && win.location.href == UCT_URI) { - win.document.documentElement._fireButtonEvent("accept"); - win.close(); - return; - } - } - ok(false, "No Unknown Content Type dialog yet?"); - } - - function onTransferComplete(aWindow2, downloadSuccess) { - ok(downloadSuccess, "Link should have been downloaded successfully"); - aWindow2.close(); - - executeSoon(aCallback); - } -} - - -var windowObserver = { - setCallback: function(aCallback) { - if (this._callback) { - ok(false, "Should only be dealing with one callback at a time."); - } - this._callback = aCallback; - }, - observe: function(aSubject, aTopic, aData) { - if (aTopic != "domwindowopened") { - return; - } - - let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); - - win.addEventListener("load", function onLoad(event) { - win.removeEventListener("load", onLoad, false); - - if (win.location == UCT_URI) { - SimpleTest.executeSoon(function() { - if (windowObserver._callback) { - windowObserver._callback(win); - delete windowObserver._callback; - } else { - ok(false, "Unexpected UCT dialog!"); - } - }); - } - }, false); - } -}; - -Services.ww.registerNotification(windowObserver); - -function test() { - waitForExplicitFinish(); - - function testOnWindow(options, callback) { - info("testOnWindow(" + options + ")"); - var win = OpenBrowserWindow(options); - info("got " + win); - whenDelayedStartupFinished(win, () => callback(win)); - } - - function whenDelayedStartupFinished(aWindow, aCallback) { - info("whenDelayedStartupFinished"); - Services.obs.addObserver(function observer(aSubject, aTopic) { - info("whenDelayedStartupFinished, got topic: " + aTopic + ", got subject: " + aSubject + ", waiting for " + aWindow); - if (aWindow == aSubject) { - Services.obs.removeObserver(observer, aTopic); - executeSoon(aCallback); - info("whenDelayedStartupFinished found our window"); - } - }, "browser-delayed-startup-finished", false); - } - - mockTransferRegisterer.register(); - - registerCleanupFunction(function () { - info("Running the cleanup code"); - mockTransferRegisterer.unregister(); - MockFilePicker.cleanup(); - Services.ww.unregisterNotification(windowObserver); - Services.prefs.clearUserPref(ALWAYS_DOWNLOAD_DIR_PREF); - Services.prefs.clearUserPref(SAVE_PER_SITE_PREF); - info("Finished running the cleanup code"); - }); - - Services.prefs.setBoolPref(ALWAYS_DOWNLOAD_DIR_PREF, false); - testOnWindow(undefined, function(win) { - let windowGonePromise = promiseWindowWillBeClosed(win); - Services.prefs.setBoolPref(SAVE_PER_SITE_PREF, true); - triggerSave(win, function() { - windowGonePromise.then(function() { - Services.prefs.setBoolPref(SAVE_PER_SITE_PREF, false); - testOnWindow(undefined, function(win2) { - triggerSave(win2, finish); - }); - }); - }); - }); -} - diff --git a/browser/base/content/test/general/browser_save_private_link_perwindowpb.js b/browser/base/content/test/general/browser_save_private_link_perwindowpb.js deleted file mode 100644 index e7ed5fa34..000000000 --- a/browser/base/content/test/general/browser_save_private_link_perwindowpb.js +++ /dev/null @@ -1,116 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function createTemporarySaveDirectory() { - var saveDir = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties) - .get("TmpD", Ci.nsIFile); - saveDir.append("testsavedir"); - if (!saveDir.exists()) - saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755); - return saveDir; -} - -function promiseNoCacheEntry(filename) { - return new Promise((resolve, reject) => { - Visitor.prototype = { - onCacheStorageInfo: function(num, consumption) - { - info("disk storage contains " + num + " entries"); - }, - onCacheEntryInfo: function(uri) - { - let urispec = uri.asciiSpec; - info(urispec); - is(urispec.includes(filename), false, "web content present in disk cache"); - }, - onCacheEntryVisitCompleted: function() - { - resolve(); - } - }; - function Visitor() {} - - let cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"] - .getService(Ci.nsICacheStorageService); - let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInfo.jsm", null); - let storage = cache.diskCacheStorage(LoadContextInfo.default, false); - storage.asyncVisitStorage(new Visitor(), true /* Do walk entries */); - }); -} - -function promiseImageDownloaded() { - return new Promise((resolve, reject) => { - let fileName; - let MockFilePicker = SpecialPowers.MockFilePicker; - MockFilePicker.init(window); - - function onTransferComplete(downloadSuccess) { - ok(downloadSuccess, "Image file should have been downloaded successfully " + fileName); - - // Give the request a chance to finish and create a cache entry - resolve(fileName); - } - - // Create the folder the image will be saved into. - var destDir = createTemporarySaveDirectory(); - var destFile = destDir.clone(); - - MockFilePicker.displayDirectory = destDir; - MockFilePicker.showCallback = function(fp) { - fileName = fp.defaultString; - destFile.append (fileName); - MockFilePicker.returnFiles = [destFile]; - MockFilePicker.filterIndex = 1; // kSaveAsType_URL - }; - - mockTransferCallback = onTransferComplete; - mockTransferRegisterer.register(); - - registerCleanupFunction(function () { - mockTransferCallback = null; - mockTransferRegisterer.unregister(); - MockFilePicker.cleanup(); - destDir.remove(true); - }); - - }); -} - -add_task(function* () { - let testURI = "http://mochi.test:8888/browser/browser/base/content/test/general/bug792517.html"; - let privateWindow = yield BrowserTestUtils.openNewBrowserWindow({private: true}); - let tab = yield BrowserTestUtils.openNewForegroundTab(privateWindow.gBrowser, testURI); - - let contextMenu = privateWindow.document.getElementById("contentAreaContextMenu"); - let popupShown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown"); - let popupHidden = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden"); - yield BrowserTestUtils.synthesizeMouseAtCenter("#img", { - type: "contextmenu", - button: 2 - }, tab.linkedBrowser); - yield popupShown; - - let cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"] - .getService(Ci.nsICacheStorageService); - cache.clear(); - - let imageDownloaded = promiseImageDownloaded(); - // Select "Save Image As" option from context menu - privateWindow.document.getElementById("context-saveimage").doCommand(); - - contextMenu.hidePopup(); - yield popupHidden; - - // wait for image download - let fileName = yield imageDownloaded; - yield promiseNoCacheEntry(fileName); - - yield BrowserTestUtils.closeWindow(privateWindow); -}); - -Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js", - this); diff --git a/browser/base/content/test/general/browser_save_video.js b/browser/base/content/test/general/browser_save_video.js deleted file mode 100644 index e81286b7a..000000000 --- a/browser/base/content/test/general/browser_save_video.js +++ /dev/null @@ -1,87 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -var MockFilePicker = SpecialPowers.MockFilePicker; -MockFilePicker.init(window); - -/** - * TestCase for bug 564387 - * <https://bugzilla.mozilla.org/show_bug.cgi?id=564387> - */ -add_task(function* () { - var fileName; - - let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - gBrowser.loadURI("http://mochi.test:8888/browser/browser/base/content/test/general/web_video.html"); - yield loadPromise; - - let popupShownPromise = BrowserTestUtils.waitForEvent(document, "popupshown"); - - yield BrowserTestUtils.synthesizeMouseAtCenter("#video1", - { type: "contextmenu", button: 2 }, - gBrowser.selectedBrowser); - info("context menu click on video1"); - - yield popupShownPromise; - - info("context menu opened on video1"); - - // Create the folder the video will be saved into. - var destDir = createTemporarySaveDirectory(); - var destFile = destDir.clone(); - - MockFilePicker.displayDirectory = destDir; - MockFilePicker.showCallback = function(fp) { - fileName = fp.defaultString; - destFile.append(fileName); - MockFilePicker.returnFiles = [destFile]; - MockFilePicker.filterIndex = 1; // kSaveAsType_URL - }; - - let transferCompletePromise = new Promise((resolve) => { - function onTransferComplete(downloadSuccess) { - ok(downloadSuccess, "Video file should have been downloaded successfully"); - - is(fileName, "web-video1-expectedName.ogv", - "Video file name is correctly retrieved from Content-Disposition http header"); - resolve(); - } - - mockTransferCallback = onTransferComplete; - mockTransferRegisterer.register(); - }); - - registerCleanupFunction(function () { - mockTransferRegisterer.unregister(); - MockFilePicker.cleanup(); - destDir.remove(true); - }); - - // Select "Save Video As" option from context menu - var saveVideoCommand = document.getElementById("context-savevideo"); - saveVideoCommand.doCommand(); - info("context-savevideo command executed"); - - let contextMenu = document.getElementById("contentAreaContextMenu"); - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden"); - contextMenu.hidePopup(); - yield popupHiddenPromise; - - yield transferCompletePromise; -}); - - -Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js", - this); - -function createTemporarySaveDirectory() { - var saveDir = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties) - .get("TmpD", Ci.nsIFile); - saveDir.append("testsavedir"); - if (!saveDir.exists()) - saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755); - return saveDir; -} diff --git a/browser/base/content/test/general/browser_save_video_frame.js b/browser/base/content/test/general/browser_save_video_frame.js deleted file mode 100644 index e9b8a0475..000000000 --- a/browser/base/content/test/general/browser_save_video_frame.js +++ /dev/null @@ -1,125 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -const VIDEO_URL = "http://mochi.test:8888/browser/browser/base/content/test/general/web_video.html"; - -/** - * mockTransfer.js provides a utility that lets us mock out - * the "Save File" dialog. - */ -Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js", - this); - -/** - * Creates and returns an nsIFile for a new temporary save - * directory. - * - * @return nsIFile - */ -function createTemporarySaveDirectory() { - let saveDir = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties) - .get("TmpD", Ci.nsIFile); - saveDir.append("testsavedir"); - if (!saveDir.exists()) - saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755); - return saveDir; -} -/** - * MockTransfer exposes a "mockTransferCallback" global which - * allows us to define a callback to be called once the mock file - * selector has selected where to save the file. - */ -function waitForTransferComplete() { - return new Promise((resolve) => { - mockTransferCallback = () => { - ok(true, "Transfer completed"); - resolve(); - } - }); -} - -/** - * Given some browser, loads a framescript that right-clicks - * on the video1 element to spawn a contextmenu. - */ -function rightClickVideo(browser) { - let frame_script = () => { - const Ci = Components.interfaces; - let utils = content.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils); - - let document = content.document; - let video = document.getElementById("video1"); - let rect = video.getBoundingClientRect(); - - /* Synthesize a click in the center of the video. */ - let left = rect.left + (rect.width / 2); - let top = rect.top + (rect.height / 2); - - utils.sendMouseEvent("contextmenu", left, top, - 2, /* aButton */ - 1, /* aClickCount */ - 0 /* aModifiers */); - }; - let mm = browser.messageManager; - mm.loadFrameScript("data:,(" + frame_script.toString() + ")();", true); -} - -/** - * Loads a page with a <video> element, right-clicks it and chooses - * to save a frame screenshot to the disk. Completes once we've - * verified that the frame has been saved to disk. - */ -add_task(function*() { - let MockFilePicker = SpecialPowers.MockFilePicker; - MockFilePicker.init(window); - - // Create the folder the video will be saved into. - let destDir = createTemporarySaveDirectory(); - let destFile = destDir.clone(); - - MockFilePicker.displayDirectory = destDir; - MockFilePicker.showCallback = function(fp) { - destFile.append(fp.defaultString); - MockFilePicker.returnFiles = [destFile]; - MockFilePicker.filterIndex = 1; // kSaveAsType_URL - }; - - mockTransferRegisterer.register(); - - // Make sure that we clean these things up when we're done. - registerCleanupFunction(function () { - mockTransferRegisterer.unregister(); - MockFilePicker.cleanup(); - destDir.remove(true); - }); - - let tab = gBrowser.addTab(); - gBrowser.selectedTab = tab; - let browser = tab.linkedBrowser; - info("Loading video tab"); - yield promiseTabLoadEvent(tab, VIDEO_URL); - info("Video tab loaded."); - - let context = document.getElementById("contentAreaContextMenu"); - let popupPromise = promisePopupShown(context); - - info("Synthesizing right-click on video element"); - rightClickVideo(browser); - info("Waiting for popup to fire popupshown."); - yield popupPromise; - info("Popup fired popupshown"); - - let saveSnapshotCommand = document.getElementById("context-video-saveimage"); - let promiseTransfer = waitForTransferComplete() - info("Firing save snapshot command"); - saveSnapshotCommand.doCommand(); - context.hidePopup(); - info("Waiting for transfer completion"); - yield promiseTransfer; - info("Transfer complete"); - gBrowser.removeTab(tab); -}); diff --git a/browser/base/content/test/general/browser_scope.js b/browser/base/content/test/general/browser_scope.js deleted file mode 100644 index f8141e5f6..000000000 --- a/browser/base/content/test/general/browser_scope.js +++ /dev/null @@ -1,10 +0,0 @@ -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: this.docShell is null"); - -function test() { - ok(!!gBrowser, "gBrowser exists"); - is(gBrowser, getBrowser(), "both ways of getting tabbrowser work"); -} diff --git a/browser/base/content/test/general/browser_selectTabAtIndex.js b/browser/base/content/test/general/browser_selectTabAtIndex.js deleted file mode 100644 index b6578aec0..000000000 --- a/browser/base/content/test/general/browser_selectTabAtIndex.js +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; - -function test() { - const isLinux = navigator.platform.indexOf("Linux") == 0; - - function assertTab(expectedTab) { - is(gBrowser.tabContainer.selectedIndex, expectedTab, - `tab index ${expectedTab} should be selected`); - } - - function sendAccelKey(key) { - // Make sure the keystroke goes to chrome. - document.activeElement.blur(); - EventUtils.synthesizeKey(key.toString(), { altKey: isLinux, accelKey: !isLinux }); - } - - function createTabs(count) { - for (let n = 0; n < count; n++) - gBrowser.addTab(); - } - - function testKey(key, expectedTab) { - sendAccelKey(key); - assertTab(expectedTab); - } - - function testIndex(index, expectedTab) { - gBrowser.selectTabAtIndex(index); - assertTab(expectedTab); - } - - // Create fewer tabs than our 9 number keys. - is(gBrowser.tabs.length, 1, "should have 1 tab"); - createTabs(4); - is(gBrowser.tabs.length, 5, "should have 5 tabs"); - - // Test keyboard shortcuts. Order tests so that no two test cases have the - // same expected tab in a row. This ensures that tab selection actually - // changed the selected tab. - testKey(8, 4); - testKey(1, 0); - testKey(2, 1); - testKey(4, 3); - testKey(9, 4); - - // Test index selection. - testIndex(0, 0); - testIndex(4, 4); - testIndex(-5, 0); - testIndex(5, 4); - testIndex(-4, 1); - testIndex(1, 1); - testIndex(-1, 4); - testIndex(9, 4); - - // Create more tabs than our 9 number keys. - createTabs(10); - is(gBrowser.tabs.length, 15, "should have 15 tabs"); - - // Test keyboard shortcuts. - testKey(2, 1); - testKey(1, 0); - testKey(4, 3); - testKey(8, 7); - testKey(9, 14); - - // Test index selection. - testIndex(-15, 0); - testIndex(14, 14); - testIndex(-14, 1); - testIndex(15, 14); - testIndex(-1, 14); - testIndex(0, 0); - testIndex(1, 1); - testIndex(9, 9); - - // Clean up tabs. - for (let n = 15; n > 1; n--) - gBrowser.removeTab(gBrowser.selectedTab, {skipPermitUnload: true}); - is(gBrowser.tabs.length, 1, "should have 1 tab"); -} diff --git a/browser/base/content/test/general/browser_selectpopup.js b/browser/base/content/test/general/browser_selectpopup.js deleted file mode 100644 index d34254d1c..000000000 --- a/browser/base/content/test/general/browser_selectpopup.js +++ /dev/null @@ -1,563 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -// This test checks that a <select> with an <optgroup> opens and can be navigated -// in a child process. This is different than single-process as a <menulist> is used -// to implement the dropdown list. - -requestLongerTimeout(2); - -const XHTML_DTD = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'; - -const PAGECONTENT = - "<html xmlns='http://www.w3.org/1999/xhtml'>" + - "<body onload='gChangeEvents = 0;gInputEvents = 0; document.body.firstChild.focus()'><select oninput='gInputEvents++' onchange='gChangeEvents++'>" + - " <optgroup label='First Group'>" + - " <option value='One'>One</option>" + - " <option value='Two'>Two</option>" + - " </optgroup>" + - " <option value='Three'>Three</option>" + - " <optgroup label='Second Group' disabled='true'>" + - " <option value='Four'>Four</option>" + - " <option value='Five'>Five</option>" + - " </optgroup>" + - " <option value='Six' disabled='true'>Six</option>" + - " <optgroup label='Third Group'>" + - " <option value='Seven'> Seven </option>" + - " <option value='Eight'> Eight </option>" + - " </optgroup></select><input />Text" + - "</body></html>"; - -const PAGECONTENT_SMALL = - "<html>" + - "<body><select id='one'>" + - " <option value='One'>One</option>" + - " <option value='Two'>Two</option>" + - "</select><select id='two'>" + - " <option value='Three'>Three</option>" + - " <option value='Four'>Four</option>" + - "</select><select id='three'>" + - " <option value='Five'>Five</option>" + - " <option value='Six'>Six</option>" + - "</select></body></html>"; - -const PAGECONTENT_SOMEHIDDEN = - "<html><head><style>.hidden { display: none; }</style></head>" + - "<body><select id='one'>" + - " <option value='One' style='display: none;'>OneHidden</option>" + - " <option value='Two' class='hidden'>TwoHidden</option>" + - " <option value='Three'>ThreeVisible</option>" + - " <option value='Four'style='display: table;'>FourVisible</option>" + - " <option value='Five'>FiveVisible</option>" + - " <optgroup label='GroupHidden' class='hidden'>" + - " <option value='Four'>Six.OneHidden</option>" + - " <option value='Five' style='display: block;'>Six.TwoHidden</option>" + - " </optgroup>" + - " <option value='Six' class='hidden' style='display: block;'>SevenVisible</option>" + - "</select></body></html>"; - -const PAGECONTENT_TRANSLATED = - "<html><body>" + - "<div id='div'>" + - "<iframe id='frame' width='320' height='295' style='border: none;'" + - " src='data:text/html,<select id=select autofocus><option>he he he</option><option>boo boo</option><option>baz baz</option></select>'" + - "</iframe>" + - "</div></body></html>"; - -function openSelectPopup(selectPopup, withMouse, selector = "select", win = window) -{ - let popupShownPromise = BrowserTestUtils.waitForEvent(selectPopup, "popupshown"); - - if (withMouse) { - return Promise.all([popupShownPromise, - BrowserTestUtils.synthesizeMouseAtCenter(selector, { }, win.gBrowser.selectedBrowser)]); - } - - EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true, code: "ArrowDown" }, win); - return popupShownPromise; -} - -function hideSelectPopup(selectPopup, mode = "enter", win = window) -{ - let popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden"); - - if (mode == "escape") { - EventUtils.synthesizeKey("KEY_Escape", { code: "Escape" }, win); - } - else if (mode == "enter") { - EventUtils.synthesizeKey("KEY_Enter", { code: "Enter" }, win); - } - else if (mode == "click") { - EventUtils.synthesizeMouseAtCenter(selectPopup.lastChild, { }, win); - } - - return popupHiddenPromise; -} - -function getInputEvents() -{ - return ContentTask.spawn(gBrowser.selectedBrowser, {}, function() { - return content.wrappedJSObject.gInputEvents; - }); -} - -function getChangeEvents() -{ - return ContentTask.spawn(gBrowser.selectedBrowser, {}, function() { - return content.wrappedJSObject.gChangeEvents; - }); -} - -function* doSelectTests(contentType, dtd) -{ - const pageUrl = "data:" + contentType + "," + escape(dtd + "\n" + PAGECONTENT); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl); - - let menulist = document.getElementById("ContentSelectDropdown"); - let selectPopup = menulist.menupopup; - - yield openSelectPopup(selectPopup); - - let isWindows = navigator.platform.indexOf("Win") >= 0; - - is(menulist.selectedIndex, 1, "Initial selection"); - is(selectPopup.firstChild.localName, "menucaption", "optgroup is caption"); - is(selectPopup.firstChild.getAttribute("label"), "First Group", "optgroup label"); - is(selectPopup.childNodes[1].localName, "menuitem", "option is menuitem"); - is(selectPopup.childNodes[1].getAttribute("label"), "One", "option label"); - - EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" }); - is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(2), "Select item 2"); - is(menulist.selectedIndex, isWindows ? 2 : 1, "Select item 2 selectedIndex"); - - EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" }); - is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(3), "Select item 3"); - is(menulist.selectedIndex, isWindows ? 3 : 1, "Select item 3 selectedIndex"); - - EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" }); - - // On Windows, one can navigate on disabled menuitems - is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(9), - "Skip optgroup header and disabled items select item 7"); - is(menulist.selectedIndex, isWindows ? 9 : 1, "Select or skip disabled item selectedIndex"); - - for (let i = 0; i < 10; i++) { - is(menulist.getItemAtIndex(i).disabled, i >= 4 && i <= 7, "item " + i + " disabled") - } - - EventUtils.synthesizeKey("KEY_ArrowUp", { code: "ArrowUp" }); - is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(3), "Select item 3 again"); - is(menulist.selectedIndex, isWindows ? 3 : 1, "Select item 3 selectedIndex"); - - is((yield getInputEvents()), 0, "Before closed - number of input events"); - is((yield getChangeEvents()), 0, "Before closed - number of change events"); - - EventUtils.synthesizeKey("a", { accelKey: true }); - yield ContentTask.spawn(gBrowser.selectedBrowser, { isWindows }, function(args) { - Assert.equal(String(content.getSelection()), args.isWindows ? "Text" : "", - "Select all while popup is open"); - }); - - // Backspace should not go back - let handleKeyPress = function(event) { - ok(false, "Should not get keypress event"); - } - window.addEventListener("keypress", handleKeyPress); - EventUtils.synthesizeKey("VK_BACK_SPACE", { }); - window.removeEventListener("keypress", handleKeyPress); - - yield hideSelectPopup(selectPopup); - - is(menulist.selectedIndex, 3, "Item 3 still selected"); - is((yield getInputEvents()), 1, "After closed - number of input events"); - is((yield getChangeEvents()), 1, "After closed - number of change events"); - - // Opening and closing the popup without changing the value should not fire a change event. - yield openSelectPopup(selectPopup, true); - yield hideSelectPopup(selectPopup, "escape"); - is((yield getInputEvents()), 1, "Open and close with no change - number of input events"); - is((yield getChangeEvents()), 1, "Open and close with no change - number of change events"); - EventUtils.synthesizeKey("VK_TAB", { }); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); - is((yield getInputEvents()), 1, "Tab away from select with no change - number of input events"); - is((yield getChangeEvents()), 1, "Tab away from select with no change - number of change events"); - - yield openSelectPopup(selectPopup, true); - EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" }); - yield hideSelectPopup(selectPopup, "escape"); - is((yield getInputEvents()), isWindows ? 2 : 1, "Open and close with change - number of input events"); - is((yield getChangeEvents()), isWindows ? 2 : 1, "Open and close with change - number of change events"); - EventUtils.synthesizeKey("VK_TAB", { }); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); - is((yield getInputEvents()), isWindows ? 2 : 1, "Tab away from select with change - number of input events"); - is((yield getChangeEvents()), isWindows ? 2 : 1, "Tab away from select with change - number of change events"); - - is(selectPopup.lastChild.previousSibling.label, "Seven", "Spaces collapsed"); - is(selectPopup.lastChild.label, "\xA0\xA0Eight\xA0\xA0", "Non-breaking spaces not collapsed"); - - yield BrowserTestUtils.removeTab(tab); -} - -add_task(function*() { - yield doSelectTests("text/html", ""); -}); - -add_task(function*() { - yield doSelectTests("application/xhtml+xml", XHTML_DTD); -}); - -// This test opens a select popup and removes the content node of a popup while -// The popup should close if its node is removed. -add_task(function*() { - const pageUrl = "data:text/html," + escape(PAGECONTENT_SMALL); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl); - - let menulist = document.getElementById("ContentSelectDropdown"); - let selectPopup = menulist.menupopup; - - // First, try it when a different <select> element than the one that is open is removed - yield openSelectPopup(selectPopup, true, "#one"); - - yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function() { - content.document.body.removeChild(content.document.getElementById("two")); - }); - - // Wait a bit just to make sure the popup won't close. - yield new Promise(resolve => setTimeout(resolve, 1000)); - - is(selectPopup.state, "open", "Different popup did not affect open popup"); - - yield hideSelectPopup(selectPopup); - - // Next, try it when the same <select> element than the one that is open is removed - yield openSelectPopup(selectPopup, true, "#three"); - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden"); - yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function() { - content.document.body.removeChild(content.document.getElementById("three")); - }); - yield popupHiddenPromise; - - ok(true, "Popup hidden when select is removed"); - - // Finally, try it when the tab is closed while the select popup is open. - yield openSelectPopup(selectPopup, true, "#one"); - - popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden"); - yield BrowserTestUtils.removeTab(tab); - yield popupHiddenPromise; - - ok(true, "Popup hidden when tab is closed"); -}); - -// This test opens a select popup that is isn't a frame and has some translations applied. -add_task(function*() { - const pageUrl = "data:text/html," + escape(PAGECONTENT_TRANSLATED); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl); - - let menulist = document.getElementById("ContentSelectDropdown"); - let selectPopup = menulist.menupopup; - - // First, get the position of the select popup when no translations have been applied. - yield openSelectPopup(selectPopup, false); - - let rect = selectPopup.getBoundingClientRect(); - let expectedX = rect.left; - let expectedY = rect.top; - - yield hideSelectPopup(selectPopup); - - // Iterate through a set of steps which each add more translation to the select's expected position. - let steps = [ - [ "div", "transform: translateX(7px) translateY(13px);", 7, 13 ], - [ "frame", "border-top: 5px solid green; border-left: 10px solid red; border-right: 35px solid blue;", 10, 5 ], - [ "frame", "border: none; padding-left: 6px; padding-right: 12px; padding-top: 2px;", -4, -3 ], - [ "select", "margin: 9px; transform: translateY(-3px);", 9, 6 ], - ]; - - for (let stepIndex = 0; stepIndex < steps.length; stepIndex++) { - let step = steps[stepIndex]; - - yield ContentTask.spawn(gBrowser.selectedBrowser, step, function*(contentStep) { - return new Promise(resolve => { - let changedWin = content; - - let elem; - if (contentStep[0] == "select") { - changedWin = content.document.getElementById("frame").contentWindow; - elem = changedWin.document.getElementById("select"); - } - else { - elem = content.document.getElementById(contentStep[0]); - } - - changedWin.addEventListener("MozAfterPaint", function onPaint() { - changedWin.removeEventListener("MozAfterPaint", onPaint); - resolve(); - }); - - elem.style = contentStep[1]; - elem.getBoundingClientRect(); - }); - }); - - yield openSelectPopup(selectPopup, false); - - expectedX += step[2]; - expectedY += step[3]; - - let popupRect = selectPopup.getBoundingClientRect(); - is(popupRect.left, expectedX, "step " + (stepIndex + 1) + " x"); - is(popupRect.top, expectedY, "step " + (stepIndex + 1) + " y"); - - yield hideSelectPopup(selectPopup); - } - - yield BrowserTestUtils.removeTab(tab); -}); - -// Test that we get the right events when a select popup is changed. -add_task(function* test_event_order() { - const URL = "data:text/html," + escape(PAGECONTENT_SMALL); - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: URL, - }, function*(browser) { - let menulist = document.getElementById("ContentSelectDropdown"); - let selectPopup = menulist.menupopup; - - // According to https://html.spec.whatwg.org/#the-select-element, - // we want to fire input, change, and then click events on the - // <select> (in that order) when it has changed. - let expectedEnter = [ - { - type: "input", - cancelable: false, - targetIsOption: false, - }, - { - type: "change", - cancelable: false, - targetIsOption: false, - }, - ]; - - let expectedClick = [ - { - type: "mousedown", - cancelable: true, - targetIsOption: true, - }, - { - type: "mouseup", - cancelable: true, - targetIsOption: true, - }, - { - type: "input", - cancelable: false, - targetIsOption: false, - }, - { - type: "change", - cancelable: false, - targetIsOption: false, - }, - { - type: "click", - cancelable: true, - targetIsOption: true, - }, - ]; - - for (let mode of ["enter", "click"]) { - let expected = mode == "enter" ? expectedEnter : expectedClick; - yield openSelectPopup(selectPopup, true, mode == "enter" ? "#one" : "#two"); - - let eventsPromise = ContentTask.spawn(browser, [mode, expected], function*([contentMode, contentExpected]) { - return new Promise((resolve) => { - function onEvent(event) { - select.removeEventListener(event.type, onEvent); - Assert.ok(contentExpected.length, "Unexpected event " + event.type); - let expectation = contentExpected.shift(); - Assert.equal(event.type, expectation.type, - "Expected the right event order"); - Assert.ok(event.bubbles, "All of these events should bubble"); - Assert.equal(event.cancelable, expectation.cancelable, - "Cancellation property should match"); - Assert.equal(event.target.localName, - expectation.targetIsOption ? "option" : "select", - "Target matches"); - if (!contentExpected.length) { - resolve(); - } - } - - let select = content.document.getElementById(contentMode == "enter" ? "one" : "two"); - for (let event of ["input", "change", "mousedown", "mouseup", "click"]) { - select.addEventListener(event, onEvent); - } - }); - }); - - EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" }); - yield hideSelectPopup(selectPopup, mode); - yield eventsPromise; - } - }); -}); - -function* performLargePopupTests(win) -{ - let browser = win.gBrowser.selectedBrowser; - - yield ContentTask.spawn(browser, null, function*() { - let doc = content.document; - let select = doc.getElementById("one"); - for (var i = 0; i < 180; i++) { - select.add(new content.Option("Test" + i)); - } - - select.options[60].selected = true; - select.focus(); - }); - - let selectPopup = win.document.getElementById("ContentSelectDropdown").menupopup; - let browserRect = browser.getBoundingClientRect(); - - let positions = [ - "margin-top: 300px;", - "position: fixed; bottom: 100px;", - "width: 100%; height: 9999px;" - ]; - - let position; - while (true) { - yield openSelectPopup(selectPopup, false, "select", win); - - let rect = selectPopup.getBoundingClientRect(); - ok(rect.top >= browserRect.top, "Popup top position in within browser area"); - ok(rect.bottom <= browserRect.bottom, "Popup bottom position in within browser area"); - - // Don't check the scroll position for the last step as the popup will be cut off. - if (positions.length > 0) { - let cs = win.getComputedStyle(selectPopup); - let bpBottom = parseFloat(cs.paddingBottom) + parseFloat(cs.borderBottomWidth); - - is(selectPopup.childNodes[60].getBoundingClientRect().bottom, - selectPopup.getBoundingClientRect().bottom - bpBottom, - "Popup scroll at correct position " + bpBottom); - } - - yield hideSelectPopup(selectPopup, "enter", win); - - position = positions.shift(); - if (!position) { - break; - } - - let contentPainted = BrowserTestUtils.contentPainted(browser); - yield ContentTask.spawn(browser, position, function*(contentPosition) { - let select = content.document.getElementById("one"); - select.setAttribute("style", contentPosition); - select.getBoundingClientRect(); - }); - yield contentPainted; - } -} - -// This test checks select elements with a large number of options to ensure that -// the popup appears within the browser area. -add_task(function* test_large_popup() { - const pageUrl = "data:text/html," + escape(PAGECONTENT_SMALL); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl); - - yield* performLargePopupTests(window); - - yield BrowserTestUtils.removeTab(tab); -}); - -// This test checks the same as the previous test but in a new smaller window. -add_task(function* test_large_popup_in_small_window() { - let newwin = yield BrowserTestUtils.openNewBrowserWindow({ width: 400, height: 400 }); - - const pageUrl = "data:text/html," + escape(PAGECONTENT_SMALL); - let browserLoadedPromise = BrowserTestUtils.browserLoaded(newwin.gBrowser.selectedBrowser); - yield BrowserTestUtils.loadURI(newwin.gBrowser.selectedBrowser, pageUrl); - yield browserLoadedPromise; - - newwin.gBrowser.selectedBrowser.focus(); - - yield* performLargePopupTests(newwin); - - yield BrowserTestUtils.closeWindow(newwin); -}); - -// This test checks that a mousemove event is fired correctly at the menu and -// not at the browser, ensuring that any mouse capture has been cleared. -add_task(function* test_mousemove_correcttarget() { - const pageUrl = "data:text/html," + escape(PAGECONTENT_SMALL); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl); - - let selectPopup = document.getElementById("ContentSelectDropdown").menupopup; - - let popupShownPromise = BrowserTestUtils.waitForEvent(selectPopup, "popupshown"); - yield BrowserTestUtils.synthesizeMouseAtCenter("#one", { type: "mousedown" }, gBrowser.selectedBrowser); - yield popupShownPromise; - - yield new Promise(resolve => { - window.addEventListener("mousemove", function checkForMouseMove(event) { - window.removeEventListener("mousemove", checkForMouseMove, true); - is(event.target.localName.indexOf("menu"), 0, "mouse over menu"); - resolve(); - }, true); - - EventUtils.synthesizeMouseAtCenter(selectPopup.firstChild, { type: "mousemove" }); - }); - - yield BrowserTestUtils.synthesizeMouseAtCenter("#one", { type: "mouseup" }, gBrowser.selectedBrowser); - - yield hideSelectPopup(selectPopup); - - // The popup should be closed when fullscreen mode is entered or exited. - for (let steps = 0; steps < 2; steps++) { - yield openSelectPopup(selectPopup, true); - let popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden"); - let sizeModeChanged = BrowserTestUtils.waitForEvent(window, "sizemodechange"); - BrowserFullScreen(); - yield sizeModeChanged; - yield popupHiddenPromise; - } - - yield BrowserTestUtils.removeTab(tab); -}); - -// This test checks when a <select> element has some options with altered display values. -add_task(function* test_somehidden() { - const pageUrl = "data:text/html," + escape(PAGECONTENT_SOMEHIDDEN); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl); - - let selectPopup = document.getElementById("ContentSelectDropdown").menupopup; - - let popupShownPromise = BrowserTestUtils.waitForEvent(selectPopup, "popupshown"); - yield BrowserTestUtils.synthesizeMouseAtCenter("#one", { type: "mousedown" }, gBrowser.selectedBrowser); - yield popupShownPromise; - - // The exact number is not needed; just ensure the height is larger than 4 items to accomodate any popup borders. - ok(selectPopup.getBoundingClientRect().height >= selectPopup.lastChild.getBoundingClientRect().height * 4, "Height contains at least 4 items"); - ok(selectPopup.getBoundingClientRect().height < selectPopup.lastChild.getBoundingClientRect().height * 5, "Height doesn't contain 5 items"); - - // The label contains the substring 'Visible' for items that are visible. - // Otherwise, it is expected to be display: none. - is(selectPopup.parentNode.itemCount, 9, "Correct number of items"); - let child = selectPopup.firstChild; - let idx = 1; - while (child) { - is(getComputedStyle(child).display, child.label.indexOf("Visible") > 0 ? "-moz-box" : "none", - "Item " + (idx++) + " is visible"); - child = child.nextSibling; - } - - yield hideSelectPopup(selectPopup, "escape"); - yield BrowserTestUtils.removeTab(tab); -}); diff --git a/browser/base/content/test/general/browser_ssl_error_reports.js b/browser/base/content/test/general/browser_ssl_error_reports.js deleted file mode 100644 index b1b1c8b84..000000000 --- a/browser/base/content/test/general/browser_ssl_error_reports.js +++ /dev/null @@ -1,174 +0,0 @@ -"use strict"; - -const URL_REPORTS = "https://example.com/browser/browser/base/content/test/general/ssl_error_reports.sjs?"; -const URL_BAD_CHAIN = "https://badchain.include-subdomains.pinning.example.com/"; -const URL_NO_CERT = "https://fail-handshake.example.com/"; -const URL_BAD_CERT = "https://expired.example.com/"; -const URL_BAD_STS_CERT = "https://badchain.include-subdomains.pinning.example.com:443/"; -const ROOT = getRootDirectory(gTestPath); -const PREF_REPORT_ENABLED = "security.ssl.errorReporting.enabled"; -const PREF_REPORT_AUTOMATIC = "security.ssl.errorReporting.automatic"; -const PREF_REPORT_URL = "security.ssl.errorReporting.url"; - -SimpleTest.requestCompleteLog(); - -Services.prefs.setIntPref("security.cert_pinning.enforcement_level", 2); - -function cleanup() { - Services.prefs.clearUserPref(PREF_REPORT_ENABLED); - Services.prefs.clearUserPref(PREF_REPORT_AUTOMATIC); - Services.prefs.clearUserPref(PREF_REPORT_URL); -} - -registerCleanupFunction(() => { - Services.prefs.clearUserPref("security.cert_pinning.enforcement_level"); - cleanup(); -}); - -add_task(function* test_send_report_neterror() { - yield testSendReportAutomatically(URL_BAD_CHAIN, "succeed", "neterror"); - yield testSendReportAutomatically(URL_NO_CERT, "nocert", "neterror"); - yield testSetAutomatic(URL_NO_CERT, "nocert", "neterror"); -}); - - -add_task(function* test_send_report_certerror() { - yield testSendReportAutomatically(URL_BAD_CERT, "badcert", "certerror"); - yield testSetAutomatic(URL_BAD_CERT, "badcert", "certerror"); -}); - -add_task(function* test_send_disabled() { - Services.prefs.setBoolPref(PREF_REPORT_ENABLED, false); - Services.prefs.setBoolPref(PREF_REPORT_AUTOMATIC, true); - Services.prefs.setCharPref(PREF_REPORT_URL, "https://example.com/invalid"); - - // Check with enabled=false but automatic=true. - yield testSendReportDisabled(URL_NO_CERT, "neterror"); - yield testSendReportDisabled(URL_BAD_CERT, "certerror"); - - Services.prefs.setBoolPref(PREF_REPORT_AUTOMATIC, false); - - // Check again with both prefs false. - yield testSendReportDisabled(URL_NO_CERT, "neterror"); - yield testSendReportDisabled(URL_BAD_CERT, "certerror"); - cleanup(); -}); - -function* testSendReportAutomatically(testURL, suffix, errorURISuffix) { - Services.prefs.setBoolPref(PREF_REPORT_ENABLED, true); - Services.prefs.setBoolPref(PREF_REPORT_AUTOMATIC, true); - Services.prefs.setCharPref(PREF_REPORT_URL, URL_REPORTS + suffix); - - // Add a tab and wait until it's loaded. - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); - let browser = tab.linkedBrowser; - - // Load the page and wait for the error report submission. - let promiseStatus = createReportResponseStatusPromise(URL_REPORTS + suffix); - browser.loadURI(testURL); - yield promiseErrorPageLoaded(browser); - - ok(!isErrorStatus(yield promiseStatus), - "SSL error report submitted successfully"); - - // Check that we loaded the right error page. - yield checkErrorPage(browser, errorURISuffix); - - // Cleanup. - gBrowser.removeTab(tab); - cleanup(); -} - -function* testSetAutomatic(testURL, suffix, errorURISuffix) { - Services.prefs.setBoolPref(PREF_REPORT_ENABLED, true); - Services.prefs.setBoolPref(PREF_REPORT_AUTOMATIC, false); - Services.prefs.setCharPref(PREF_REPORT_URL, URL_REPORTS + suffix); - - // Add a tab and wait until it's loaded. - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); - let browser = tab.linkedBrowser; - - // Load the page. - browser.loadURI(testURL); - yield promiseErrorPageLoaded(browser); - - // Check that we loaded the right error page. - yield checkErrorPage(browser, errorURISuffix); - - let statusPromise = createReportResponseStatusPromise(URL_REPORTS + suffix); - - // Click the checkbox, enable automatic error reports. - yield ContentTask.spawn(browser, null, function* () { - content.document.getElementById("automaticallyReportInFuture").click(); - }); - - // Wait for the error report submission. - yield statusPromise; - - let isAutomaticReportingEnabled = () => - Services.prefs.getBoolPref(PREF_REPORT_AUTOMATIC); - - // Check that the pref was flipped. - ok(isAutomaticReportingEnabled(), "automatic SSL report submission enabled"); - - // Disable automatic error reports. - yield ContentTask.spawn(browser, null, function* () { - content.document.getElementById("automaticallyReportInFuture").click(); - }); - - // Check that the pref was flipped. - ok(!isAutomaticReportingEnabled(), "automatic SSL report submission disabled"); - - // Cleanup. - gBrowser.removeTab(tab); - cleanup(); -} - -function* testSendReportDisabled(testURL, errorURISuffix) { - // Add a tab and wait until it's loaded. - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); - let browser = tab.linkedBrowser; - - // Load the page. - browser.loadURI(testURL); - yield promiseErrorPageLoaded(browser); - - // Check that we loaded the right error page. - yield checkErrorPage(browser, errorURISuffix); - - // Check that the error reporting section is hidden. - yield ContentTask.spawn(browser, null, function* () { - let section = content.document.getElementById("certificateErrorReporting"); - Assert.equal(content.getComputedStyle(section).display, "none", - "error reporting section should be hidden"); - }); - - // Cleanup. - gBrowser.removeTab(tab); -} - -function isErrorStatus(status) { - return status < 200 || status >= 300; -} - -// use the observer service to see when a report is sent -function createReportResponseStatusPromise(expectedURI) { - return new Promise(resolve => { - let observer = (subject, topic, data) => { - subject.QueryInterface(Ci.nsIHttpChannel); - let requestURI = subject.URI.spec; - if (requestURI == expectedURI) { - Services.obs.removeObserver(observer, "http-on-examine-response"); - resolve(subject.responseStatus); - } - }; - Services.obs.addObserver(observer, "http-on-examine-response", false); - }); -} - -function checkErrorPage(browser, suffix) { - return ContentTask.spawn(browser, { suffix }, function* (args) { - let uri = content.document.documentURI; - Assert.ok(uri.startsWith(`about:${args.suffix}`), "correct error page loaded"); - }); -} diff --git a/browser/base/content/test/general/browser_star_hsts.js b/browser/base/content/test/general/browser_star_hsts.js deleted file mode 100644 index c52e563bc..000000000 --- a/browser/base/content/test/general/browser_star_hsts.js +++ /dev/null @@ -1,85 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -var secureURL = "https://example.com/browser/browser/base/content/test/general/browser_star_hsts.sjs"; -var unsecureURL = "http://example.com/browser/browser/base/content/test/general/browser_star_hsts.sjs"; - -add_task(function* test_star_redirect() { - registerCleanupFunction(function() { - // Ensure to remove example.com from the HSTS list. - let sss = Cc["@mozilla.org/ssservice;1"] - .getService(Ci.nsISiteSecurityService); - sss.removeState(Ci.nsISiteSecurityService.HEADER_HSTS, - NetUtil.newURI("http://example.com/"), 0); - PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId); - gBrowser.removeCurrentTab(); - }); - - let tab = gBrowser.selectedTab = gBrowser.addTab(); - // This will add the page to the HSTS cache. - yield promiseTabLoadEvent(tab, secureURL, secureURL); - // This should transparently be redirected to the secure page. - yield promiseTabLoadEvent(tab, unsecureURL, secureURL); - - yield promiseStarState(BookmarkingUI.STATUS_UNSTARRED); - - let promiseBookmark = promiseOnBookmarkItemAdded(gBrowser.currentURI); - BookmarkingUI.star.click(); - // This resolves on the next tick, so the star should have already been - // updated at that point. - yield promiseBookmark; - - is(BookmarkingUI.status, BookmarkingUI.STATUS_STARRED, "The star is starred"); -}); - -/** - * Waits for the star to reflect the expected state. - */ -function promiseStarState(aValue) { - let deferred = Promise.defer(); - let expectedStatus = aValue ? BookmarkingUI.STATUS_STARRED - : BookmarkingUI.STATUS_UNSTARRED; - (function checkState() { - if (BookmarkingUI.status == BookmarkingUI.STATUS_UPDATING || - BookmarkingUI.status != expectedStatus) { - info("Waiting for star button change."); - setTimeout(checkState, 1000); - } else { - deferred.resolve(); - } - })(); - return deferred.promise; -} - -/** - * Starts a load in an existing tab and waits for it to finish (via some event). - * - * @param aTab - * The tab to load into. - * @param aUrl - * The url to load. - * @param [optional] aFinalURL - * The url to wait for, same as aURL if not defined. - * @return {Promise} resolved when the event is handled. - */ -function promiseTabLoadEvent(aTab, aURL, aFinalURL) -{ - if (!aFinalURL) - aFinalURL = aURL; - let deferred = Promise.defer(); - info("Wait for load tab event"); - aTab.linkedBrowser.addEventListener("load", function load(event) { - if (event.originalTarget != aTab.linkedBrowser.contentDocument || - event.target.location.href == "about:blank" || - event.target.location.href != aFinalURL) { - info("skipping spurious load event"); - return; - } - aTab.linkedBrowser.removeEventListener("load", load, true); - info("Tab load event received"); - deferred.resolve(); - }, true, true); - aTab.linkedBrowser.loadURI(aURL); - return deferred.promise; -} diff --git a/browser/base/content/test/general/browser_star_hsts.sjs b/browser/base/content/test/general/browser_star_hsts.sjs deleted file mode 100644 index 10c7aae12..000000000 --- a/browser/base/content/test/general/browser_star_hsts.sjs +++ /dev/null @@ -1,13 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function handleRequest(request, response) -{ - let page = "<!DOCTYPE html><html><body><p>HSTS page</p></body></html>"; - response.setStatusLine(request.httpVersion, "200", "OK"); - response.setHeader("Strict-Transport-Security", "max-age=60"); - response.setHeader("Content-Type", "text/html", false); - response.setHeader("Content-Length", page.length + "", false); - response.write(page); -} diff --git a/browser/base/content/test/general/browser_subframe_favicons_not_used.js b/browser/base/content/test/general/browser_subframe_favicons_not_used.js deleted file mode 100644 index 7efe78d9b..000000000 --- a/browser/base/content/test/general/browser_subframe_favicons_not_used.js +++ /dev/null @@ -1,20 +0,0 @@ -/* Make sure <link rel="..."> isn't respected in sub-frames. */ - -function test() { - waitForExplicitFinish(); - - let testPath = getRootDirectory(gTestPath); - - let tab = gBrowser.addTab(testPath + "file_bug970276_popup1.html"); - - tab.linkedBrowser.addEventListener("load", function() { - tab.linkedBrowser.removeEventListener("load", arguments.callee, true); - - let expectedIcon = testPath + "file_bug970276_favicon1.ico"; - is(gBrowser.getIcon(tab), expectedIcon, "Correct icon."); - - gBrowser.removeTab(tab); - - finish(); - }, true); -} diff --git a/browser/base/content/test/general/browser_syncui.js b/browser/base/content/test/general/browser_syncui.js deleted file mode 100644 index daf0fa497..000000000 --- a/browser/base/content/test/general/browser_syncui.js +++ /dev/null @@ -1,205 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -var {Log} = Cu.import("resource://gre/modules/Log.jsm", {}); -var {Weave} = Cu.import("resource://services-sync/main.js", {}); - -var stringBundle = Cc["@mozilla.org/intl/stringbundle;1"] - .getService(Ci.nsIStringBundleService) - .createBundle("chrome://weave/locale/services/sync.properties"); - -// ensure test output sees log messages. -Log.repository.getLogger("browserwindow.syncui").addAppender(new Log.DumpAppender()); - -// Send the specified sync-related notification and return a promise that -// resolves once gSyncUI._promiseUpateUI is complete and the UI is ready to check. -function notifyAndPromiseUIUpdated(topic) { - return new Promise(resolve => { - // Instrument gSyncUI so we know when the update is complete. - let oldPromiseUpdateUI = gSyncUI._promiseUpdateUI.bind(gSyncUI); - gSyncUI._promiseUpdateUI = function() { - return oldPromiseUpdateUI().then(() => { - // Restore our override. - gSyncUI._promiseUpdateUI = oldPromiseUpdateUI; - // Resolve the promise so the caller knows the update is done. - resolve(); - }); - }; - // Now send the notification. - Services.obs.notifyObservers(null, topic, null); - }); -} - -// Sync manages 3 broadcasters so the menus correctly reflect the Sync state. -// Only one of these 3 should ever be visible - pass the ID of the broadcaster -// you expect to be visible and it will check it's the only one that is. -function checkBroadcasterVisible(broadcasterId) { - let all = ["sync-reauth-state", "sync-setup-state", "sync-syncnow-state"]; - Assert.ok(all.indexOf(broadcasterId) >= 0, "valid id"); - for (let check of all) { - let eltHidden = document.getElementById(check).hidden; - Assert.equal(eltHidden, check == broadcasterId ? false : true, check); - } -} - -function promiseObserver(topic) { - return new Promise(resolve => { - let obs = (aSubject, aTopic, aData) => { - Services.obs.removeObserver(obs, aTopic); - resolve(aSubject); - } - Services.obs.addObserver(obs, topic, false); - }); -} - -function checkButtonTooltips(stringPrefix) { - for (let butId of ["PanelUI-remotetabs-syncnow", "PanelUI-fxa-icon"]) { - let text = document.getElementById(butId).getAttribute("tooltiptext"); - let desc = `Text is "${text}", expecting it to start with "${stringPrefix}"` - Assert.ok(text.startsWith(stringPrefix), desc); - } -} - -add_task(function* prepare() { - // add the Sync button to the toolbar so we can get it! - CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_NAVBAR); - registerCleanupFunction(() => { - CustomizableUI.removeWidgetFromArea("sync-button"); - }); - - let xps = Components.classes["@mozilla.org/weave/service;1"] - .getService(Components.interfaces.nsISupports) - .wrappedJSObject; - yield xps.whenLoaded(); - // Put Sync and the UI into a known state. - Weave.Status.login = Weave.LOGIN_FAILED_NO_USERNAME; - yield notifyAndPromiseUIUpdated("weave:service:login:error"); - - checkBroadcasterVisible("sync-setup-state"); - checkButtonTooltips("Sign In To Sync"); - // mock out the "_needsSetup()" function so we don't short-circuit. - let oldNeedsSetup = window.gSyncUI._needsSetup; - window.gSyncUI._needsSetup = () => Promise.resolve(false); - registerCleanupFunction(() => { - window.gSyncUI._needsSetup = oldNeedsSetup; - // and an observer to set the state back to what it should be now we've - // restored the stub. - Services.obs.notifyObservers(null, "weave:service:login:finish", null); - }); - // and a notification to have the state change away from "needs setup" - yield notifyAndPromiseUIUpdated("weave:service:login:finish"); - checkBroadcasterVisible("sync-syncnow-state"); - // open the sync-button panel so we can check elements in that. - document.getElementById("sync-button").click(); -}); - -add_task(function* testSyncNeedsVerification() { - // mock out the "_needsVerification()" function - let oldNeedsVerification = window.gSyncUI._needsVerification; - window.gSyncUI._needsVerification = () => true; - try { - // a notification for the state change - yield notifyAndPromiseUIUpdated("weave:service:login:finish"); - checkButtonTooltips("Verify"); - } finally { - window.gSyncUI._needsVerification = oldNeedsVerification; - } -}); - - -add_task(function* testSyncLoginError() { - checkBroadcasterVisible("sync-syncnow-state"); - - // Pretend we are in a "login failed" error state - Weave.Status.sync = Weave.LOGIN_FAILED; - Weave.Status.login = Weave.LOGIN_FAILED_LOGIN_REJECTED; - yield notifyAndPromiseUIUpdated("weave:ui:sync:error"); - - // But the menu *should* reflect the login error. - checkBroadcasterVisible("sync-reauth-state"); - // The tooltips for the buttons should also reflect it. - checkButtonTooltips("Reconnect"); - - // Now pretend we just had a successful login - the error notification should go away. - Weave.Status.sync = Weave.STATUS_OK; - Weave.Status.login = Weave.LOGIN_SUCCEEDED; - yield notifyAndPromiseUIUpdated("weave:service:login:start"); - yield notifyAndPromiseUIUpdated("weave:service:login:finish"); - // The menus should be back to "all good" - checkBroadcasterVisible("sync-syncnow-state"); -}); - -function checkButtonsStatus(shouldBeActive) { - for (let eid of [ - "sync-status", // the broadcaster itself. - "sync-button", // the main sync button which observes the broadcaster - "PanelUI-fxa-icon", // the sync icon in the fxa footer that observes it. - ]) { - let elt = document.getElementById(eid); - if (shouldBeActive) { - Assert.equal(elt.getAttribute("syncstatus"), "active", `${eid} should be active`); - } else { - Assert.ok(!elt.hasAttribute("syncstatus"), `${eid} should have no status attr`); - } - } -} - -function* testButtonActions(startNotification, endNotification, expectActive = true) { - checkButtonsStatus(false); - // pretend a sync is starting. - yield notifyAndPromiseUIUpdated(startNotification); - checkButtonsStatus(expectActive); - // and has stopped - yield notifyAndPromiseUIUpdated(endNotification); - checkButtonsStatus(false); -} - -function *doTestButtonActivities() { - // logins do not "activate" the spinner/button as they may block and make - // the UI look like Sync is never completing. - yield testButtonActions("weave:service:login:start", "weave:service:login:finish", false); - yield testButtonActions("weave:service:login:start", "weave:service:login:error", false); - - // But notifications for Sync itself should activate it. - yield testButtonActions("weave:service:sync:start", "weave:service:sync:finish"); - yield testButtonActions("weave:service:sync:start", "weave:service:sync:error"); - - // and ensure the counters correctly handle multiple in-flight syncs - yield notifyAndPromiseUIUpdated("weave:service:sync:start"); - checkButtonsStatus(true); - // sync stops. - yield notifyAndPromiseUIUpdated("weave:service:sync:finish"); - // Button should not be active. - checkButtonsStatus(false); -} - -add_task(function* testButtonActivitiesInNavBar() { - // check the button's functionality while the button is in the NavBar - which - // it already is. - yield doTestButtonActivities(); -}); - -add_task(function* testFormatLastSyncDateNow() { - let now = new Date(); - let nowString = gSyncUI.formatLastSyncDate(now); - Assert.equal(nowString, "Last sync: " + now.toLocaleDateString(undefined, {weekday: 'long', hour: 'numeric', minute: 'numeric'})); -}); - -add_task(function* testFormatLastSyncDateMonthAgo() { - let monthAgo = new Date(); - monthAgo.setMonth(monthAgo.getMonth() - 1); - let monthAgoString = gSyncUI.formatLastSyncDate(monthAgo); - Assert.equal(monthAgoString, "Last sync: " + monthAgo.toLocaleDateString(undefined, {month: 'long', day: 'numeric'})); -}); - -add_task(function* testButtonActivitiesInPanel() { - // check the button's functionality while the button is in the panel - it's - // currently in the NavBar - move it to the panel and open it. - CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_PANEL); - yield PanelUI.show(); - try { - yield doTestButtonActivities(); - } finally { - PanelUI.hide(); - } -}); diff --git a/browser/base/content/test/general/browser_tabDrop.js b/browser/base/content/test/general/browser_tabDrop.js deleted file mode 100644 index fd743e6dc..000000000 --- a/browser/base/content/test/general/browser_tabDrop.js +++ /dev/null @@ -1,103 +0,0 @@ -registerCleanupFunction(function* cleanup() { - while (gBrowser.tabs.length > 1) { - yield BrowserTestUtils.removeTab(gBrowser.tabs[gBrowser.tabs.length - 1]); - } - Services.search.currentEngine = originalEngine; - let engine = Services.search.getEngineByName("MozSearch"); - Services.search.removeEngine(engine); -}); - -let originalEngine; -add_task(function* test_setup() { - // Stop search-engine loads from hitting the network - Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET", - "http://example.com/?q={searchTerms}"); - let engine = Services.search.getEngineByName("MozSearch"); - originalEngine = Services.search.currentEngine; - Services.search.currentEngine = engine; -}); - -add_task(function*() { yield dropText("mochi.test/first", 1); }); -add_task(function*() { yield dropText("javascript:'bad'"); }); -add_task(function*() { yield dropText("jAvascript:'bad'"); }); -add_task(function*() { yield dropText("search this", 1); }); -add_task(function*() { yield dropText("mochi.test/second", 1); }); -add_task(function*() { yield dropText("data:text/html,bad"); }); -add_task(function*() { yield dropText("mochi.test/third", 1); }); - -// Single text/plain item, with multiple links. -add_task(function*() { yield dropText("mochi.test/1\nmochi.test/2", 2); }); -add_task(function*() { yield dropText("javascript:'bad1'\nmochi.test/3", 0); }); -add_task(function*() { yield dropText("mochi.test/4\ndata:text/html,bad1", 0); }); - -// Multiple text/plain items, with single and multiple links. -add_task(function*() { - yield drop([[{type: "text/plain", - data: "mochi.test/5"}], - [{type: "text/plain", - data: "mochi.test/6\nmochi.test/7"}]], 3); -}); - -// Single text/x-moz-url item, with multiple links. -// "text/x-moz-url" has titles in even-numbered lines. -add_task(function*() { - yield drop([[{type: "text/x-moz-url", - data: "mochi.test/8\nTITLE8\nmochi.test/9\nTITLE9"}]], 2); -}); - -// Single item with multiple types. -add_task(function*() { - yield drop([[{type: "text/plain", - data: "mochi.test/10"}, - {type: "text/x-moz-url", - data: "mochi.test/11\nTITLE11"}]], 1); -}); - -function dropText(text, expectedTabOpenCount=0) { - return drop([[{type: "text/plain", data: text}]], expectedTabOpenCount); -} - -function* drop(dragData, expectedTabOpenCount=0) { - let dragDataString = JSON.stringify(dragData); - info(`Starting test for datagData:${dragDataString}; expectedTabOpenCount:${expectedTabOpenCount}`); - let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let EventUtils = {}; - scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils); - - let awaitDrop = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "drop"); - let actualTabOpenCount = 0; - let openedTabs = []; - let checkCount = function(event) { - openedTabs.push(event.target); - actualTabOpenCount++; - return actualTabOpenCount == expectedTabOpenCount; - }; - let awaitTabOpen = expectedTabOpenCount && BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen", false, checkCount); - // A drop type of "link" onto an existing tab would normally trigger a - // load in that same tab, but tabbrowser code in _getDragTargetTab treats - // drops on the outer edges of a tab differently (loading a new tab - // instead). Make events created by synthesizeDrop have all of their - // coordinates set to 0 (screenX/screenY), so they're treated as drops - // on the outer edge of the tab, thus they open new tabs. - var event = { - clientX: 0, - clientY: 0, - screenX: 0, - screenY: 0, - }; - EventUtils.synthesizeDrop(gBrowser.selectedTab, gBrowser.selectedTab, dragData, "link", window, undefined, event); - let tabsOpened = false; - if (awaitTabOpen) { - yield awaitTabOpen; - info("Got TabOpen event"); - tabsOpened = true; - for (let tab of openedTabs) { - yield BrowserTestUtils.removeTab(tab); - } - } - is(tabsOpened, !!expectedTabOpenCount, `Tabs for ${dragDataString} should only open if any of dropped items are valid`); - - yield awaitDrop; - ok(true, "Got drop event"); -} diff --git a/browser/base/content/test/general/browser_tabReorder.js b/browser/base/content/test/general/browser_tabReorder.js deleted file mode 100644 index 9e0503e95..000000000 --- a/browser/base/content/test/general/browser_tabReorder.js +++ /dev/null @@ -1,49 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - let initialTabsLength = gBrowser.tabs.length; - - let newTab1 = gBrowser.selectedTab = gBrowser.addTab("about:robots", {skipAnimation: true}); - let newTab2 = gBrowser.selectedTab = gBrowser.addTab("about:about", {skipAnimation: true}); - let newTab3 = gBrowser.selectedTab = gBrowser.addTab("about:config", {skipAnimation: true}); - registerCleanupFunction(function () { - while (gBrowser.tabs.length > initialTabsLength) { - gBrowser.removeTab(gBrowser.tabs[initialTabsLength]); - } - }); - - is(gBrowser.tabs.length, initialTabsLength + 3, "new tabs are opened"); - is(gBrowser.tabs[initialTabsLength], newTab1, "newTab1 position is correct"); - is(gBrowser.tabs[initialTabsLength + 1], newTab2, "newTab2 position is correct"); - is(gBrowser.tabs[initialTabsLength + 2], newTab3, "newTab3 position is correct"); - - let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let EventUtils = {}; - scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils); - - function dragAndDrop(tab1, tab2, copy) { - let rect = tab2.getBoundingClientRect(); - let event = { - ctrlKey: copy, - altKey: copy, - clientX: rect.left + rect.width / 2 + 10, - clientY: rect.top + rect.height / 2, - }; - - EventUtils.synthesizeDrop(tab1, tab2, null, copy ? "copy" : "move", window, window, event); - } - - dragAndDrop(newTab1, newTab2, false); - is(gBrowser.tabs.length, initialTabsLength + 3, "tabs are still there"); - is(gBrowser.tabs[initialTabsLength], newTab2, "newTab2 and newTab1 are swapped"); - is(gBrowser.tabs[initialTabsLength + 1], newTab1, "newTab1 and newTab2 are swapped"); - is(gBrowser.tabs[initialTabsLength + 2], newTab3, "newTab3 stays same place"); - - dragAndDrop(newTab2, newTab1, true); - is(gBrowser.tabs.length, initialTabsLength + 4, "a tab is duplicated"); - is(gBrowser.tabs[initialTabsLength], newTab2, "newTab2 stays same place"); - is(gBrowser.tabs[initialTabsLength + 1], newTab1, "newTab1 stays same place"); - is(gBrowser.tabs[initialTabsLength + 3], newTab3, "a new tab is inserted before newTab3"); -} diff --git a/browser/base/content/test/general/browser_tab_close_dependent_window.js b/browser/base/content/test/general/browser_tab_close_dependent_window.js deleted file mode 100644 index ab8a960ac..000000000 --- a/browser/base/content/test/general/browser_tab_close_dependent_window.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -add_task(function* closing_tab_with_dependents_should_close_window() { - info("Opening window"); - let win = yield BrowserTestUtils.openNewBrowserWindow(); - - info("Opening tab with data URI"); - let tab = yield BrowserTestUtils.openNewForegroundTab(win.gBrowser, `data:text/html,<html%20onclick="W=window.open()"><body%20onbeforeunload="W.close()">`); - info("Closing original tab in this window."); - yield BrowserTestUtils.removeTab(win.gBrowser.tabs[0]); - info("Clicking into the window"); - let depTabOpened = BrowserTestUtils.waitForEvent(win.gBrowser.tabContainer, "TabOpen"); - yield BrowserTestUtils.synthesizeMouse("html", 0, 0, {}, tab.linkedBrowser); - - let openedTab = (yield depTabOpened).target; - info("Got opened tab"); - - let windowClosedPromise = BrowserTestUtils.windowClosed(win); - yield BrowserTestUtils.removeTab(tab); - is(Cu.isDeadWrapper(openedTab) || openedTab.linkedBrowser == null, true, "Opened tab should also have closed"); - info("If we timeout now, the window failed to close - that shouldn't happen!"); - yield windowClosedPromise; -}); - diff --git a/browser/base/content/test/general/browser_tab_detach_restore.js b/browser/base/content/test/general/browser_tab_detach_restore.js deleted file mode 100644 index d482edc26..000000000 --- a/browser/base/content/test/general/browser_tab_detach_restore.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; - -const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); - -add_task(function*() { - let uri = "http://example.com/browser/browser/base/content/test/general/dummy_page.html"; - - // Clear out the closed windows set to start - while (SessionStore.getClosedWindowCount() > 0) - SessionStore.forgetClosedWindow(0); - - let tab = gBrowser.addTab(); - tab.linkedBrowser.loadURI(uri); - yield BrowserTestUtils.browserLoaded(tab.linkedBrowser); - yield TabStateFlusher.flush(tab.linkedBrowser); - - let key = tab.linkedBrowser.permanentKey; - let win = gBrowser.replaceTabWithWindow(tab); - yield new Promise(resolve => whenDelayedStartupFinished(win, resolve)); - - is(win.gBrowser.selectedBrowser.permanentKey, key, "Should have properly copied the permanentKey"); - yield BrowserTestUtils.closeWindow(win); - - is(SessionStore.getClosedWindowCount(), 1, "Should have restore data for the closed window"); - - win = SessionStore.undoCloseWindow(0); - yield BrowserTestUtils.waitForEvent(win, "load"); - yield BrowserTestUtils.waitForEvent(win.gBrowser.tabs[0], "SSTabRestored"); - - is(win.gBrowser.tabs.length, 1, "Should have restored one tab"); - is(win.gBrowser.selectedBrowser.currentURI.spec, uri, "Should have restored the right page"); - - yield promiseWindowClosed(win); -}); diff --git a/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js b/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js deleted file mode 100644 index a8fc34083..000000000 --- a/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js +++ /dev/null @@ -1,216 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -requestLongerTimeout(2); - -const EVENTUTILS_URL = "chrome://mochikit/content/tests/SimpleTest/EventUtils.js"; -var EventUtils = {}; - -Services.scriptloader.loadSubScript(EVENTUTILS_URL, EventUtils); - -/** - * Tests that tabs from Private Browsing windows cannot be dragged - * into non-private windows, and vice-versa. - */ -add_task(function* test_dragging_private_windows() { - let normalWin = yield BrowserTestUtils.openNewBrowserWindow(); - let privateWin = - yield BrowserTestUtils.openNewBrowserWindow({private: true}); - - let normalTab = - yield BrowserTestUtils.openNewForegroundTab(normalWin.gBrowser); - let privateTab = - yield BrowserTestUtils.openNewForegroundTab(privateWin.gBrowser); - - let effect = EventUtils.synthesizeDrop(normalTab, privateTab, - [[{type: TAB_DROP_TYPE, data: normalTab}]], - null, normalWin, privateWin); - is(effect, "none", "Should not be able to drag a normal tab to a private window"); - - effect = EventUtils.synthesizeDrop(privateTab, normalTab, - [[{type: TAB_DROP_TYPE, data: privateTab}]], - null, privateWin, normalWin); - is(effect, "none", "Should not be able to drag a private tab to a normal window"); - - normalWin.gBrowser.swapBrowsersAndCloseOther(normalTab, privateTab); - is(normalWin.gBrowser.tabs.length, 2, - "Prevent moving a normal tab to a private tabbrowser"); - is(privateWin.gBrowser.tabs.length, 2, - "Prevent accepting a normal tab in a private tabbrowser"); - - privateWin.gBrowser.swapBrowsersAndCloseOther(privateTab, normalTab); - is(privateWin.gBrowser.tabs.length, 2, - "Prevent moving a private tab to a normal tabbrowser"); - is(normalWin.gBrowser.tabs.length, 2, - "Prevent accepting a private tab in a normal tabbrowser"); - - yield BrowserTestUtils.closeWindow(normalWin); - yield BrowserTestUtils.closeWindow(privateWin); -}); - -/** - * Tests that tabs from e10s windows cannot be dragged into non-e10s - * windows, and vice-versa. - */ -add_task(function* test_dragging_e10s_windows() { - if (!gMultiProcessBrowser) { - return; - } - - let remoteWin = yield BrowserTestUtils.openNewBrowserWindow({remote: true}); - let nonRemoteWin = yield BrowserTestUtils.openNewBrowserWindow({remote: false}); - - let remoteTab = - yield BrowserTestUtils.openNewForegroundTab(remoteWin.gBrowser); - let nonRemoteTab = - yield BrowserTestUtils.openNewForegroundTab(nonRemoteWin.gBrowser); - - let effect = EventUtils.synthesizeDrop(remoteTab, nonRemoteTab, - [[{type: TAB_DROP_TYPE, data: remoteTab}]], - null, remoteWin, nonRemoteWin); - is(effect, "none", "Should not be able to drag a remote tab to a non-e10s window"); - - effect = EventUtils.synthesizeDrop(nonRemoteTab, remoteTab, - [[{type: TAB_DROP_TYPE, data: nonRemoteTab}]], - null, nonRemoteWin, remoteWin); - is(effect, "none", "Should not be able to drag a non-remote tab to an e10s window"); - - remoteWin.gBrowser.swapBrowsersAndCloseOther(remoteTab, nonRemoteTab); - is(remoteWin.gBrowser.tabs.length, 2, - "Prevent moving a normal tab to a private tabbrowser"); - is(nonRemoteWin.gBrowser.tabs.length, 2, - "Prevent accepting a normal tab in a private tabbrowser"); - - nonRemoteWin.gBrowser.swapBrowsersAndCloseOther(nonRemoteTab, remoteTab); - is(nonRemoteWin.gBrowser.tabs.length, 2, - "Prevent moving a private tab to a normal tabbrowser"); - is(remoteWin.gBrowser.tabs.length, 2, - "Prevent accepting a private tab in a normal tabbrowser"); - - yield BrowserTestUtils.closeWindow(remoteWin); - yield BrowserTestUtils.closeWindow(nonRemoteWin); -}); - -/** - * Tests that remoteness-blacklisted tabs from e10s windows can - * be dragged between e10s windows. - */ -add_task(function* test_dragging_blacklisted() { - if (!gMultiProcessBrowser) { - return; - } - - let remoteWin1 = yield BrowserTestUtils.openNewBrowserWindow({remote: true}); - remoteWin1.gBrowser.myID = "remoteWin1"; - let remoteWin2 = yield BrowserTestUtils.openNewBrowserWindow({remote: true}); - remoteWin2.gBrowser.myID = "remoteWin2"; - - // Anything under chrome://mochitests/content/ will be blacklisted, and - // open in the parent process. - const BLACKLISTED_URL = getRootDirectory(gTestPath) + - "browser_tab_drag_drop_perwindow.js"; - let blacklistedTab = - yield BrowserTestUtils.openNewForegroundTab(remoteWin1.gBrowser, - BLACKLISTED_URL); - - ok(blacklistedTab.linkedBrowser, "Newly created tab should have a browser."); - - ok(!blacklistedTab.linkedBrowser.isRemoteBrowser, - `Expected a non-remote browser for URL: ${BLACKLISTED_URL}`); - - let otherTab = - yield BrowserTestUtils.openNewForegroundTab(remoteWin2.gBrowser); - - let effect = EventUtils.synthesizeDrop(blacklistedTab, otherTab, - [[{type: TAB_DROP_TYPE, data: blacklistedTab}]], - null, remoteWin1, remoteWin2); - is(effect, "move", "Should be able to drag the blacklisted tab."); - - // The synthesized drop should also do the work of swapping the - // browsers, so no need to call swapBrowsersAndCloseOther manually. - - is(remoteWin1.gBrowser.tabs.length, 1, - "Should have moved the blacklisted tab out of this window."); - is(remoteWin2.gBrowser.tabs.length, 3, - "Should have inserted the blacklisted tab into the other window."); - - // The currently selected tab in the second window should be the - // one we just dragged in. - let draggedBrowser = remoteWin2.gBrowser.selectedBrowser; - ok(!draggedBrowser.isRemoteBrowser, - "The browser we just dragged in should not be remote."); - - is(draggedBrowser.currentURI.spec, BLACKLISTED_URL, - `Expected the URL of the dragged in tab to be ${BLACKLISTED_URL}`); - - yield BrowserTestUtils.closeWindow(remoteWin1); - yield BrowserTestUtils.closeWindow(remoteWin2); -}); - - -/** - * Tests that tabs dragged between windows dispatch TabOpen and TabClose - * events with the appropriate adoption details. - */ -add_task(function* test_dragging_adoption_events() { - let win1 = yield BrowserTestUtils.openNewBrowserWindow(); - let win2 = yield BrowserTestUtils.openNewBrowserWindow(); - - let tab1 = yield BrowserTestUtils.openNewForegroundTab(win1.gBrowser); - let tab2 = yield BrowserTestUtils.openNewForegroundTab(win2.gBrowser); - - let awaitCloseEvent = BrowserTestUtils.waitForEvent(tab1, "TabClose"); - let awaitOpenEvent = BrowserTestUtils.waitForEvent(win2, "TabOpen"); - - let effect = EventUtils.synthesizeDrop(tab1, tab2, - [[{type: TAB_DROP_TYPE, data: tab1}]], - null, win1, win2); - is(effect, "move", "Tab should be moved from win1 to win2."); - - let closeEvent = yield awaitCloseEvent; - let openEvent = yield awaitOpenEvent; - - is(openEvent.detail.adoptedTab, tab1, "New tab adopted old tab"); - is(closeEvent.detail.adoptedBy, openEvent.target, "Old tab adopted by new tab"); - - yield BrowserTestUtils.closeWindow(win1); - yield BrowserTestUtils.closeWindow(win2); -}); - - -/** - * Tests that per-site zoom settings remain active after a tab is - * dragged between windows. - */ -add_task(function* test_dragging_zoom_handling() { - const ZOOM_FACTOR = 1.62; - - let win1 = yield BrowserTestUtils.openNewBrowserWindow(); - let win2 = yield BrowserTestUtils.openNewBrowserWindow(); - - let tab1 = yield BrowserTestUtils.openNewForegroundTab(win1.gBrowser); - let tab2 = yield BrowserTestUtils.openNewForegroundTab(win2.gBrowser, - "http://example.com/"); - - win2.FullZoom.setZoom(ZOOM_FACTOR); - FullZoomHelper.zoomTest(tab2, ZOOM_FACTOR, - "Original tab should have correct zoom factor"); - - let effect = EventUtils.synthesizeDrop(tab2, tab1, - [[{type: TAB_DROP_TYPE, data: tab2}]], - null, win2, win1); - is(effect, "move", "Tab should be moved from win2 to win1."); - - // Delay slightly to make sure we've finished executing any promise - // chains in the zoom code. - yield new Promise(resolve => setTimeout(resolve, 0)); - - FullZoomHelper.zoomTest(win1.gBrowser.selectedTab, ZOOM_FACTOR, - "Dragged tab should have correct zoom factor"); - - win1.FullZoom.reset(); - - yield BrowserTestUtils.closeWindow(win1); - yield BrowserTestUtils.closeWindow(win2); -}); diff --git a/browser/base/content/test/general/browser_tab_dragdrop.js b/browser/base/content/test/general/browser_tab_dragdrop.js deleted file mode 100644 index cfe996e1e..000000000 --- a/browser/base/content/test/general/browser_tab_dragdrop.js +++ /dev/null @@ -1,186 +0,0 @@ -function swapTabsAndCloseOther(a, b) { - gBrowser.swapBrowsersAndCloseOther(gBrowser.tabs[b], gBrowser.tabs[a]); -} - -var getClicks = function(tab) { - return ContentTask.spawn(tab.linkedBrowser, {}, function() { - return content.wrappedJSObject.clicks; - }); -} - -var clickTest = Task.async(function*(tab) { - let clicks = yield getClicks(tab); - - yield ContentTask.spawn(tab.linkedBrowser, {}, function() { - let target = content.document.body; - let rect = target.getBoundingClientRect(); - let left = (rect.left + rect.right) / 2; - let top = (rect.top + rect.bottom) / 2; - - let utils = content.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindowUtils); - utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0); - utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0); - }); - - let newClicks = yield getClicks(tab); - is(newClicks, clicks + 1, "adding 1 more click on BODY"); -}); - -function loadURI(tab, url) { - tab.linkedBrowser.loadURI(url); - return BrowserTestUtils.browserLoaded(tab.linkedBrowser); -} - -// Creates a framescript which caches the current object value from the plugin -// in the page. checkObjectValue below verifies that the framescript is still -// active for the browser and that the cached value matches that from the plugin -// in the page which tells us the plugin hasn't been reinitialized. -function* cacheObjectValue(browser) { - yield ContentTask.spawn(browser, null, function*() { - let plugin = content.document.wrappedJSObject.body.firstChild; - info(`plugin is ${plugin}`); - let win = content.document.defaultView; - info(`win is ${win}`); - win.objectValue = plugin.getObjectValue(); - info(`got objectValue: ${win.objectValue}`); - win.checkObjectValueListener = () => { - let result; - let exception; - try { - result = plugin.checkObjectValue(win.objectValue); - } catch (e) { - exception = e.toString(); - } - info(`sending plugin.checkObjectValue(objectValue): ${result}`); - sendAsyncMessage("Test:CheckObjectValueResult", { - result, - exception - }); - }; - - addMessageListener("Test:CheckObjectValue", win.checkObjectValueListener); - }); -} - -// Note, can't run this via registerCleanupFunction because it needs the -// browser to still be alive and have a messageManager. -function* cleanupObjectValue(browser) { - info("entered cleanupObjectValue") - yield ContentTask.spawn(browser, null, function*() { - info("in cleanup function"); - let win = content.document.defaultView; - info(`about to delete objectValue: ${win.objectValue}`); - delete win.objectValue; - removeMessageListener("Test:CheckObjectValue", win.checkObjectValueListener); - info(`about to delete checkObjectValueListener: ${win.checkObjectValueListener}`); - delete win.checkObjectValueListener; - info(`deleted objectValue (${win.objectValue}) and checkObjectValueListener (${win.checkObjectValueListener})`); - }); - info("exiting cleanupObjectValue") -} - -// See the notes for cacheObjectValue above. -function checkObjectValue(browser) { - let mm = browser.messageManager; - - return new Promise((resolve, reject) => { - let listener = ({ data }) => { - mm.removeMessageListener("Test:CheckObjectValueResult", listener); - if (data.result === null) { - ok(false, "checkObjectValue threw an exception: " + data.exception); - reject(data.exception); - } else { - resolve(data.result); - } - }; - - mm.addMessageListener("Test:CheckObjectValueResult", listener); - mm.sendAsyncMessage("Test:CheckObjectValue"); - }); -} - -add_task(function*() { - let embed = '<embed type="application/x-test" allowscriptaccess="always" allowfullscreen="true" wmode="window" width="640" height="480"></embed>' - setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED); - - // create a few tabs - let tabs = [ - gBrowser.tabs[0], - gBrowser.addTab("about:blank", {skipAnimation: true}), - gBrowser.addTab("about:blank", {skipAnimation: true}), - gBrowser.addTab("about:blank", {skipAnimation: true}), - gBrowser.addTab("about:blank", {skipAnimation: true}) - ]; - - // Initially 0 1 2 3 4 - yield loadURI(tabs[1], "data:text/html;charset=utf-8,<title>tab1</title><body>tab1<iframe>"); - yield loadURI(tabs[2], "data:text/plain;charset=utf-8,tab2"); - yield loadURI(tabs[3], "data:text/html;charset=utf-8,<title>tab3</title><body>tab3<iframe>"); - yield loadURI(tabs[4], "data:text/html;charset=utf-8,<body onload='clicks=0' onclick='++clicks'>"+embed); - yield BrowserTestUtils.switchTab(gBrowser, tabs[3]); - - swapTabsAndCloseOther(2, 3); // now: 0 1 2 4 - is(gBrowser.tabs[1], tabs[1], "tab1"); - is(gBrowser.tabs[2], tabs[3], "tab3"); - is(gBrowser.tabs[3], tabs[4], "tab4"); - delete tabs[2]; - - info("about to cacheObjectValue") - yield cacheObjectValue(tabs[4].linkedBrowser); - info("just finished cacheObjectValue") - - swapTabsAndCloseOther(3, 2); // now: 0 1 4 - is(Array.prototype.indexOf.call(gBrowser.tabs, gBrowser.selectedTab), 2, - "The third tab should be selected"); - delete tabs[4]; - - - ok((yield checkObjectValue(gBrowser.tabs[2].linkedBrowser)), "same plugin instance"); - - is(gBrowser.tabs[1], tabs[1], "tab1"); - is(gBrowser.tabs[2], tabs[3], "tab4"); - - let clicks = yield getClicks(gBrowser.tabs[2]); - is(clicks, 0, "no click on BODY so far"); - yield clickTest(gBrowser.tabs[2]); - - swapTabsAndCloseOther(2, 1); // now: 0 4 - is(gBrowser.tabs[1], tabs[1], "tab1"); - delete tabs[3]; - - ok((yield checkObjectValue(gBrowser.tabs[1].linkedBrowser)), "same plugin instance"); - yield cleanupObjectValue(gBrowser.tabs[1].linkedBrowser); - - yield clickTest(gBrowser.tabs[1]); - - // Load a new document (about:blank) in tab4, then detach that tab into a new window. - // In the new window, navigate back to the original document and click on its <body>, - // verify that its onclick was called. - is(Array.prototype.indexOf.call(gBrowser.tabs, gBrowser.selectedTab), 1, - "The second tab should be selected"); - is(gBrowser.tabs[1], tabs[1], - "The second tab in gBrowser.tabs should be equal to the second tab in our array"); - is(gBrowser.selectedTab, tabs[1], - "The second tab in our array is the selected tab"); - yield loadURI(tabs[1], "about:blank"); - let key = tabs[1].linkedBrowser.permanentKey; - - let win = gBrowser.replaceTabWithWindow(tabs[1]); - yield new Promise(resolve => whenDelayedStartupFinished(win, resolve)); - delete tabs[1]; - - // Verify that the original window now only has the initial tab left in it. - is(gBrowser.tabs[0], tabs[0], "tab0"); - is(gBrowser.tabs[0].linkedBrowser.currentURI.spec, "about:blank", "tab0 uri"); - - let tab = win.gBrowser.tabs[0]; - is(tab.linkedBrowser.permanentKey, key, "Should have kept the key"); - - let awaitPageShow = BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, "pageshow"); - win.gBrowser.goBack(); - yield awaitPageShow; - - yield clickTest(tab); - promiseWindowClosed(win); -}); diff --git a/browser/base/content/test/general/browser_tab_dragdrop2.js b/browser/base/content/test/general/browser_tab_dragdrop2.js deleted file mode 100644 index 2ab622d8b..000000000 --- a/browser/base/content/test/general/browser_tab_dragdrop2.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; - -const ROOT = getRootDirectory(gTestPath); -const URI = ROOT + "browser_tab_dragdrop2_frame1.xul"; - -// Load the test page (which runs some child popup tests) in a new window. -// After the tests were run, tear off the tab into a new window and run popup -// tests a second time. We don't care about tests results, exceptions and -// crashes will be caught. -add_task(function* () { - // Open a new window. - let args = "chrome,all,dialog=no"; - let win = window.openDialog(getBrowserURL(), "_blank", args, URI); - - // Wait until the tests were run. - yield promiseTestsDone(win); - ok(true, "tests succeeded"); - - // Create a second tab so that we can move the original one out. - win.gBrowser.addTab("about:blank", {skipAnimation: true}); - - // Tear off the original tab. - let browser = win.gBrowser.selectedBrowser; - let tabClosed = promiseWaitForEvent(browser, "pagehide", true); - let win2 = win.gBrowser.replaceTabWithWindow(win.gBrowser.tabs[0]); - - // Add a 'TestsDone' event listener to ensure that the docShells is properly - // swapped to the new window instead of the page being loaded again. If this - // works fine we should *NOT* see a TestsDone event. - let onTestsDone = () => ok(false, "shouldn't run tests when tearing off"); - win2.addEventListener("TestsDone", onTestsDone); - - // Wait until the original tab is gone and the new window is ready. - yield Promise.all([tabClosed, promiseDelayedStartupFinished(win2)]); - - // Remove the 'TestsDone' event listener as now - // we're kicking off a new test run manually. - win2.removeEventListener("TestsDone", onTestsDone); - - // Run tests once again. - let promise = promiseTestsDone(win2); - win2.content.test_panels(); - yield promise; - ok(true, "tests succeeded a second time"); - - // Cleanup. - yield promiseWindowClosed(win2); - yield promiseWindowClosed(win); -}); - -function promiseTestsDone(win) { - return promiseWaitForEvent(win, "TestsDone"); -} - -function promiseDelayedStartupFinished(win) { - return new Promise(resolve => whenDelayedStartupFinished(win, resolve)); -} diff --git a/browser/base/content/test/general/browser_tab_dragdrop2_frame1.xul b/browser/base/content/test/general/browser_tab_dragdrop2_frame1.xul deleted file mode 100644 index d11709942..000000000 --- a/browser/base/content/test/general/browser_tab_dragdrop2_frame1.xul +++ /dev/null @@ -1,169 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> -<!-- - XUL Widget Test for panels - --> -<window title="Titlebar" width="200" height="200" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> - -<tree id="tree" seltype="single" width="100" height="100"> - <treecols> - <treecol flex="1"/> - <treecol flex="1"/> - </treecols> - <treechildren id="treechildren"> - <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> - <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> - <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> - <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> - <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> - <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> - </treechildren> -</tree> - - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> - - <!-- test code goes here --> - <script type="application/javascript"><![CDATA[ - -SimpleTest.waitForExplicitFinish(); - -var currentTest = null; - -var i, waitSteps; -var my_debug = false; -function test_panels() -{ - i = waitSteps = 0; - checkTreeCoords(); - - addEventListener("popupshown", popupShown, false); - addEventListener("popuphidden", nextTest, false); - return nextTest(); -} - -function nextTest() -{ - ok(true,"popuphidden " + i) - if (i == tests.length) { - let details = {bubbles: true, cancelable: false}; - document.dispatchEvent(new CustomEvent("TestsDone", details)); - return i; - } - - currentTest = tests[i]; - var panel = createPanel(currentTest.attrs); - SimpleTest.waitForFocus(() => currentTest.test(panel)); - return i; -} - -function popupShown(event) -{ - var panel = event.target; - if (waitSteps > 0 && navigator.platform.indexOf("Linux") >= 0 && - panel.boxObject.screenY == 210) { - waitSteps--; - setTimeout(popupShown, 10, event); - return; - } - ++i; - - currentTest.result(currentTest.testname + " ", panel); - panel.hidePopup(); -} - -function createPanel(attrs) -{ - var panel = document.createElement("panel"); - for (var a in attrs) { - panel.setAttribute(a, attrs[a]); - } - - var button = document.createElement("button"); - panel.appendChild(button); - button.label = "OK"; - button.width = 120; - button.height = 40; - button.setAttribute("style", "-moz-appearance: none; border: 0; margin: 0;"); - panel.setAttribute("style", "-moz-appearance: none; border: 0; margin: 0;"); - return document.documentElement.appendChild(panel); -} - -function checkTreeCoords() -{ - var tree = $("tree"); - var treechildren = $("treechildren"); - tree.currentIndex = 0; - tree.treeBoxObject.scrollToRow(0); - synthesizeMouse(treechildren, 10, tree.treeBoxObject.rowHeight + 2, { }); - - tree.treeBoxObject.scrollToRow(2); - synthesizeMouse(treechildren, 10, tree.treeBoxObject.rowHeight + 2, { }); -} - -var tests = [ - { - testname: "normal panel", - attrs: { }, - test: function(panel) { - panel.openPopupAtScreen(200, 210); - }, - result: function(testname, panel) { - if (my_debug) alert(testname); - var panelrect = panel.getBoundingClientRect(); - } - }, - { - // only noautohide panels support titlebars, so one shouldn't be shown here - testname: "autohide panel with titlebar", - attrs: { titlebar: "normal" }, - test: function(panel) { - panel.openPopupAtScreen(200, 210); - }, - result: function(testname, panel) { - if (my_debug) alert(testname); - var panelrect = panel.getBoundingClientRect(); - } - }, - { - testname: "noautohide panel with titlebar", - attrs: { noautohide: true, titlebar: "normal" }, - test: function(panel) { - waitSteps = 25; - panel.openPopupAtScreen(200, 210); - }, - result: function(testname, panel) { - if (my_debug) alert(testname); - var panelrect = panel.getBoundingClientRect(); - - var gotMouseEvent = false; - function mouseMoved(event) - { - gotMouseEvent = true; - } - - panel.addEventListener("mousemove", mouseMoved, true); - synthesizeMouse(panel, 10, 10, { type: "mousemove" }); - panel.removeEventListener("mousemove", mouseMoved, true); - - var tree = $("tree"); - tree.currentIndex = 0; - panel.appendChild(tree); - checkTreeCoords(); - } - } -]; - -SimpleTest.waitForFocus(test_panels); - -]]> -</script> - -</window> diff --git a/browser/base/content/test/general/browser_tabbar_big_widgets.js b/browser/base/content/test/general/browser_tabbar_big_widgets.js deleted file mode 100644 index 7a4c45138..000000000 --- a/browser/base/content/test/general/browser_tabbar_big_widgets.js +++ /dev/null @@ -1,29 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -const kButtonId = "test-tabbar-size-with-large-buttons"; - -function test() { - registerCleanupFunction(cleanup); - let titlebar = document.getElementById("titlebar"); - let originalHeight = titlebar.getBoundingClientRect().height; - let button = document.createElement("toolbarbutton"); - button.id = kButtonId; - button.setAttribute("style", "min-height: 100px"); - gNavToolbox.palette.appendChild(button); - CustomizableUI.addWidgetToArea(kButtonId, CustomizableUI.AREA_TABSTRIP); - let currentHeight = titlebar.getBoundingClientRect().height; - ok(currentHeight > originalHeight, "Titlebar should have grown"); - CustomizableUI.removeWidgetFromArea(kButtonId); - currentHeight = titlebar.getBoundingClientRect().height; - is(currentHeight, originalHeight, "Titlebar should have gone back to its original size."); -} - -function cleanup() { - let btn = document.getElementById(kButtonId); - if (btn) { - btn.remove(); - } -} - diff --git a/browser/base/content/test/general/browser_tabfocus.js b/browser/base/content/test/general/browser_tabfocus.js deleted file mode 100644 index 4042421e8..000000000 --- a/browser/base/content/test/general/browser_tabfocus.js +++ /dev/null @@ -1,565 +0,0 @@ -/* - * This test checks that focus is adjusted properly when switching tabs. - */ - -var testPage1 = "<html id='html1'><body id='body1'><button id='button1'>Tab 1</button></body></html>"; -var testPage2 = "<html id='html2'><body id='body2'><button id='button2'>Tab 2</button></body></html>"; -var testPage3 = "<html id='html3'><body id='body3'><button id='button3'>Tab 3</button></body></html>"; - -const fm = Services.focus; - -function EventStore() { - this["main-window"] = []; - this["window1"] = []; - this["window2"] = []; -} - -EventStore.prototype = { - "push": function (event) { - if (event.indexOf("1") > -1) { - this["window1"].push(event); - } else if (event.indexOf("2") > -1) { - this["window2"].push(event); - } else { - this["main-window"].push(event); - } - } -} - -var tab1 = null; -var tab2 = null; -var browser1 = null; -var browser2 = null; -var _lastfocus; -var _lastfocuswindow = null; -var actualEvents = new EventStore(); -var expectedEvents = new EventStore(); -var currentTestName = ""; -var _expectedElement = null; -var _expectedWindow = null; - -var currentPromiseResolver = null; - -function* getFocusedElementForBrowser(browser, dontCheckExtraFocus = false) -{ - if (gMultiProcessBrowser) { - return new Promise((resolve, reject) => { - messageManager.addMessageListener("Browser:GetCurrentFocus", function getCurrentFocus(message) { - messageManager.removeMessageListener("Browser:GetCurrentFocus", getCurrentFocus); - resolve(message.data.details); - }); - - // The dontCheckExtraFocus flag is used to indicate not to check some - // additional focus related properties. This is needed as both URLs are - // loaded using the same child process and share focus managers. - browser.messageManager.sendAsyncMessage("Browser:GetFocusedElement", - { dontCheckExtraFocus : dontCheckExtraFocus }); - }); - } - var focusedWindow = {}; - var node = fm.getFocusedElementForWindow(browser.contentWindow, false, focusedWindow); - return "Focus is " + (node ? node.id : "<none>"); -} - -function focusInChild() -{ - var contentFM = Components.classes["@mozilla.org/focus-manager;1"]. - getService(Components.interfaces.nsIFocusManager); - - function getWindowDocId(target) - { - return (String(target.location).indexOf("1") >= 0) ? "window1" : "window2"; - } - - function eventListener(event) { - var id; - if (event.target instanceof Components.interfaces.nsIDOMWindow) - id = getWindowDocId(event.originalTarget) + "-window"; - else if (event.target instanceof Components.interfaces.nsIDOMDocument) - id = getWindowDocId(event.originalTarget) + "-document"; - else - id = event.originalTarget.id; - sendSyncMessage("Browser:FocusChanged", { details : event.type + ": " + id }); - } - - addEventListener("focus", eventListener, true); - addEventListener("blur", eventListener, true); - - addMessageListener("Browser:ChangeFocus", function changeFocus(message) { - content.document.getElementById(message.data.id)[message.data.type](); - }); - - addMessageListener("Browser:GetFocusedElement", function getFocusedElement(message) { - var focusedWindow = {}; - var node = contentFM.getFocusedElementForWindow(content, false, focusedWindow); - var details = "Focus is " + (node ? node.id : "<none>"); - - /* Check focus manager properties. Add an error onto the string if they are - not what is expected which will cause matching to fail in the parent process. */ - let doc = content.document; - if (!message.data.dontCheckExtraFocus) { - if (contentFM.focusedElement != node) { - details += "<ERROR: focusedElement doesn't match>"; - } - if (contentFM.focusedWindow && contentFM.focusedWindow != content) { - details += "<ERROR: focusedWindow doesn't match>"; - } - if ((contentFM.focusedWindow == content) != doc.hasFocus()) { - details += "<ERROR: child hasFocus() is not correct>"; - } - if ((contentFM.focusedElement && doc.activeElement != contentFM.focusedElement) || - (!contentFM.focusedElement && doc.activeElement != doc.body)) { - details += "<ERROR: child activeElement is not correct>"; - } - } - - sendSyncMessage("Browser:GetCurrentFocus", { details : details }); - }); -} - -function focusElementInChild(elementid, type) -{ - let browser = (elementid.indexOf("1") >= 0) ? browser1 : browser2; - if (gMultiProcessBrowser) { - browser.messageManager.sendAsyncMessage("Browser:ChangeFocus", - { id: elementid, type: type }); - } - else { - browser.contentDocument.getElementById(elementid)[type](); - } -} - -add_task(function*() { - tab1 = gBrowser.addTab(); - browser1 = gBrowser.getBrowserForTab(tab1); - - tab2 = gBrowser.addTab(); - browser2 = gBrowser.getBrowserForTab(tab2); - - yield promiseTabLoadEvent(tab1, "data:text/html," + escape(testPage1)); - yield promiseTabLoadEvent(tab2, "data:text/html," + escape(testPage2)); - - var childFocusScript = "data:,(" + focusInChild.toString() + ")();"; - browser1.messageManager.loadFrameScript(childFocusScript, true); - browser2.messageManager.loadFrameScript(childFocusScript, true); - - gURLBar.focus(); - yield SimpleTest.promiseFocus(); - - if (gMultiProcessBrowser) { - messageManager.addMessageListener("Browser:FocusChanged", message => { - actualEvents.push(message.data.details); - compareFocusResults(); - }); - } - - _lastfocus = "urlbar"; - _lastfocuswindow = "main-window"; - - window.addEventListener("focus", _browser_tabfocus_test_eventOccured, true); - window.addEventListener("blur", _browser_tabfocus_test_eventOccured, true); - - // make sure that the focus initially starts out blank - var focusedWindow = {}; - - let focused = yield getFocusedElementForBrowser(browser1); - is(focused, "Focus is <none>", "initial focus in tab 1"); - - focused = yield getFocusedElementForBrowser(browser2); - is(focused, "Focus is <none>", "initial focus in tab 2"); - - is(document.activeElement, gURLBar.inputField, "focus after loading two tabs"); - - yield* expectFocusShiftAfterTabSwitch(tab2, "window2", null, true, - "after tab change, focus in new tab"); - - focused = yield getFocusedElementForBrowser(browser2); - is(focused, "Focus is <none>", "focusedElement after tab change, focus in new tab"); - - // switching tabs when nothing in the new tab is focused - // should focus the browser - yield* expectFocusShiftAfterTabSwitch(tab1, "window1", null, true, - "after tab change, focus in original tab"); - - focused = yield getFocusedElementForBrowser(browser1); - is(focused, "Focus is <none>", "focusedElement after tab change, focus in original tab"); - - // focusing a button in the current tab should focus it - yield expectFocusShift(() => focusElementInChild("button1", "focus"), - "window1", "button1", true, - "after button focused"); - - focused = yield getFocusedElementForBrowser(browser1); - is(focused, "Focus is button1", "focusedElement in first browser after button focused"); - - // focusing a button in a background tab should not change the actual - // focus, but should set the focus that would be in that background tab to - // that button. - yield expectFocusShift(() => focusElementInChild("button2", "focus"), - "window1", "button1", false, - "after button focus in unfocused tab"); - - focused = yield getFocusedElementForBrowser(browser1, false); - is(focused, "Focus is button1", "focusedElement in first browser after button focus in unfocused tab"); - focused = yield getFocusedElementForBrowser(browser2, true); - is(focused, "Focus is button2", "focusedElement in second browser after button focus in unfocused tab"); - - // switching tabs should now make the button in the other tab focused - yield* expectFocusShiftAfterTabSwitch(tab2, "window2", "button2", true, - "after tab change with button focused"); - - // blurring an element in a background tab should not change the active - // focus, but should clear the focus in that tab. - yield expectFocusShift(() => focusElementInChild("button1", "blur"), - "window2", "button2", false, - "focusedWindow after blur in unfocused tab"); - - focused = yield getFocusedElementForBrowser(browser1, true); - is(focused, "Focus is <none>", "focusedElement in first browser after focus in unfocused tab"); - focused = yield getFocusedElementForBrowser(browser2, false); - is(focused, "Focus is button2", "focusedElement in second browser after focus in unfocused tab"); - - // When focus is in the tab bar, it should be retained there - yield expectFocusShift(() => gBrowser.selectedTab.focus(), - "main-window", "tab2", true, - "focusing tab element"); - yield* expectFocusShiftAfterTabSwitch(tab1, "main-window", "tab1", true, - "tab change when selected tab element was focused"); - - let switchWaiter; - if (gMultiProcessBrowser) { - switchWaiter = new Promise((resolve, reject) => { - gBrowser.addEventListener("TabSwitchDone", function listener() { - gBrowser.removeEventListener("TabSwitchDone", listener); - executeSoon(resolve); - }); - }); - } - - yield* expectFocusShiftAfterTabSwitch(tab2, "main-window", "tab2", true, - "another tab change when selected tab element was focused"); - - // When this a remote browser, wait for the paint on the second browser so that - // any post tab-switching stuff has time to complete before blurring the tab. - // Otherwise, the _adjustFocusAfterTabSwitch in tabbrowser gets confused and - // isn't sure what tab is really focused. - if (gMultiProcessBrowser) { - yield switchWaiter; - } - - yield expectFocusShift(() => gBrowser.selectedTab.blur(), - "main-window", null, true, - "blurring tab element"); - - // focusing the url field should switch active focus away from the browser but - // not clear what would be the focus in the browser - focusElementInChild("button1", "focus"); - - yield expectFocusShift(() => gURLBar.focus(), - "main-window", "urlbar", true, - "focusedWindow after url field focused"); - focused = yield getFocusedElementForBrowser(browser1, true); - is(focused, "Focus is button1", "focusedElement after url field focused, first browser"); - focused = yield getFocusedElementForBrowser(browser2, true); - is(focused, "Focus is button2", "focusedElement after url field focused, second browser"); - - yield expectFocusShift(() => gURLBar.blur(), - "main-window", null, true, - "blurring url field"); - - // when a chrome element is focused, switching tabs to a tab with a button - // with the current focus should focus the button - yield* expectFocusShiftAfterTabSwitch(tab1, "window1", "button1", true, - "after tab change, focus in url field, button focused in new tab"); - - focused = yield getFocusedElementForBrowser(browser1, false); - is(focused, "Focus is button1", "after switch tab, focus in unfocused tab, first browser"); - focused = yield getFocusedElementForBrowser(browser2, true); - is(focused, "Focus is button2", "after switch tab, focus in unfocused tab, second browser"); - - // blurring an element in the current tab should clear the active focus - yield expectFocusShift(() => focusElementInChild("button1", "blur"), - "window1", null, true, - "after blur in focused tab"); - - focused = yield getFocusedElementForBrowser(browser1, false); - is(focused, "Focus is <none>", "focusedWindow after blur in focused tab, child"); - focusedWindow = {}; - is(fm.getFocusedElementForWindow(window, false, focusedWindow), browser1, "focusedElement after blur in focused tab, parent"); - - // blurring an non-focused url field should have no effect - yield expectFocusShift(() => gURLBar.blur(), - "window1", null, false, - "after blur in unfocused url field"); - - focusedWindow = {}; - is(fm.getFocusedElementForWindow(window, false, focusedWindow), browser1, "focusedElement after blur in unfocused url field"); - - // switch focus to a tab with a currently focused element - yield* expectFocusShiftAfterTabSwitch(tab2, "window2", "button2", true, - "after switch from unfocused to focused tab"); - focused = yield getFocusedElementForBrowser(browser2, true); - is(focused, "Focus is button2", "focusedElement after switch from unfocused to focused tab"); - - // clearing focus on the chrome window should switch the focus to the - // chrome window - yield expectFocusShift(() => fm.clearFocus(window), - "main-window", null, true, - "after switch to chrome with no focused element"); - - focusedWindow = {}; - is(fm.getFocusedElementForWindow(window, false, focusedWindow), null, "focusedElement after switch to chrome with no focused element"); - - // switch focus to another tab when neither have an active focus - yield* expectFocusShiftAfterTabSwitch(tab1, "window1", null, true, - "focusedWindow after tab switch from no focus to no focus"); - - focused = yield getFocusedElementForBrowser(browser1, false); - is(focused, "Focus is <none>", "after tab switch from no focus to no focus, first browser"); - focused = yield getFocusedElementForBrowser(browser2, true); - is(focused, "Focus is button2", "after tab switch from no focus to no focus, second browser"); - - // next, check whether navigating forward, focusing the urlbar and then - // navigating back maintains the focus in the urlbar. - yield expectFocusShift(() => focusElementInChild("button1", "focus"), - "window1", "button1", true, - "focus button"); - - yield promiseTabLoadEvent(tab1, "data:text/html," + escape(testPage3)); - - // now go back again - gURLBar.focus(); - - yield new Promise((resolve, reject) => { - window.addEventListener("pageshow", function navigationOccured(event) { - window.removeEventListener("pageshow", navigationOccured, true); - resolve(); - }, true); - document.getElementById('Browser:Back').doCommand(); - }); - - is(window.document.activeElement, gURLBar.inputField, "urlbar still focused after navigating back"); - - // Document navigation with F6 does not yet work in mutli-process browsers. - if (!gMultiProcessBrowser) { - gURLBar.focus(); - actualEvents = new EventStore(); - _lastfocus = "urlbar"; - _lastfocuswindow = "main-window"; - - yield expectFocusShift(() => EventUtils.synthesizeKey("VK_F6", { }), - "window1", "html1", - true, "switch document forward with f6"); - - EventUtils.synthesizeKey("VK_F6", { }); - is(fm.focusedWindow, window, "switch document forward again with f6"); - - browser1.style.MozUserFocus = "ignore"; - browser1.clientWidth; - EventUtils.synthesizeKey("VK_F6", { }); - is(fm.focusedWindow, window, "switch document forward again with f6 when browser non-focusable"); - - browser1.style.MozUserFocus = "normal"; - browser1.clientWidth; - } - - window.removeEventListener("focus", _browser_tabfocus_test_eventOccured, true); - window.removeEventListener("blur", _browser_tabfocus_test_eventOccured, true); - - gBrowser.removeCurrentTab(); - gBrowser.removeCurrentTab(); - - finish(); -}); - -function _browser_tabfocus_test_eventOccured(event) -{ - function getWindowDocId(target) - { - if (target == browser1.contentWindow || target == browser1.contentDocument) { - return "window1"; - } - if (target == browser2.contentWindow || target == browser2.contentDocument) { - return "window2"; - } - return "main-window"; - } - - var id; - - // Some focus events from the child bubble up? Ignore them. - if (Cu.isCrossProcessWrapper(event.originalTarget)) - return; - - if (event.target instanceof Window) - id = getWindowDocId(event.originalTarget) + "-window"; - else if (event.target instanceof Document) - id = getWindowDocId(event.originalTarget) + "-document"; - else if (event.target.id == "urlbar" && event.originalTarget.localName == "input") - id = "urlbar"; - else if (event.originalTarget.localName == "browser") - id = (event.originalTarget == browser1) ? "browser1" : "browser2"; - else if (event.originalTarget.localName == "tab") - id = (event.originalTarget == tab1) ? "tab1" : "tab2"; - else - id = event.originalTarget.id; - - actualEvents.push(event.type + ": " + id); - compareFocusResults(); -} - -function getId(element) -{ - if (!element) { - return null; - } - - if (element.localName == "browser") { - return element == browser1 ? "browser1" : "browser2"; - } - - if (element.localName == "tab") { - return element == tab1 ? "tab1" : "tab2"; - } - - return (element.localName == "input") ? "urlbar" : element.id; -} - -function compareFocusResults() -{ - if (!currentPromiseResolver) - return; - - let winIds = ["main-window", "window1", "window2"]; - - for (let winId of winIds) { - if (actualEvents[winId].length < expectedEvents[winId].length) - return; - } - - for (let winId of winIds) { - for (let e = 0; e < expectedEvents.length; e++) { - is(actualEvents[winId][e], expectedEvents[winId][e], currentTestName + " events [event " + e + "]"); - } - actualEvents[winId] = []; - } - - // Use executeSoon as this will be called during a focus/blur event handler - executeSoon(() => { - let matchWindow = window; - if (gMultiProcessBrowser) { - is(_expectedWindow, "main-window", "main-window is always expected"); - } - else if (_expectedWindow != "main-window") { - matchWindow = (_expectedWindow == "window1" ? browser1.contentWindow : browser2.contentWindow); - } - - var focusedElement = fm.focusedElement; - is(getId(focusedElement), _expectedElement, currentTestName + " focusedElement"); - is(fm.focusedWindow, matchWindow, currentTestName + " focusedWindow"); - var focusedWindow = {}; - is(getId(fm.getFocusedElementForWindow(matchWindow, false, focusedWindow)), - _expectedElement, currentTestName + " getFocusedElementForWindow"); - is(focusedWindow.value, matchWindow, currentTestName + " getFocusedElementForWindow frame"); - is(matchWindow.document.hasFocus(), true, currentTestName + " hasFocus"); - var expectedActive = _expectedElement; - if (!expectedActive) { - expectedActive = matchWindow.document instanceof XULDocument ? - "main-window" : getId(matchWindow.document.body); - } - is(getId(matchWindow.document.activeElement), expectedActive, currentTestName + " activeElement"); - - currentPromiseResolver(); - currentPromiseResolver = null; - }); -} - -function* expectFocusShiftAfterTabSwitch(tab, expectedWindow, expectedElement, focusChanged, testid) -{ - let tabSwitchPromise = null; - yield expectFocusShift(() => { tabSwitchPromise = BrowserTestUtils.switchTab(gBrowser, tab) }, - expectedWindow, expectedElement, focusChanged, testid) - yield tabSwitchPromise; -} - -function* expectFocusShift(callback, expectedWindow, expectedElement, focusChanged, testid) -{ - currentPromiseResolver = null; - currentTestName = testid; - - expectedEvents = new EventStore(); - - if (focusChanged) { - _expectedElement = expectedElement; - _expectedWindow = expectedWindow; - - // When the content is in a child process, the expected element in the chrome window - // will always be the urlbar or a browser element. - if (gMultiProcessBrowser) { - if (_expectedWindow == "window1") { - _expectedElement = "browser1"; - } - else if (_expectedWindow == "window2") { - _expectedElement = "browser2"; - } - _expectedWindow = "main-window"; - } - - if (gMultiProcessBrowser && _lastfocuswindow != "main-window" && - _lastfocuswindow != expectedWindow) { - let browserid = _lastfocuswindow == "window1" ? "browser1" : "browser2"; - expectedEvents.push("blur: " + browserid); - } - - var newElementIsFocused = (expectedElement && !expectedElement.startsWith("html")); - if (newElementIsFocused && gMultiProcessBrowser && - _lastfocuswindow != "main-window" && - expectedWindow == "main-window") { - // When switching from a child to a chrome element, the focus on the element will arrive first. - expectedEvents.push("focus: " + expectedElement); - newElementIsFocused = false; - } - - if (_lastfocus && _lastfocus != _expectedElement) - expectedEvents.push("blur: " + _lastfocus); - - if (_lastfocuswindow && - _lastfocuswindow != expectedWindow) { - - if (!gMultiProcessBrowser || _lastfocuswindow != "main-window") { - expectedEvents.push("blur: " + _lastfocuswindow + "-document"); - expectedEvents.push("blur: " + _lastfocuswindow + "-window"); - } - } - - if (expectedWindow && _lastfocuswindow != expectedWindow) { - if (gMultiProcessBrowser && expectedWindow != "main-window") { - let browserid = expectedWindow == "window1" ? "browser1" : "browser2"; - expectedEvents.push("focus: " + browserid); - } - - if (!gMultiProcessBrowser || expectedWindow != "main-window") { - expectedEvents.push("focus: " + expectedWindow + "-document"); - expectedEvents.push("focus: " + expectedWindow + "-window"); - } - } - - if (newElementIsFocused) { - expectedEvents.push("focus: " + expectedElement); - } - - _lastfocus = expectedElement; - _lastfocuswindow = expectedWindow; - } - - return new Promise((resolve, reject) => { - currentPromiseResolver = resolve; - callback(); - - // No events are expected, so resolve the promise immediately. - if (expectedEvents["main-window"].length + expectedEvents["window1"].length + expectedEvents["window2"].length == 0) { - currentPromiseResolver(); - currentPromiseResolver = null; - } - }); -} diff --git a/browser/base/content/test/general/browser_tabkeynavigation.js b/browser/base/content/test/general/browser_tabkeynavigation.js deleted file mode 100644 index d8e51f4b9..000000000 --- a/browser/base/content/test/general/browser_tabkeynavigation.js +++ /dev/null @@ -1,156 +0,0 @@ -/* - * This test checks that keyboard navigation for tabs isn't blocked by content - */ -add_task(function* test() { - - let testPage1 = "data:text/html,<html id='tab1'><body><button id='button1'>Tab 1</button></body></html>"; - let testPage2 = "data:text/html,<html id='tab2'><body><button id='button2'>Tab 2</button><script>function preventDefault(event) { event.preventDefault(); event.stopImmediatePropagation(); } window.addEventListener('keydown', preventDefault, true); window.addEventListener('keypress', preventDefault, true);</script></body></html>"; - let testPage3 = "data:text/html,<html id='tab3'><body><button id='button3'>Tab 3</button></body></html>"; - - let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, testPage1); - let browser1 = gBrowser.getBrowserForTab(tab1); - let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, testPage2); - let tab3 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, testPage3); - - // Kill the animation for simpler test. - Services.prefs.setBoolPref("browser.tabs.animate", false); - - gBrowser.selectedTab = tab1; - browser1.focus(); - - is(gBrowser.selectedTab, tab1, - "Tab1 should be activated"); - EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated by pressing Ctrl+Tab on Tab1"); - - EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true }); - is(gBrowser.selectedTab, tab3, - "Tab3 should be activated by pressing Ctrl+Tab on Tab2"); - - EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated by pressing Ctrl+Shift+Tab on Tab3"); - - EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: true }); - is(gBrowser.selectedTab, tab1, - "Tab1 should be activated by pressing Ctrl+Shift+Tab on Tab2"); - - gBrowser.selectedTab = tab1; - browser1.focus(); - - is(gBrowser.selectedTab, tab1, - "Tab1 should be activated"); - EventUtils.synthesizeKey("VK_PAGE_DOWN", { ctrlKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated by pressing Ctrl+PageDown on Tab1"); - - EventUtils.synthesizeKey("VK_PAGE_DOWN", { ctrlKey: true }); - is(gBrowser.selectedTab, tab3, - "Tab3 should be activated by pressing Ctrl+PageDown on Tab2"); - - EventUtils.synthesizeKey("VK_PAGE_UP", { ctrlKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated by pressing Ctrl+PageUp on Tab3"); - - EventUtils.synthesizeKey("VK_PAGE_UP", { ctrlKey: true }); - is(gBrowser.selectedTab, tab1, - "Tab1 should be activated by pressing Ctrl+PageUp on Tab2"); - - if (gBrowser.mTabBox._handleMetaAltArrows) { - gBrowser.selectedTab = tab1; - browser1.focus(); - - let ltr = window.getComputedStyle(gBrowser.mTabBox, "").direction == "ltr"; - let advanceKey = ltr ? "VK_RIGHT" : "VK_LEFT"; - let reverseKey = ltr ? "VK_LEFT" : "VK_RIGHT"; - - is(gBrowser.selectedTab, tab1, - "Tab1 should be activated"); - EventUtils.synthesizeKey(advanceKey, { altKey: true, metaKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated by pressing Ctrl+" + advanceKey + " on Tab1"); - - EventUtils.synthesizeKey(advanceKey, { altKey: true, metaKey: true }); - is(gBrowser.selectedTab, tab3, - "Tab3 should be activated by pressing Ctrl+" + advanceKey + " on Tab2"); - - EventUtils.synthesizeKey(reverseKey, { altKey: true, metaKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated by pressing Ctrl+" + reverseKey + " on Tab3"); - - EventUtils.synthesizeKey(reverseKey, { altKey: true, metaKey: true }); - is(gBrowser.selectedTab, tab1, - "Tab1 should be activated by pressing Ctrl+" + reverseKey + " on Tab2"); - } - - gBrowser.selectedTab = tab2; - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated"); - is(gBrowser.tabContainer.selectedIndex, 2, - "Tab2 index should be 2"); - - EventUtils.synthesizeKey("VK_PAGE_DOWN", { ctrlKey: true, shiftKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated after Ctrl+Shift+PageDown"); - is(gBrowser.tabContainer.selectedIndex, 3, - "Tab2 index should be 1 after Ctrl+Shift+PageDown"); - - EventUtils.synthesizeKey("VK_PAGE_UP", { ctrlKey: true, shiftKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated after Ctrl+Shift+PageUp"); - is(gBrowser.tabContainer.selectedIndex, 2, - "Tab2 index should be 2 after Ctrl+Shift+PageUp"); - - if (navigator.platform.indexOf("Mac") == 0) { - gBrowser.selectedTab = tab1; - browser1.focus(); - - // XXX Currently, Command + "{" and "}" don't work if keydown event is - // consumed because following keypress event isn't fired. - - let ltr = window.getComputedStyle(gBrowser.mTabBox, "").direction == "ltr"; - let advanceKey = ltr ? "}" : "{"; - let reverseKey = ltr ? "{" : "}"; - - is(gBrowser.selectedTab, tab1, - "Tab1 should be activated"); - - EventUtils.synthesizeKey(advanceKey, { metaKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated by pressing Ctrl+" + advanceKey + " on Tab1"); - - EventUtils.synthesizeKey(advanceKey, { metaKey: true }); - is(gBrowser.selectedTab, tab3, - "Tab3 should be activated by pressing Ctrl+" + advanceKey + " on Tab2"); - - EventUtils.synthesizeKey(reverseKey, { metaKey: true }); - is(gBrowser.selectedTab, tab2, - "Tab2 should be activated by pressing Ctrl+" + reverseKey + " on Tab3"); - - EventUtils.synthesizeKey(reverseKey, { metaKey: true }); - is(gBrowser.selectedTab, tab1, - "Tab1 should be activated by pressing Ctrl+" + reverseKey + " on Tab2"); - } else { - gBrowser.selectedTab = tab2; - EventUtils.synthesizeKey("VK_F4", { type: "keydown", ctrlKey: true }); - - isnot(gBrowser.selectedTab, tab2, - "Tab2 should be closed by pressing Ctrl+F4 on Tab2"); - is(gBrowser.tabs.length, 3, - "The count of tabs should be 3 since tab2 should be closed"); - - // NOTE: keypress event shouldn't be fired since the keydown event should - // be consumed by tab2. - EventUtils.synthesizeKey("VK_F4", { type: "keyup", ctrlKey: true }); - is(gBrowser.tabs.length, 3, - "The count of tabs should be 3 since renaming key events shouldn't close other tabs"); - } - - gBrowser.selectedTab = tab3; - while (gBrowser.tabs.length > 1) { - gBrowser.removeCurrentTab(); - } - - Services.prefs.clearUserPref("browser.tabs.animate"); -}); diff --git a/browser/base/content/test/general/browser_tabopen_reflows.js b/browser/base/content/test/general/browser_tabopen_reflows.js deleted file mode 100644 index 8e04cf12e..000000000 --- a/browser/base/content/test/general/browser_tabopen_reflows.js +++ /dev/null @@ -1,157 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -XPCOMUtils.defineLazyGetter(this, "docShell", () => { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); -}); - -const EXPECTED_REFLOWS = [ - // tabbrowser.adjustTabstrip() call after tabopen animation has finished - "adjustTabstrip@chrome://browser/content/tabbrowser.xml|" + - "_handleNewTab@chrome://browser/content/tabbrowser.xml|" + - "onxbltransitionend@chrome://browser/content/tabbrowser.xml|", - - // switching focus in updateCurrentBrowser() causes reflows - "_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.xml|" + - "updateCurrentBrowser@chrome://browser/content/tabbrowser.xml|" + - "onselect@chrome://browser/content/browser.xul|", - - // switching focus in openLinkIn() causes reflows - "openLinkIn@chrome://browser/content/utilityOverlay.js|" + - "openUILinkIn@chrome://browser/content/utilityOverlay.js|" + - "BrowserOpenTab@chrome://browser/content/browser.js|", - - // accessing element.scrollPosition in _fillTrailingGap() flushes layout - "get_scrollPosition@chrome://global/content/bindings/scrollbox.xml|" + - "_fillTrailingGap@chrome://browser/content/tabbrowser.xml|" + - "_handleNewTab@chrome://browser/content/tabbrowser.xml|" + - "onxbltransitionend@chrome://browser/content/tabbrowser.xml|", - - // SessionStore.getWindowDimensions() - "ssi_getWindowDimension@resource:///modules/sessionstore/SessionStore.jsm|" + - "ssi_updateWindowFeatures/<@resource:///modules/sessionstore/SessionStore.jsm|" + - "ssi_updateWindowFeatures@resource:///modules/sessionstore/SessionStore.jsm|" + - "ssi_collectWindowData@resource:///modules/sessionstore/SessionStore.jsm|", - - // selection change notification may cause querying the focused editor content - // by IME and that will cause reflow. - "select@chrome://global/content/bindings/textbox.xml|" + - "focusAndSelectUrlBar@chrome://browser/content/browser.js|" + - "openLinkIn@chrome://browser/content/utilityOverlay.js|" + - "openUILinkIn@chrome://browser/content/utilityOverlay.js|" + - "BrowserOpenTab@chrome://browser/content/browser.js|", - -]; - -const PREF_PRELOAD = "browser.newtab.preload"; -const PREF_NEWTAB_DIRECTORYSOURCE = "browser.newtabpage.directory.source"; - -/* - * This test ensures that there are no unexpected - * uninterruptible reflows when opening new tabs. - */ -add_task(function*() { - let DirectoryLinksProvider = Cu.import("resource:///modules/DirectoryLinksProvider.jsm", {}).DirectoryLinksProvider; - let NewTabUtils = Cu.import("resource://gre/modules/NewTabUtils.jsm", {}).NewTabUtils; - let Promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise; - - // resolves promise when directory links are downloaded and written to disk - function watchLinksChangeOnce() { - let deferred = Promise.defer(); - let observer = { - onManyLinksChanged: () => { - DirectoryLinksProvider.removeObserver(observer); - NewTabUtils.links.populateCache(() => { - NewTabUtils.allPages.update(); - deferred.resolve(); - }, true); - } - }; - observer.onDownloadFail = observer.onManyLinksChanged; - DirectoryLinksProvider.addObserver(observer); - return deferred.promise; - } - - let gOrigDirectorySource = Services.prefs.getCharPref(PREF_NEWTAB_DIRECTORYSOURCE); - registerCleanupFunction(() => { - Services.prefs.clearUserPref(PREF_PRELOAD); - Services.prefs.setCharPref(PREF_NEWTAB_DIRECTORYSOURCE, gOrigDirectorySource); - return watchLinksChangeOnce(); - }); - - Services.prefs.setBoolPref(PREF_PRELOAD, false); - // set directory source to dummy/empty links - Services.prefs.setCharPref(PREF_NEWTAB_DIRECTORYSOURCE, 'data:application/json,{"test":1}'); - - // run tests when directory source change completes - yield watchLinksChangeOnce(); - - // Perform a click in the top left of content to ensure the mouse isn't - // hovering over any of the tiles - let target = gBrowser.selectedBrowser; - let rect = target.getBoundingClientRect(); - let left = rect.left + 1; - let top = rect.top + 1; - - let utils = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils); - utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0); - utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0); - - // Add a reflow observer and open a new tab. - docShell.addWeakReflowObserver(observer); - BrowserOpenTab(); - - // Wait until the tabopen animation has finished. - yield waitForTransitionEnd(); - - // Remove reflow observer and clean up. - docShell.removeWeakReflowObserver(observer); - gBrowser.removeCurrentTab(); -}); - -var observer = { - reflow: function (start, end) { - // Gather information about the current code path. - let path = (new Error().stack).split("\n").slice(1).map(line => { - return line.replace(/:\d+:\d+$/, ""); - }).join("|"); - let pathWithLineNumbers = (new Error().stack).split("\n").slice(1).join("|"); - - // Stack trace is empty. Reflow was triggered by native code. - if (path === "") { - return; - } - - // Check if this is an expected reflow. - for (let stack of EXPECTED_REFLOWS) { - if (path.startsWith(stack)) { - ok(true, "expected uninterruptible reflow '" + stack + "'"); - return; - } - } - - ok(false, "unexpected uninterruptible reflow '" + pathWithLineNumbers + "'"); - }, - - reflowInterruptible: function (start, end) { - // We're not interested in interruptible reflows. - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver, - Ci.nsISupportsWeakReference]) -}; - -function waitForTransitionEnd() { - return new Promise(resolve => { - let tab = gBrowser.selectedTab; - tab.addEventListener("transitionend", function onEnd(event) { - if (event.propertyName === "max-width") { - tab.removeEventListener("transitionend", onEnd); - resolve(); - } - }); - }); -} diff --git a/browser/base/content/test/general/browser_tabs_close_beforeunload.js b/browser/base/content/test/general/browser_tabs_close_beforeunload.js deleted file mode 100644 index b867efd72..000000000 --- a/browser/base/content/test/general/browser_tabs_close_beforeunload.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; - -SimpleTest.requestCompleteLog(); - -SpecialPowers.pushPrefEnv({"set": [["dom.require_user_interaction_for_beforeunload", false]]}); - -const FIRST_TAB = getRootDirectory(gTestPath) + "close_beforeunload_opens_second_tab.html"; -const SECOND_TAB = getRootDirectory(gTestPath) + "close_beforeunload.html"; - -add_task(function*() { - info("Opening first tab"); - let firstTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, FIRST_TAB); - let secondTabLoadedPromise; - let secondTab; - let tabOpened = new Promise(resolve => { - info("Adding tabopen listener"); - gBrowser.tabContainer.addEventListener("TabOpen", function tabOpenListener(e) { - info("Got tabopen, removing listener and waiting for load"); - gBrowser.tabContainer.removeEventListener("TabOpen", tabOpenListener, false, false); - secondTab = e.target; - secondTabLoadedPromise = BrowserTestUtils.browserLoaded(secondTab.linkedBrowser, false, SECOND_TAB); - resolve(); - }, false, false); - }); - info("Opening second tab using a click"); - yield ContentTask.spawn(firstTab.linkedBrowser, "", function*() { - content.document.getElementsByTagName("a")[0].click(); - }); - info("Waiting for the second tab to be opened"); - yield tabOpened; - info("Waiting for the load in that tab to finish"); - yield secondTabLoadedPromise; - - let closeBtn = document.getAnonymousElementByAttribute(secondTab, "anonid", "close-button"); - let closePromise = BrowserTestUtils.removeTab(secondTab, {dontRemove: true}); - info("closing second tab (which will self-close in beforeunload)"); - closeBtn.click(); - ok(secondTab.closing, "Second tab should be marked as closing synchronously."); - yield closePromise; - ok(secondTab.closing, "Second tab should still be marked as closing"); - ok(!secondTab.linkedBrowser, "Second tab's browser should be dead"); - ok(!firstTab.closing, "First tab should not be closing"); - ok(firstTab.linkedBrowser, "First tab's browser should be alive"); - info("closing first tab"); - yield BrowserTestUtils.removeTab(firstTab); - - ok(firstTab.closing, "First tab should be marked as closing"); - ok(!firstTab.linkedBrowser, "First tab's browser should be dead"); -}); diff --git a/browser/base/content/test/general/browser_tabs_isActive.js b/browser/base/content/test/general/browser_tabs_isActive.js deleted file mode 100644 index 0725757e7..000000000 --- a/browser/base/content/test/general/browser_tabs_isActive.js +++ /dev/null @@ -1,152 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Test for the docshell active state of local and remote browsers. - -const kTestPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; - -function promiseNewTabSwitched() { - return new Promise(resolve => { - gBrowser.addEventListener("TabSwitchDone", function onSwitch() { - gBrowser.removeEventListener("TabSwitchDone", onSwitch); - executeSoon(resolve); - }); - }); -} - -function getParentTabState(aTab) { - return aTab.linkedBrowser.docShellIsActive; -} - -function getChildTabState(aTab) { - return ContentTask.spawn(aTab.linkedBrowser, {}, function* () { - return docShell.isActive; - }); -} - -function checkState(parentSide, childSide, value, message) { - is(parentSide, value, message + " (parent side)"); - is(childSide, value, message + " (child side)"); -} - -function waitForMs(aMs) { - return new Promise((resolve) => { - setTimeout(done, aMs); - function done() { - resolve(true); - } - }); -} - -add_task(function *() { - let url = kTestPage; - let originalTab = gBrowser.selectedTab; // test tab - let newTab = gBrowser.addTab(url, {skipAnimation: true}); - let parentSide, childSide; - - // new tab added but not selected checks - parentSide = getParentTabState(newTab); - childSide = yield getChildTabState(newTab); - checkState(parentSide, childSide, false, "newly added " + url + " tab is not active"); - parentSide = getParentTabState(originalTab); - childSide = yield getChildTabState(originalTab); - checkState(parentSide, childSide, true, "original tab is active initially"); - - // select the newly added tab and wait for TabSwitchDone event - let tabSwitchedPromise = promiseNewTabSwitched(); - gBrowser.selectedTab = newTab; - yield tabSwitchedPromise; - - if (Services.appinfo.browserTabsRemoteAutostart) { - ok(newTab.linkedBrowser.isRemoteBrowser, "for testing we need a remote tab"); - } - - // check active state of both tabs - parentSide = getParentTabState(newTab); - childSide = yield getChildTabState(newTab); - checkState(parentSide, childSide, true, "newly added " + url + " tab is active after selection"); - parentSide = getParentTabState(originalTab); - childSide = yield getChildTabState(originalTab); - checkState(parentSide, childSide, false, "original tab is not active while unselected"); - - // switch back to the original test tab and wait for TabSwitchDone event - tabSwitchedPromise = promiseNewTabSwitched(); - gBrowser.selectedTab = originalTab; - yield tabSwitchedPromise; - - // check active state of both tabs - parentSide = getParentTabState(newTab); - childSide = yield getChildTabState(newTab); - checkState(parentSide, childSide, false, "newly added " + url + " tab is not active after switch back"); - parentSide = getParentTabState(originalTab); - childSide = yield getChildTabState(originalTab); - checkState(parentSide, childSide, true, "original tab is active again after switch back"); - - // switch to the new tab and wait for TabSwitchDone event - tabSwitchedPromise = promiseNewTabSwitched(); - gBrowser.selectedTab = newTab; - yield tabSwitchedPromise; - - // check active state of both tabs - parentSide = getParentTabState(newTab); - childSide = yield getChildTabState(newTab); - checkState(parentSide, childSide, true, "newly added " + url + " tab is not active after switch back"); - parentSide = getParentTabState(originalTab); - childSide = yield getChildTabState(originalTab); - checkState(parentSide, childSide, false, "original tab is active again after switch back"); - - gBrowser.removeTab(newTab); -}); - -add_task(function *() { - let url = "about:about"; - let originalTab = gBrowser.selectedTab; // test tab - let newTab = gBrowser.addTab(url, {skipAnimation: true}); - let parentSide, childSide; - - parentSide = getParentTabState(newTab); - childSide = yield getChildTabState(newTab); - checkState(parentSide, childSide, false, "newly added " + url + " tab is not active"); - parentSide = getParentTabState(originalTab); - childSide = yield getChildTabState(originalTab); - checkState(parentSide, childSide, true, "original tab is active initially"); - - let tabSwitchedPromise = promiseNewTabSwitched(); - gBrowser.selectedTab = newTab; - yield tabSwitchedPromise; - - if (Services.appinfo.browserTabsRemoteAutostart) { - ok(!newTab.linkedBrowser.isRemoteBrowser, "for testing we need a local tab"); - } - - parentSide = getParentTabState(newTab); - childSide = yield getChildTabState(newTab); - checkState(parentSide, childSide, true, "newly added " + url + " tab is active after selection"); - parentSide = getParentTabState(originalTab); - childSide = yield getChildTabState(originalTab); - checkState(parentSide, childSide, false, "original tab is not active while unselected"); - - tabSwitchedPromise = promiseNewTabSwitched(); - gBrowser.selectedTab = originalTab; - yield tabSwitchedPromise; - - parentSide = getParentTabState(newTab); - childSide = yield getChildTabState(newTab); - checkState(parentSide, childSide, false, "newly added " + url + " tab is not active after switch back"); - parentSide = getParentTabState(originalTab); - childSide = yield getChildTabState(originalTab); - checkState(parentSide, childSide, true, "original tab is active again after switch back"); - - tabSwitchedPromise = promiseNewTabSwitched(); - gBrowser.selectedTab = newTab; - yield tabSwitchedPromise; - - parentSide = getParentTabState(newTab); - childSide = yield getChildTabState(newTab); - checkState(parentSide, childSide, true, "newly added " + url + " tab is not active after switch back"); - parentSide = getParentTabState(originalTab); - childSide = yield getChildTabState(originalTab); - checkState(parentSide, childSide, false, "original tab is active again after switch back"); - - gBrowser.removeTab(newTab); -}); diff --git a/browser/base/content/test/general/browser_tabs_owner.js b/browser/base/content/test/general/browser_tabs_owner.js deleted file mode 100644 index 300d783ba..000000000 --- a/browser/base/content/test/general/browser_tabs_owner.js +++ /dev/null @@ -1,44 +0,0 @@ -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: gBrowser._finalizeTabSwitch is not a function"); - -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: gBrowser._finalizeTabSwitch is not a function"); - -function test() { - gBrowser.addTab(); - gBrowser.addTab(); - gBrowser.addTab(); - - var tabs = gBrowser.tabs; - var owner; - - is(tabs.length, 4, "4 tabs are open"); - - owner = gBrowser.selectedTab = tabs[2]; - BrowserOpenTab(); - is(gBrowser.selectedTab, tabs[4], "newly opened tab is selected"); - gBrowser.removeCurrentTab(); - is(gBrowser.selectedTab, owner, "owner is selected"); - - owner = gBrowser.selectedTab; - BrowserOpenTab(); - gBrowser.selectedTab = tabs[1]; - gBrowser.selectedTab = tabs[4]; - gBrowser.removeCurrentTab(); - isnot(gBrowser.selectedTab, owner, "selecting a different tab clears the owner relation"); - - owner = gBrowser.selectedTab; - BrowserOpenTab(); - gBrowser.moveTabTo(gBrowser.selectedTab, 0); - gBrowser.removeCurrentTab(); - is(gBrowser.selectedTab, owner, "owner relatitionship persists when tab is moved"); - - while (tabs.length > 1) - gBrowser.removeCurrentTab(); -} diff --git a/browser/base/content/test/general/browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js b/browser/base/content/test/general/browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js deleted file mode 100644 index f90f047d3..000000000 --- a/browser/base/content/test/general/browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js +++ /dev/null @@ -1,126 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -const OPEN_LOCATION_PREF = "browser.link.open_newwindow"; -const NON_REMOTE_PAGE = "about:welcomeback"; - -Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); - -requestLongerTimeout(2); - -function frame_script() { - content.document.body.innerHTML = ` - <a href="about:home" target="_blank" id="testAnchor">Open a window</a> - `; - - let element = content.document.getElementById("testAnchor"); - element.click(); -} - -/** - * Takes some browser in some window, and forces that browser - * to become non-remote, and then navigates it to a page that - * we're not supposed to be displaying remotely. Returns a - * Promise that resolves when the browser is no longer remote. - */ -function prepareNonRemoteBrowser(aWindow, browser) { - browser.loadURI(NON_REMOTE_PAGE); - return BrowserTestUtils.browserLoaded(browser); -} - -registerCleanupFunction(() => { - Services.prefs.clearUserPref(OPEN_LOCATION_PREF); -}); - -/** - * Test that if we open a new tab from a link in a non-remote - * browser in an e10s window, that the new tab will load properly. - */ -add_task(function* test_new_tab() { - let normalWindow = yield BrowserTestUtils.openNewBrowserWindow({ - remote: true, - }); - let privateWindow = yield BrowserTestUtils.openNewBrowserWindow({ - remote: true, - private: true, - }); - - for (let testWindow of [normalWindow, privateWindow]) { - yield promiseWaitForFocus(testWindow); - let testBrowser = testWindow.gBrowser.selectedBrowser; - info("Preparing non-remote browser"); - yield prepareNonRemoteBrowser(testWindow, testBrowser); - info("Non-remote browser prepared - sending frame script"); - - // Get our framescript ready - let mm = testBrowser.messageManager; - mm.loadFrameScript("data:,(" + frame_script.toString() + ")();", true); - - let tabOpenEvent = yield waitForNewTabEvent(testWindow.gBrowser); - let newTab = tabOpenEvent.target; - - yield promiseTabLoadEvent(newTab); - - // Our framescript opens to about:home which means that the - // tab should eventually become remote. - ok(newTab.linkedBrowser.isRemoteBrowser, - "The opened browser never became remote."); - - testWindow.gBrowser.removeTab(newTab); - } - - normalWindow.close(); - privateWindow.close(); -}); - -/** - * Test that if we open a new window from a link in a non-remote - * browser in an e10s window, that the new window is not an e10s - * window. Also tests with a private browsing window. - */ -add_task(function* test_new_window() { - let normalWindow = yield BrowserTestUtils.openNewBrowserWindow({ - remote: true - }, true); - let privateWindow = yield BrowserTestUtils.openNewBrowserWindow({ - remote: true, - private: true, - }, true); - - // Fiddle with the prefs so that we open target="_blank" links - // in new windows instead of new tabs. - Services.prefs.setIntPref(OPEN_LOCATION_PREF, - Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW); - - for (let testWindow of [normalWindow, privateWindow]) { - yield promiseWaitForFocus(testWindow); - let testBrowser = testWindow.gBrowser.selectedBrowser; - yield prepareNonRemoteBrowser(testWindow, testBrowser); - - // Get our framescript ready - let mm = testBrowser.messageManager; - mm.loadFrameScript("data:,(" + frame_script.toString() + ")();", true); - - // Click on the link in the browser, and wait for the new window. - let {subject: newWindow} = - yield promiseTopicObserved("browser-delayed-startup-finished"); - - is(PrivateBrowsingUtils.isWindowPrivate(testWindow), - PrivateBrowsingUtils.isWindowPrivate(newWindow), - "Private browsing state of new window does not match the original!"); - - let newTab = newWindow.gBrowser.selectedTab; - - yield promiseTabLoadEvent(newTab); - - // Our framescript opens to about:home which means that the - // tab should eventually become remote. - ok(newTab.linkedBrowser.isRemoteBrowser, - "The opened browser never became remote."); - newWindow.close(); - } - - normalWindow.close(); - privateWindow.close(); -}); diff --git a/browser/base/content/test/general/browser_trackingUI_1.js b/browser/base/content/test/general/browser_trackingUI_1.js deleted file mode 100644 index 937d607af..000000000 --- a/browser/base/content/test/general/browser_trackingUI_1.js +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Test that the Tracking Protection section is visible in the Control Center - * and has the correct state for the cases when: - * 1) A page with no tracking elements is loaded. - * 2) A page with tracking elements is loaded and they are blocked. - * 3) A page with tracking elements is loaded and they are not blocked. - * See also Bugs 1175327, 1043801, 1178985 - */ - -var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; -const PREF = "privacy.trackingprotection.enabled"; -const PB_PREF = "privacy.trackingprotection.pbmode.enabled"; -const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/benignPage.html"; -const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html"; -var TrackingProtection = null; -var tabbrowser = null; - -var {UrlClassifierTestUtils} = Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm", {}); - -registerCleanupFunction(function() { - TrackingProtection = tabbrowser = null; - UrlClassifierTestUtils.cleanupTestTrackers(); - Services.prefs.clearUserPref(PREF); - Services.prefs.clearUserPref(PB_PREF); - while (gBrowser.tabs.length > 1) { - gBrowser.removeCurrentTab(); - } -}); - -function hidden(sel) { - let win = tabbrowser.ownerGlobal; - let el = win.document.querySelector(sel); - let display = win.getComputedStyle(el).getPropertyValue("display", null); - let opacity = win.getComputedStyle(el).getPropertyValue("opacity", null); - return display === "none" || opacity === "0"; -} - -function clickButton(sel) { - let win = tabbrowser.ownerGlobal; - let el = win.document.querySelector(sel); - el.doCommand(); -} - -function testBenignPage() { - info("Non-tracking content must not be blocked"); - ok(!TrackingProtection.container.hidden, "The container is visible"); - ok(!TrackingProtection.content.hasAttribute("state"), "content: no state"); - ok(!TrackingProtection.icon.hasAttribute("state"), "icon: no state"); - ok(!TrackingProtection.icon.hasAttribute("tooltiptext"), "icon: no tooltip"); - - ok(hidden("#tracking-protection-icon"), "icon is hidden"); - ok(hidden("#tracking-action-block"), "blockButton is hidden"); - ok(hidden("#tracking-action-unblock"), "unblockButton is hidden"); - - // Make sure that the no tracking elements message appears - ok(!hidden("#tracking-not-detected"), "labelNoTracking is visible"); - ok(hidden("#tracking-loaded"), "labelTrackingLoaded is hidden"); - ok(hidden("#tracking-blocked"), "labelTrackingBlocked is hidden"); -} - -function testTrackingPage(window) { - info("Tracking content must be blocked"); - ok(!TrackingProtection.container.hidden, "The container is visible"); - is(TrackingProtection.content.getAttribute("state"), "blocked-tracking-content", - 'content: state="blocked-tracking-content"'); - is(TrackingProtection.icon.getAttribute("state"), "blocked-tracking-content", - 'icon: state="blocked-tracking-content"'); - is(TrackingProtection.icon.getAttribute("tooltiptext"), - gNavigatorBundle.getString("trackingProtection.icon.activeTooltip"), "correct tooltip"); - - ok(!hidden("#tracking-protection-icon"), "icon is visible"); - ok(hidden("#tracking-action-block"), "blockButton is hidden"); - - - if (PrivateBrowsingUtils.isWindowPrivate(window)) { - ok(hidden("#tracking-action-unblock"), "unblockButton is hidden"); - ok(!hidden("#tracking-action-unblock-private"), "unblockButtonPrivate is visible"); - } else { - ok(!hidden("#tracking-action-unblock"), "unblockButton is visible"); - ok(hidden("#tracking-action-unblock-private"), "unblockButtonPrivate is hidden"); - } - - // Make sure that the blocked tracking elements message appears - ok(hidden("#tracking-not-detected"), "labelNoTracking is hidden"); - ok(hidden("#tracking-loaded"), "labelTrackingLoaded is hidden"); - ok(!hidden("#tracking-blocked"), "labelTrackingBlocked is visible"); -} - -function testTrackingPageUnblocked() { - info("Tracking content must be white-listed and not blocked"); - ok(!TrackingProtection.container.hidden, "The container is visible"); - is(TrackingProtection.content.getAttribute("state"), "loaded-tracking-content", - 'content: state="loaded-tracking-content"'); - is(TrackingProtection.icon.getAttribute("state"), "loaded-tracking-content", - 'icon: state="loaded-tracking-content"'); - is(TrackingProtection.icon.getAttribute("tooltiptext"), - gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"), "correct tooltip"); - - ok(!hidden("#tracking-protection-icon"), "icon is visible"); - ok(!hidden("#tracking-action-block"), "blockButton is visible"); - ok(hidden("#tracking-action-unblock"), "unblockButton is hidden"); - - // Make sure that the blocked tracking elements message appears - ok(hidden("#tracking-not-detected"), "labelNoTracking is hidden"); - ok(!hidden("#tracking-loaded"), "labelTrackingLoaded is visible"); - ok(hidden("#tracking-blocked"), "labelTrackingBlocked is hidden"); -} - -function* testTrackingProtectionForTab(tab) { - info("Load a test page not containing tracking elements"); - yield promiseTabLoadEvent(tab, BENIGN_PAGE); - testBenignPage(); - - info("Load a test page containing tracking elements"); - yield promiseTabLoadEvent(tab, TRACKING_PAGE); - testTrackingPage(tab.ownerGlobal); - - info("Disable TP for the page (which reloads the page)"); - let tabReloadPromise = promiseTabLoadEvent(tab); - clickButton("#tracking-action-unblock"); - yield tabReloadPromise; - testTrackingPageUnblocked(); - - info("Re-enable TP for the page (which reloads the page)"); - tabReloadPromise = promiseTabLoadEvent(tab); - clickButton("#tracking-action-block"); - yield tabReloadPromise; - testTrackingPage(tab.ownerGlobal); -} - -add_task(function* testNormalBrowsing() { - yield UrlClassifierTestUtils.addTestTrackers(); - - tabbrowser = gBrowser; - let tab = tabbrowser.selectedTab = tabbrowser.addTab(); - - TrackingProtection = gBrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "TP is attached to the browser window"); - is(TrackingProtection.enabled, Services.prefs.getBoolPref(PREF), - "TP.enabled is based on the original pref value"); - - Services.prefs.setBoolPref(PREF, true); - ok(TrackingProtection.enabled, "TP is enabled after setting the pref"); - - yield testTrackingProtectionForTab(tab); - - Services.prefs.setBoolPref(PREF, false); - ok(!TrackingProtection.enabled, "TP is disabled after setting the pref"); -}); - -add_task(function* testPrivateBrowsing() { - let privateWin = yield promiseOpenAndLoadWindow({private: true}, true); - tabbrowser = privateWin.gBrowser; - let tab = tabbrowser.selectedTab = tabbrowser.addTab(); - - TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "TP is attached to the private window"); - is(TrackingProtection.enabled, Services.prefs.getBoolPref(PB_PREF), - "TP.enabled is based on the pb pref value"); - - Services.prefs.setBoolPref(PB_PREF, true); - ok(TrackingProtection.enabled, "TP is enabled after setting the pref"); - - yield testTrackingProtectionForTab(tab); - - Services.prefs.setBoolPref(PB_PREF, false); - ok(!TrackingProtection.enabled, "TP is disabled after setting the pref"); - - privateWin.close(); -}); diff --git a/browser/base/content/test/general/browser_trackingUI_2.js b/browser/base/content/test/general/browser_trackingUI_2.js deleted file mode 100644 index 96ccb6c2e..000000000 --- a/browser/base/content/test/general/browser_trackingUI_2.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Test that the Tracking Protection section is never visible in the - * Control Center when the feature is off. - * See also Bugs 1175327, 1043801, 1178985. - */ - -var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; -const PREF = "privacy.trackingprotection.enabled"; -const PB_PREF = "privacy.trackingprotection.pbmode.enabled"; -const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/benignPage.html"; -const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html"; -var TrackingProtection = null; -var tabbrowser = null; - -var {UrlClassifierTestUtils} = Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm", {}); - -registerCleanupFunction(function() { - TrackingProtection = tabbrowser = null; - UrlClassifierTestUtils.cleanupTestTrackers(); - Services.prefs.clearUserPref(PREF); - Services.prefs.clearUserPref(PB_PREF); - while (gBrowser.tabs.length > 1) { - gBrowser.removeCurrentTab(); - } -}); - -function hidden(el) { - let win = el.ownerGlobal; - let display = win.getComputedStyle(el).getPropertyValue("display", null); - let opacity = win.getComputedStyle(el).getPropertyValue("opacity", null); - - return display === "none" || opacity === "0"; -} - -add_task(function* testNormalBrowsing() { - yield UrlClassifierTestUtils.addTestTrackers(); - - tabbrowser = gBrowser; - let {gIdentityHandler} = tabbrowser.ownerGlobal; - let tab = tabbrowser.selectedTab = tabbrowser.addTab(); - - TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "TP is attached to the browser window"); - is(TrackingProtection.enabled, Services.prefs.getBoolPref(PREF), - "TP.enabled is based on the original pref value"); - - Services.prefs.setBoolPref(PREF, true); - ok(TrackingProtection.enabled, "TP is enabled after setting the pref"); - - Services.prefs.setBoolPref(PREF, false); - ok(!TrackingProtection.enabled, "TP is disabled after setting the pref"); - - info("Load a test page containing tracking elements"); - yield promiseTabLoadEvent(tab, TRACKING_PAGE); - gIdentityHandler._identityBox.click(); - ok(hidden(TrackingProtection.container), "The container is hidden"); - gIdentityHandler._identityPopup.hidden = true; - - info("Load a test page not containing tracking elements"); - yield promiseTabLoadEvent(tab, BENIGN_PAGE); - gIdentityHandler._identityBox.click(); - ok(hidden(TrackingProtection.container), "The container is hidden"); - gIdentityHandler._identityPopup.hidden = true; -}); - -add_task(function* testPrivateBrowsing() { - let privateWin = yield promiseOpenAndLoadWindow({private: true}, true); - tabbrowser = privateWin.gBrowser; - let {gIdentityHandler} = tabbrowser.ownerGlobal; - let tab = tabbrowser.selectedTab = tabbrowser.addTab(); - - TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "TP is attached to the private window"); - is(TrackingProtection.enabled, Services.prefs.getBoolPref(PB_PREF), - "TP.enabled is based on the pb pref value"); - - Services.prefs.setBoolPref(PB_PREF, true); - ok(TrackingProtection.enabled, "TP is enabled after setting the pref"); - - Services.prefs.setBoolPref(PB_PREF, false); - ok(!TrackingProtection.enabled, "TP is disabled after setting the pref"); - - info("Load a test page containing tracking elements"); - yield promiseTabLoadEvent(tab, TRACKING_PAGE); - gIdentityHandler._identityBox.click(); - ok(hidden(TrackingProtection.container), "The container is hidden"); - gIdentityHandler._identityPopup.hidden = true; - - info("Load a test page not containing tracking elements"); - gIdentityHandler._identityBox.click(); - yield promiseTabLoadEvent(tab, BENIGN_PAGE); - ok(hidden(TrackingProtection.container), "The container is hidden"); - gIdentityHandler._identityPopup.hidden = true; - - privateWin.close(); -}); diff --git a/browser/base/content/test/general/browser_trackingUI_3.js b/browser/base/content/test/general/browser_trackingUI_3.js deleted file mode 100644 index 63f8a13bc..000000000 --- a/browser/base/content/test/general/browser_trackingUI_3.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Test that the Tracking Protection is correctly enabled / disabled - * in both normal and private windows given all possible states of the prefs: - * privacy.trackingprotection.enabled - * privacy.trackingprotection.pbmode.enabled - * See also Bug 1178985. - */ - -const PREF = "privacy.trackingprotection.enabled"; -const PB_PREF = "privacy.trackingprotection.pbmode.enabled"; - -registerCleanupFunction(function() { - Services.prefs.clearUserPref(PREF); - Services.prefs.clearUserPref(PB_PREF); -}); - -add_task(function* testNormalBrowsing() { - let TrackingProtection = gBrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "TP is attached to the browser window"); - - Services.prefs.setBoolPref(PREF, true); - Services.prefs.setBoolPref(PB_PREF, false); - ok(TrackingProtection.enabled, "TP is enabled (ENABLED=true,PB=false)"); - Services.prefs.setBoolPref(PB_PREF, true); - ok(TrackingProtection.enabled, "TP is enabled (ENABLED=true,PB=true)"); - - Services.prefs.setBoolPref(PREF, false); - Services.prefs.setBoolPref(PB_PREF, false); - ok(!TrackingProtection.enabled, "TP is disabled (ENABLED=false,PB=false)"); - Services.prefs.setBoolPref(PB_PREF, true); - ok(!TrackingProtection.enabled, "TP is disabled (ENABLED=false,PB=true)"); -}); - -add_task(function* testPrivateBrowsing() { - let privateWin = yield promiseOpenAndLoadWindow({private: true}, true); - let TrackingProtection = privateWin.gBrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "TP is attached to the browser window"); - - Services.prefs.setBoolPref(PREF, true); - Services.prefs.setBoolPref(PB_PREF, false); - ok(TrackingProtection.enabled, "TP is enabled (ENABLED=true,PB=false)"); - Services.prefs.setBoolPref(PB_PREF, true); - ok(TrackingProtection.enabled, "TP is enabled (ENABLED=true,PB=true)"); - - Services.prefs.setBoolPref(PREF, false); - Services.prefs.setBoolPref(PB_PREF, false); - ok(!TrackingProtection.enabled, "TP is disabled (ENABLED=false,PB=false)"); - Services.prefs.setBoolPref(PB_PREF, true); - ok(TrackingProtection.enabled, "TP is enabled (ENABLED=false,PB=true)"); - - privateWin.close(); -}); diff --git a/browser/base/content/test/general/browser_trackingUI_4.js b/browser/base/content/test/general/browser_trackingUI_4.js deleted file mode 100644 index 93a06913e..000000000 --- a/browser/base/content/test/general/browser_trackingUI_4.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Test that the Tracking Protection icon is properly animated in the identity - * block when loading tabs and switching between tabs. - * See also Bug 1175858. - */ - -var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; -const PREF = "privacy.trackingprotection.enabled"; -const PB_PREF = "privacy.trackingprotection.pbmode.enabled"; -const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/benignPage.html"; -const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html"; -var TrackingProtection = null; -var tabbrowser = null; - -var {UrlClassifierTestUtils} = Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm", {}); - -registerCleanupFunction(function() { - TrackingProtection = tabbrowser = null; - UrlClassifierTestUtils.cleanupTestTrackers(); - Services.prefs.clearUserPref(PREF); - Services.prefs.clearUserPref(PB_PREF); - while (gBrowser.tabs.length > 1) { - gBrowser.removeCurrentTab(); - } -}); - -function waitForSecurityChange(numChanges = 1) { - return new Promise(resolve => { - let n = 0; - let listener = { - onSecurityChange: function() { - n = n + 1; - info ("Received onSecurityChange event " + n + " of " + numChanges); - if (n >= numChanges) { - tabbrowser.removeProgressListener(listener); - resolve(); - } - } - }; - tabbrowser.addProgressListener(listener); - }); -} - -function* testTrackingProtectionAnimation() { - info("Load a test page not containing tracking elements"); - let benignTab = yield BrowserTestUtils.openNewForegroundTab(tabbrowser, BENIGN_PAGE); - - ok(!TrackingProtection.icon.hasAttribute("state"), "icon: no state"); - ok(TrackingProtection.icon.hasAttribute("animate"), "icon: animate"); - - info("Load a test page containing tracking elements"); - let trackingTab = yield BrowserTestUtils.openNewForegroundTab(tabbrowser, TRACKING_PAGE); - - ok(TrackingProtection.icon.hasAttribute("state"), "icon: state"); - ok(TrackingProtection.icon.hasAttribute("animate"), "icon: animate"); - - info("Switch from tracking -> benign tab"); - let securityChanged = waitForSecurityChange(); - tabbrowser.selectedTab = benignTab; - yield securityChanged; - - ok(!TrackingProtection.icon.hasAttribute("state"), "icon: no state"); - ok(!TrackingProtection.icon.hasAttribute("animate"), "icon: no animate"); - - info("Switch from benign -> tracking tab"); - securityChanged = waitForSecurityChange(); - tabbrowser.selectedTab = trackingTab; - yield securityChanged; - - ok(TrackingProtection.icon.hasAttribute("state"), "icon: state"); - ok(!TrackingProtection.icon.hasAttribute("animate"), "icon: no animate"); - - info("Reload tracking tab"); - securityChanged = waitForSecurityChange(2); - tabbrowser.reload(); - yield securityChanged; - - ok(TrackingProtection.icon.hasAttribute("state"), "icon: state"); - ok(TrackingProtection.icon.hasAttribute("animate"), "icon: animate"); -} - -add_task(function* testNormalBrowsing() { - yield UrlClassifierTestUtils.addTestTrackers(); - - tabbrowser = gBrowser; - - TrackingProtection = gBrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "TP is attached to the browser window"); - - Services.prefs.setBoolPref(PREF, true); - ok(TrackingProtection.enabled, "TP is enabled after setting the pref"); - - yield testTrackingProtectionAnimation(); -}); - -add_task(function* testPrivateBrowsing() { - let privateWin = yield promiseOpenAndLoadWindow({private: true}, true); - tabbrowser = privateWin.gBrowser; - - TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "TP is attached to the private window"); - - Services.prefs.setBoolPref(PB_PREF, true); - ok(TrackingProtection.enabled, "TP is enabled after setting the pref"); - - yield testTrackingProtectionAnimation(); - - privateWin.close(); -}); diff --git a/browser/base/content/test/general/browser_trackingUI_5.js b/browser/base/content/test/general/browser_trackingUI_5.js deleted file mode 100644 index 23164a5b2..000000000 --- a/browser/base/content/test/general/browser_trackingUI_5.js +++ /dev/null @@ -1,131 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Test that sites added to the Tracking Protection whitelist in private -// browsing mode don't persist once the private browsing window closes. - -const PB_PREF = "privacy.trackingprotection.pbmode.enabled"; -const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html"; -var TrackingProtection = null; -var browser = null; -var {UrlClassifierTestUtils} = Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm", {}); - -registerCleanupFunction(function() { - TrackingProtection = browser = null; - UrlClassifierTestUtils.cleanupTestTrackers(); -}); - -function hidden(sel) { - let win = browser.ownerGlobal; - let el = win.document.querySelector(sel); - let display = win.getComputedStyle(el).getPropertyValue("display", null); - return display === "none"; -} - -function identityPopupState() { - let win = browser.ownerGlobal; - return win.document.getElementById("identity-popup").state; -} - -function clickButton(sel) { - let win = browser.ownerGlobal; - let el = win.document.querySelector(sel); - el.doCommand(); -} - -function testTrackingPage(window) { - info("Tracking content must be blocked"); - ok(!TrackingProtection.container.hidden, "The container is visible"); - is(TrackingProtection.content.getAttribute("state"), "blocked-tracking-content", - 'content: state="blocked-tracking-content"'); - is(TrackingProtection.icon.getAttribute("state"), "blocked-tracking-content", - 'icon: state="blocked-tracking-content"'); - - ok(!hidden("#tracking-protection-icon"), "icon is visible"); - ok(hidden("#tracking-action-block"), "blockButton is hidden"); - - ok(hidden("#tracking-action-unblock"), "unblockButton is hidden"); - ok(!hidden("#tracking-action-unblock-private"), "unblockButtonPrivate is visible"); - - // Make sure that the blocked tracking elements message appears - ok(hidden("#tracking-not-detected"), "labelNoTracking is hidden"); - ok(hidden("#tracking-loaded"), "labelTrackingLoaded is hidden"); - ok(!hidden("#tracking-blocked"), "labelTrackingBlocked is visible"); -} - -function testTrackingPageUnblocked() { - info("Tracking content must be white-listed and not blocked"); - ok(!TrackingProtection.container.hidden, "The container is visible"); - is(TrackingProtection.content.getAttribute("state"), "loaded-tracking-content", - 'content: state="loaded-tracking-content"'); - is(TrackingProtection.icon.getAttribute("state"), "loaded-tracking-content", - 'icon: state="loaded-tracking-content"'); - - ok(!hidden("#tracking-protection-icon"), "icon is visible"); - ok(!hidden("#tracking-action-block"), "blockButton is visible"); - ok(hidden("#tracking-action-unblock"), "unblockButton is hidden"); - - // Make sure that the blocked tracking elements message appears - ok(hidden("#tracking-not-detected"), "labelNoTracking is hidden"); - ok(!hidden("#tracking-loaded"), "labelTrackingLoaded is visible"); - ok(hidden("#tracking-blocked"), "labelTrackingBlocked is hidden"); -} - -add_task(function* testExceptionAddition() { - yield UrlClassifierTestUtils.addTestTrackers(); - let privateWin = yield promiseOpenAndLoadWindow({private: true}, true); - browser = privateWin.gBrowser; - let tab = browser.selectedTab = browser.addTab(); - - TrackingProtection = browser.ownerGlobal.TrackingProtection; - yield pushPrefs([PB_PREF, true]); - - ok(TrackingProtection.enabled, "TP is enabled after setting the pref"); - - info("Load a test page containing tracking elements"); - yield promiseTabLoadEvent(tab, TRACKING_PAGE); - - testTrackingPage(tab.ownerGlobal); - - info("Disable TP for the page (which reloads the page)"); - let tabReloadPromise = promiseTabLoadEvent(tab); - clickButton("#tracking-action-unblock"); - is(identityPopupState(), "closed", "foobar"); - - yield tabReloadPromise; - testTrackingPageUnblocked(); - - info("Test that the exception is remembered across tabs in the same private window"); - tab = browser.selectedTab = browser.addTab(); - - info("Load a test page containing tracking elements"); - yield promiseTabLoadEvent(tab, TRACKING_PAGE); - testTrackingPageUnblocked(); - - yield promiseWindowClosed(privateWin); -}); - -add_task(function* testExceptionPersistence() { - info("Open another private browsing window"); - let privateWin = yield promiseOpenAndLoadWindow({private: true}, true); - browser = privateWin.gBrowser; - let tab = browser.selectedTab = browser.addTab(); - - TrackingProtection = browser.ownerGlobal.TrackingProtection; - ok(TrackingProtection.enabled, "TP is still enabled"); - - info("Load a test page containing tracking elements"); - yield promiseTabLoadEvent(tab, TRACKING_PAGE); - - testTrackingPage(tab.ownerGlobal); - - info("Disable TP for the page (which reloads the page)"); - let tabReloadPromise = promiseTabLoadEvent(tab); - clickButton("#tracking-action-unblock"); - is(identityPopupState(), "closed", "foobar"); - - yield tabReloadPromise; - testTrackingPageUnblocked(); - - privateWin.close(); -}); diff --git a/browser/base/content/test/general/browser_trackingUI_6.js b/browser/base/content/test/general/browser_trackingUI_6.js deleted file mode 100644 index be91bc4a0..000000000 --- a/browser/base/content/test/general/browser_trackingUI_6.js +++ /dev/null @@ -1,46 +0,0 @@ -const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/file_trackingUI_6.html"; - -function waitForSecurityChange(numChanges = 1) { - return new Promise(resolve => { - let n = 0; - let listener = { - onSecurityChange: function() { - n = n + 1; - info ("Received onSecurityChange event " + n + " of " + numChanges); - if (n >= numChanges) { - gBrowser.removeProgressListener(listener); - resolve(); - } - } - }; - gBrowser.addProgressListener(listener); - }); -} - -add_task(function* test_fetch() { - yield new Promise(resolve => { - SpecialPowers.pushPrefEnv({ set: [['privacy.trackingprotection.enabled', true]] }, - resolve); - }); - - yield BrowserTestUtils.withNewTab({ gBrowser, url: URL }, function* (newTabBrowser) { - let securityChange = waitForSecurityChange(); - yield ContentTask.spawn(newTabBrowser, null, function* () { - yield content.wrappedJSObject.test_fetch() - .then(response => Assert.ok(false, "should have denied the request")) - .catch(e => Assert.ok(true, `Caught exception: ${e}`)); - }); - yield securityChange; - - var TrackingProtection = newTabBrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "got TP object"); - ok(TrackingProtection.enabled, "TP is enabled"); - - is(TrackingProtection.content.getAttribute("state"), "blocked-tracking-content", - 'content: state="blocked-tracking-content"'); - is(TrackingProtection.icon.getAttribute("state"), "blocked-tracking-content", - 'icon: state="blocked-tracking-content"'); - is(TrackingProtection.icon.getAttribute("tooltiptext"), - gNavigatorBundle.getString("trackingProtection.icon.activeTooltip"), "correct tooltip"); - }); -}); diff --git a/browser/base/content/test/general/browser_trackingUI_telemetry.js b/browser/base/content/test/general/browser_trackingUI_telemetry.js deleted file mode 100644 index d9fce18d4..000000000 --- a/browser/base/content/test/general/browser_trackingUI_telemetry.js +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Test telemetry for Tracking Protection - */ - -var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; -const PREF = "privacy.trackingprotection.enabled"; -const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/benignPage.html"; -const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html"; -const {UrlClassifierTestUtils} = Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm", {}); - -/** - * Enable local telemetry recording for the duration of the tests. - */ -var oldCanRecord = Services.telemetry.canRecordExtended; -Services.telemetry.canRecordExtended = true; -Services.prefs.setBoolPref(PREF, false); -Services.telemetry.getHistogramById("TRACKING_PROTECTION_ENABLED").clear(); -registerCleanupFunction(function () { - UrlClassifierTestUtils.cleanupTestTrackers(); - Services.telemetry.canRecordExtended = oldCanRecord; - Services.prefs.clearUserPref(PREF); -}); - -function getShieldHistogram() { - return Services.telemetry.getHistogramById("TRACKING_PROTECTION_SHIELD"); -} - -function getEnabledHistogram() { - return Services.telemetry.getHistogramById("TRACKING_PROTECTION_ENABLED"); -} - -function getEventsHistogram() { - return Services.telemetry.getHistogramById("TRACKING_PROTECTION_EVENTS"); -} - -function getShieldCounts() { - return getShieldHistogram().snapshot().counts; -} - -function getEnabledCounts() { - return getEnabledHistogram().snapshot().counts; -} - -function getEventCounts() { - return getEventsHistogram().snapshot().counts; -} - -add_task(function* setup() { - yield UrlClassifierTestUtils.addTestTrackers(); - - let TrackingProtection = gBrowser.ownerGlobal.TrackingProtection; - ok(TrackingProtection, "TP is attached to the browser window"); - ok(!TrackingProtection.enabled, "TP is not enabled"); - - // Open a window with TP disabled to make sure 'enabled' is logged correctly. - let newWin = yield promiseOpenAndLoadWindow({}, true); - yield promiseWindowClosed(newWin); - - is(getEnabledCounts()[0], 1, "TP was disabled once on start up"); - is(getEnabledCounts()[1], 0, "TP was not enabled on start up"); - - // Enable TP so the next browser to open will log 'enabled' - Services.prefs.setBoolPref(PREF, true); -}); - - -add_task(function* testNewWindow() { - let newWin = yield promiseOpenAndLoadWindow({}, true); - let tab = newWin.gBrowser.selectedTab = newWin.gBrowser.addTab(); - let TrackingProtection = newWin.TrackingProtection; - ok(TrackingProtection, "TP is attached to the browser window"); - - is(getEnabledCounts()[0], 1, "TP was disabled once on start up"); - is(getEnabledCounts()[1], 1, "TP was enabled once on start up"); - - // Reset these to make counting easier - getEventsHistogram().clear(); - getShieldHistogram().clear(); - - yield promiseTabLoadEvent(tab, BENIGN_PAGE); - is(getEventCounts()[0], 1, "Total page loads"); - is(getEventCounts()[1], 0, "Disable actions"); - is(getEventCounts()[2], 0, "Enable actions"); - is(getShieldCounts()[0], 1, "Page loads without tracking"); - - yield promiseTabLoadEvent(tab, TRACKING_PAGE); - // Note that right now the events and shield histogram is not measuring what - // you might think. Since onSecurityChange fires twice for a tracking page, - // the total page loads count is double counting, and the shield count - // (which is meant to measure times when the shield wasn't shown) fires even - // when tracking elements exist on the page. - todo_is(getEventCounts()[0], 2, "FIXME: TOTAL PAGE LOADS IS DOUBLE COUNTING"); - is(getEventCounts()[1], 0, "Disable actions"); - is(getEventCounts()[2], 0, "Enable actions"); - todo_is(getShieldCounts()[0], 1, "FIXME: TOTAL PAGE LOADS WITHOUT TRACKING IS DOUBLE COUNTING"); - - info("Disable TP for the page (which reloads the page)"); - let tabReloadPromise = promiseTabLoadEvent(tab); - newWin.document.querySelector("#tracking-action-unblock").doCommand(); - yield tabReloadPromise; - todo_is(getEventCounts()[0], 3, "FIXME: TOTAL PAGE LOADS IS DOUBLE COUNTING"); - is(getEventCounts()[1], 1, "Disable actions"); - is(getEventCounts()[2], 0, "Enable actions"); - todo_is(getShieldCounts()[0], 1, "FIXME: TOTAL PAGE LOADS WITHOUT TRACKING IS DOUBLE COUNTING"); - - info("Re-enable TP for the page (which reloads the page)"); - tabReloadPromise = promiseTabLoadEvent(tab); - newWin.document.querySelector("#tracking-action-block").doCommand(); - yield tabReloadPromise; - todo_is(getEventCounts()[0], 4, "FIXME: TOTAL PAGE LOADS IS DOUBLE COUNTING"); - is(getEventCounts()[1], 1, "Disable actions"); - is(getEventCounts()[2], 1, "Enable actions"); - todo_is(getShieldCounts()[0], 1, "FIXME: TOTAL PAGE LOADS WITHOUT TRACKING IS DOUBLE COUNTING"); - - yield promiseWindowClosed(newWin); - - // Reset these to make counting easier for the next test - getEventsHistogram().clear(); - getShieldHistogram().clear(); - getEnabledHistogram().clear(); -}); - -add_task(function* testPrivateBrowsing() { - let privateWin = yield promiseOpenAndLoadWindow({private: true}, true); - let tab = privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab(); - let TrackingProtection = privateWin.TrackingProtection; - ok(TrackingProtection, "TP is attached to the browser window"); - - // Do a bunch of actions and make sure that no telemetry data is gathered - yield promiseTabLoadEvent(tab, BENIGN_PAGE); - yield promiseTabLoadEvent(tab, TRACKING_PAGE); - let tabReloadPromise = promiseTabLoadEvent(tab); - privateWin.document.querySelector("#tracking-action-unblock").doCommand(); - yield tabReloadPromise; - tabReloadPromise = promiseTabLoadEvent(tab); - privateWin.document.querySelector("#tracking-action-block").doCommand(); - yield tabReloadPromise; - - // Sum up all the counts to make sure that nothing got logged - is(getEnabledCounts().reduce((p, c) => p+c), 0, "Telemetry logging off in PB mode"); - is(getEventCounts().reduce((p, c) => p+c), 0, "Telemetry logging off in PB mode"); - is(getShieldCounts().reduce((p, c) => p+c), 0, "Telemetry logging off in PB mode"); - - yield promiseWindowClosed(privateWin); -}); diff --git a/browser/base/content/test/general/browser_typeAheadFind.js b/browser/base/content/test/general/browser_typeAheadFind.js deleted file mode 100644 index 1d550944a..000000000 --- a/browser/base/content/test/general/browser_typeAheadFind.js +++ /dev/null @@ -1,22 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -add_task(function *() { - let testWindow = yield BrowserTestUtils.openNewBrowserWindow(); - - testWindow.gBrowser.loadURI("data:text/html,<h1>A Page</h1>"); - yield BrowserTestUtils.browserLoaded(testWindow.gBrowser.selectedBrowser); - - yield SimpleTest.promiseFocus(testWindow.gBrowser.selectedBrowser); - - ok(!testWindow.gFindBarInitialized, "find bar is not initialized"); - - let findBarOpenPromise = promiseWaitForEvent(testWindow.gBrowser, "findbaropen"); - EventUtils.synthesizeKey("/", {}, testWindow); - yield findBarOpenPromise; - - ok(testWindow.gFindBarInitialized, "find bar is now initialized"); - - yield BrowserTestUtils.closeWindow(testWindow); -}); diff --git a/browser/base/content/test/general/browser_unknownContentType_title.js b/browser/base/content/test/general/browser_unknownContentType_title.js deleted file mode 100644 index 269406bdb..000000000 --- a/browser/base/content/test/general/browser_unknownContentType_title.js +++ /dev/null @@ -1,33 +0,0 @@ -const url = "data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Ctitle%3ETest%20Page%3C%2Ftitle%3E%3C%2Fhead%3E%3C%2Fhtml%3E"; -const unknown_url = "http://example.com/browser/browser/base/content/test/general/unknownContentType_file.pif"; - -function waitForNewWindow() { - return new Promise(resolve => { - let listener = (win) => { - Services.obs.removeObserver(listener, "toplevel-window-ready"); - win.addEventListener("load", () => { - resolve(win); - }); - }; - - Services.obs.addObserver(listener, "toplevel-window-ready", false) - }); -} - -add_task(function*() { - let tab = gBrowser.selectedTab = gBrowser.addTab(url); - let browser = tab.linkedBrowser; - yield promiseTabLoaded(gBrowser.selectedTab); - - is(gBrowser.contentTitle, "Test Page", "Should have the right title.") - - browser.loadURI(unknown_url); - let win = yield waitForNewWindow(); - is(win.location, "chrome://mozapps/content/downloads/unknownContentType.xul", - "Should have seen the unknown content dialog."); - is(gBrowser.contentTitle, "Test Page", "Should still have the right title.") - - win.close(); - yield promiseWaitForFocus(window); - gBrowser.removeCurrentTab(); -}); diff --git a/browser/base/content/test/general/browser_unloaddialogs.js b/browser/base/content/test/general/browser_unloaddialogs.js deleted file mode 100644 index bf3790b95..000000000 --- a/browser/base/content/test/general/browser_unloaddialogs.js +++ /dev/null @@ -1,41 +0,0 @@ -var testUrls = - [ - "data:text/html,<script>" + - "function handle(evt) {" + - "evt.target.removeEventListener(evt.type, handle, true);" + - "try { alert('This should NOT appear'); } catch(e) { }" + - "}" + - "window.addEventListener('pagehide', handle, true);" + - "window.addEventListener('beforeunload', handle, true);" + - "window.addEventListener('unload', handle, true);" + - "</script><body>Testing alert during pagehide/beforeunload/unload</body>", - "data:text/html,<script>" + - "function handle(evt) {" + - "evt.target.removeEventListener(evt.type, handle, true);" + - "try { prompt('This should NOT appear'); } catch(e) { }" + - "}" + - "window.addEventListener('pagehide', handle, true);" + - "window.addEventListener('beforeunload', handle, true);" + - "window.addEventListener('unload', handle, true);" + - "</script><body>Testing prompt during pagehide/beforeunload/unload</body>", - "data:text/html,<script>" + - "function handle(evt) {" + - "evt.target.removeEventListener(evt.type, handle, true);" + - "try { confirm('This should NOT appear'); } catch(e) { }" + - "}" + - "window.addEventListener('pagehide', handle, true);" + - "window.addEventListener('beforeunload', handle, true);" + - "window.addEventListener('unload', handle, true);" + - "</script><body>Testing confirm during pagehide/beforeunload/unload</body>", - ]; - -add_task(function*() { - for (let url of testUrls) { - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, url); - ok(true, "Loaded page " + url); - // Wait one turn of the event loop before closing, so everything settles. - yield new Promise(resolve => setTimeout(resolve, 0)); - yield BrowserTestUtils.removeTab(tab); - ok(true, "Closed page " + url + " without timeout"); - } -}); diff --git a/browser/base/content/test/general/browser_utilityOverlay.js b/browser/base/content/test/general/browser_utilityOverlay.js deleted file mode 100644 index 34adc00d9..000000000 --- a/browser/base/content/test/general/browser_utilityOverlay.js +++ /dev/null @@ -1,112 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -const gTests = [ - test_eventMatchesKey, - test_getTopWin, - test_getBoolPref, - test_openNewTabWith, - test_openUILink -]; - -function test () { - waitForExplicitFinish(); - executeSoon(runNextTest); -} - -function runNextTest() { - if (gTests.length) { - let testFun = gTests.shift(); - info("Running " + testFun.name); - testFun() - } - else { - finish(); - } -} - -function test_eventMatchesKey() { - let eventMatchResult; - let key; - let checkEvent = function(e) { - e.stopPropagation(); - e.preventDefault(); - eventMatchResult = eventMatchesKey(e, key); - } - document.addEventListener("keypress", checkEvent); - - try { - key = document.createElement("key"); - let keyset = document.getElementById("mainKeyset"); - key.setAttribute("key", "t"); - key.setAttribute("modifiers", "accel"); - keyset.appendChild(key); - EventUtils.synthesizeKey("t", {accelKey: true}); - is(eventMatchResult, true, "eventMatchesKey: one modifier"); - keyset.removeChild(key); - - key = document.createElement("key"); - key.setAttribute("key", "g"); - key.setAttribute("modifiers", "accel,shift"); - keyset.appendChild(key); - EventUtils.synthesizeKey("g", {accelKey: true, shiftKey: true}); - is(eventMatchResult, true, "eventMatchesKey: combination modifiers"); - keyset.removeChild(key); - - key = document.createElement("key"); - key.setAttribute("key", "w"); - key.setAttribute("modifiers", "accel"); - keyset.appendChild(key); - EventUtils.synthesizeKey("f", {accelKey: true}); - is(eventMatchResult, false, "eventMatchesKey: mismatch keys"); - keyset.removeChild(key); - - key = document.createElement("key"); - key.setAttribute("keycode", "VK_DELETE"); - keyset.appendChild(key); - EventUtils.synthesizeKey("VK_DELETE", {accelKey: true}); - is(eventMatchResult, false, "eventMatchesKey: mismatch modifiers"); - keyset.removeChild(key); - } finally { - // Make sure to remove the event listener so future tests don't - // fail when they simulate key presses. - document.removeEventListener("keypress", checkEvent); - } - - runNextTest(); -} - -function test_getTopWin() { - is(getTopWin(), window, "got top window"); - runNextTest(); -} - - -function test_getBoolPref() { - is(getBoolPref("browser.search.openintab", false), false, "getBoolPref"); - is(getBoolPref("this.pref.doesnt.exist", true), true, "getBoolPref fallback"); - is(getBoolPref("this.pref.doesnt.exist", false), false, "getBoolPref fallback #2"); - runNextTest(); -} - -function test_openNewTabWith() { - openNewTabWith("http://example.com/"); - let tab = gBrowser.selectedTab = gBrowser.tabs[1]; - BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => { - is(tab.linkedBrowser.currentURI.spec, "http://example.com/", "example.com loaded"); - gBrowser.removeCurrentTab(); - runNextTest(); - }); -} - -function test_openUILink() { - let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank"); - BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => { - is(tab.linkedBrowser.currentURI.spec, "http://example.org/", "example.org loaded"); - gBrowser.removeCurrentTab(); - runNextTest(); - }); - - openUILink("http://example.org/"); // defaults to "current" -} diff --git a/browser/base/content/test/general/browser_viewSourceInTabOnViewSource.js b/browser/base/content/test/general/browser_viewSourceInTabOnViewSource.js deleted file mode 100644 index c8f3cdc96..000000000 --- a/browser/base/content/test/general/browser_viewSourceInTabOnViewSource.js +++ /dev/null @@ -1,55 +0,0 @@ -function wait_while_tab_is_busy() { - return new Promise(resolve => { - let progressListener = { - onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) { - if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) { - gBrowser.removeProgressListener(this); - setTimeout(resolve, 0); - } - } - }; - gBrowser.addProgressListener(progressListener); - }); -} - -// This function waits for the tab to stop being busy instead of waiting for it -// to load, since the canViewSource change happens at that time. -var with_new_tab_opened = Task.async(function* (options, taskFn) { - let busyPromise = wait_while_tab_is_busy(); - let tab = yield BrowserTestUtils.openNewForegroundTab(options.gBrowser, options.url, false); - yield busyPromise; - yield taskFn(tab.linkedBrowser); - gBrowser.removeTab(tab); -}); - -add_task(function*() { - yield new Promise((resolve) => { - SpecialPowers.pushPrefEnv({"set": [ - ["view_source.tab", true], - ]}, resolve); - }); -}); - -add_task(function* test_regular_page() { - function* test_expect_view_source_enabled(browser) { - ok(!XULBrowserWindow.canViewSource.hasAttribute("disabled"), - "View Source should be enabled"); - } - - yield with_new_tab_opened({ - gBrowser, - url: "http://example.com", - }, test_expect_view_source_enabled); -}); - -add_task(function* test_view_source_page() { - function* test_expect_view_source_disabled(browser) { - ok(XULBrowserWindow.canViewSource.hasAttribute("disabled"), - "View Source should be disabled"); - } - - yield with_new_tab_opened({ - gBrowser, - url: "view-source:http://example.com", - }, test_expect_view_source_disabled); -}); diff --git a/browser/base/content/test/general/browser_visibleFindSelection.js b/browser/base/content/test/general/browser_visibleFindSelection.js deleted file mode 100644 index 630490644..000000000 --- a/browser/base/content/test/general/browser_visibleFindSelection.js +++ /dev/null @@ -1,52 +0,0 @@ -add_task(function*() { - const childContent = "<div style='position: absolute; left: 2200px; background: green; width: 200px; height: 200px;'>" + - "div</div><div style='position: absolute; left: 0px; background: red; width: 200px; height: 200px;'>" + - "<span id='s'>div</span></div>"; - - let tab = gBrowser.selectedTab = gBrowser.addTab(); - - yield promiseTabLoadEvent(tab, "data:text/html," + escape(childContent)); - yield SimpleTest.promiseFocus(gBrowser.selectedBrowser.contentWindowAsCPOW); - - let findBarOpenPromise = promiseWaitForEvent(gBrowser, "findbaropen"); - EventUtils.synthesizeKey("f", { accelKey: true }); - yield findBarOpenPromise; - - ok(gFindBarInitialized, "find bar is now initialized"); - - // Finds the div in the green box. - let scrollPromise = promiseWaitForEvent(gBrowser, "scroll"); - EventUtils.synthesizeKey("d", {}); - EventUtils.synthesizeKey("i", {}); - EventUtils.synthesizeKey("v", {}); - yield scrollPromise; - - // Wait for one paint to ensure we've processed the previous key events and scrolling. - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () { - return new Promise( - resolve => { - content.requestAnimationFrame(() => { - setTimeout(resolve, 0); - }); - } - ); - }); - - // Finds the div in the red box. - scrollPromise = promiseWaitForEvent(gBrowser, "scroll"); - EventUtils.synthesizeKey("g", { accelKey: true }); - yield scrollPromise; - - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () { - Assert.ok(content.document.getElementById("s").getBoundingClientRect().left >= 0, - "scroll should include find result"); - }); - - // clear the find bar - EventUtils.synthesizeKey("a", { accelKey: true }); - EventUtils.synthesizeKey("VK_DELETE", { }); - - gFindBar.close(); - gBrowser.removeCurrentTab(); -}); - diff --git a/browser/base/content/test/general/browser_visibleTabs.js b/browser/base/content/test/general/browser_visibleTabs.js deleted file mode 100644 index e9130bc18..000000000 --- a/browser/base/content/test/general/browser_visibleTabs.js +++ /dev/null @@ -1,97 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -"use strict"; - -add_task(function* () { - // There should be one tab when we start the test - let [origTab] = gBrowser.visibleTabs; - - // Add a tab that will get pinned - let pinned = gBrowser.addTab(); - gBrowser.pinTab(pinned); - - let testTab = gBrowser.addTab(); - - let visible = gBrowser.visibleTabs; - is(visible.length, 3, "3 tabs should be open"); - is(visible[0], pinned, "the pinned tab is first"); - is(visible[1], origTab, "original tab is next"); - is(visible[2], testTab, "last created tab is last"); - - // Only show the test tab (but also get pinned and selected) - is(gBrowser.selectedTab, origTab, "sanity check that we're on the original tab"); - gBrowser.showOnlyTheseTabs([testTab]); - is(gBrowser.visibleTabs.length, 3, "all 3 tabs are still visible"); - - // Select the test tab and only show that (and pinned) - gBrowser.selectedTab = testTab; - gBrowser.showOnlyTheseTabs([testTab]); - - visible = gBrowser.visibleTabs; - is(visible.length, 2, "2 tabs should be visible including the pinned"); - is(visible[0], pinned, "first is pinned"); - is(visible[1], testTab, "next is the test tab"); - is(gBrowser.tabs.length, 3, "3 tabs should still be open"); - - gBrowser.selectTabAtIndex(1); - is(gBrowser.selectedTab, testTab, "second tab is the test tab"); - gBrowser.selectTabAtIndex(0); - is(gBrowser.selectedTab, pinned, "first tab is pinned"); - gBrowser.selectTabAtIndex(2); - is(gBrowser.selectedTab, testTab, "no third tab, so no change"); - gBrowser.selectTabAtIndex(0); - is(gBrowser.selectedTab, pinned, "switch back to the pinned"); - gBrowser.selectTabAtIndex(2); - is(gBrowser.selectedTab, testTab, "no third tab, so select last tab"); - gBrowser.selectTabAtIndex(-2); - is(gBrowser.selectedTab, pinned, "pinned tab is second from left (when orig tab is hidden)"); - gBrowser.selectTabAtIndex(-1); - is(gBrowser.selectedTab, testTab, "last tab is the test tab"); - - gBrowser.tabContainer.advanceSelectedTab(1, true); - is(gBrowser.selectedTab, pinned, "wrapped around the end to pinned"); - gBrowser.tabContainer.advanceSelectedTab(1, true); - is(gBrowser.selectedTab, testTab, "next to test tab"); - gBrowser.tabContainer.advanceSelectedTab(1, true); - is(gBrowser.selectedTab, pinned, "next to pinned again"); - - gBrowser.tabContainer.advanceSelectedTab(-1, true); - is(gBrowser.selectedTab, testTab, "going backwards to last tab"); - gBrowser.tabContainer.advanceSelectedTab(-1, true); - is(gBrowser.selectedTab, pinned, "next to pinned"); - gBrowser.tabContainer.advanceSelectedTab(-1, true); - is(gBrowser.selectedTab, testTab, "next to test tab again"); - - // Try showing all tabs - gBrowser.showOnlyTheseTabs(Array.slice(gBrowser.tabs)); - is(gBrowser.visibleTabs.length, 3, "all 3 tabs are visible again"); - - // Select the pinned tab and show the testTab to make sure selection updates - gBrowser.selectedTab = pinned; - gBrowser.showOnlyTheseTabs([testTab]); - is(gBrowser.tabs[1], origTab, "make sure origTab is in the middle"); - is(origTab.hidden, true, "make sure it's hidden"); - gBrowser.removeTab(pinned); - is(gBrowser.selectedTab, testTab, "making sure origTab was skipped"); - is(gBrowser.visibleTabs.length, 1, "only testTab is there"); - - // Only show one of the non-pinned tabs (but testTab is selected) - gBrowser.showOnlyTheseTabs([origTab]); - is(gBrowser.visibleTabs.length, 2, "got 2 tabs"); - - // Now really only show one of the tabs - gBrowser.showOnlyTheseTabs([testTab]); - visible = gBrowser.visibleTabs; - is(visible.length, 1, "only the original tab is visible"); - is(visible[0], testTab, "it's the original tab"); - is(gBrowser.tabs.length, 2, "still have 2 open tabs"); - - // Close the last visible tab and make sure we still get a visible tab - gBrowser.removeTab(testTab); - is(gBrowser.visibleTabs.length, 1, "only orig is left and visible"); - is(gBrowser.tabs.length, 1, "sanity check that it matches"); - is(gBrowser.selectedTab, origTab, "got the orig tab"); - is(origTab.hidden, false, "and it's not hidden -- visible!"); -}); diff --git a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js deleted file mode 100644 index 827f86c05..000000000 --- a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js +++ /dev/null @@ -1,34 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - waitForExplicitFinish(); - - let tabOne = gBrowser.addTab("about:blank"); - let tabTwo = gBrowser.addTab("http://mochi.test:8888/"); - gBrowser.selectedTab = tabTwo; - - let browser = gBrowser.getBrowserForTab(tabTwo); - let onLoad = function() { - browser.removeEventListener("load", onLoad, true); - - gBrowser.showOnlyTheseTabs([tabTwo]); - - is(gBrowser.visibleTabs.length, 1, "Only one tab is visible"); - - let uris = PlacesCommandHook.uniqueCurrentPages; - is(uris.length, 1, "Only one uri is returned"); - - is(uris[0].uri.spec, tabTwo.linkedBrowser.currentURI.spec, "It's the correct URI"); - - gBrowser.removeTab(tabOne); - gBrowser.removeTab(tabTwo); - Array.forEach(gBrowser.tabs, function(tab) { - gBrowser.showTab(tab); - }); - - finish(); - } - browser.addEventListener("load", onLoad, true); -} diff --git a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.js b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.js deleted file mode 100644 index 0a0ea87bd..000000000 --- a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.js +++ /dev/null @@ -1,66 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -function test() { - waitForExplicitFinish(); - - // There should be one tab when we start the test - let [origTab] = gBrowser.visibleTabs; - is(gBrowser.visibleTabs.length, 1, "1 tab should be open"); - is(Disabled(), true, "Bookmark All Tabs should be disabled"); - - // Add a tab - let testTab1 = gBrowser.addTab(); - is(gBrowser.visibleTabs.length, 2, "2 tabs should be open"); - is(Disabled(), true, "Bookmark All Tabs should be disabled since there are two tabs with the same address"); - - let testTab2 = gBrowser.addTab("about:mozilla"); - is(gBrowser.visibleTabs.length, 3, "3 tabs should be open"); - // Wait for tab load, the code checks for currentURI. - testTab2.linkedBrowser.addEventListener("load", function () { - testTab2.linkedBrowser.removeEventListener("load", arguments.callee, true); - is(Disabled(), false, "Bookmark All Tabs should be enabled since there are two tabs with different addresses"); - - // Hide the original tab - gBrowser.selectedTab = testTab2; - gBrowser.showOnlyTheseTabs([testTab2]); - is(gBrowser.visibleTabs.length, 1, "1 tab should be visible"); - is(Disabled(), true, "Bookmark All Tabs should be disabled as there is only one visible tab"); - - // Add a tab that will get pinned - let pinned = gBrowser.addTab(); - is(gBrowser.visibleTabs.length, 2, "2 tabs should be visible now"); - is(Disabled(), false, "Bookmark All Tabs should be available as there are two visible tabs"); - gBrowser.pinTab(pinned); - is(Hidden(), false, "Bookmark All Tabs should be visible on a normal tab"); - is(Disabled(), true, "Bookmark All Tabs should not be available since one tab is pinned"); - gBrowser.selectedTab = pinned; - is(Hidden(), true, "Bookmark All Tabs should be hidden on a pinned tab"); - - // Show all tabs - let allTabs = Array.from(gBrowser.tabs); - gBrowser.showOnlyTheseTabs(allTabs); - - // reset the environment - gBrowser.removeTab(testTab2); - gBrowser.removeTab(testTab1); - gBrowser.removeTab(pinned); - is(gBrowser.visibleTabs.length, 1, "only orig is left and visible"); - is(gBrowser.tabs.length, 1, "sanity check that it matches"); - is(Disabled(), true, "Bookmark All Tabs should be hidden"); - is(gBrowser.selectedTab, origTab, "got the orig tab"); - is(origTab.hidden, false, "and it's not hidden -- visible!"); - finish(); - }, true); -} - -function Disabled() { - updateTabContextMenu(); - return document.getElementById("Browser:BookmarkAllTabs").getAttribute("disabled") == "true"; -} - -function Hidden() { - updateTabContextMenu(); - return document.getElementById("context_bookmarkAllTabs").hidden; -} diff --git a/browser/base/content/test/general/browser_visibleTabs_contextMenu.js b/browser/base/content/test/general/browser_visibleTabs_contextMenu.js deleted file mode 100644 index 4fdab3d8a..000000000 --- a/browser/base/content/test/general/browser_visibleTabs_contextMenu.js +++ /dev/null @@ -1,72 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -const remoteClientsFixture = [ { id: 1, name: "Foo"}, { id: 2, name: "Bar"} ]; - -add_task(function* test() { - // There should be one tab when we start the test - let [origTab] = gBrowser.visibleTabs; - is(gBrowser.visibleTabs.length, 1, "there is one visible tab"); - let testTab = gBrowser.addTab(); - is(gBrowser.visibleTabs.length, 2, "there are now two visible tabs"); - - // Check the context menu with two tabs - updateTabContextMenu(origTab); - is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled"); - is(document.getElementById("context_reloadAllTabs").disabled, false, "Reload All Tabs is enabled"); - - - if (gFxAccounts.sendTabToDeviceEnabled) { - // Check the send tab to device menu item - const oldGetter = setupRemoteClientsFixture(remoteClientsFixture); - yield updateTabContextMenu(origTab, function* () { - yield openMenuItemSubmenu("context_sendTabToDevice"); - }); - is(document.getElementById("context_sendTabToDevice").hidden, false, "Send tab to device is shown"); - let targets = document.getElementById("context_sendTabToDevicePopupMenu").childNodes; - is(targets[0].getAttribute("label"), "Foo", "Foo target is present"); - is(targets[1].getAttribute("label"), "Bar", "Bar target is present"); - is(targets[3].getAttribute("label"), "All Devices", "All Devices target is present"); - restoreRemoteClients(oldGetter); - } - - // Hide the original tab. - gBrowser.selectedTab = testTab; - gBrowser.showOnlyTheseTabs([testTab]); - is(gBrowser.visibleTabs.length, 1, "now there is only one visible tab"); - - // Check the context menu with one tab. - updateTabContextMenu(testTab); - is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled when more than one tab exists"); - is(document.getElementById("context_reloadAllTabs").disabled, true, "Reload All Tabs is disabled"); - - // Add a tab that will get pinned - // So now there's one pinned tab, one visible unpinned tab, and one hidden tab - let pinned = gBrowser.addTab(); - gBrowser.pinTab(pinned); - is(gBrowser.visibleTabs.length, 2, "now there are two visible tabs"); - - // Check the context menu on the unpinned visible tab - updateTabContextMenu(testTab); - is(document.getElementById("context_closeOtherTabs").disabled, true, "Close Other Tabs is disabled"); - is(document.getElementById("context_closeTabsToTheEnd").disabled, true, "Close Tabs To The End is disabled"); - - // Show all tabs - let allTabs = Array.from(gBrowser.tabs); - gBrowser.showOnlyTheseTabs(allTabs); - - // Check the context menu now - updateTabContextMenu(testTab); - is(document.getElementById("context_closeOtherTabs").disabled, false, "Close Other Tabs is enabled"); - is(document.getElementById("context_closeTabsToTheEnd").disabled, true, "Close Tabs To The End is disabled"); - - // Check the context menu of the original tab - // Close Tabs To The End should now be enabled - updateTabContextMenu(origTab); - is(document.getElementById("context_closeTabsToTheEnd").disabled, false, "Close Tabs To The End is enabled"); - - gBrowser.removeTab(testTab); - gBrowser.removeTab(pinned); -}); - diff --git a/browser/base/content/test/general/browser_visibleTabs_tabPreview.js b/browser/base/content/test/general/browser_visibleTabs_tabPreview.js deleted file mode 100644 index 7ce4b143f..000000000 --- a/browser/base/content/test/general/browser_visibleTabs_tabPreview.js +++ /dev/null @@ -1,41 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -add_task(function* test() { - gPrefService.setBoolPref("browser.ctrlTab.previews", true); - - let [origTab] = gBrowser.visibleTabs; - let tabOne = gBrowser.addTab(); - let tabTwo = gBrowser.addTab(); - - // test the ctrlTab.tabList - pressCtrlTab(); - ok(ctrlTab.tabList.length, 3, "Show 3 tabs in tab preview"); - releaseCtrl(); - - gBrowser.showOnlyTheseTabs([origTab]); - pressCtrlTab(); - ok(ctrlTab.tabList.length, 1, "Show 1 tab in tab preview"); - ok(!ctrlTab.isOpen, "With 1 tab open, Ctrl+Tab doesn't open the preview panel"); - - gBrowser.showOnlyTheseTabs([origTab, tabOne, tabTwo]); - pressCtrlTab(); - ok(ctrlTab.isOpen, "With 3 tabs open, Ctrl+Tab does open the preview panel"); - releaseCtrl(); - - // cleanup - gBrowser.removeTab(tabOne); - gBrowser.removeTab(tabTwo); - - if (gPrefService.prefHasUserValue("browser.ctrlTab.previews")) - gPrefService.clearUserPref("browser.ctrlTab.previews"); -}); - -function pressCtrlTab(aShiftKey) { - EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: !!aShiftKey }); -} - -function releaseCtrl() { - EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" }); -} diff --git a/browser/base/content/test/general/browser_web_channel.html b/browser/base/content/test/general/browser_web_channel.html deleted file mode 100644 index f117ccca2..000000000 --- a/browser/base/content/test/general/browser_web_channel.html +++ /dev/null @@ -1,189 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <title>web_channel_test</title> -</head> -<body> -<script> - var IFRAME_SRC_ROOT = "http://mochi.test:8888/browser/browser/base/content/test/general/browser_web_channel_iframe.html"; - - window.onload = function() { - var testName = window.location.search.replace(/^\?/, ""); - - switch (testName) { - case "generic": - test_generic(); - break; - case "twoway": - test_twoWay(); - break; - case "multichannel": - test_multichannel(); - break; - case "iframe": - test_iframe(); - break; - case "iframe_pre_redirect": - test_iframe_pre_redirect(); - break; - case "unsolicited": - test_unsolicited(); - break; - case "bubbles": - test_bubbles(); - break; - case "object": - test_object(); - break; - default: - throw new Error(`INVALID TEST NAME ${testName}`); - } - }; - - function test_generic() { - var event = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "generic", - message: { - something: { - nested: "hello", - }, - } - }) - }); - - window.dispatchEvent(event); - } - - function test_twoWay() { - var firstMessage = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "twoway", - message: { - command: "one", - }, - }) - }); - - window.addEventListener("WebChannelMessageToContent", function(e) { - var secondMessage = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "twoway", - message: { - command: "two", - detail: e.detail.message, - }, - }), - }); - - if (!e.detail.message.error) { - window.dispatchEvent(secondMessage); - } - }, true); - - window.dispatchEvent(firstMessage); - } - - function test_multichannel() { - var event1 = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "wrongchannel", - message: {}, - }) - }); - - var event2 = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "multichannel", - message: {}, - }) - }); - - window.dispatchEvent(event1); - window.dispatchEvent(event2); - } - - function test_iframe() { - // Note that this message is the response to the message sent - // by the iframe! This is bad, as this page is *not* trusted. - window.addEventListener("WebChannelMessageToContent", function(e) { - // the test parent will fail if the echo message is received. - echoEventToChannel(e, "echo"); - }); - - // only attach the iframe for the iframe test to avoid - // interfering with other tests. - var iframe = document.createElement("iframe"); - iframe.setAttribute("src", IFRAME_SRC_ROOT + "?iframe"); - document.body.appendChild(iframe); - } - - function test_iframe_pre_redirect() { - var iframe = document.createElement("iframe"); - iframe.setAttribute("src", IFRAME_SRC_ROOT + "?iframe_pre_redirect"); - document.body.appendChild(iframe); - } - - function test_unsolicited() { - // echo any unsolicted events back to chrome. - window.addEventListener("WebChannelMessageToContent", function(e) { - echoEventToChannel(e, "echo"); - }, true); - } - - function test_bubbles() { - var event = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "not_a_window", - message: { - command: "start" - } - }) - }); - - var nonWindowTarget = document.getElementById("not_a_window"); - - nonWindowTarget.addEventListener("WebChannelMessageToContent", function(e) { - echoEventToChannel(e, "not_a_window"); - }, true); - - - nonWindowTarget.dispatchEvent(event); - } - - function test_object() { - let objectMessage = new window.CustomEvent("WebChannelMessageToChrome", { - detail: { - id: "objects", - message: { type: "object" } - } - }); - - let stringMessage = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "objects", - message: { type: "string" } - }) - }); - // Test fails if objectMessage is received, we send stringMessage to know - // when we should stop listening for objectMessage - window.dispatchEvent(objectMessage); - window.dispatchEvent(stringMessage); - } - - function echoEventToChannel(e, channelId) { - var echoedEvent = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: channelId, - message: e.detail.message, - }) - }); - - e.target.dispatchEvent(echoedEvent); - } -</script> - -<div id="not_a_window"></div> -</body> -</html> diff --git a/browser/base/content/test/general/browser_web_channel.js b/browser/base/content/test/general/browser_web_channel.js deleted file mode 100644 index abc1c6fef..000000000 --- a/browser/base/content/test/general/browser_web_channel.js +++ /dev/null @@ -1,436 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -Cu.import("resource://gre/modules/Promise.jsm"); -Cu.import("resource://gre/modules/Task.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "WebChannel", - "resource://gre/modules/WebChannel.jsm"); - -const HTTP_PATH = "http://example.com"; -const HTTP_ENDPOINT = "/browser/browser/base/content/test/general/browser_web_channel.html"; -const HTTP_MISMATCH_PATH = "http://example.org"; -const HTTP_IFRAME_PATH = "http://mochi.test:8888"; -const HTTP_REDIRECTED_IFRAME_PATH = "http://example.org"; - -requestLongerTimeout(2); // timeouts in debug builds. - -// Keep this synced with /mobile/android/tests/browser/robocop/testWebChannel.js -// as much as possible. (We only have that since we can't run browser chrome -// tests on Android. Yet?) -var gTests = [ - { - desc: "WebChannel generic message", - run: function* () { - return new Promise(function(resolve, reject) { - let tab; - let channel = new WebChannel("generic", Services.io.newURI(HTTP_PATH, null, null)); - channel.listen(function (id, message, target) { - is(id, "generic"); - is(message.something.nested, "hello"); - channel.stopListening(); - gBrowser.removeTab(tab); - resolve(); - }); - - tab = gBrowser.addTab(HTTP_PATH + HTTP_ENDPOINT + "?generic"); - }); - } - }, - { - desc: "WebChannel generic message in a private window.", - run: function* () { - let promiseTestDone = new Promise(function(resolve, reject) { - let channel = new WebChannel("generic", Services.io.newURI(HTTP_PATH, null, null)); - channel.listen(function(id, message, target) { - is(id, "generic"); - is(message.something.nested, "hello"); - channel.stopListening(); - resolve(); - }); - }); - - const url = HTTP_PATH + HTTP_ENDPOINT + "?generic"; - let privateWindow = yield BrowserTestUtils.openNewBrowserWindow({private: true}); - yield BrowserTestUtils.openNewForegroundTab(privateWindow.gBrowser, url); - yield promiseTestDone; - yield BrowserTestUtils.closeWindow(privateWindow); - } - }, - { - desc: "WebChannel two way communication", - run: function* () { - return new Promise(function(resolve, reject) { - let tab; - let channel = new WebChannel("twoway", Services.io.newURI(HTTP_PATH, null, null)); - - channel.listen(function (id, message, sender) { - is(id, "twoway", "bad id"); - ok(message.command, "command not ok"); - - if (message.command === "one") { - channel.send({ data: { nested: true } }, sender); - } - - if (message.command === "two") { - is(message.detail.data.nested, true); - channel.stopListening(); - gBrowser.removeTab(tab); - resolve(); - } - }); - - tab = gBrowser.addTab(HTTP_PATH + HTTP_ENDPOINT + "?twoway"); - }); - } - }, - { - desc: "WebChannel two way communication in an iframe", - run: function* () { - let parentChannel = new WebChannel("echo", Services.io.newURI(HTTP_PATH, null, null)); - let iframeChannel = new WebChannel("twoway", Services.io.newURI(HTTP_IFRAME_PATH, null, null)); - let promiseTestDone = new Promise(function (resolve, reject) { - parentChannel.listen(function (id, message, sender) { - reject(new Error("WebChannel message incorrectly sent to parent")); - }); - - iframeChannel.listen(function (id, message, sender) { - is(id, "twoway", "bad id (2)"); - ok(message.command, "command not ok (2)"); - - if (message.command === "one") { - iframeChannel.send({ data: { nested: true } }, sender); - } - - if (message.command === "two") { - is(message.detail.data.nested, true); - resolve(); - } - }); - }); - yield BrowserTestUtils.withNewTab({ - gBrowser: gBrowser, - url: HTTP_PATH + HTTP_ENDPOINT + "?iframe" - }, function* () { - yield promiseTestDone; - parentChannel.stopListening(); - iframeChannel.stopListening(); - }); - } - }, - { - desc: "WebChannel response to a redirected iframe", - run: function* () { - /** - * This test checks that WebChannel responses are only sent - * to an iframe if the iframe has not redirected to another origin. - * Test flow: - * 1. create a page, embed an iframe on origin A. - * 2. the iframe sends a message `redirecting`, then redirects to - * origin B. - * 3. the iframe at origin B is set up to echo any messages back to the - * test parent. - * 4. the test parent receives the `redirecting` message from origin A. - * the test parent creates a new channel with origin B. - * 5. when origin B is ready, it sends a `loaded` message to the test - * parent, letting the test parent know origin B is ready to echo - * messages. - * 5. the test parent tries to send a response to origin A. If the - * WebChannel does not perform a valid origin check, the response - * will be received by origin B. If the WebChannel does perform - * a valid origin check, the response will not be sent. - * 6. the test parent sends a `done` message to origin B, which origin - * B echoes back. If the response to origin A is not echoed but - * the message to origin B is, then hooray, the test passes. - */ - - let preRedirectChannel = new WebChannel("pre_redirect", Services.io.newURI(HTTP_IFRAME_PATH, null, null)); - let postRedirectChannel = new WebChannel("post_redirect", Services.io.newURI(HTTP_REDIRECTED_IFRAME_PATH, null, null)); - - let promiseTestDone = new Promise(function (resolve, reject) { - preRedirectChannel.listen(function (id, message, preRedirectSender) { - if (message.command === "redirecting") { - - postRedirectChannel.listen(function (aId, aMessage, aPostRedirectSender) { - is(aId, "post_redirect"); - isnot(aMessage.command, "no_response_expected"); - - if (aMessage.command === "loaded") { - // The message should not be received on the preRedirectChannel - // because the target window has redirected. - preRedirectChannel.send({ command: "no_response_expected" }, preRedirectSender); - postRedirectChannel.send({ command: "done" }, aPostRedirectSender); - } else if (aMessage.command === "done") { - resolve(); - } else { - reject(new Error(`Unexpected command ${aMessage.command}`)); - } - }); - } else { - reject(new Error(`Unexpected command ${message.command}`)); - } - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser: gBrowser, - url: HTTP_PATH + HTTP_ENDPOINT + "?iframe_pre_redirect" - }, function* () { - yield promiseTestDone; - preRedirectChannel.stopListening(); - postRedirectChannel.stopListening(); - }); - } - }, - { - desc: "WebChannel multichannel", - run: function* () { - return new Promise(function(resolve, reject) { - let tab; - let channel = new WebChannel("multichannel", Services.io.newURI(HTTP_PATH, null, null)); - - channel.listen(function (id, message, sender) { - is(id, "multichannel"); - gBrowser.removeTab(tab); - resolve(); - }); - - tab = gBrowser.addTab(HTTP_PATH + HTTP_ENDPOINT + "?multichannel"); - }); - } - }, - { - desc: "WebChannel unsolicited send, using system principal", - run: function* () { - let channel = new WebChannel("echo", Services.io.newURI(HTTP_PATH, null, null)); - - // an unsolicted message is sent from Chrome->Content which is then - // echoed back. If the echo is received here, then the content - // received the message. - let messagePromise = new Promise(function (resolve, reject) { - channel.listen(function (id, message, sender) { - is(id, "echo"); - is(message.command, "unsolicited"); - - resolve() - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: HTTP_PATH + HTTP_ENDPOINT + "?unsolicited" - }, function* (targetBrowser) { - channel.send({ command: "unsolicited" }, { - browser: targetBrowser, - principal: Services.scriptSecurityManager.getSystemPrincipal() - }); - yield messagePromise; - channel.stopListening(); - }); - } - }, - { - desc: "WebChannel unsolicited send, using target origin's principal", - run: function* () { - let targetURI = Services.io.newURI(HTTP_PATH, null, null); - let channel = new WebChannel("echo", targetURI); - - // an unsolicted message is sent from Chrome->Content which is then - // echoed back. If the echo is received here, then the content - // received the message. - let messagePromise = new Promise(function (resolve, reject) { - channel.listen(function (id, message, sender) { - is(id, "echo"); - is(message.command, "unsolicited"); - - resolve(); - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: HTTP_PATH + HTTP_ENDPOINT + "?unsolicited" - }, function* (targetBrowser) { - - channel.send({ command: "unsolicited" }, { - browser: targetBrowser, - principal: Services.scriptSecurityManager.getNoAppCodebasePrincipal(targetURI) - }); - - yield messagePromise; - channel.stopListening(); - }); - } - }, - { - desc: "WebChannel unsolicited send with principal mismatch", - run: function* () { - let targetURI = Services.io.newURI(HTTP_PATH, null, null); - let channel = new WebChannel("echo", targetURI); - - // two unsolicited messages are sent from Chrome->Content. The first, - // `unsolicited_no_response_expected` is sent to the wrong principal - // and should not be echoed back. The second, `done`, is sent to the - // correct principal and should be echoed back. - let messagePromise = new Promise(function (resolve, reject) { - channel.listen(function (id, message, sender) { - is(id, "echo"); - - if (message.command === "done") { - resolve(); - } else { - reject(new Error(`Unexpected command ${message.command}`)); - } - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser: gBrowser, - url: HTTP_PATH + HTTP_ENDPOINT + "?unsolicited" - }, function* (targetBrowser) { - - let mismatchURI = Services.io.newURI(HTTP_MISMATCH_PATH, null, null); - let mismatchPrincipal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(mismatchURI); - - // send a message to the wrong principal. It should not be delivered - // to content, and should not be echoed back. - channel.send({ command: "unsolicited_no_response_expected" }, { - browser: targetBrowser, - principal: mismatchPrincipal - }); - - let targetPrincipal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(targetURI); - - // send the `done` message to the correct principal. It - // should be echoed back. - channel.send({ command: "done" }, { - browser: targetBrowser, - principal: targetPrincipal - }); - - yield messagePromise; - channel.stopListening(); - }); - } - }, - { - desc: "WebChannel non-window target", - run: function* () { - /** - * This test ensures messages can be received from and responses - * sent to non-window elements. - * - * First wait for the non-window element to send a "start" message. - * Then send the non-window element a "done" message. - * The non-window element will echo the "done" message back, if it - * receives the message. - * Listen for the response. If received, good to go! - */ - let channel = new WebChannel("not_a_window", Services.io.newURI(HTTP_PATH, null, null)); - - let testDonePromise = new Promise(function (resolve, reject) { - channel.listen(function (id, message, sender) { - if (message.command === "start") { - channel.send({ command: "done" }, sender); - } else if (message.command === "done") { - resolve(); - } else { - reject(new Error(`Unexpected command ${message.command}`)); - } - }); - }); - - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: HTTP_PATH + HTTP_ENDPOINT + "?bubbles" - }, function* () { - yield testDonePromise; - channel.stopListening(); - }); - } - }, - { - desc: "WebChannel disallows non-string message from non-whitelisted origin", - run: function* () { - /** - * This test ensures that non-string messages can't be sent via WebChannels. - * We create a page (on a non-whitelisted origin) which should send us two - * messages immediately. The first message has an object for it's detail, - * and the second has a string. We check that we only get the second - * message. - */ - let channel = new WebChannel("objects", Services.io.newURI(HTTP_PATH, null, null)); - let testDonePromise = new Promise((resolve, reject) => { - channel.listen((id, message, sender) => { - is(id, "objects"); - is(message.type, "string"); - resolve(); - }); - }); - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: HTTP_PATH + HTTP_ENDPOINT + "?object" - }, function* () { - yield testDonePromise; - channel.stopListening(); - }); - } - }, - { - desc: "WebChannel allows both string and non-string message from whitelisted origin", - run: function* () { - /** - * Same process as above, but we whitelist the origin before loading the page, - * and expect to get *both* messages back (each exactly once). - */ - let channel = new WebChannel("objects", Services.io.newURI(HTTP_PATH, null, null)); - - let testDonePromise = new Promise((resolve, reject) => { - let sawObject = false; - let sawString = false; - channel.listen((id, message, sender) => { - is(id, "objects"); - if (message.type === "object") { - ok(!sawObject); - sawObject = true; - } else if (message.type === "string") { - ok(!sawString); - sawString = true; - } else { - reject(new Error(`Unknown message type: ${message.type}`)) - } - if (sawObject && sawString) { - resolve(); - } - }); - }); - const webchannelWhitelistPref = "webchannel.allowObject.urlWhitelist"; - let origWhitelist = Services.prefs.getCharPref(webchannelWhitelistPref); - let newWhitelist = origWhitelist + " " + HTTP_PATH; - Services.prefs.setCharPref(webchannelWhitelistPref, newWhitelist); - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: HTTP_PATH + HTTP_ENDPOINT + "?object" - }, function* () { - yield testDonePromise; - Services.prefs.setCharPref(webchannelWhitelistPref, origWhitelist); - channel.stopListening(); - }); - } - } -]; // gTests - -function test() { - waitForExplicitFinish(); - - Task.spawn(function* () { - for (let testCase of gTests) { - info("Running: " + testCase.desc); - yield testCase.run(); - } - }).then(finish, ex => { - ok(false, "Unexpected Exception: " + ex); - finish(); - }); -} diff --git a/browser/base/content/test/general/browser_web_channel_iframe.html b/browser/base/content/test/general/browser_web_channel_iframe.html deleted file mode 100644 index 7900e7530..000000000 --- a/browser/base/content/test/general/browser_web_channel_iframe.html +++ /dev/null @@ -1,96 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <title>web_channel_test (iframe)</title> -</head> -<body> -<script> - var REDIRECTED_IFRAME_SRC_ROOT = "http://example.org/browser/browser/base/content/test/general/browser_web_channel_iframe.html"; - - window.onload = function() { - var testName = window.location.search.replace(/^\?/, ""); - switch (testName) { - case "iframe": - test_iframe(); - break; - case "iframe_pre_redirect": - test_iframe_pre_redirect(); - break; - case "iframe_post_redirect": - test_iframe_post_redirect(); - break; - default: - throw new Error(`INVALID TEST NAME ${testName}`); - } - }; - - function test_iframe() { - var firstMessage = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "twoway", - message: { - command: "one", - }, - }) - }); - - window.addEventListener("WebChannelMessageToContent", function(e) { - var secondMessage = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "twoway", - message: { - command: "two", - detail: e.detail.message, - }, - }), - }); - - if (!e.detail.message.error) { - window.dispatchEvent(secondMessage); - } - }, true); - - window.dispatchEvent(firstMessage); - } - - - function test_iframe_pre_redirect() { - var firstMessage = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "pre_redirect", - message: { - command: "redirecting", - }, - }), - }); - window.dispatchEvent(firstMessage); - document.location = REDIRECTED_IFRAME_SRC_ROOT + "?iframe_post_redirect"; - } - - function test_iframe_post_redirect() { - window.addEventListener("WebChannelMessageToContent", function(e) { - var echoMessage = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "post_redirect", - message: e.detail.message, - }), - }); - - window.dispatchEvent(echoMessage); - }, true); - - // Let the test parent know the page has loaded and is ready to echo events - var loadedMessage = new window.CustomEvent("WebChannelMessageToChrome", { - detail: JSON.stringify({ - id: "post_redirect", - message: { - command: "loaded", - }, - }), - }); - window.dispatchEvent(loadedMessage); - } -</script> -</body> -</html> diff --git a/browser/base/content/test/general/browser_windowactivation.js b/browser/base/content/test/general/browser_windowactivation.js deleted file mode 100644 index ae4ba75dc..000000000 --- a/browser/base/content/test/general/browser_windowactivation.js +++ /dev/null @@ -1,183 +0,0 @@ -/* - * This test checks that window activation state is set properly with multiple tabs. - */ - -var testPage = "data:text/html,<body><style>:-moz-window-inactive { background-color: red; }</style><div id='area'></div></body>"; - -var colorChangeNotifications = 0; -var otherWindow; - -var browser1, browser2; - -function test() { - waitForExplicitFinish(); - waitForFocus(reallyRunTests); -} - -function reallyRunTests() { - - let tab1 = gBrowser.addTab(); - let tab2 = gBrowser.addTab(); - browser1 = gBrowser.getBrowserForTab(tab1); - browser2 = gBrowser.getBrowserForTab(tab2); - - gURLBar.focus(); - - var loadCount = 0; - function check() - { - // wait for both tabs to load - if (++loadCount != 2) { - return; - } - - browser1.removeEventListener("load", check, true); - browser2.removeEventListener("load", check, true); - - sendGetBackgroundRequest(true); - } - - // The test performs four checks, using -moz-window-inactive on two child tabs. - // First, the initial state should be transparent. The second check is done - // while another window is focused. The third check is done after that window - // is closed and the main window focused again. The fourth check is done after - // switching to the second tab. - window.messageManager.addMessageListener("Test:BackgroundColorChanged", function(message) { - colorChangeNotifications++; - - switch (colorChangeNotifications) { - case 1: - is(message.data.color, "transparent", "first window initial"); - break; - case 2: - is(message.data.color, "transparent", "second window initial"); - runOtherWindowTests(); - break; - case 3: - is(message.data.color, "rgb(255, 0, 0)", "first window lowered"); - break; - case 4: - is(message.data.color, "rgb(255, 0, 0)", "second window lowered"); - sendGetBackgroundRequest(true); - otherWindow.close(); - break; - case 5: - is(message.data.color, "transparent", "first window raised"); - break; - case 6: - is(message.data.color, "transparent", "second window raised"); - gBrowser.selectedTab = tab2; - break; - case 7: - is(message.data.color, "transparent", "first window after tab switch"); - break; - case 8: - is(message.data.color, "transparent", "second window after tab switch"); - finishTest(); - break; - case 9: - ok(false, "too many color change notifications"); - break; - } - }); - - window.messageManager.addMessageListener("Test:FocusReceived", function(message) { - // No color change should occur after a tab switch. - if (colorChangeNotifications == 6) { - sendGetBackgroundRequest(false); - } - }); - - window.messageManager.addMessageListener("Test:ActivateEvent", function(message) { - ok(message.data.ok, "Test:ActivateEvent"); - }); - - window.messageManager.addMessageListener("Test:DeactivateEvent", function(message) { - ok(message.data.ok, "Test:DeactivateEvent"); - }); - - browser1.addEventListener("load", check, true); - browser2.addEventListener("load", check, true); - browser1.contentWindow.location = testPage; - browser2.contentWindow.location = testPage; - - browser1.messageManager.loadFrameScript("data:,(" + childFunction.toString() + ")();", true); - browser2.messageManager.loadFrameScript("data:,(" + childFunction.toString() + ")();", true); - - gBrowser.selectedTab = tab1; -} - -function sendGetBackgroundRequest(ifChanged) -{ - browser1.messageManager.sendAsyncMessage("Test:GetBackgroundColor", { ifChanged: ifChanged }); - browser2.messageManager.sendAsyncMessage("Test:GetBackgroundColor", { ifChanged: ifChanged }); -} - -function runOtherWindowTests() { - otherWindow = window.open("data:text/html,<body>Hi</body>", "", "chrome"); - waitForFocus(function () { - sendGetBackgroundRequest(true); - }, otherWindow); -} - -function finishTest() -{ - gBrowser.removeCurrentTab(); - gBrowser.removeCurrentTab(); - otherWindow = null; - finish(); -} - -function childFunction() -{ - let oldColor = null; - - let expectingResponse = false; - let ifChanged = true; - - addMessageListener("Test:GetBackgroundColor", function(message) { - expectingResponse = true; - ifChanged = message.data.ifChanged; - }); - - content.addEventListener("focus", function () { - sendAsyncMessage("Test:FocusReceived", { }); - }, false); - - var windowGotActivate = false; - var windowGotDeactivate = false; - addEventListener("activate", function() { - sendAsyncMessage("Test:ActivateEvent", { ok: !windowGotActivate }); - windowGotActivate = false; - }); - - addEventListener("deactivate", function() { - sendAsyncMessage("Test:DeactivateEvent", { ok: !windowGotDeactivate }); - windowGotDeactivate = false; - }); - content.addEventListener("activate", function() { - windowGotActivate = true; - }); - - content.addEventListener("deactivate", function() { - windowGotDeactivate = true; - }); - - content.setInterval(function () { - if (!expectingResponse) { - return; - } - - let area = content.document.getElementById("area"); - if (!area) { - return; /* hasn't loaded yet */ - } - - let color = content.getComputedStyle(area, "").backgroundColor; - if (oldColor != color || !ifChanged) { - expectingResponse = false; - oldColor = color; - sendAsyncMessage("Test:BackgroundColorChanged", { color: color }); - } - }, 20); -} diff --git a/browser/base/content/test/general/browser_windowopen_reflows.js b/browser/base/content/test/general/browser_windowopen_reflows.js deleted file mode 100644 index 7dac8aad6..000000000 --- a/browser/base/content/test/general/browser_windowopen_reflows.js +++ /dev/null @@ -1,117 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -const EXPECTED_REFLOWS = [ - // handleEvent flushes layout to get the tabstrip width after a resize. - "handleEvent@chrome://browser/content/tabbrowser.xml|", - - // Loading a tab causes a reflow. - "loadTabs@chrome://browser/content/tabbrowser.xml|" + - "loadOneOrMoreURIs@chrome://browser/content/browser.js|" + - "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|", - - // Selecting the address bar causes a reflow. - "select@chrome://global/content/bindings/textbox.xml|" + - "focusAndSelectUrlBar@chrome://browser/content/browser.js|" + - "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|", - - // Focusing the content area causes a reflow. - "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|", - - // Sometimes sessionstore collects data during this test, which causes a sync reflow - // (https://bugzilla.mozilla.org/show_bug.cgi?id=892154 will fix this) - "ssi_getWindowDimension@resource:///modules/sessionstore/SessionStore.jsm", -]; - -if (Services.appinfo.OS == "WINNT" || Services.appinfo.OS == "Darwin") { - // TabsInTitlebar._update causes a reflow on OS X and Windows trying to do calculations - // since layout info is already dirty. This doesn't seem to happen before - // MozAfterPaint on Linux. - EXPECTED_REFLOWS.push("TabsInTitlebar._update/rect@chrome://browser/content/browser-tabsintitlebar.js|" + - "TabsInTitlebar._update@chrome://browser/content/browser-tabsintitlebar.js|" + - "updateAppearance@chrome://browser/content/browser-tabsintitlebar.js|" + - "handleEvent@chrome://browser/content/tabbrowser.xml|"); -} - -if (Services.appinfo.OS == "Darwin") { - // _onOverflow causes a reflow getting widths. - EXPECTED_REFLOWS.push("OverflowableToolbar.prototype._onOverflow@resource:///modules/CustomizableUI.jsm|" + - "OverflowableToolbar.prototype.init@resource:///modules/CustomizableUI.jsm|" + - "OverflowableToolbar.prototype.observe@resource:///modules/CustomizableUI.jsm|" + - "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|"); - // Same as above since in packaged builds there are no function names and the resource URI includes "app" - EXPECTED_REFLOWS.push("@resource://app/modules/CustomizableUI.jsm|" + - "@resource://app/modules/CustomizableUI.jsm|" + - "@resource://app/modules/CustomizableUI.jsm|" + - "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|"); -} - -/* - * This test ensures that there are no unexpected - * uninterruptible reflows when opening new windows. - */ -function test() { - waitForExplicitFinish(); - - // Add a reflow observer and open a new window - let win = OpenBrowserWindow(); - let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); - docShell.addWeakReflowObserver(observer); - - // Wait until the mozafterpaint event occurs. - waitForMozAfterPaint(win, function paintListener() { - // Remove reflow observer and clean up. - docShell.removeWeakReflowObserver(observer); - win.close(); - - finish(); - }); -} - -var observer = { - reflow: function (start, end) { - // Gather information about the current code path. - let stack = new Error().stack; - let path = stack.split("\n").slice(1).map(line => { - return line.replace(/:\d+:\d+$/, ""); - }).join("|"); - let pathWithLineNumbers = (new Error().stack).split("\n").slice(1).join("|"); - - // Stack trace is empty. Reflow was triggered by native code. - if (path === "") { - return; - } - - // Check if this is an expected reflow. - for (let expectedStack of EXPECTED_REFLOWS) { - if (path.startsWith(expectedStack) || - // Accept an empty function name for gBrowserInit._delayedStartup or TabsInTitlebar._update to workaround bug 906578. - path.startsWith(expectedStack.replace(/(^|\|)(gBrowserInit\._delayedStartup|TabsInTitlebar\._update)@/, "$1@"))) { - ok(true, "expected uninterruptible reflow '" + expectedStack + "'"); - return; - } - } - - ok(false, "unexpected uninterruptible reflow '" + pathWithLineNumbers + "'"); - }, - - reflowInterruptible: function (start, end) { - // We're not interested in interruptible reflows. - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver, - Ci.nsISupportsWeakReference]) -}; - -function waitForMozAfterPaint(win, callback) { - win.addEventListener("MozAfterPaint", function onEnd(event) { - if (event.target != win) - return; - win.removeEventListener("MozAfterPaint", onEnd); - executeSoon(callback); - }); -} diff --git a/browser/base/content/test/general/browser_zbug569342.js b/browser/base/content/test/general/browser_zbug569342.js deleted file mode 100644 index 2dac5acde..000000000 --- a/browser/base/content/test/general/browser_zbug569342.js +++ /dev/null @@ -1,80 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -var gTab = null; - -function load(url, cb) { - gTab = gBrowser.addTab(url); - gBrowser.addEventListener("load", function (event) { - if (event.target.location != url) - return; - - gBrowser.removeEventListener("load", arguments.callee, true); - // Trigger onLocationChange by switching tabs. - gBrowser.selectedTab = gTab; - cb(); - }, true); -} - -function test() { - waitForExplicitFinish(); - - ok(gFindBar.hidden, "Find bar should not be visible by default"); - - // Open the Find bar before we navigate to pages that shouldn't have it. - EventUtils.synthesizeKey("f", { accelKey: true }); - ok(!gFindBar.hidden, "Find bar should be visible"); - - nextTest(); -} - -var urls = [ - "about:config", - "about:addons", -]; - -function nextTest() { - let url = urls.shift(); - if (url) { - testFindDisabled(url, nextTest); - } else { - // Make sure the find bar is re-enabled after disabled page is closed. - testFindEnabled("about:blank", function () { - EventUtils.synthesizeKey("VK_ESCAPE", { }); - ok(gFindBar.hidden, "Find bar should now be hidden"); - finish(); - }); - } -} - -function testFindDisabled(url, cb) { - load(url, function() { - ok(gFindBar.hidden, "Find bar should not be visible"); - EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow); - ok(gFindBar.hidden, "Find bar should not be visible"); - EventUtils.synthesizeKey("f", { accelKey: true }); - ok(gFindBar.hidden, "Find bar should not be visible"); - ok(document.getElementById("cmd_find").getAttribute("disabled"), - "Find command should be disabled"); - - gBrowser.removeTab(gTab); - cb(); - }); -} - -function testFindEnabled(url, cb) { - load(url, function() { - ok(!document.getElementById("cmd_find").getAttribute("disabled"), - "Find command should not be disabled"); - - // Open Find bar and then close it. - EventUtils.synthesizeKey("f", { accelKey: true }); - ok(!gFindBar.hidden, "Find bar should be visible again"); - EventUtils.synthesizeKey("VK_ESCAPE", { }); - ok(gFindBar.hidden, "Find bar should now be hidden"); - - gBrowser.removeTab(gTab); - cb(); - }); -} diff --git a/browser/base/content/test/general/bug1262648_string_with_newlines.dtd b/browser/base/content/test/general/bug1262648_string_with_newlines.dtd deleted file mode 100644 index 308072c4e..000000000 --- a/browser/base/content/test/general/bug1262648_string_with_newlines.dtd +++ /dev/null @@ -1,3 +0,0 @@ -<!ENTITY foo.bar "This string -contains -newlines!">
\ No newline at end of file diff --git a/browser/base/content/test/general/bug364677-data.xml b/browser/base/content/test/general/bug364677-data.xml deleted file mode 100644 index b48915c05..000000000 --- a/browser/base/content/test/general/bug364677-data.xml +++ /dev/null @@ -1,5 +0,0 @@ -<rss version="2.0"> - <channel> - <title>t</title> - </channel> -</rss> diff --git a/browser/base/content/test/general/bug364677-data.xml^headers^ b/browser/base/content/test/general/bug364677-data.xml^headers^ deleted file mode 100644 index f203c6368..000000000 --- a/browser/base/content/test/general/bug364677-data.xml^headers^ +++ /dev/null @@ -1 +0,0 @@ -Content-Type: text/xml diff --git a/browser/base/content/test/general/bug395533-data.txt b/browser/base/content/test/general/bug395533-data.txt deleted file mode 100644 index e0ed39850..000000000 --- a/browser/base/content/test/general/bug395533-data.txt +++ /dev/null @@ -1,6 +0,0 @@ -<rss version="2.0"> - <channel> - <link>http://example.org/</link> - <title>t</title> - </channel> -</rss> diff --git a/browser/base/content/test/general/bug592338.html b/browser/base/content/test/general/bug592338.html deleted file mode 100644 index 159b21a76..000000000 --- a/browser/base/content/test/general/bug592338.html +++ /dev/null @@ -1,24 +0,0 @@ -<html> -<head> -<script type="text/javascript"> -var theme = { - id: "test", - name: "Test Background", - headerURL: "http://example.com/firefox/personas/01/header.jpg", - footerURL: "http://example.com/firefox/personas/01/footer.jpg", - textcolor: "#fff", - accentcolor: "#6b6b6b" -}; - -function setTheme(node) { - node.setAttribute("data-browsertheme", JSON.stringify(theme)); - var event = document.createEvent("Events"); - event.initEvent("InstallBrowserTheme", true, false); - node.dispatchEvent(event); -} -</script> -</head> -<body> -<a id="theme-install" href="#" onclick="setTheme(this)">Install</a> -</body> -</html> diff --git a/browser/base/content/test/general/bug792517-2.html b/browser/base/content/test/general/bug792517-2.html deleted file mode 100644 index bfc24d817..000000000 --- a/browser/base/content/test/general/bug792517-2.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> -<a href="bug792517.sjs" id="fff">this is a link</a> -</body> -</html> diff --git a/browser/base/content/test/general/bug792517.html b/browser/base/content/test/general/bug792517.html deleted file mode 100644 index e7c040bf1..000000000 --- a/browser/base/content/test/general/bug792517.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> -<img src="moz.png" id="img"> -</body> -</html> diff --git a/browser/base/content/test/general/bug792517.sjs b/browser/base/content/test/general/bug792517.sjs deleted file mode 100644 index 91e5aa23f..000000000 --- a/browser/base/content/test/general/bug792517.sjs +++ /dev/null @@ -1,13 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -function handleRequest(aRequest, aResponse) { - aResponse.setStatusLine(aRequest.httpVersion, 200); - if (aRequest.hasHeader('Cookie')) { - aResponse.write("cookie-present"); - } else { - aResponse.setHeader("Set-Cookie", "foopy=1"); - aResponse.write("cookie-not-present"); - } -} diff --git a/browser/base/content/test/general/bug839103.css b/browser/base/content/test/general/bug839103.css deleted file mode 100644 index 611907d3d..000000000 --- a/browser/base/content/test/general/bug839103.css +++ /dev/null @@ -1 +0,0 @@ -* {} diff --git a/browser/base/content/test/general/clipboard_pastefile.html b/browser/base/content/test/general/clipboard_pastefile.html deleted file mode 100644 index fcbf60ed2..000000000 --- a/browser/base/content/test/general/clipboard_pastefile.html +++ /dev/null @@ -1,37 +0,0 @@ -<html><body> -<script> -function checkPaste(event) -{ - let output = document.getElementById("output"); - output.textContent = checkPasteHelper(event); -} - -function checkPasteHelper(event) -{ - let dt = event.clipboardData; - if (dt.types.length != 2) - return "Wrong number of types; got " + dt.types.length; - - for (let type of dt.types) { - if (type != "Files" && type != "application/x-moz-file") - return "Invalid type for types; got" + type; - } - - for (let type of dt.mozTypesAt(0)) { - if (type != "Files" && type != "application/x-moz-file") - return "Invalid type for mozTypesAt; got" + type; - } - - if (dt.getData("text/plain")) - return "text/plain found with getData"; - if (dt.mozGetDataAt("text/plain", 0)) - return "text/plain found with mozGetDataAt"; - - return "Passed"; -} -</script> - -<input id="input" onpaste="checkPaste(event)"> -<div id="output"></div> - -</body></html> diff --git a/browser/base/content/test/general/close_beforeunload.html b/browser/base/content/test/general/close_beforeunload.html deleted file mode 100644 index 4b62002cc..000000000 --- a/browser/base/content/test/general/close_beforeunload.html +++ /dev/null @@ -1,8 +0,0 @@ -<body> - <p>I will close myself if you close me.</p> - <script> - window.onbeforeunload = function() { - window.close(); - }; - </script> -</body> diff --git a/browser/base/content/test/general/close_beforeunload_opens_second_tab.html b/browser/base/content/test/general/close_beforeunload_opens_second_tab.html deleted file mode 100644 index 243307a0e..000000000 --- a/browser/base/content/test/general/close_beforeunload_opens_second_tab.html +++ /dev/null @@ -1,3 +0,0 @@ -<body>
- <a href="#" onclick="window.open('close_beforeunload.html', '_blank')">Open second tab</a>
-</body>
diff --git a/browser/base/content/test/general/contentSearchUI.html b/browser/base/content/test/general/contentSearchUI.html deleted file mode 100644 index 3750ac2b0..000000000 --- a/browser/base/content/test/general/contentSearchUI.html +++ /dev/null @@ -1,21 +0,0 @@ -<!DOCTYPE html> -<!-- Any copyright is dedicated to the Public Domain. - - http://creativecommons.org/publicdomain/zero/1.0/ --> - -<html> -<head> -<meta charset="utf-8"> -<script type="application/javascript;version=1.8" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"> -</script> -<script type="application/javascript;version=1.8" - src="chrome://browser/content/contentSearchUI.js"> -</script> -<link rel="stylesheet" href="chrome://browser/content/contentSearchUI.css"/> -</head> -<body> - -<div id="container" style="position: relative;"><input type="text" value=""/></div> - -</body> -</html> diff --git a/browser/base/content/test/general/contentSearchUI.js b/browser/base/content/test/general/contentSearchUI.js deleted file mode 100644 index 0e46230a2..000000000 --- a/browser/base/content/test/general/contentSearchUI.js +++ /dev/null @@ -1,209 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -(function () { - -const TEST_MSG = "ContentSearchUIControllerTest"; -const ENGINE_NAME = "browser_searchSuggestionEngine searchSuggestionEngine.xml"; -var gController; - -addMessageListener(TEST_MSG, msg => { - messageHandlers[msg.data.type](msg.data.data); -}); - -var messageHandlers = { - - init: function() { - Services.search.currentEngine = Services.search.getEngineByName(ENGINE_NAME); - let input = content.document.querySelector("input"); - gController = - new content.ContentSearchUIController(input, input.parentNode, "test", "test"); - content.addEventListener("ContentSearchService", function listener(aEvent) { - if (aEvent.detail.type == "State" && - gController.defaultEngine.name == ENGINE_NAME) { - content.removeEventListener("ContentSearchService", listener); - ack("init"); - } - }); - gController.remoteTimeout = 5000; - }, - - key: function (arg) { - let keyName = typeof(arg) == "string" ? arg : arg.key; - content.synthesizeKey(keyName, arg.modifiers || {}); - let wait = arg.waitForSuggestions ? waitForSuggestions : cb => cb(); - wait(ack.bind(null, "key")); - }, - - startComposition: function (arg) { - content.synthesizeComposition({ type: "compositionstart", data: "" }); - ack("startComposition"); - }, - - changeComposition: function (arg) { - let data = typeof(arg) == "string" ? arg : arg.data; - content.synthesizeCompositionChange({ - composition: { - string: data, - clauses: [ - { length: data.length, attr: content.COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - caret: { start: data.length, length: 0 } - }); - let wait = arg.waitForSuggestions ? waitForSuggestions : cb => cb(); - wait(ack.bind(null, "changeComposition")); - }, - - commitComposition: function () { - content.synthesizeComposition({ type: "compositioncommitasis" }); - ack("commitComposition"); - }, - - focus: function () { - gController.input.focus(); - ack("focus"); - }, - - blur: function () { - gController.input.blur(); - ack("blur"); - }, - - waitForSearch: function () { - waitForContentSearchEvent("Search", aData => ack("waitForSearch", aData)); - }, - - waitForSearchSettings: function () { - waitForContentSearchEvent("ManageEngines", - aData => ack("waitForSearchSettings", aData)); - }, - - mousemove: function (itemIndex) { - let row; - if (itemIndex == -1) { - row = gController._table.firstChild; - } - else { - let allElts = [...gController._suggestionsList.children, - ...gController._oneOffButtons, - content.document.getElementById("contentSearchSettingsButton")]; - row = allElts[itemIndex]; - } - let event = { - type: "mousemove", - clickcount: 0, - } - row.addEventListener("mousemove", function handler() { - row.removeEventListener("mousemove", handler); - ack("mousemove"); - }); - content.synthesizeMouseAtCenter(row, event); - }, - - click: function (arg) { - let eltIdx = typeof(arg) == "object" ? arg.eltIdx : arg; - let row; - if (eltIdx == -1) { - row = gController._table.firstChild; - } - else { - let allElts = [...gController._suggestionsList.children, - ...gController._oneOffButtons, - content.document.getElementById("contentSearchSettingsButton")]; - row = allElts[eltIdx]; - } - let event = arg.modifiers || {}; - // synthesizeMouseAtCenter defaults to sending a mousedown followed by a - // mouseup if the event type is not specified. - content.synthesizeMouseAtCenter(row, event); - ack("click"); - }, - - addInputValueToFormHistory: function () { - gController.addInputValueToFormHistory(); - ack("addInputValueToFormHistory"); - }, - - addDuplicateOneOff: function () { - let btn = gController._oneOffButtons[gController._oneOffButtons.length - 1]; - let newBtn = btn.cloneNode(true); - btn.parentNode.appendChild(newBtn); - gController._oneOffButtons.push(newBtn); - ack("addDuplicateOneOff"); - }, - - removeLastOneOff: function () { - gController._oneOffButtons.pop().remove(); - ack("removeLastOneOff"); - }, - - reset: function () { - // Reset both the input and suggestions by select all + delete. If there was - // no text entered, this won't have any effect, so also escape to ensure the - // suggestions table is closed. - gController.input.focus(); - content.synthesizeKey("a", { accelKey: true }); - content.synthesizeKey("VK_DELETE", {}); - content.synthesizeKey("VK_ESCAPE", {}); - ack("reset"); - }, -}; - -function ack(aType, aData) { - sendAsyncMessage(TEST_MSG, { type: aType, data: aData || currentState() }); -} - -function waitForSuggestions(cb) { - let observer = new content.MutationObserver(() => { - if (gController.input.getAttribute("aria-expanded") == "true") { - observer.disconnect(); - cb(); - } - }); - observer.observe(gController.input, { - attributes: true, - attributeFilter: ["aria-expanded"], - }); -} - -function waitForContentSearchEvent(messageType, cb) { - let mm = content.SpecialPowers.Cc["@mozilla.org/globalmessagemanager;1"]. - getService(content.SpecialPowers.Ci.nsIMessageListenerManager); - mm.addMessageListener("ContentSearch", function listener(aMsg) { - if (aMsg.data.type != messageType) { - return; - } - mm.removeMessageListener("ContentSearch", listener); - cb(aMsg.data.data); - }); -} - -function currentState() { - let state = { - selectedIndex: gController.selectedIndex, - selectedButtonIndex: gController.selectedButtonIndex, - numSuggestions: gController._table.hidden ? 0 : gController.numSuggestions, - suggestionAtIndex: [], - isFormHistorySuggestionAtIndex: [], - - tableHidden: gController._table.hidden, - - inputValue: gController.input.value, - ariaExpanded: gController.input.getAttribute("aria-expanded"), - }; - - if (state.numSuggestions) { - for (let i = 0; i < gController.numSuggestions; i++) { - state.suggestionAtIndex.push(gController.suggestionAtIndex(i)); - state.isFormHistorySuggestionAtIndex.push( - gController.isFormHistorySuggestionAtIndex(i)); - } - } - - return state; -} - -})(); diff --git a/browser/base/content/test/general/content_aboutAccounts.js b/browser/base/content/test/general/content_aboutAccounts.js deleted file mode 100644 index 12ac04934..000000000 --- a/browser/base/content/test/general/content_aboutAccounts.js +++ /dev/null @@ -1,87 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -// This file is loaded as a "content script" for browser_aboutAccounts tests -"use strict"; - -var {interfaces: Ci, utils: Cu} = Components; - -addEventListener("load", function load(event) { - if (event.target != content.document) { - return; - } -// content.document.removeEventListener("load", load, true); - sendAsyncMessage("test:document:load"); - // Opening Sync prefs in tests is a pain as leaks are reported due to the - // in-flight promises. For now we just mock the openPrefs() function and have - // it send a message back to the test so we know it was called. - content.openPrefs = function() { - sendAsyncMessage("test:openPrefsCalled"); - } -}, true); - -addEventListener("DOMContentLoaded", function domContentLoaded(event) { - removeEventListener("DOMContentLoaded", domContentLoaded, true); - let iframe = content.document.getElementById("remote"); - if (!iframe) { - // at least one test initially loads about:blank - in that case, we are done. - return; - } - // We use DOMContentLoaded here as that fires for our iframe even when we've - // arranged for the URL in the iframe to cause an error. - addEventListener("DOMContentLoaded", function iframeLoaded(dclEvent) { - if (iframe.contentWindow.location.href == "about:blank" || - dclEvent.target != iframe.contentDocument) { - return; - } - removeEventListener("DOMContentLoaded", iframeLoaded, true); - sendAsyncMessage("test:iframe:load", {url: iframe.contentDocument.location.href}); - // And an event listener for the test responses, which we send to the test - // via a message. - iframe.contentWindow.addEventListener("FirefoxAccountsTestResponse", function (fxAccountsEvent) { - sendAsyncMessage("test:response", {data: fxAccountsEvent.detail.data}); - }, true); - }, true); -}, true); - -// Return the visibility state of a list of ids. -addMessageListener("test:check-visibilities", function (message) { - let result = {}; - for (let id of message.data.ids) { - let elt = content.document.getElementById(id); - if (elt) { - let displayStyle = content.window.getComputedStyle(elt).display; - if (displayStyle == 'none') { - result[id] = false; - } else if (displayStyle == 'block') { - result[id] = true; - } else { - result[id] = "strange: " + displayStyle; // tests should fail! - } - } else { - result[id] = "doesn't exist: " + id; - } - } - sendAsyncMessage("test:check-visibilities-response", result); -}); - -addMessageListener("test:load-with-mocked-profile-path", function (message) { - addEventListener("DOMContentLoaded", function domContentLoaded(event) { - removeEventListener("DOMContentLoaded", domContentLoaded, true); - content.getDefaultProfilePath = () => message.data.profilePath; - // now wait for the iframe to load. - let iframe = content.document.getElementById("remote"); - iframe.addEventListener("load", function iframeLoaded(loadEvent) { - if (iframe.contentWindow.location.href == "about:blank" || - loadEvent.target != iframe) { - return; - } - iframe.removeEventListener("load", iframeLoaded, true); - sendAsyncMessage("test:load-with-mocked-profile-path-response", - {url: iframe.contentDocument.location.href}); - }, true); - }); - let webNav = docShell.QueryInterface(Ci.nsIWebNavigation); - webNav.loadURI(message.data.url, webNav.LOAD_FLAGS_NONE, null, null, null); -}, true); diff --git a/browser/base/content/test/general/contextmenu_common.js b/browser/base/content/test/general/contextmenu_common.js deleted file mode 100644 index 1a0fa931a..000000000 --- a/browser/base/content/test/general/contextmenu_common.js +++ /dev/null @@ -1,324 +0,0 @@ -var lastElement; - -function openContextMenuFor(element, shiftkey, waitForSpellCheck) { - // Context menu should be closed before we open it again. - is(SpecialPowers.wrap(contextMenu).state, "closed", "checking if popup is closed"); - - if (lastElement) - lastElement.blur(); - element.focus(); - - // Some elements need time to focus and spellcheck before any tests are - // run on them. - function actuallyOpenContextMenuFor() { - lastElement = element; - var eventDetails = { type : "contextmenu", button : 2, shiftKey : shiftkey }; - synthesizeMouse(element, 2, 2, eventDetails, element.ownerGlobal); - } - - if (waitForSpellCheck) { - var { onSpellCheck } = SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", {}); - onSpellCheck(element, actuallyOpenContextMenuFor); - } - else { - actuallyOpenContextMenuFor(); - } -} - -function closeContextMenu() { - contextMenu.hidePopup(); -} - -function getVisibleMenuItems(aMenu, aData) { - var items = []; - var accessKeys = {}; - for (var i = 0; i < aMenu.childNodes.length; i++) { - var item = aMenu.childNodes[i]; - if (item.hidden) - continue; - - var key = item.accessKey; - if (key) - key = key.toLowerCase(); - - var isPageMenuItem = item.hasAttribute("generateditemid"); - - if (item.nodeName == "menuitem") { - var isGenerated = item.className == "spell-suggestion" - || item.className == "sendtab-target"; - if (isGenerated) { - is(item.id, "", "child menuitem #" + i + " is generated"); - } else if (isPageMenuItem) { - is(item.id, "", "child menuitem #" + i + " is a generated page menu item"); - } else { - ok(item.id, "child menuitem #" + i + " has an ID"); - } - var label = item.getAttribute("label"); - ok(label.length, "menuitem " + item.id + " has a label"); - if (isGenerated) { - is(key, "", "Generated items shouldn't have an access key"); - items.push("*" + label); - } else if (isPageMenuItem) { - items.push("+" + label); - } else if (item.id.indexOf("spell-check-dictionary-") != 0 && - item.id != "spell-no-suggestions" && - item.id != "spell-add-dictionaries-main" && - item.id != "context-savelinktopocket" && - item.id != "fill-login-saved-passwords" && - item.id != "fill-login-no-logins") { - ok(key, "menuitem " + item.id + " has an access key"); - if (accessKeys[key]) - ok(false, "menuitem " + item.id + " has same accesskey as " + accessKeys[key]); - else - accessKeys[key] = item.id; - } - if (!isGenerated && !isPageMenuItem) { - items.push(item.id); - } - if (isPageMenuItem) { - var p = {}; - p.type = item.getAttribute("type"); - p.icon = item.getAttribute("image"); - p.checked = item.hasAttribute("checked"); - p.disabled = item.hasAttribute("disabled"); - items.push(p); - } else { - items.push(!item.disabled); - } - } else if (item.nodeName == "menuseparator") { - ok(true, "--- seperator id is " + item.id); - items.push("---"); - items.push(null); - } else if (item.nodeName == "menu") { - if (isPageMenuItem) { - item.id = "generated-submenu-" + aData.generatedSubmenuId++; - } - ok(item.id, "child menu #" + i + " has an ID"); - if (!isPageMenuItem) { - ok(key, "menu has an access key"); - if (accessKeys[key]) - ok(false, "menu " + item.id + " has same accesskey as " + accessKeys[key]); - else - accessKeys[key] = item.id; - } - items.push(item.id); - items.push(!item.disabled); - // Add a dummy item so that the indexes in checkMenu are the same - // for expectedItems and actualItems. - items.push([]); - items.push(null); - } else if (item.nodeName == "menugroup") { - ok(item.id, "child menugroup #" + i + " has an ID"); - items.push(item.id); - items.push(!item.disabled); - var menugroupChildren = []; - for (var child of item.children) { - if (child.hidden) - continue; - - menugroupChildren.push([child.id, !child.disabled]); - } - items.push(menugroupChildren); - items.push(null); - } else { - ok(false, "child #" + i + " of menu ID " + aMenu.id + - " has an unknown type (" + item.nodeName + ")"); - } - } - return items; -} - -function checkContextMenu(expectedItems) { - is(contextMenu.state, "open", "checking if popup is open"); - var data = { generatedSubmenuId: 1 }; - checkMenu(contextMenu, expectedItems, data); -} - -function checkMenuItem(actualItem, actualEnabled, expectedItem, expectedEnabled, index) { - is(actualItem, expectedItem, - "checking item #" + index/2 + " (" + expectedItem + ") name"); - - if (typeof expectedEnabled == "object" && expectedEnabled != null || - typeof actualEnabled == "object" && actualEnabled != null) { - - ok(!(actualEnabled == null), "actualEnabled is not null"); - ok(!(expectedEnabled == null), "expectedEnabled is not null"); - is(typeof actualEnabled, typeof expectedEnabled, "checking types"); - - if (typeof actualEnabled != typeof expectedEnabled || - actualEnabled == null || expectedEnabled == null) - return; - - is(actualEnabled.type, expectedEnabled.type, - "checking item #" + index/2 + " (" + expectedItem + ") type attr value"); - var icon = actualEnabled.icon; - if (icon) { - var tmp = ""; - var j = icon.length - 1; - while (j && icon[j] != "/") { - tmp = icon[j--] + tmp; - } - icon = tmp; - } - is(icon, expectedEnabled.icon, - "checking item #" + index/2 + " (" + expectedItem + ") icon attr value"); - is(actualEnabled.checked, expectedEnabled.checked, - "checking item #" + index/2 + " (" + expectedItem + ") has checked attr"); - is(actualEnabled.disabled, expectedEnabled.disabled, - "checking item #" + index/2 + " (" + expectedItem + ") has disabled attr"); - } else if (expectedEnabled != null) - is(actualEnabled, expectedEnabled, - "checking item #" + index/2 + " (" + expectedItem + ") enabled state"); -} - -/* - * checkMenu - checks to see if the specified <menupopup> contains the - * expected items and state. - * expectedItems is a array of (1) item IDs and (2) a boolean specifying if - * the item is enabled or not (or null to ignore it). Submenus can be checked - * by providing a nested array entry after the expected <menu> ID. - * For example: ["blah", true, // item enabled - * "submenu", null, // submenu - * ["sub1", true, // submenu contents - * "sub2", false], null, // submenu contents - * "lol", false] // item disabled - * - */ -function checkMenu(menu, expectedItems, data) { - var actualItems = getVisibleMenuItems(menu, data); - // ok(false, "Items are: " + actualItems); - for (var i = 0; i < expectedItems.length; i+=2) { - var actualItem = actualItems[i]; - var actualEnabled = actualItems[i + 1]; - var expectedItem = expectedItems[i]; - var expectedEnabled = expectedItems[i + 1]; - if (expectedItem instanceof Array) { - ok(true, "Checking submenu/menugroup..."); - var previousId = expectedItems[i - 2]; // The last item was the menu ID. - var previousItem = menu.getElementsByAttribute("id", previousId)[0]; - ok(previousItem, (previousItem ? previousItem.nodeName : "item") + " with previous id (" + previousId + ") found"); - if (previousItem && previousItem.nodeName == "menu") { - ok(previousItem, "got a submenu element of id='" + previousId + "'"); - is(previousItem.nodeName, "menu", "submenu element of id='" + previousId + - "' has expected nodeName"); - checkMenu(previousItem.menupopup, expectedItem, data, i); - } else if (previousItem && previousItem.nodeName == "menugroup") { - ok(expectedItem.length, "menugroup must not be empty"); - for (var j = 0; j < expectedItem.length / 2; j++) { - checkMenuItem(actualItems[i][j][0], actualItems[i][j][1], expectedItem[j*2], expectedItem[j*2+1], i+j*2); - } - i += j; - } else { - ok(false, "previous item is not a menu or menugroup"); - } - } else { - checkMenuItem(actualItem, actualEnabled, expectedItem, expectedEnabled, i); - } - } - // Could find unexpected extra items at the end... - is(actualItems.length, expectedItems.length, "checking expected number of menu entries"); -} - -let lastElementSelector = null; -/** - * Right-clicks on the element that matches `selector` and checks the - * context menu that appears against the `menuItems` array. - * - * @param {String} selector - * A selector passed to querySelector to find - * the element that will be referenced. - * @param {Array} menuItems - * An array of menuitem ids and their associated enabled state. A state - * of null means that it will be ignored. Ids of '---' are used for - * menuseparators. - * @param {Object} options, optional - * skipFocusChange: don't move focus to the element before test, useful - * if you want to delay spell-check initialization - * offsetX: horizontal mouse offset from the top-left corner of - * the element, optional - * offsetY: vertical mouse offset from the top-left corner of the - * element, optional - * centered: if true, mouse position is centered in element, defaults - * to true if offsetX and offsetY are not provided - * waitForSpellCheck: wait until spellcheck is initialized before - * starting test - * preCheckContextMenuFn: callback to run before opening menu - * onContextMenuShown: callback to run when the context menu is shown - * postCheckContextMenuFn: callback to run after opening menu - * @return {Promise} resolved after the test finishes - */ -function* test_contextmenu(selector, menuItems, options={}) { - contextMenu = document.getElementById("contentAreaContextMenu"); - is(contextMenu.state, "closed", "checking if popup is closed"); - - // Default to centered if no positioning is defined. - if (!options.offsetX && !options.offsetY) { - options.centered = true; - } - - if (!options.skipFocusChange) { - yield ContentTask.spawn(gBrowser.selectedBrowser, - [lastElementSelector, selector], - function*([contentLastElementSelector, contentSelector]) { - if (contentLastElementSelector) { - let contentLastElement = content.document.querySelector(contentLastElementSelector); - contentLastElement.blur(); - } - let element = content.document.querySelector(contentSelector); - element.focus(); - }); - lastElementSelector = selector; - info(`Moved focus to ${selector}`); - } - - if (options.preCheckContextMenuFn) { - yield options.preCheckContextMenuFn(); - info("Completed preCheckContextMenuFn"); - } - - if (options.waitForSpellCheck) { - info("Waiting for spell check"); - yield ContentTask.spawn(gBrowser.selectedBrowser, selector, function*(contentSelector) { - let {onSpellCheck} = Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", {}); - let element = content.document.querySelector(contentSelector); - yield new Promise(resolve => onSpellCheck(element, resolve)); - info("Spell check running"); - }); - } - - let awaitPopupShown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown"); - yield BrowserTestUtils.synthesizeMouse(selector, options.offsetX || 0, options.offsetY || 0, { - type: "contextmenu", - button: 2, - shiftkey: options.shiftkey, - centered: options.centered - }, - gBrowser.selectedBrowser); - yield awaitPopupShown; - info("Popup Shown"); - - if (options.onContextMenuShown) { - yield options.onContextMenuShown(); - info("Completed onContextMenuShown"); - } - - if (menuItems) { - if (Services.prefs.getBoolPref("devtools.inspector.enabled")) { - let inspectItems = ["---", null, - "context-inspect", true]; - menuItems = menuItems.concat(inspectItems); - } - - checkContextMenu(menuItems); - } - - let awaitPopupHidden = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden"); - - if (options.postCheckContextMenuFn) { - yield options.postCheckContextMenuFn(); - info("Completed postCheckContextMenuFn"); - } - - contextMenu.hidePopup(); - yield awaitPopupHidden; -} diff --git a/browser/base/content/test/general/ctxmenu-image.png b/browser/base/content/test/general/ctxmenu-image.png Binary files differdeleted file mode 100644 index 4c3be5084..000000000 --- a/browser/base/content/test/general/ctxmenu-image.png +++ /dev/null diff --git a/browser/base/content/test/general/discovery.html b/browser/base/content/test/general/discovery.html deleted file mode 100644 index 1679e6545..000000000 --- a/browser/base/content/test/general/discovery.html +++ /dev/null @@ -1,8 +0,0 @@ -<!DOCTYPE HTML> -<html> - <head id="linkparent"> - <title>Autodiscovery Test</title> - </head> - <body> - </body> -</html> diff --git a/browser/base/content/test/general/download_page.html b/browser/base/content/test/general/download_page.html deleted file mode 100644 index 4f9154033..000000000 --- a/browser/base/content/test/general/download_page.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=676619 ---> - <head> - <title>Test for the download attribute</title> - - </head> - <body> - <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=676619">Bug 676619</a> - <br/> - <ul> - <li><a href="data:text/plain,Hey What are you looking for?" - download="test.txt" id="link1">Download "test.txt"</a></li> - <li><a href="video.ogg" - download id="link2">Download "video.ogg"</a></li> - <li><a href="video.ogg" - download="just some video" id="link3">Download "just some video"</a></li> - <li><a href="data:text/plain,test" - download="with-target.txt" id="link4">Download "with-target.txt"</a></li> - <li><a href="javascript:(1+2)+''" - download="javascript.txt" id="link5">Download "javascript.txt"</a></li> - </ul> - <script> - var li = document.createElement('li'); - var a = document.createElement('a'); - - a.href = window.URL.createObjectURL(new Blob(["just text"])) ; - a.download = "test.blob"; - a.id = "link6"; - a.textContent = 'Download "test.blob"'; - - li.appendChild(a); - document.getElementsByTagName('ul')[0].appendChild(li); - - window.addEventListener("beforeunload", function (evt) { - document.getElementById("unload-flag").textContent = "Fail"; - }); - </script> - <ul> - <li><a href="http://example.com/" - download="example.com" id="link7" target="_blank">Download "example.com"</a></li> - <ul> - <div id="unload-flag">Okay</div> - </body> -</html> diff --git a/browser/base/content/test/general/dummy_page.html b/browser/base/content/test/general/dummy_page.html deleted file mode 100644 index 1a87e2840..000000000 --- a/browser/base/content/test/general/dummy_page.html +++ /dev/null @@ -1,9 +0,0 @@ -<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> diff --git a/browser/base/content/test/general/feed_discovery.html b/browser/base/content/test/general/feed_discovery.html deleted file mode 100644 index baecba19b..000000000 --- a/browser/base/content/test/general/feed_discovery.html +++ /dev/null @@ -1,73 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=377611 ---> - <head> - <title>Test for feed discovery</title> - <meta charset="utf-8"> - - <!-- Straight up standard --> - <link rel="alternate" type="application/atom+xml" title="1" href="/1.atom" /> - <link rel="alternate" type="application/rss+xml" title="2" href="/2.rss" /> - <link rel="feed" title="3" href="/3.xml" /> - - <!-- rel is a space-separated list --> - <link rel=" alternate " type="application/atom+xml" title="4" href="/4.atom" /> - <link rel="foo alternate" type="application/atom+xml" title="5" href="/5.atom" /> - <link rel="alternate foo" type="application/atom+xml" title="6" href="/6.atom" /> - <link rel="foo alternate foo" type="application/atom+xml" title="7" href="/7.atom" /> - <link rel="meat feed cake" title="8" href="/8.atom" /> - - <!-- rel is case-insensitive --> - <link rel="ALTERNate" type="application/atom+xml" title="9" href="/9.atom" /> - <link rel="fEEd" title="10" href="/10.atom" /> - - <!-- type can have leading and trailing whitespace --> - <link rel="alternate" type=" application/atom+xml " title="11" href="/11.atom" /> - - <!-- type is case-insensitive --> - <link rel="alternate" type="aPPliCAtion/ATom+xML" title="12" href="/12.atom" /> - - <!-- "feed stylesheet" is a feed, though "alternate stylesheet" isn't --> - <link rel="feed stylesheet" title="13" href="/13.atom" /> - - <!-- hyphens or letters around rel not allowed --> - <link rel="disabled-alternate" type="application/atom+xml" title="Bogus1" href="/Bogus1" /> - <link rel="alternates" type="application/atom+xml" title="Bogus2" href="/Bogus2" /> - <link rel=" alternate-like" type="application/atom+xml" title="Bogus3" href="/Bogus3" /> - - <!-- don't tolerate text/xml if title includes 'rss' not as a word --> - <link rel="alternate" type="text/xml" title="Bogus4 scissorsshaped" href="/Bogus4" /> - - <!-- don't tolerate application/xml if title includes 'rss' not as a word --> - <link rel="alternate" type="application/xml" title="Bogus5 scissorsshaped" href="/Bogus5" /> - - <!-- don't tolerate application/rdf+xml if title includes 'rss' not as a word --> - <link rel="alternate" type="application/rdf+xml" title="Bogus6 scissorsshaped" href="/Bogus6" /> - - <!-- don't tolerate random types --> - <link rel="alternate" type="text/plain" title="Bogus7 rss" href="/Bogus7" /> - - <!-- don't find Atom by title --> - <link rel="foopy" type="application/atom+xml" title="Bogus8 Atom and RSS" href="/Bogus8" /> - - <!-- don't find application/rss+xml by title --> - <link rel="goats" type="application/rss+xml" title="Bogus9 RSS and Atom" href="/Bogus9" /> - - <!-- don't find application/rdf+xml by title --> - <link rel="alternate" type="application/rdf+xml" title="Bogus10 RSS and Atom" href="/Bogus10" /> - - <!-- don't find application/xml by title --> - <link rel="alternate" type="application/xml" title="Bogus11 RSS and Atom" href="/Bogus11" /> - - <!-- don't find text/xml by title --> - <link rel="alternate" type="text/xml" title="Bogus12 RSS and Atom" href="/Bogus12" /> - - <!-- alternate and stylesheet isn't a feed --> - <link rel="alternate stylesheet" type="application/rss+xml" title="Bogus13 RSS" href="/Bogus13" /> - </head> - <body> - </body> -</html> - diff --git a/browser/base/content/test/general/feed_tab.html b/browser/base/content/test/general/feed_tab.html deleted file mode 100644 index 50903f48b..000000000 --- a/browser/base/content/test/general/feed_tab.html +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=458579 ---> - <head> - <title>Test for page info feeds tab</title> - - <!-- Straight up standard --> - <link rel="alternate" type="application/atom+xml" title="1" href="/1.atom" /> - <link rel="alternate" type="application/rss+xml" title="2" href="/2.rss" /> - <link rel="feed" title="3" href="/3.xml" /> - - </head> - <body> - </body> -</html> diff --git a/browser/base/content/test/general/file_bug1045809_1.html b/browser/base/content/test/general/file_bug1045809_1.html deleted file mode 100644 index 9baf2d45d..000000000 --- a/browser/base/content/test/general/file_bug1045809_1.html +++ /dev/null @@ -1,7 +0,0 @@ -<html> - <head> - </head> - <body> - <iframe src="http://test1.example.com/browser/browser/base/content/test/general/file_bug1045809_2.html"></iframe> - </body> -</html> diff --git a/browser/base/content/test/general/file_bug1045809_2.html b/browser/base/content/test/general/file_bug1045809_2.html deleted file mode 100644 index 67a297dbc..000000000 --- a/browser/base/content/test/general/file_bug1045809_2.html +++ /dev/null @@ -1,7 +0,0 @@ -<html> - <head> - </head> - <body> - <div id="mixedContentContainer">Mixed Content is here</div> - </body> -</html> diff --git a/browser/base/content/test/general/file_bug822367_1.html b/browser/base/content/test/general/file_bug822367_1.html deleted file mode 100644 index 62f42d226..000000000 --- a/browser/base/content/test/general/file_bug822367_1.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test 1 for Mixed Content Blocker User Override - Mixed Script -https://bugzilla.mozilla.org/show_bug.cgi?id=822367 ---> -<head> - <meta charset="utf-8"> - <title>Test 1 for Bug 822367</title> -</head> -<body> - <div id="testContent"> - <p id="p1"></p> - </div> - <script src="http://example.com/browser/browser/base/content/test/general/file_bug822367_1.js"> - </script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug822367_1.js b/browser/base/content/test/general/file_bug822367_1.js deleted file mode 100644 index 175de363b..000000000 --- a/browser/base/content/test/general/file_bug822367_1.js +++ /dev/null @@ -1 +0,0 @@ -document.getElementById('p1').innerHTML="hello"; diff --git a/browser/base/content/test/general/file_bug822367_2.html b/browser/base/content/test/general/file_bug822367_2.html deleted file mode 100644 index fe56ee213..000000000 --- a/browser/base/content/test/general/file_bug822367_2.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test 2 for Mixed Content Blocker User Override - Mixed Display -https://bugzilla.mozilla.org/show_bug.cgi?id=822367 ---> -<head> - <meta charset="utf-8"> - <title>Test 2 for Bug 822367 - Mixed Display</title> -</head> -<body> - <div id="testContent"> - <img src="http://example.com/tests/image/test/mochitest/blue.png"> - </div> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug822367_3.html b/browser/base/content/test/general/file_bug822367_3.html deleted file mode 100644 index c1ff2c000..000000000 --- a/browser/base/content/test/general/file_bug822367_3.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test 3 for Mixed Content Blocker User Override - Mixed Script and Display -https://bugzilla.mozilla.org/show_bug.cgi?id=822367 ---> -<head> - <meta charset="utf-8"> - <title>Test 3 for Bug 822367</title> - <script> - function foo() { - var x = document.createElement('p'); - x.setAttribute("id", "p2"); - x.innerHTML = "bye"; - document.getElementById("testContent").appendChild(x); - } - </script> -</head> -<body> - <div id="testContent"> - <p id="p1"></p> - <img src="http://example.com/tests/image/test/mochitest/blue.png" onload="foo()"> - </div> - <script src="http://example.com/browser/browser/base/content/test/general/file_bug822367_1.js"> - </script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug822367_4.html b/browser/base/content/test/general/file_bug822367_4.html deleted file mode 100644 index 9a073143f..000000000 --- a/browser/base/content/test/general/file_bug822367_4.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test 4 for Mixed Content Blocker User Override - Mixed Script and Display -https://bugzilla.mozilla.org/show_bug.cgi?id=822367 ---> -<head> - <meta charset="utf-8"> - <title>Test 4 for Bug 822367</title> -</head> -<body> - <div id="testContent"> - <p id="p1"></p> - </div> - <script src="http://example.com/browser/browser/base/content/test/general/file_bug822367_4.js"> - </script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug822367_4.js b/browser/base/content/test/general/file_bug822367_4.js deleted file mode 100644 index 301db89c7..000000000 --- a/browser/base/content/test/general/file_bug822367_4.js +++ /dev/null @@ -1 +0,0 @@ -document.location = "https://example.com/browser/browser/base/content/test/general/file_bug822367_4B.html"; diff --git a/browser/base/content/test/general/file_bug822367_4B.html b/browser/base/content/test/general/file_bug822367_4B.html deleted file mode 100644 index 76ea2b623..000000000 --- a/browser/base/content/test/general/file_bug822367_4B.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test 4B for Mixed Content Blocker User Override - Location Changed -https://bugzilla.mozilla.org/show_bug.cgi?id=822367 ---> -<head> - <meta charset="utf-8"> - <title>Test 4B Location Change for Bug 822367</title> -</head> -<body> - <div id="testContent"> - <p id="p1"></p> - </div> - <script src="http://example.com/browser/browser/base/content/test/general/file_bug822367_1.js"> - </script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug822367_5.html b/browser/base/content/test/general/file_bug822367_5.html deleted file mode 100644 index 3c9a9317e..000000000 --- a/browser/base/content/test/general/file_bug822367_5.html +++ /dev/null @@ -1,24 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test 5 for Mixed Content Blocker User Override - Mixed Script in document.open() -https://bugzilla.mozilla.org/show_bug.cgi?id=822367 ---> -<head> - <meta charset="utf-8"> - <title>Test 5 for Bug 822367</title> - <script> - function createDoc() - { - var doc=document.open("text/html", "replace"); - doc.write('<!DOCTYPE html><html><body><p id="p1">This is some content</p><script src="http://example.com/browser/browser/base/content/test/general/file_bug822367_1.js">\<\/script\>\<\/body>\<\/html>'); - doc.close(); - } - </script> -</head> -<body> - <div id="testContent"> - <img src="https://example.com/tests/image/test/mochitest/blue.png" onload="createDoc()"> - </div> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug822367_6.html b/browser/base/content/test/general/file_bug822367_6.html deleted file mode 100644 index baa5674c2..000000000 --- a/browser/base/content/test/general/file_bug822367_6.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test 6 for Mixed Content Blocker User Override - Mixed Script in document.open() within an iframe -https://bugzilla.mozilla.org/show_bug.cgi?id=822367 ---> -<head> - <meta charset="utf-8"> - <title>Test 6 for Bug 822367</title> -</head> -<body> - <div id="testContent"> - <iframe name="f1" id="f1" src="https://example.com/browser/browser/base/content/test/general/file_bug822367_5.html"></iframe> - </div> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug902156.js b/browser/base/content/test/general/file_bug902156.js deleted file mode 100644 index f943dd628..000000000 --- a/browser/base/content/test/general/file_bug902156.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - * Once the mixed content blocker is disabled for the page, this scripts loads - * and updates the text inside the div container. - */ -document.getElementById("mctestdiv").innerHTML = "Mixed Content Blocker disabled"; diff --git a/browser/base/content/test/general/file_bug902156_1.html b/browser/base/content/test/general/file_bug902156_1.html deleted file mode 100644 index e3625de99..000000000 --- a/browser/base/content/test/general/file_bug902156_1.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 1 for Bug 902156 - See file browser_bug902156.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=902156 ---> -<head> - <meta charset="utf-8"> - <title>Test 1 for Bug 902156</title> -</head> -<body> - <div id="mctestdiv">Mixed Content Blocker enabled</div> - <script src="http://test1.example.com/browser/browser/base/content/test/general/file_bug902156.js" ></script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug902156_2.html b/browser/base/content/test/general/file_bug902156_2.html deleted file mode 100644 index 25aff3349..000000000 --- a/browser/base/content/test/general/file_bug902156_2.html +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 2 for Bug 902156 - See file browser_bug902156.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=902156 ---> -<head> - <meta charset="utf-8"> - <title>Test 2 for Bug 902156</title> -</head> -<body> - <div id="mctestdiv">Mixed Content Blocker enabled</div> - <a href="https://test2.example.com/browser/browser/base/content/test/general/file_bug902156_1.html" - id="mctestlink" target="_top">Go to http site</a> - <script src="http://test2.example.com/browser/browser/base/content/test/general/file_bug902156.js" ></script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug902156_3.html b/browser/base/content/test/general/file_bug902156_3.html deleted file mode 100644 index 65805adff..000000000 --- a/browser/base/content/test/general/file_bug902156_3.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 3 for Bug 902156 - See file browser_bug902156.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=902156 ---> -<head> - <meta charset="utf-8"> - <title>Test 3 for Bug 902156</title> -</head> -<body> - <div id="mctestdiv">Mixed Content Blocker enabled</div> - <script src="http://test1.example.com/browser/browser/base/content/test/general/file_bug902156.js" ></script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug906190.js b/browser/base/content/test/general/file_bug906190.js deleted file mode 100644 index f943dd628..000000000 --- a/browser/base/content/test/general/file_bug906190.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - * Once the mixed content blocker is disabled for the page, this scripts loads - * and updates the text inside the div container. - */ -document.getElementById("mctestdiv").innerHTML = "Mixed Content Blocker disabled"; diff --git a/browser/base/content/test/general/file_bug906190.sjs b/browser/base/content/test/general/file_bug906190.sjs deleted file mode 100644 index bff126874..000000000 --- a/browser/base/content/test/general/file_bug906190.sjs +++ /dev/null @@ -1,17 +0,0 @@ -function handleRequest(request, response) { - var page = "<!DOCTYPE html><html><body>bug 906190</body></html>"; - var path = "https://test1.example.com/browser/browser/base/content/test/general/"; - var url; - - if (request.queryString.includes('bad-redirection=1')) { - url = path + "this_page_does_not_exist.html"; - } else { - url = path + "file_bug906190_redirected.html"; - } - - response.setHeader("Cache-Control", "no-cache", false); - response.setHeader("Content-Type", "text/html", false); - response.setStatusLine(request.httpVersion, "302", "Found"); - response.setHeader("Location", url, false); - response.write(page); -} diff --git a/browser/base/content/test/general/file_bug906190_1.html b/browser/base/content/test/general/file_bug906190_1.html deleted file mode 100644 index cbb3cac26..000000000 --- a/browser/base/content/test/general/file_bug906190_1.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 1 for Bug 906190 - See file browser_bug902156.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=906190 ---> -<head> - <meta charset="utf-8"> - <title>Test 1 for Bug 906190</title> -</head> -<body> - <div id="mctestdiv">Mixed Content Blocker enabled</div> - <script src="http://test1.example.com/browser/browser/base/content/test/general/file_bug906190.js" ></script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug906190_2.html b/browser/base/content/test/general/file_bug906190_2.html deleted file mode 100644 index 70c7c61cf..000000000 --- a/browser/base/content/test/general/file_bug906190_2.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 2 for Bug 906190 - See file browser_bug902156.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=906190 ---> -<head> - <meta charset="utf-8"> - <title>Test 2 for Bug 906190</title> -</head> -<body> - <div id="mctestdiv">Mixed Content Blocker enabled</div> - <script src="http://test2.example.com/browser/browser/base/content/test/general/file_bug906190.js" ></script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug906190_3_4.html b/browser/base/content/test/general/file_bug906190_3_4.html deleted file mode 100644 index aea6648a9..000000000 --- a/browser/base/content/test/general/file_bug906190_3_4.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 3 and 4 for Bug 906190 - See file browser_bug902156.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=906190 ---> -<head> - <meta charset="utf-8"> - <meta http-equiv="refresh" content="0; url=https://test1.example.com/browser/browser/base/content/test/general/file_bug906190_redirected.html"> - <title>Test 3 and 4 for Bug 906190</title> -</head> -<body> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug906190_redirected.html b/browser/base/content/test/general/file_bug906190_redirected.html deleted file mode 100644 index cc324bd25..000000000 --- a/browser/base/content/test/general/file_bug906190_redirected.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Redirected Page of Test 3 to 6 for Bug 906190 - See file browser_bug902156.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=906190 ---> -<head> - <meta charset="utf-8"> - <title>Redirected Page for Bug 906190</title> -</head> -<body> - <div id="mctestdiv">Mixed Content Blocker enabled</div> - <script src="http://test1.example.com/browser/browser/base/content/test/general/file_bug906190.js" ></script> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug970276_favicon1.ico b/browser/base/content/test/general/file_bug970276_favicon1.ico Binary files differdeleted file mode 100644 index d44438903..000000000 --- a/browser/base/content/test/general/file_bug970276_favicon1.ico +++ /dev/null diff --git a/browser/base/content/test/general/file_bug970276_favicon2.ico b/browser/base/content/test/general/file_bug970276_favicon2.ico Binary files differdeleted file mode 100644 index d44438903..000000000 --- a/browser/base/content/test/general/file_bug970276_favicon2.ico +++ /dev/null diff --git a/browser/base/content/test/general/file_bug970276_popup1.html b/browser/base/content/test/general/file_bug970276_popup1.html deleted file mode 100644 index 5ce7dab87..000000000 --- a/browser/base/content/test/general/file_bug970276_popup1.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test file for bug 970276.</title> - - <!--Set a favicon; that's the whole point of this file.--> - <link rel="icon" href="file_bug970276_favicon1.ico"> -</head> -<body> - Test file for bug 970276. - - <iframe src="file_bug970276_popup2.html"> -</body> -</html> diff --git a/browser/base/content/test/general/file_bug970276_popup2.html b/browser/base/content/test/general/file_bug970276_popup2.html deleted file mode 100644 index 0b9e5294e..000000000 --- a/browser/base/content/test/general/file_bug970276_popup2.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test file for bug 970276.</title> - - <!--Set a favicon; that's the whole point of this file.--> - <link rel="icon" href="file_bug970276_favicon2.ico"> -</head> -<body> - Test inner file for bug 970276. -</body> -</html> diff --git a/browser/base/content/test/general/file_csp_block_all_mixedcontent.html b/browser/base/content/test/general/file_csp_block_all_mixedcontent.html deleted file mode 100644 index 93a7f13d9..000000000 --- a/browser/base/content/test/general/file_csp_block_all_mixedcontent.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE HTML> -<html><head><meta charset="utf-8"> -<title>Bug 1122236 - CSP: Implement block-all-mixed-content</title> -</head> -<meta http-equiv="Content-Security-Policy" content="block-all-mixed-content"> -<body> -<script src="http://example.com/browser/browser/base/content/test/general/file_csp_block_all_mixedcontent.js"/> -</body> -</html> diff --git a/browser/base/content/test/general/file_csp_block_all_mixedcontent.js b/browser/base/content/test/general/file_csp_block_all_mixedcontent.js deleted file mode 100644 index dc6d6a64e..000000000 --- a/browser/base/content/test/general/file_csp_block_all_mixedcontent.js +++ /dev/null @@ -1,3 +0,0 @@ -// empty script file just used for testing Bug 1122236. -// Making sure the UI is not degraded when blocking -// mixed content using the CSP directive: block-all-mixed-content. diff --git a/browser/base/content/test/general/file_documentnavigation_frameset.html b/browser/base/content/test/general/file_documentnavigation_frameset.html deleted file mode 100644 index beb01addf..000000000 --- a/browser/base/content/test/general/file_documentnavigation_frameset.html +++ /dev/null @@ -1,12 +0,0 @@ -<html id="outer"> - -<frameset rows="30%, 70%"> - <frame src="data:text/html,<html id='htmlframe1' ><body id='framebody1'><input id='i1'><body></html>"> - <frameset cols="30%, 33%, 34%"> - <frame src="data:text/html,<html id='htmlframe2'><body id='framebody2'><input id='i2'><body></html>"> - <frame src="data:text/html,<html id='htmlframe3'><body id='framebody3'><input id='i3'><body></html>"> - <frame src="data:text/html,<html id='htmlframe4'><body id='framebody4'><input id='i4'><body></html>"> - </frameset> -</frameset> - -</html> diff --git a/browser/base/content/test/general/file_double_close_tab.html b/browser/base/content/test/general/file_double_close_tab.html deleted file mode 100644 index 0bead5efc..000000000 --- a/browser/base/content/test/general/file_double_close_tab.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset="utf-8"> - <title>Test page that blocks beforeunload. Used in tests for bug 1050638 and bug 305085</title> - </head> - <body> - This page will block beforeunload. It should still be user-closable at all times. - <script> - window.onbeforeunload = function() { - return "stop"; - }; - </script> - </body> -</html> diff --git a/browser/base/content/test/general/file_favicon_change.html b/browser/base/content/test/general/file_favicon_change.html deleted file mode 100644 index 18ac6526b..000000000 --- a/browser/base/content/test/general/file_favicon_change.html +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE html> -<html><head> - <meta http-equiv="content-type" content="text/html; charset=utf-8"> - <link rel="icon" href="http://example.org/one-icon" type="image/ico" id="i"> -</head> -<body> - <script> - window.addEventListener("PleaseChangeFavicon", function() { - var ico = document.getElementById("i"); - ico.setAttribute("href", "http://example.org/other-icon"); - }); - </script> -</body></html> diff --git a/browser/base/content/test/general/file_favicon_change_not_in_document.html b/browser/base/content/test/general/file_favicon_change_not_in_document.html deleted file mode 100644 index deebb07dc..000000000 --- a/browser/base/content/test/general/file_favicon_change_not_in_document.html +++ /dev/null @@ -1,21 +0,0 @@ -<!DOCTYPE html> -<html><head> - <meta http-equiv="content-type" content="text/html; charset=utf-8"> - <link rel="icon" href="http://example.org/one-icon" type="image/ico" id="i"> -</head> -<body onload="onload()"> - <script> - function onload() { - var ico = document.createElement("link"); - ico.setAttribute("rel", "icon"); - ico.setAttribute("type", "image/ico"); - ico.setAttribute("href", "http://example.org/other-icon"); - setTimeout(function() { - ico.setAttribute("href", "http://example.org/yet-another-icon"); - document.getElementById("i").remove(); - document.head.appendChild(ico); - }, 1000); - } - </script> -</body></html> - diff --git a/browser/base/content/test/general/file_fullscreen-window-open.html b/browser/base/content/test/general/file_fullscreen-window-open.html deleted file mode 100644 index 1584f4c98..000000000 --- a/browser/base/content/test/general/file_fullscreen-window-open.html +++ /dev/null @@ -1,24 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>Test for window.open() when browser is in fullscreen</title> - </head> - <body> - <script> - window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad, true); - - document.getElementById("test").addEventListener("click", onClick, true); - }, true); - - function onClick(aEvent) { - aEvent.preventDefault(); - - var dataStr = aEvent.target.getAttribute("data-test-param"); - var data = JSON.parse(dataStr); - window.open(data.uri, data.title, data.option); - } - </script> - <a id="test" href="" data-test-param="">Test</a> - </body> -</html> diff --git a/browser/base/content/test/general/file_generic_favicon.ico b/browser/base/content/test/general/file_generic_favicon.ico Binary files differdeleted file mode 100644 index d44438903..000000000 --- a/browser/base/content/test/general/file_generic_favicon.ico +++ /dev/null diff --git a/browser/base/content/test/general/file_mediaPlayback.html b/browser/base/content/test/general/file_mediaPlayback.html deleted file mode 100644 index a6979287e..000000000 --- a/browser/base/content/test/general/file_mediaPlayback.html +++ /dev/null @@ -1,2 +0,0 @@ -<!DOCTYPE html> -<audio src="audio.ogg" controls loop> diff --git a/browser/base/content/test/general/file_mixedContentFramesOnHttp.html b/browser/base/content/test/general/file_mixedContentFramesOnHttp.html deleted file mode 100644 index 3bd16aea5..000000000 --- a/browser/base/content/test/general/file_mixedContentFramesOnHttp.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test for https://bugzilla.mozilla.org/show_bug.cgi?id=1182551 ---> -<head> - <meta charset="utf-8"> - <title>Test for Bug 1182551</title> -</head> -<body> - <p>Test for Bug 1182551. This is an HTTP top level page. We include an HTTPS iframe that loads mixed passive content.</p> - <iframe src="https://example.org/browser/browser/base/content/test/general/file_mixedPassiveContent.html"></iframe> -</body> -</html> diff --git a/browser/base/content/test/general/file_mixedContentFromOnunload.html b/browser/base/content/test/general/file_mixedContentFromOnunload.html deleted file mode 100644 index fb28a2889..000000000 --- a/browser/base/content/test/general/file_mixedContentFromOnunload.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test for https://bugzilla.mozilla.org/show_bug.cgi?id=947079 ---> -<head> - <meta charset="utf-8"> - <title>Test for Bug 947079</title> -</head> -<body> - <p>Test for Bug 947079</p> - <script> - window.addEventListener('unload', function() { - new Image().src = 'http://mochi.test:8888/tests/image/test/mochitest/blue.png'; - }); - </script> -</body> -</html> diff --git a/browser/base/content/test/general/file_mixedContentFromOnunload_test1.html b/browser/base/content/test/general/file_mixedContentFromOnunload_test1.html deleted file mode 100644 index 1d027b036..000000000 --- a/browser/base/content/test/general/file_mixedContentFromOnunload_test1.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test 1 for https://bugzilla.mozilla.org/show_bug.cgi?id=947079 -Page with no insecure subresources ---> -<head> - <meta charset="utf-8"> - <title>Test 1 for Bug 947079</title> -</head> -<body> - <p>There are no insecure resource loads on this page</p> -</body> -</html> diff --git a/browser/base/content/test/general/file_mixedContentFromOnunload_test2.html b/browser/base/content/test/general/file_mixedContentFromOnunload_test2.html deleted file mode 100644 index 4813337cc..000000000 --- a/browser/base/content/test/general/file_mixedContentFromOnunload_test2.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test 2 for https://bugzilla.mozilla.org/show_bug.cgi?id=947079 -Page with an insecure image load ---> -<head> - <meta charset="utf-8"> - <title>Test 2 for Bug 947079</title> -</head> -<body> - <p>Page with http image load</p> - <img src="http://test2.example.com/tests/image/test/mochitest/blue.png"> -</body> -</html> diff --git a/browser/base/content/test/general/file_mixedPassiveContent.html b/browser/base/content/test/general/file_mixedPassiveContent.html deleted file mode 100644 index a60ac94e8..000000000 --- a/browser/base/content/test/general/file_mixedPassiveContent.html +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -Test for https://bugzilla.mozilla.org/show_bug.cgi?id=1182551 ---> -<head> - <meta charset="utf-8"> - <title>HTTPS page with HTTP image</title> -</head> -<body> - <img src="http://mochi.test:8888/tests/image/test/mochitest/blue.png"> -</body> -</html> diff --git a/browser/base/content/test/general/file_trackingUI_6.html b/browser/base/content/test/general/file_trackingUI_6.html deleted file mode 100644 index 52e1ae63f..000000000 --- a/browser/base/content/test/general/file_trackingUI_6.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="UTF-8"> - <title>Testing the shield from fetch and XHR</title> -</head> -<body> - <p>Hello there!</p> - <script type="application/javascript; version=1.8"> - function test_fetch() { - let url = "http://trackertest.org/browser/browser/base/content/test/general/file_trackingUI_6.js"; - return fetch(url); - } - </script> -</body> -</html> diff --git a/browser/base/content/test/general/file_trackingUI_6.js b/browser/base/content/test/general/file_trackingUI_6.js deleted file mode 100644 index f7ac687cf..000000000 --- a/browser/base/content/test/general/file_trackingUI_6.js +++ /dev/null @@ -1,2 +0,0 @@ -/* Some code goes here! */ -void 0; diff --git a/browser/base/content/test/general/file_trackingUI_6.js^headers^ b/browser/base/content/test/general/file_trackingUI_6.js^headers^ deleted file mode 100644 index cb762eff8..000000000 --- a/browser/base/content/test/general/file_trackingUI_6.js^headers^ +++ /dev/null @@ -1 +0,0 @@ -Access-Control-Allow-Origin: * diff --git a/browser/base/content/test/general/file_with_favicon.html b/browser/base/content/test/general/file_with_favicon.html deleted file mode 100644 index 0702b4aab..000000000 --- a/browser/base/content/test/general/file_with_favicon.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test file for bugs with favicons</title> - - <!--Set a favicon; that's the whole point of this file.--> - <link rel="icon" href="file_generic_favicon.ico"> -</head> -<body> - Test file for bugs with favicons -</body> -</html> diff --git a/browser/base/content/test/general/fxa_profile_handler.sjs b/browser/base/content/test/general/fxa_profile_handler.sjs deleted file mode 100644 index 7160b76d0..000000000 --- a/browser/base/content/test/general/fxa_profile_handler.sjs +++ /dev/null @@ -1,34 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -// This is basically an echo server! -// We just grab responseStatus and responseBody query params! - -function reallyHandleRequest(request, response) { - var query = "?" + request.queryString; - - var responseStatus = 200; - var match = /responseStatus=([^&]*)/.exec(query); - if (match) { - responseStatus = parseInt(match[1]); - } - - var responseBody = ""; - match = /responseBody=([^&]*)/.exec(query); - if (match) { - responseBody = decodeURIComponent(match[1]); - } - - response.setStatusLine("1.0", responseStatus, "OK"); - response.write(responseBody); -} - -function handleRequest(request, response) -{ - try { - reallyHandleRequest(request, response); - } catch (e) { - response.setStatusLine("1.0", 500, "NotOK"); - response.write("Error handling request: " + e); - } -} diff --git a/browser/base/content/test/general/gZipOfflineChild.cacheManifest b/browser/base/content/test/general/gZipOfflineChild.cacheManifest deleted file mode 100644 index ae0545d12..000000000 --- a/browser/base/content/test/general/gZipOfflineChild.cacheManifest +++ /dev/null @@ -1,2 +0,0 @@ -CACHE MANIFEST -gZipOfflineChild.html diff --git a/browser/base/content/test/general/gZipOfflineChild.cacheManifest^headers^ b/browser/base/content/test/general/gZipOfflineChild.cacheManifest^headers^ deleted file mode 100644 index 257f2eb60..000000000 --- a/browser/base/content/test/general/gZipOfflineChild.cacheManifest^headers^ +++ /dev/null @@ -1 +0,0 @@ -Content-Type: text/cache-manifest diff --git a/browser/base/content/test/general/gZipOfflineChild.html b/browser/base/content/test/general/gZipOfflineChild.html Binary files differdeleted file mode 100644 index ea2caa125..000000000 --- a/browser/base/content/test/general/gZipOfflineChild.html +++ /dev/null diff --git a/browser/base/content/test/general/gZipOfflineChild.html^headers^ b/browser/base/content/test/general/gZipOfflineChild.html^headers^ deleted file mode 100644 index 4204d8601..000000000 --- a/browser/base/content/test/general/gZipOfflineChild.html^headers^ +++ /dev/null @@ -1,2 +0,0 @@ -Content-Type: text/html -Content-Encoding: gzip diff --git a/browser/base/content/test/general/gZipOfflineChild_uncompressed.html b/browser/base/content/test/general/gZipOfflineChild_uncompressed.html deleted file mode 100644 index 4ab8f8d5e..000000000 --- a/browser/base/content/test/general/gZipOfflineChild_uncompressed.html +++ /dev/null @@ -1,21 +0,0 @@ -<html manifest="gZipOfflineChild.cacheManifest"> -<head> - <!-- This file is gzipped to create gZipOfflineChild.html --> -<title></title> -<script type="text/javascript"> - -function finish(success) { - window.parent.postMessage(success, "*"); -} - -applicationCache.oncached = function() { finish("oncache"); } -applicationCache.onnoupdate = function() { finish("onupdate"); } -applicationCache.onerror = function() { finish("onerror"); } - -</script> -</head> - -<body> -<h1>Child</h1> -</body> -</html> diff --git a/browser/base/content/test/general/head.js b/browser/base/content/test/general/head.js deleted file mode 100644 index 6c28615fe..000000000 --- a/browser/base/content/test/general/head.js +++ /dev/null @@ -1,1069 +0,0 @@ -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"); - -/** - * Wait for a <notification> to be closed then call the specified callback. - */ -function waitForNotificationClose(notification, cb) { - let parent = notification.parentNode; - - let observer = new MutationObserver(function onMutatations(mutations) { - for (let mutation of mutations) { - for (let i = 0; i < mutation.removedNodes.length; i++) { - let node = mutation.removedNodes.item(i); - if (node != notification) { - continue; - } - observer.disconnect(); - cb(); - } - } - }); - observer.observe(parent, {childList: true}); -} - -function closeAllNotifications () { - let notificationBox = document.getElementById("global-notificationbox"); - - if (!notificationBox || !notificationBox.currentNotification) { - return Promise.resolve(); - } - - let deferred = Promise.defer(); - for (let notification of notificationBox.allNotifications) { - waitForNotificationClose(notification, function () { - if (notificationBox.allNotifications.length === 0) { - deferred.resolve(); - } - }); - notification.close(); - } - - return deferred.promise; -} - -function whenDelayedStartupFinished(aWindow, aCallback) { - Services.obs.addObserver(function observer(aSubject, aTopic) { - if (aWindow == aSubject) { - Services.obs.removeObserver(observer, aTopic); - executeSoon(aCallback); - } - }, "browser-delayed-startup-finished", false); -} - -function updateTabContextMenu(tab, onOpened) { - let menu = document.getElementById("tabContextMenu"); - if (!tab) - tab = gBrowser.selectedTab; - var evt = new Event(""); - tab.dispatchEvent(evt); - menu.openPopup(tab, "end_after", 0, 0, true, false, evt); - is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab"); - const onFinished = () => menu.hidePopup(); - if (onOpened) { - return Task.spawn(function*() { - yield onOpened(); - onFinished(); - }); - } - onFinished(); - return Promise.resolve(); -} - -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(); -} - -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); - }); -} - -/** - * Allows setting focus on a window, and waiting for that window to achieve - * focus. - * - * @param aWindow - * The window to focus and wait for. - * - * @return {Promise} - * @resolves When the window is focused. - * @rejects Never. - */ -function promiseWaitForFocus(aWindow) { - return new Promise((resolve) => { - waitForFocus(resolve, aWindow); - }); -} - -function getTestPlugin(aName) { - var pluginName = aName || "Test Plug-in"; - var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); - var tags = ph.getPluginTags(); - - // Find the test plugin - for (var i = 0; i < tags.length; i++) { - if (tags[i].name == pluginName) - return tags[i]; - } - ok(false, "Unable to find plugin"); - return null; -} - -// call this to set the test plugin(s) initially expected enabled state. -// it will automatically be reset to it's previous value after the test -// ends -function setTestPluginEnabledState(newEnabledState, pluginName) { - var plugin = getTestPlugin(pluginName); - var oldEnabledState = plugin.enabledState; - plugin.enabledState = newEnabledState; - SimpleTest.registerCleanupFunction(function() { - getTestPlugin(pluginName).enabledState = oldEnabledState; - }); -} - -function pushPrefs(...aPrefs) { - let deferred = Promise.defer(); - SpecialPowers.pushPrefEnv({"set": aPrefs}, deferred.resolve); - return deferred.promise; -} - -function updateBlocklist(aCallback) { - var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"] - .getService(Ci.nsITimerCallback); - var observer = function() { - Services.obs.removeObserver(observer, "blocklist-updated"); - SimpleTest.executeSoon(aCallback); - }; - Services.obs.addObserver(observer, "blocklist-updated", false); - blocklistNotifier.notify(null); -} - -var _originalTestBlocklistURL = null; -function setAndUpdateBlocklist(aURL, aCallback) { - if (!_originalTestBlocklistURL) - _originalTestBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url"); - Services.prefs.setCharPref("extensions.blocklist.url", aURL); - updateBlocklist(aCallback); -} - -function resetBlocklist() { - Services.prefs.setCharPref("extensions.blocklist.url", _originalTestBlocklistURL); -} - -function whenNewWindowLoaded(aOptions, aCallback) { - let win = OpenBrowserWindow(aOptions); - win.addEventListener("load", function onLoad() { - win.removeEventListener("load", onLoad, false); - aCallback(win); - }, false); -} - -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; -} - -/** - * Waits for all pending async statements on the default connection, before - * proceeding with aCallback. - * - * @param aCallback - * Function to be called when done. - * @param aScope - * Scope for the callback. - * @param aArguments - * Arguments array for the callback. - * - * @note The result is achieved by asynchronously executing a query requiring - * a write lock. Since all statements on the same connection are - * serialized, the end of this write operation means that all writes are - * complete. Note that WAL makes so that writers don't block readers, but - * this is a problem only across different connections. - */ -function waitForAsyncUpdates(aCallback, aScope, aArguments) { - let scope = aScope || this; - let args = aArguments || []; - let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase) - .DBConnection; - let begin = db.createAsyncStatement("BEGIN EXCLUSIVE"); - begin.executeAsync(); - begin.finalize(); - - let commit = db.createAsyncStatement("COMMIT"); - commit.executeAsync({ - handleResult: function() {}, - handleError: function() {}, - handleCompletion: function(aReason) { - aCallback.apply(scope, args); - } - }); - commit.finalize(); -} - -/** - * Asynchronously check a url is visited. - - * @param aURI The URI. - * @param aExpectedValue The expected value. - * @return {Promise} - * @resolves When the check has been added successfully. - * @rejects JavaScript exception. - */ -function promiseIsURIVisited(aURI, aExpectedValue) { - let deferred = Promise.defer(); - PlacesUtils.asyncHistory.isURIVisited(aURI, function(unused, aIsVisited) { - deferred.resolve(aIsVisited); - }); - - 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; -} - -/** - * Ensures that the specified URIs are either cleared or not. - * - * @param aURIs - * Array of page URIs - * @param aShouldBeCleared - * True if each visit to the URI should be cleared, false otherwise - */ -function promiseHistoryClearedState(aURIs, aShouldBeCleared) { - let deferred = Promise.defer(); - let callbackCount = 0; - let niceStr = aShouldBeCleared ? "no longer" : "still"; - function callbackDone() { - if (++callbackCount == aURIs.length) - deferred.resolve(); - } - aURIs.forEach(function (aURI) { - PlacesUtils.asyncHistory.isURIVisited(aURI, function(uri, isVisited) { - is(isVisited, !aShouldBeCleared, - "history visit " + uri.spec + " should " + niceStr + " exist"); - callbackDone(); - }); - }); - - 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(contentStopFromProgressListener) { - 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(contentStopFromProgressListener, 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 the next load to complete in any browser or the given browser. - * If a <tabbrowser> is given it waits for a load in any of its browsers. - * - * @return promise - */ -function waitForDocLoadComplete(aBrowser=gBrowser) { - return new Promise(resolve => { - let listener = { - onStateChange: function (webProgress, req, flags, status) { - let docStop = Ci.nsIWebProgressListener.STATE_IS_NETWORK | - Ci.nsIWebProgressListener.STATE_STOP; - info("Saw state " + flags.toString(16) + " and status " + status.toString(16)); - - // When a load needs to be retargetted to a new process it is cancelled - // with NS_BINDING_ABORTED so ignore that case - if ((flags & docStop) == docStop && status != Cr.NS_BINDING_ABORTED) { - aBrowser.removeProgressListener(this); - waitForDocLoadComplete.listeners.delete(this); - - let chan = req.QueryInterface(Ci.nsIChannel); - info("Browser loaded " + chan.originalURI.spec); - resolve(); - } - }, - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, - Ci.nsISupportsWeakReference]) - }; - aBrowser.addProgressListener(listener); - waitForDocLoadComplete.listeners.add(listener); - info("Waiting for browser load"); - }); -} - -// Keep a set of progress listeners for waitForDocLoadComplete() to make sure -// they're not GC'ed before we saw the page load. -waitForDocLoadComplete.listeners = new Set(); -registerCleanupFunction(() => waitForDocLoadComplete.listeners.clear()); - -var FullZoomHelper = { - - selectTabAndWaitForLocationChange: function selectTabAndWaitForLocationChange(tab) { - if (!tab) - throw new Error("tab must be given."); - if (gBrowser.selectedTab == tab) - return Promise.resolve(); - - return Promise.all([BrowserTestUtils.switchTab(gBrowser, tab), - this.waitForLocationChange()]); - }, - - removeTabAndWaitForLocationChange: function removeTabAndWaitForLocationChange(tab) { - tab = tab || gBrowser.selectedTab; - let selected = gBrowser.selectedTab == tab; - gBrowser.removeTab(tab); - if (selected) - return this.waitForLocationChange(); - return Promise.resolve(); - }, - - waitForLocationChange: function waitForLocationChange() { - return new Promise(resolve => { - Services.obs.addObserver(function obs(subj, topic, data) { - Services.obs.removeObserver(obs, topic); - resolve(); - }, "browser-fullZoom:location-change", false); - }); - }, - - load: function load(tab, url) { - return new Promise(resolve => { - let didLoad = false; - let didZoom = false; - - promiseTabLoadEvent(tab).then(event => { - didLoad = true; - if (didZoom) - resolve(); - }, true); - - this.waitForLocationChange().then(function () { - didZoom = true; - if (didLoad) - resolve(); - }); - - tab.linkedBrowser.loadURI(url); - }); - }, - - zoomTest: function zoomTest(tab, val, msg) { - is(ZoomManager.getZoomForBrowser(tab.linkedBrowser), val, msg); - }, - - enlarge: function enlarge() { - return new Promise(resolve => FullZoom.enlarge(resolve)); - }, - - reduce: function reduce() { - return new Promise(resolve => FullZoom.reduce(resolve)); - }, - - reset: function reset() { - return FullZoom.reset(); - }, - - BACK: 0, - FORWARD: 1, - navigate: function navigate(direction) { - return new Promise(resolve => { - let didPs = false; - let didZoom = false; - - gBrowser.addEventListener("pageshow", function listener(event) { - gBrowser.removeEventListener("pageshow", listener, true); - didPs = true; - if (didZoom) - resolve(); - }, true); - - if (direction == this.BACK) - gBrowser.goBack(); - else if (direction == this.FORWARD) - gBrowser.goForward(); - - this.waitForLocationChange().then(function () { - didZoom = true; - if (didPs) - resolve(); - }); - }); - }, - - failAndContinue: function failAndContinue(func) { - return function (err) { - ok(false, err); - func(); - }; - }, -}; - -/** - * 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) -{ - 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; - } - - let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle); - - if (url) - BrowserTestUtils.loadURI(tab.linkedBrowser, url); - - return loaded; -} - -/** - * Returns a Promise that resolves once a new tab has been opened in - * a xul:tabbrowser. - * - * @param aTabBrowser - * The xul:tabbrowser to monitor for a new tab. - * @return {Promise} - * Resolved when the new tab has been opened. - * @resolves to the TabOpen event that was fired. - * @rejects Never. - */ -function waitForNewTabEvent(aTabBrowser) { - return promiseWaitForEvent(aTabBrowser.tabContainer, "TabOpen"); -} - -/** - * Test the state of the identity box and control center to make - * sure they are correctly showing the expected mixed content states. - * - * @note The checks are done synchronously, but new code should wait on the - * returned Promise object to ensure the identity panel has closed. - * Bug 1221114 is filed to fix the existing code. - * - * @param tabbrowser - * @param Object states - * MUST include the following properties: - * { - * activeLoaded: true|false, - * activeBlocked: true|false, - * passiveLoaded: true|false, - * } - * - * @return {Promise} - * @resolves When the operation has finished and the identity panel has closed. - */ -function assertMixedContentBlockingState(tabbrowser, states = {}) { - if (!tabbrowser || !("activeLoaded" in states) || - !("activeBlocked" in states) || !("passiveLoaded" in states)) { - throw new Error("assertMixedContentBlockingState requires a browser and a states object"); - } - - let {passiveLoaded, activeLoaded, activeBlocked} = states; - let {gIdentityHandler} = tabbrowser.ownerGlobal; - let doc = tabbrowser.ownerDocument; - let identityBox = gIdentityHandler._identityBox; - let classList = identityBox.classList; - let connectionIcon = doc.getElementById("connection-icon"); - let connectionIconImage = tabbrowser.ownerGlobal.getComputedStyle(connectionIcon). - getPropertyValue("list-style-image"); - - let stateSecure = gIdentityHandler._state & Ci.nsIWebProgressListener.STATE_IS_SECURE; - let stateBroken = gIdentityHandler._state & Ci.nsIWebProgressListener.STATE_IS_BROKEN; - let stateInsecure = gIdentityHandler._state & Ci.nsIWebProgressListener.STATE_IS_INSECURE; - let stateActiveBlocked = gIdentityHandler._state & Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT; - let stateActiveLoaded = gIdentityHandler._state & Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT; - let statePassiveLoaded = gIdentityHandler._state & Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT; - - is(activeBlocked, !!stateActiveBlocked, "Expected state for activeBlocked matches UI state"); - is(activeLoaded, !!stateActiveLoaded, "Expected state for activeLoaded matches UI state"); - is(passiveLoaded, !!statePassiveLoaded, "Expected state for passiveLoaded matches UI state"); - - if (stateInsecure) { - // HTTP request, there should be no MCB classes for the identity box and the non secure icon - // should always be visible regardless of MCB state. - ok(classList.contains("unknownIdentity"), "unknownIdentity on HTTP page"); - is_element_hidden(connectionIcon); - - ok(!classList.contains("mixedActiveContent"), "No MCB icon on HTTP page"); - ok(!classList.contains("mixedActiveBlocked"), "No MCB icon on HTTP page"); - ok(!classList.contains("mixedDisplayContent"), "No MCB icon on HTTP page"); - ok(!classList.contains("mixedDisplayContentLoadedActiveBlocked"), "No MCB icon on HTTP page"); - } else { - // Make sure the identity box UI has the correct mixedcontent states and icons - is(classList.contains("mixedActiveContent"), activeLoaded, - "identityBox has expected class for activeLoaded"); - is(classList.contains("mixedActiveBlocked"), activeBlocked && !passiveLoaded, - "identityBox has expected class for activeBlocked && !passiveLoaded"); - is(classList.contains("mixedDisplayContent"), passiveLoaded && !(activeLoaded || activeBlocked), - "identityBox has expected class for passiveLoaded && !(activeLoaded || activeBlocked)"); - is(classList.contains("mixedDisplayContentLoadedActiveBlocked"), passiveLoaded && activeBlocked, - "identityBox has expected class for passiveLoaded && activeBlocked"); - - is_element_visible(connectionIcon); - if (activeLoaded) { - is(connectionIconImage, "url(\"chrome://browser/skin/connection-mixed-active-loaded.svg#icon\")", - "Using active loaded icon"); - } - if (activeBlocked && !passiveLoaded) { - is(connectionIconImage, "url(\"chrome://browser/skin/connection-secure.svg\")", - "Using active blocked icon"); - } - if (passiveLoaded && !(activeLoaded || activeBlocked)) { - is(connectionIconImage, "url(\"chrome://browser/skin/connection-mixed-passive-loaded.svg#icon\")", - "Using passive loaded icon"); - } - if (passiveLoaded && activeBlocked) { - is(connectionIconImage, "url(\"chrome://browser/skin/connection-mixed-passive-loaded.svg#icon\")", - "Using active blocked and passive loaded icon"); - } - } - - // Make sure the identity popup has the correct mixedcontent states - gIdentityHandler._identityBox.click(); - let popupAttr = doc.getElementById("identity-popup").getAttribute("mixedcontent"); - let bodyAttr = doc.getElementById("identity-popup-securityView-body").getAttribute("mixedcontent"); - - is(popupAttr.includes("active-loaded"), activeLoaded, - "identity-popup has expected attr for activeLoaded"); - is(bodyAttr.includes("active-loaded"), activeLoaded, - "securityView-body has expected attr for activeLoaded"); - - is(popupAttr.includes("active-blocked"), activeBlocked, - "identity-popup has expected attr for activeBlocked"); - is(bodyAttr.includes("active-blocked"), activeBlocked, - "securityView-body has expected attr for activeBlocked"); - - is(popupAttr.includes("passive-loaded"), passiveLoaded, - "identity-popup has expected attr for passiveLoaded"); - is(bodyAttr.includes("passive-loaded"), passiveLoaded, - "securityView-body has expected attr for passiveLoaded"); - - // Make sure the correct icon is visible in the Control Center. - // This logic is controlled with CSS, so this helps prevent regressions there. - let securityView = doc.getElementById("identity-popup-securityView"); - let securityViewBG = tabbrowser.ownerGlobal.getComputedStyle(securityView). - getPropertyValue("background-image"); - let securityContentBG = tabbrowser.ownerGlobal.getComputedStyle(securityView). - getPropertyValue("background-image"); - - if (stateInsecure) { - is(securityViewBG, "url(\"chrome://browser/skin/controlcenter/conn-not-secure.svg\")", - "CC using 'not secure' icon"); - is(securityContentBG, "url(\"chrome://browser/skin/controlcenter/conn-not-secure.svg\")", - "CC using 'not secure' icon"); - } - - if (stateSecure) { - is(securityViewBG, "url(\"chrome://browser/skin/controlcenter/connection.svg#connection-secure\")", - "CC using secure icon"); - is(securityContentBG, "url(\"chrome://browser/skin/controlcenter/connection.svg#connection-secure\")", - "CC using secure icon"); - } - - if (stateBroken) { - if (activeLoaded) { - is(securityViewBG, "url(\"chrome://browser/skin/controlcenter/mcb-disabled.svg\")", - "CC using active loaded icon"); - is(securityContentBG, "url(\"chrome://browser/skin/controlcenter/mcb-disabled.svg\")", - "CC using active loaded icon"); - } else if (activeBlocked || passiveLoaded) { - is(securityViewBG, "url(\"chrome://browser/skin/controlcenter/connection.svg#connection-degraded\")", - "CC using degraded icon"); - is(securityContentBG, "url(\"chrome://browser/skin/controlcenter/connection.svg#connection-degraded\")", - "CC using degraded icon"); - } else { - // There is a case here with weak ciphers, but no bc tests are handling this yet. - is(securityViewBG, "url(\"chrome://browser/skin/controlcenter/connection.svg#connection-degraded\")", - "CC using degraded icon"); - is(securityContentBG, "url(\"chrome://browser/skin/controlcenter/connection.svg#connection-degraded\")", - "CC using degraded icon"); - } - } - - if (activeLoaded || activeBlocked || passiveLoaded) { - doc.getElementById("identity-popup-security-expander").click(); - is(Array.filter(doc.querySelectorAll("[observes=identity-popup-mcb-learn-more]"), - element => !is_hidden(element)).length, 1, - "The 'Learn more' link should be visible once."); - } - - gIdentityHandler._identityPopup.hidden = true; - - // Wait for the panel to be closed before continuing. The promisePopupHidden - // function cannot be used because it's unreliable unless promisePopupShown is - // also called before closing the panel. This cannot be done until all callers - // are made asynchronous (bug 1221114). - return new Promise(resolve => executeSoon(resolve)); -} - -function is_hidden(element) { - var style = element.ownerGlobal.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.ownerGlobal.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 promiseNotificationShown(notification) { - let win = notification.browser.ownerGlobal; - if (win.PopupNotifications.panel.state == "open") { - return Promise.resolve(); - } - let panelPromise = promisePopupShown(win.PopupNotifications.panel); - notification.reshow(); - return panelPromise; -} - -/** - * Allows waiting for an observer notification once. - * - * @param aTopic - * Notification topic to observe. - * - * @return {Promise} - * @resolves An object with subject and data properties from the observed - * notification. - * @rejects Never. - */ -function promiseTopicObserved(aTopic) -{ - return new Promise((resolve) => { - Services.obs.addObserver( - function PTO_observe(aSubject, aTopic2, aData) { - Services.obs.removeObserver(PTO_observe, aTopic2); - resolve({subject: aSubject, data: aData}); - }, aTopic, false); - }); -} - -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(); - }, - }); - }); -} - -// Compares the security state of the page with what is expected -function isSecurityState(expectedState) { - let ui = gTestBrowser.securityUI; - if (!ui) { - ok(false, "No security UI to get the security state"); - return; - } - - const wpl = Components.interfaces.nsIWebProgressListener; - - // determine the security state - let isSecure = ui.state & wpl.STATE_IS_SECURE; - let isBroken = ui.state & wpl.STATE_IS_BROKEN; - let isInsecure = ui.state & wpl.STATE_IS_INSECURE; - - let actualState; - if (isSecure && !(isBroken || isInsecure)) { - actualState = "secure"; - } else if (isBroken && !(isSecure || isInsecure)) { - actualState = "broken"; - } else if (isInsecure && !(isSecure || isBroken)) { - actualState = "insecure"; - } else { - actualState = "unknown"; - } - - is(expectedState, actualState, "Expected state " + expectedState + " and the actual state is " + actualState + "."); -} - -/** - * Resolves when a bookmark with the given uri is added. - */ -function promiseOnBookmarkItemAdded(aExpectedURI) { - return new Promise((resolve, reject) => { - let bookmarksObserver = { - onItemAdded: function (aItemId, aFolderId, aIndex, aItemType, aURI) { - info("Added a bookmark to " + aURI.spec); - PlacesUtils.bookmarks.removeObserver(bookmarksObserver); - if (aURI.equals(aExpectedURI)) { - resolve(); - } - else { - reject(new Error("Added an unexpected bookmark")); - } - }, - onBeginUpdateBatch: function () {}, - onEndUpdateBatch: function () {}, - onItemRemoved: function () {}, - onItemChanged: function () {}, - onItemVisited: function () {}, - onItemMoved: function () {}, - QueryInterface: XPCOMUtils.generateQI([ - Ci.nsINavBookmarkObserver, - ]) - }; - info("Waiting for a bookmark to be added"); - PlacesUtils.bookmarks.addObserver(bookmarksObserver, false); - }); -} - -function promiseErrorPageLoaded(browser) { - return new Promise(resolve => { - browser.addEventListener("DOMContentLoaded", function onLoad() { - browser.removeEventListener("DOMContentLoaded", onLoad, false, true); - resolve(); - }, false, true); - }); -} - -function* loadBadCertPage(url) { - const EXCEPTION_DIALOG_URI = "chrome://pippki/content/exceptionDialog.xul"; - let exceptionDialogResolved = new Promise(function(resolve) { - // When the certificate exception dialog has opened, click the button to add - // an exception. - let certExceptionDialogObserver = { - observe: function(aSubject, aTopic, aData) { - if (aTopic == "cert-exception-ui-ready") { - Services.obs.removeObserver(this, "cert-exception-ui-ready"); - let certExceptionDialog = getCertExceptionDialog(EXCEPTION_DIALOG_URI); - ok(certExceptionDialog, "found exception dialog"); - executeSoon(function() { - certExceptionDialog.documentElement.getButton("extra1").click(); - resolve(); - }); - } - } - }; - - Services.obs.addObserver(certExceptionDialogObserver, - "cert-exception-ui-ready", false); - }); - - let loaded = BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser); - yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url); - yield loaded; - - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { - content.document.getElementById("exceptionDialogButton").click(); - }); - yield exceptionDialogResolved; - yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); -} - -// Utility function to get a handle on the certificate exception dialog. -// Modified from toolkit/components/passwordmgr/test/prompt_common.js -function getCertExceptionDialog(aLocation) { - let enumerator = Services.wm.getXULWindowEnumerator(null); - - while (enumerator.hasMoreElements()) { - let win = enumerator.getNext(); - let windowDocShell = win.QueryInterface(Ci.nsIXULWindow).docShell; - - let containedDocShells = windowDocShell.getDocShellEnumerator( - Ci.nsIDocShellTreeItem.typeChrome, - Ci.nsIDocShell.ENUMERATE_FORWARDS); - while (containedDocShells.hasMoreElements()) { - // Get the corresponding document for this docshell - let childDocShell = containedDocShells.getNext(); - let childDoc = childDocShell.QueryInterface(Ci.nsIDocShell) - .contentViewer - .DOMDocument; - - if (childDoc.location.href == aLocation) { - return childDoc; - } - } - } - return undefined; -} - -function setupRemoteClientsFixture(fixture) { - let oldRemoteClientsGetter = - Object.getOwnPropertyDescriptor(gFxAccounts, "remoteClients").get; - - Object.defineProperty(gFxAccounts, "remoteClients", { - get: function() { return fixture; } - }); - return oldRemoteClientsGetter; -} - -function restoreRemoteClients(getter) { - Object.defineProperty(gFxAccounts, "remoteClients", { - get: getter - }); -} - -function* openMenuItemSubmenu(id) { - let menuPopup = document.getElementById(id).menupopup; - let menuPopupPromise = BrowserTestUtils.waitForEvent(menuPopup, "popupshown"); - menuPopup.showPopup(); - yield menuPopupPromise; -} diff --git a/browser/base/content/test/general/head_plain.js b/browser/base/content/test/general/head_plain.js deleted file mode 100644 index 3796c7d2b..000000000 --- a/browser/base/content/test/general/head_plain.js +++ /dev/null @@ -1,27 +0,0 @@ - -function getTestPlugin(pluginName) { - var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] - .getService(SpecialPowers.Ci.nsIPluginHost); - var tags = ph.getPluginTags(); - var name = pluginName || "Test Plug-in"; - for (var tag of tags) { - if (tag.name == name) { - return tag; - } - } - - ok(false, "Could not find plugin tag with plugin name '" + name + "'"); - return null; -} - -// call this to set the test plugin(s) initially expected enabled state. -// it will automatically be reset to it's previous value after the test -// ends -function setTestPluginEnabledState(newEnabledState, pluginName) { - var plugin = getTestPlugin(pluginName); - var oldEnabledState = plugin.enabledState; - plugin.enabledState = newEnabledState; - SimpleTest.registerCleanupFunction(function() { - getTestPlugin(pluginName).enabledState = oldEnabledState; - }); -} diff --git a/browser/base/content/test/general/healthreport_pingData.js b/browser/base/content/test/general/healthreport_pingData.js deleted file mode 100644 index 1737baba1..000000000 --- a/browser/base/content/test/general/healthreport_pingData.js +++ /dev/null @@ -1,17 +0,0 @@ -var TEST_PINGS = [ - { - type: "test-telemetryArchive-1", - payload: { foo: "bar" }, - date: new Date(2010, 1, 1, 10, 0, 0), - }, - { - type: "test-telemetryArchive-2", - payload: { x: { y: "z"} }, - date: new Date(2010, 1, 1, 11, 0, 0), - }, - { - type: "test-telemetryArchive-3", - payload: { moo: "meh" }, - date: new Date(2010, 1, 1, 12, 0, 0), - }, -]; diff --git a/browser/base/content/test/general/healthreport_testRemoteCommands.html b/browser/base/content/test/general/healthreport_testRemoteCommands.html deleted file mode 100644 index 7978914f2..000000000 --- a/browser/base/content/test/general/healthreport_testRemoteCommands.html +++ /dev/null @@ -1,243 +0,0 @@ -<html> - <head> - <meta charset="utf-8"> -<script type="application/javascript;version=1.7" - src="healthreport_pingData.js"> -</script> -<script type="application/javascript;version=1.7"> - -function init() { - window.addEventListener("message", doTest, false); - doTest(); -} - -function checkSubmissionValue(payload, expectedValue) { - return payload.enabled == expectedValue; -} - -function isArray(arg) { - return Object.prototype.toString.call(arg) === '[object Array]'; -} - -function writeDiagnostic(text) { - let node = document.createTextNode(text); - let br = document.createElement("br"); - document.body.appendChild(node); - document.body.appendChild(br); -} - -function validateCurrentTelemetryEnvironment(data) { - // Simple check for now: check that the received object has the expected - // top-level properties. - const expectedKeys = ["profile", "settings", "system", "build", "partner", "addons"]; - return expectedKeys.every(key => (key in data)); -} - -function validateCurrentTelemetryPingData(ping) { - // Simple check for now: check that the received object has the expected - // top-level properties and that the type and reason match. - const expectedKeys = ["environment", "clientId", "payload", "application", - "version", "type", "id"]; - return expectedKeys.every(key => (key in ping)) && - (ping.type == "main") && - ("info" in ping.payload) && - ("reason" in ping.payload.info) && - (ping.payload.info.reason == "gather-subsession-payload"); -} - -function validateTelemetryPingList(list) { - if (!isArray(list)) { - console.log("Telemetry ping list is not an array."); - return false; - } - - // Telemetry may generate other pings (e.g. "deletion" pings), so filter those - // out. - const TEST_TYPES_REGEX = /^test-telemetryArchive/; - list = list.filter(p => TEST_TYPES_REGEX.test(p.type)); - - if (list.length != TEST_PINGS.length) { - console.log("Telemetry ping length is not correct."); - return false; - } - - let valid = true; - for (let i=0; i<list.length; ++i) { - let received = list[i]; - let expected = TEST_PINGS[i]; - if (received.type != expected.type || - received.timestampCreated != expected.date.getTime()) { - writeDiagnostic("Telemetry ping " + i + " does not match."); - writeDiagnostic("Expected: " + JSON.stringify(expected)); - writeDiagnostic("Received: " + JSON.stringify(received)); - valid = false; - } else { - writeDiagnostic("Telemetry ping " + i + " matches."); - } - } - - return true; -} - -function validateTelemetryPingData(expected, received) { - const receivedDate = new Date(received.creationDate); - if (received.id != expected.id || - received.type != expected.type || - receivedDate.getTime() != expected.date.getTime()) { - writeDiagnostic("Telemetry ping data for " + expected.id + " doesn't match."); - writeDiagnostic("Expected: " + JSON.stringify(expected)); - writeDiagnostic("Received: " + JSON.stringify(received)); - return false; - } - - writeDiagnostic("Telemetry ping data for " + expected.id + " matched."); - return true; -} - -var tests = [ -{ - info: "Checking initial value is enabled", - event: "RequestCurrentPrefs", - payloadType: "prefs", - validateResponse: function(payload) { - return checkSubmissionValue(payload, true); - }, -}, -{ - info: "Verifying disabling works", - event: "DisableDataSubmission", - payloadType: "prefs", - validateResponse: function(payload) { - return checkSubmissionValue(payload, false); - }, -}, -{ - info: "Verifying we're still disabled", - event: "RequestCurrentPrefs", - payloadType: "prefs", - validateResponse: function(payload) { - return checkSubmissionValue(payload, false); - }, -}, -{ - info: "Verifying that we can get the current ping data while submission is disabled", - event: "RequestCurrentPingData", - payloadType: "telemetry-current-ping-data", - validateResponse: function(payload) { - return validateCurrentTelemetryPingData(payload); - }, -}, -{ - info: "Verifying enabling works", - event: "EnableDataSubmission", - payloadType: "prefs", - validateResponse: function(payload) { - return checkSubmissionValue(payload, true); - }, -}, -{ - info: "Verifying we're still re-enabled", - event: "RequestCurrentPrefs", - payloadType: "prefs", - validateResponse: function(payload) { - return checkSubmissionValue(payload, true); - }, -}, -{ - info: "Verifying that we can get the current Telemetry environment data", - event: "RequestCurrentEnvironment", - payloadType: "telemetry-current-environment-data", - validateResponse: function(payload) { - return validateCurrentTelemetryEnvironment(payload); - }, -}, -{ - info: "Verifying that we can get the current Telemetry ping data", - event: "RequestCurrentPingData", - payloadType: "telemetry-current-ping-data", - validateResponse: function(payload) { - return validateCurrentTelemetryPingData(payload); - }, -}, -{ - info: "Verifying that we get the proper Telemetry ping list", - event: "RequestTelemetryPingList", - payloadType: "telemetry-ping-list", - validateResponse: function(payload) { - // Validate the ping list - if (!validateTelemetryPingList(payload)) { - return false; - } - - // Now that we received the ping ids, set up additional test tasks - // that check loading the individual pings. - for (let i=0; i<TEST_PINGS.length; ++i) { - TEST_PINGS[i].id = payload[i].id; - tests.push({ - info: "Verifying that we can get the proper Telemetry ping data #" + (i + 1), - event: "RequestTelemetryPingData", - eventData: { id: TEST_PINGS[i].id }, - payloadType: "telemetry-ping-data", - validateResponse: function(payload) { - return validateTelemetryPingData(TEST_PINGS[i], payload.pingData); - }, - }); - } - - return true; - }, -}, -]; - -var currentTest = -1; -function doTest(evt) { - if (evt) { - if (currentTest < 0 || !evt.data.content) - return; // not yet testing - - var test = tests[currentTest]; - if (evt.data.type != test.payloadType) - return; // skip unrequested events - - var error = JSON.stringify(evt.data.content); - var pass = false; - try { - pass = test.validateResponse(evt.data.content) - } catch (e) {} - reportResult(test.info, pass, error); - } - // start the next test if there are any left - if (tests[++currentTest]) - sendToBrowser(tests[currentTest].event, tests[currentTest].eventData); - else - reportFinished(); -} - -function reportResult(info, pass, error) { - var data = {type: "testResult", info: info, pass: pass, error: error}; - var event = new CustomEvent("FirefoxHealthReportTestResponse", {detail: {data: data}, bubbles: true}); - document.dispatchEvent(event); -} - -function reportFinished(cmd) { - var data = {type: "testsComplete", count: tests.length}; - var event = new CustomEvent("FirefoxHealthReportTestResponse", {detail: {data: data}, bubbles: true}); - document.dispatchEvent(event); -} - -function sendToBrowser(type, eventData) { - eventData = eventData || {}; - let detail = {command: type}; - for (let key of Object.keys(eventData)) { - detail[key] = eventData[key]; - } - - var event = new CustomEvent("RemoteHealthReportCommand", {detail: detail, bubbles: true}); - document.dispatchEvent(event); -} - -</script> - </head> - <body onload="init()"> - </body> -</html> diff --git a/browser/base/content/test/general/insecure_opener.html b/browser/base/content/test/general/insecure_opener.html deleted file mode 100644 index 26ed014f6..000000000 --- a/browser/base/content/test/general/insecure_opener.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE HTML> -<html dir="ltr" xml:lang="en-US" lang="en-US"> - <head> - <meta charset="utf8"> - </head> - <body> - <a id="link" target="_blank" href="https://example.com/browser/toolkit/components/passwordmgr/test/browser/form_basic.html">Click me, I'm "secure".</a> - </body> -</html> diff --git a/browser/base/content/test/general/mochitest.ini b/browser/base/content/test/general/mochitest.ini deleted file mode 100644 index a07a01b87..000000000 --- a/browser/base/content/test/general/mochitest.ini +++ /dev/null @@ -1,27 +0,0 @@ -[DEFAULT] -support-files = - audio.ogg - bug364677-data.xml - bug364677-data.xml^headers^ - bug395533-data.txt - contextmenu_common.js - ctxmenu-image.png - head_plain.js - offlineByDefault.js - offlineChild.cacheManifest - offlineChild.cacheManifest^headers^ - offlineChild.html - offlineChild2.cacheManifest - offlineChild2.cacheManifest^headers^ - offlineChild2.html - offlineEvent.cacheManifest - offlineEvent.cacheManifest^headers^ - offlineEvent.html - subtst_contextmenu.html - video.ogg - !/image/test/mochitest/blue.png - -[test_bug364677.html] -[test_bug395533.html] -[test_offlineNotification.html] -skip-if = e10s # Bug 1257785 diff --git a/browser/base/content/test/general/moz.png b/browser/base/content/test/general/moz.png Binary files differdeleted file mode 100644 index 769c63634..000000000 --- a/browser/base/content/test/general/moz.png +++ /dev/null diff --git a/browser/base/content/test/general/navigating_window_with_download.html b/browser/base/content/test/general/navigating_window_with_download.html deleted file mode 100644 index 6b0918941..000000000 --- a/browser/base/content/test/general/navigating_window_with_download.html +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE html> -<html> - <head><title>This window will navigate while you're downloading something</title></head> - <body> - <iframe src="http://mochi.test:8888/browser/browser/base/content/test/general/unknownContentType_file.pif"></iframe> - </body> -</html> diff --git a/browser/base/content/test/general/offlineByDefault.js b/browser/base/content/test/general/offlineByDefault.js deleted file mode 100644 index 72f7e52a0..000000000 --- a/browser/base/content/test/general/offlineByDefault.js +++ /dev/null @@ -1,17 +0,0 @@ -var offlineByDefault = { - defaultValue: false, - prefBranch: SpecialPowers.Cc["@mozilla.org/preferences-service;1"].getService(SpecialPowers.Ci.nsIPrefBranch), - set: function(allow) { - try { - this.defaultValue = this.prefBranch.getBoolPref("offline-apps.allow_by_default"); - } catch (e) { - this.defaultValue = false - } - this.prefBranch.setBoolPref("offline-apps.allow_by_default", allow); - }, - reset: function() { - this.prefBranch.setBoolPref("offline-apps.allow_by_default", this.defaultValue); - } -} - -offlineByDefault.set(false); diff --git a/browser/base/content/test/general/offlineChild.cacheManifest b/browser/base/content/test/general/offlineChild.cacheManifest deleted file mode 100644 index 091fe7194..000000000 --- a/browser/base/content/test/general/offlineChild.cacheManifest +++ /dev/null @@ -1,2 +0,0 @@ -CACHE MANIFEST -offlineChild.html diff --git a/browser/base/content/test/general/offlineChild.cacheManifest^headers^ b/browser/base/content/test/general/offlineChild.cacheManifest^headers^ deleted file mode 100644 index 257f2eb60..000000000 --- a/browser/base/content/test/general/offlineChild.cacheManifest^headers^ +++ /dev/null @@ -1 +0,0 @@ -Content-Type: text/cache-manifest diff --git a/browser/base/content/test/general/offlineChild.html b/browser/base/content/test/general/offlineChild.html deleted file mode 100644 index 43f225b3b..000000000 --- a/browser/base/content/test/general/offlineChild.html +++ /dev/null @@ -1,20 +0,0 @@ -<html manifest="offlineChild.cacheManifest"> -<head> -<title></title> -<script type="text/javascript"> - -function finish(success) { - window.parent.postMessage(success ? "success" : "failure", "*"); -} - -applicationCache.oncached = function() { finish(true); } -applicationCache.onnoupdate = function() { finish(true); } -applicationCache.onerror = function() { finish(false); } - -</script> -</head> - -<body> -<h1>Child</h1> -</body> -</html> diff --git a/browser/base/content/test/general/offlineChild2.cacheManifest b/browser/base/content/test/general/offlineChild2.cacheManifest deleted file mode 100644 index 19efe54fe..000000000 --- a/browser/base/content/test/general/offlineChild2.cacheManifest +++ /dev/null @@ -1,2 +0,0 @@ -CACHE MANIFEST -offlineChild2.html diff --git a/browser/base/content/test/general/offlineChild2.cacheManifest^headers^ b/browser/base/content/test/general/offlineChild2.cacheManifest^headers^ deleted file mode 100644 index 257f2eb60..000000000 --- a/browser/base/content/test/general/offlineChild2.cacheManifest^headers^ +++ /dev/null @@ -1 +0,0 @@ -Content-Type: text/cache-manifest diff --git a/browser/base/content/test/general/offlineChild2.html b/browser/base/content/test/general/offlineChild2.html deleted file mode 100644 index ac762e759..000000000 --- a/browser/base/content/test/general/offlineChild2.html +++ /dev/null @@ -1,20 +0,0 @@ -<html manifest="offlineChild2.cacheManifest"> -<head> -<title></title> -<script type="text/javascript"> - -function finish(success) { - window.parent.postMessage(success ? "success" : "failure", "*"); -} - -applicationCache.oncached = function() { finish(true); } -applicationCache.onnoupdate = function() { finish(true); } -applicationCache.onerror = function() { finish(false); } - -</script> -</head> - -<body> -<h1>Child</h1> -</body> -</html> diff --git a/browser/base/content/test/general/offlineEvent.cacheManifest b/browser/base/content/test/general/offlineEvent.cacheManifest deleted file mode 100644 index 091fe7194..000000000 --- a/browser/base/content/test/general/offlineEvent.cacheManifest +++ /dev/null @@ -1,2 +0,0 @@ -CACHE MANIFEST -offlineChild.html diff --git a/browser/base/content/test/general/offlineEvent.cacheManifest^headers^ b/browser/base/content/test/general/offlineEvent.cacheManifest^headers^ deleted file mode 100644 index 257f2eb60..000000000 --- a/browser/base/content/test/general/offlineEvent.cacheManifest^headers^ +++ /dev/null @@ -1 +0,0 @@ -Content-Type: text/cache-manifest diff --git a/browser/base/content/test/general/offlineEvent.html b/browser/base/content/test/general/offlineEvent.html deleted file mode 100644 index f6e2494e2..000000000 --- a/browser/base/content/test/general/offlineEvent.html +++ /dev/null @@ -1,9 +0,0 @@ -<html manifest="offlineEvent.cacheManifest"> -<head> -<title></title> -</head> - -<body> -<h1>Child</h1> -</body> -</html> diff --git a/browser/base/content/test/general/offlineQuotaNotification.cacheManifest b/browser/base/content/test/general/offlineQuotaNotification.cacheManifest deleted file mode 100644 index 2e210abd2..000000000 --- a/browser/base/content/test/general/offlineQuotaNotification.cacheManifest +++ /dev/null @@ -1,7 +0,0 @@ -CACHE MANIFEST -# Any copyright is dedicated to the Public Domain. -# http://creativecommons.org/publicdomain/zero/1.0/ - -# store a "large" file so an "over quota warning" will be issued - any file -# larger than 1kb and in '_BROWSER_FILES' should be right... -title_test.svg diff --git a/browser/base/content/test/general/offlineQuotaNotification.html b/browser/base/content/test/general/offlineQuotaNotification.html deleted file mode 100644 index b1b91bf9e..000000000 --- a/browser/base/content/test/general/offlineQuotaNotification.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE HTML> -<html manifest="offlineQuotaNotification.cacheManifest"> -<head> - <meta charset="utf-8"> - <title>Test offline app quota notification</title> - <!-- Any copyright is dedicated to the Public Domain. - - http://creativecommons.org/publicdomain/zero/1.0/ --> -</head> -</html> diff --git a/browser/base/content/test/general/page_style_sample.html b/browser/base/content/test/general/page_style_sample.html deleted file mode 100644 index 54cbaa9e6..000000000 --- a/browser/base/content/test/general/page_style_sample.html +++ /dev/null @@ -1,41 +0,0 @@ -<html> - <head> - <title>Test for page style menu</title> - <!-- data-state values: - 0: should not appear in the page style menu - 0-todo: should not appear in the page style menu, but does - 1: should appear in the page style menu - 2: should appear in the page style menu as the selected stylesheet --> - <link data-state="1" href="404.css" title="1" rel="alternate stylesheet"> - <link data-state="0" title="2" rel="alternate stylesheet"> - <link data-state="0" href="404.css" rel="alternate stylesheet"> - <link data-state="0" href="404.css" title="" rel="alternate stylesheet"> - <link data-state="1" href="404.css" title="3" rel="stylesheet alternate"> - <link data-state="1" href="404.css" title="4" rel=" alternate stylesheet "> - <link data-state="1" href="404.css" title="5" rel="alternate stylesheet"> - <link data-state="2" href="404.css" title="6" rel="stylesheet"> - <link data-state="1" href="404.css" title="7" rel="foo stylesheet"> - <link data-state="0" href="404.css" title="8" rel="alternate"> - <link data-state="1" href="404.css" title="9" rel="alternate STYLEsheet"> - <link data-state="1" href="404.css" title="10" rel="alternate stylesheet" media=""> - <link data-state="1" href="404.css" title="11" rel="alternate stylesheet" media="all"> - <link data-state="1" href="404.css" title="12" rel="alternate stylesheet" media="ALL "> - <link data-state="1" href="404.css" title="13" rel="alternate stylesheet" media="screen"> - <link data-state="1" href="404.css" title="14" rel="alternate stylesheet" media=" Screen"> - <link data-state="0" href="404.css" title="15" rel="alternate stylesheet" media="screen foo"> - <link data-state="0" href="404.css" title="16" rel="alternate stylesheet" media="all screen"> - <link data-state="0" href="404.css" title="17" rel="alternate stylesheet" media="foo bar"> - <link data-state="1" href="404.css" title="18" rel="alternate stylesheet" media="all,screen"> - <link data-state="1" href="404.css" title="19" rel="alternate stylesheet" media="all, screen"> - <link data-state="0" href="404.css" title="20" rel="alternate stylesheet" media="all screen"> - <link data-state="0" href="404.css" title="21" rel="alternate stylesheet" media="foo"> - <link data-state="0" href="404.css" title="22" rel="alternate stylesheet" media="allscreen"> - <link data-state="0" href="404.css" title="23" rel="alternate stylesheet" media="_all"> - <link data-state="0" href="404.css" title="24" rel="alternate stylesheet" media="not screen"> - <link data-state="1" href="404.css" title="25" rel="alternate stylesheet" media="only screen"> - <link data-state="1" href="404.css" title="26" rel="alternate stylesheet" media="screen and (min-device-width: 1px)"> - <link data-state="0" href="404.css" title="27" rel="alternate stylesheet" media="screen and (max-device-width: 1px)"> - <style data-state="1" title="28">/* some more styles */</style> - </head> - <body></body> -</html> diff --git a/browser/base/content/test/general/parsingTestHelpers.jsm b/browser/base/content/test/general/parsingTestHelpers.jsm deleted file mode 100644 index 69c764483..000000000 --- a/browser/base/content/test/general/parsingTestHelpers.jsm +++ /dev/null @@ -1,131 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -this.EXPORTED_SYMBOLS = ["generateURIsFromDirTree"]; - -const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; - -/* Shorthand constructors to construct an nsI(Local)File and zip reader: */ -const LocalFile = new Components.Constructor("@mozilla.org/file/local;1", Ci.nsIFile, "initWithPath"); -const ZipReader = new Components.Constructor("@mozilla.org/libjar/zip-reader;1", "nsIZipReader", "open"); - - -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/osfile.jsm"); -Cu.import("resource://gre/modules/Task.jsm"); - - -/** - * Returns a promise that is resolved with a list of files that have one of the - * extensions passed, represented by their nsIURI objects, which exist inside - * the directory passed. - * - * @param dir the directory which to scan for files (nsIFile) - * @param extensions the extensions of files we're interested in (Array). - */ -function generateURIsFromDirTree(dir, extensions) { - if (!Array.isArray(extensions)) { - extensions = [extensions]; - } - let dirQueue = [dir.path]; - return Task.spawn(function*() { - let rv = []; - while (dirQueue.length) { - let nextDir = dirQueue.shift(); - let {subdirs, files} = yield iterateOverPath(nextDir, extensions); - dirQueue.push(...subdirs); - rv.push(...files); - } - return rv; - }); -} - -/** - * Uses OS.File.DirectoryIterator to asynchronously iterate over a directory. - * It returns a promise that is resolved with an object with two properties: - * - files: an array of nsIURIs corresponding to files that match the extensions passed - * - subdirs: an array of paths for subdirectories we need to recurse into - * (handled by generateURIsFromDirTree above) - * - * @param path the path to check (string) - * @param extensions the file extensions we're interested in. - */ -function iterateOverPath(path, extensions) { - let iterator = new OS.File.DirectoryIterator(path); - let parentDir = new LocalFile(path); - let subdirs = []; - let files = []; - - let pathEntryIterator = (entry) => { - if (entry.isDir) { - subdirs.push(entry.path); - } else if (extensions.some((extension) => entry.name.endsWith(extension))) { - let file = parentDir.clone(); - file.append(entry.name); - // the build system might leave dead symlinks hanging around, which are - // returned as part of the directory iterator, but don't actually exist: - if (file.exists()) { - let uriSpec = getURLForFile(file); - files.push(Services.io.newURI(uriSpec, null, null)); - } - } else if (entry.name.endsWith(".ja") || entry.name.endsWith(".jar") || - entry.name.endsWith(".zip") || entry.name.endsWith(".xpi")) { - let file = parentDir.clone(); - file.append(entry.name); - for (let extension of extensions) { - let jarEntryIterator = generateEntriesFromJarFile(file, extension); - files.push(...jarEntryIterator); - } - } - }; - - return new Promise((resolve, reject) => { - Task.spawn(function* () { - try { - // Iterate through the directory - yield iterator.forEach(pathEntryIterator); - resolve({files: files, subdirs: subdirs}); - } catch (ex) { - reject(ex); - } finally { - iterator.close(); - } - }); - }); -} - -/* Helper function to generate a URI spec (NB: not an nsIURI yet!) - * given an nsIFile object */ -function getURLForFile(file) { - let fileHandler = Services.io.getProtocolHandler("file"); - fileHandler = fileHandler.QueryInterface(Ci.nsIFileProtocolHandler); - return fileHandler.getURLSpecFromActualFile(file); -} - -/** - * A generator that generates nsIURIs for particular files found in jar files - * like omni.ja. - * - * @param jarFile an nsIFile object for the jar file that needs checking. - * @param extension the extension we're interested in. - */ -function* generateEntriesFromJarFile(jarFile, extension) { - let zr = new ZipReader(jarFile); - let entryEnumerator = zr.findEntries("*" + extension + "$"); - - const kURIStart = getURLForFile(jarFile); - while (entryEnumerator.hasMore()) { - let entry = entryEnumerator.getNext(); - // Ignore the JS cache which is stored in omni.ja - if (entry.startsWith("jsloader") || entry.startsWith("jssubloader")) { - continue; - } - let entryURISpec = "jar:" + kURIStart + "!/" + entry; - yield Services.io.newURI(entryURISpec, null, null); - } - zr.close(); -} - - diff --git a/browser/base/content/test/general/permissions.html b/browser/base/content/test/general/permissions.html deleted file mode 100644 index 46436a006..000000000 --- a/browser/base/content/test/general/permissions.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE HTML> -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - 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/. --> -<html dir="ltr" xml:lang="en-US" lang="en-US"> - <head> - <meta charset="utf8"> - </head> - <body> - <!-- This page could eventually request permissions from content - and make sure that chrome responds appropriately --> - <button id="geo" onclick="navigator.geolocation.getCurrentPosition(() => {})">Geolocation</button> - </body> -</html> diff --git a/browser/base/content/test/general/pinning_headers.sjs b/browser/base/content/test/general/pinning_headers.sjs deleted file mode 100644 index 51496183a..000000000 --- a/browser/base/content/test/general/pinning_headers.sjs +++ /dev/null @@ -1,23 +0,0 @@ -const INVALIDPIN1 = "pin-sha256=\"d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=\";"; -const INVALIDPIN2 = "pin-sha256=\"AAAAAAAAAAAAAAAAAAAAAAAAAj0e1Md7GkYYkVoZWmM=\";"; -const VALIDPIN = "pin-sha256=\"hXweb81C3HnmM2Ai1dnUzFba40UJMhuu8qZmvN/6WWc=\";"; - -function handleRequest(request, response) -{ - // avoid confusing cache behaviors - response.setHeader("Cache-Control", "no-cache", false); - - response.setHeader("Content-Type", "text/plain; charset=utf-8", false); - switch (request.queryString) { - case "zeromaxagevalid": - response.setHeader("Public-Key-Pins", "max-age=0;" + VALIDPIN + - INVALIDPIN2 + "includeSubdomains"); - break; - case "valid": - default: - response.setHeader("Public-Key-Pins", "max-age=50000;" + VALIDPIN + - INVALIDPIN2 + "includeSubdomains"); - } - - response.write("Hello world!" + request.host); -} diff --git a/browser/base/content/test/general/print_postdata.sjs b/browser/base/content/test/general/print_postdata.sjs deleted file mode 100644 index 4175a2480..000000000 --- a/browser/base/content/test/general/print_postdata.sjs +++ /dev/null @@ -1,22 +0,0 @@ -const CC = Components.Constructor; -const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1", - "nsIBinaryInputStream", - "setInputStream"); - -function handleRequest(request, response) { - response.setHeader("Content-Type", "text/plain", false); - if (request.method == "GET") { - response.write(request.queryString); - } else { - var body = new BinaryInputStream(request.bodyInputStream); - - var avail; - var bytes = []; - - while ((avail = body.available()) > 0) - Array.prototype.push.apply(bytes, body.readByteArray(avail)); - - var data = String.fromCharCode.apply(null, bytes); - response.bodyOutputStream.write(data, data.length); - } -} diff --git a/browser/base/content/test/general/refresh_header.sjs b/browser/base/content/test/general/refresh_header.sjs deleted file mode 100644 index 327372f9b..000000000 --- a/browser/base/content/test/general/refresh_header.sjs +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Will cause an auto-refresh to the URL provided in the query string - * after some delay using the refresh HTTP header. - * - * Expects the query string to be in the format: - * - * ?p=[URL of the page to redirect to]&d=[delay] - * - * Example: - * - * ?p=http%3A%2F%2Fexample.org%2Fbrowser%2Fbrowser%2Fbase%2Fcontent%2Ftest%2Fgeneral%2Frefresh_meta.sjs&d=200 - */ -function handleRequest(request, response) { - Components.utils.importGlobalProperties(["URLSearchParams"]); - let query = new URLSearchParams(request.queryString); - - let page = query.get("p"); - let delay = query.get("d"); - - response.setHeader("Content-Type", "text/html", false); - response.setStatusLine(request.httpVersion, "200", "Found"); - response.setHeader("refresh", `${delay}; url=${page}`); - response.write("OK"); -}
\ No newline at end of file diff --git a/browser/base/content/test/general/refresh_meta.sjs b/browser/base/content/test/general/refresh_meta.sjs deleted file mode 100644 index 648fac1a3..000000000 --- a/browser/base/content/test/general/refresh_meta.sjs +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Will cause an auto-refresh to the URL provided in the query string - * after some delay using a <meta> tag. - * - * Expects the query string to be in the format: - * - * ?p=[URL of the page to redirect to]&d=[delay] - * - * Example: - * - * ?p=http%3A%2F%2Fexample.org%2Fbrowser%2Fbrowser%2Fbase%2Fcontent%2Ftest%2Fgeneral%2Frefresh_meta.sjs&d=200 - */ -function handleRequest(request, response) { - Components.utils.importGlobalProperties(["URLSearchParams"]); - let query = new URLSearchParams(request.queryString); - - let page = query.get("p"); - let delay = query.get("d"); - - let html = `<!DOCTYPE HTML> - <html> - <head> - <meta charset='utf-8'> - <META http-equiv='refresh' content='${delay}; url=${page}'> - <title>Gonna refresh you, folks.</title> - </head> - <body> - <h1>Wait for it...</h1> - </body> - </html>`; - - response.setHeader("Content-Type", "text/html", false); - response.setStatusLine(request.httpVersion, "200", "Found"); - response.setHeader("Cache-Control", "no-cache", false); - response.write(html); -}
\ No newline at end of file diff --git a/browser/base/content/test/general/searchSuggestionEngine.sjs b/browser/base/content/test/general/searchSuggestionEngine.sjs deleted file mode 100644 index 1978b4f66..000000000 --- a/browser/base/content/test/general/searchSuggestionEngine.sjs +++ /dev/null @@ -1,9 +0,0 @@ -/* 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)); -} diff --git a/browser/base/content/test/general/searchSuggestionEngine.xml b/browser/base/content/test/general/searchSuggestionEngine.xml deleted file mode 100644 index 3d1f294f5..000000000 --- a/browser/base/content/test/general/searchSuggestionEngine.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?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/general/searchSuggestionEngine.sjs?{searchTerms}"/> -<Url type="text/html" method="GET" template="http://mochi.test:8888/" rel="searchform"/> -</SearchPlugin> diff --git a/browser/base/content/test/general/searchSuggestionEngine2.xml b/browser/base/content/test/general/searchSuggestionEngine2.xml deleted file mode 100644 index 05644649a..000000000 --- a/browser/base/content/test/general/searchSuggestionEngine2.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?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 searchSuggestionEngine2.xml</ShortName> -<Url type="application/x-suggestions+json" method="GET" template="http://mochi.test:8888/browser/browser/base/content/test/general/searchSuggestionEngine.sjs?{searchTerms}"/> -<Url type="text/html" method="GET" template="http://www.browser-searchSuggestionEngine.com/searchSuggestionEngine2&terms={searchTerms}" rel="searchform"/> -</SearchPlugin> diff --git a/browser/base/content/test/general/ssl_error_reports.sjs b/browser/base/content/test/general/ssl_error_reports.sjs deleted file mode 100644 index e2e5bafc0..000000000 --- a/browser/base/content/test/general/ssl_error_reports.sjs +++ /dev/null @@ -1,91 +0,0 @@ -const EXPECTED_CHAIN = [ - "MIIDCjCCAfKgAwIBAgIENUiGYDANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDExtBbHRlcm5hdGUgVHJ1c3RlZCBBdXRob3JpdHkwHhcNMTQxMDAxMjExNDE5WhcNMjQxMDAxMjExNDE5WjAxMS8wLQYDVQQDEyZpbmNsdWRlLXN1YmRvbWFpbnMucGlubmluZy5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALxYrge8C4eVfTb6/lJ4k/+/4J6wlnWpp5Szxy1MHhsLB+LJh/HRHqkO/tsigT204kTeU3dxuAfQHz0g+Td8dr6KICLLNVFUPw+XjhBV4AtxV8wcprs6EmdBhJgAjkFB4M76BL7/Ow0NfH012WNESn8TTbsp3isgkmrXjTZhWR33vIL1eDNimykp/Os/+JO+x9KVfdCtDCrPwO9Yusial5JiaW7qemRtVuUDL87NSJ7xokPEOSc9luv/fBamZ3rgqf3K6epqg+0o3nNCCcNFnfLW52G0t69+dIjr39WISHnqqZj3Sb7JPU6OmxTd13ByoLkoM3ZUQ2Lpas+RJvQyGXkCAwEAAaM1MDMwMQYDVR0RBCowKIImaW5jbHVkZS1zdWJkb21haW5zLnBpbm5pbmcuZXhhbXBsZS5jb20wDQYJKoZIhvcNAQELBQADggEBAAmzXfeoOS59FkNABRonFPRyFl7BoGpVJENUteFfTa2pdAhGYdo19Y4uILTTj+vtDAa5yryb5Uvd+YuJnExosbMMkzCrmZ9+VJCJdqUTb+idwk9/sgPl2gtGeRmefB0hXSUFHc/p1CDufSpYOmj9NCUZD2JEsybgJQNulkfAsVnS3lzDcxAwcO+RC/1uJDSiUtcBpWS4FW58liuDYE7PD67kLJHZPVUV2WCMuIl4VM2tKPtvShz1JkZ5UytOLs6jPfviNAk/ftXczaE2/RJgM2MnDX9nGzOxG6ONcVNCljL8avhFBCosutE6i5LYSZR6V14YY/xOn15WDSuWdnIsJCo=", - "MIIC2jCCAcKgAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDExtBbHRlcm5hdGUgVHJ1c3RlZCBBdXRob3JpdHkwHhcNMTQwOTI1MjEyMTU0WhcNMjQwOTI1MjEyMTU0WjAmMSQwIgYDVQQDExtBbHRlcm5hdGUgVHJ1c3RlZCBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDBT+BwAhO52IWgSIdZZifU9LHOs3IR/+8DCC0WP5d/OuyKlZ6Rqd0tsd3i7durhQyjHSbLf2lJStcnFjcVEbEnNI76RuvlN8xLLn5eV+2Ayr4cZYKztudwRmw+DV/iYAiMSy0hs7m3ssfX7qpoi1aNRjUanwU0VTCPQhF1bEKAC2du+C5Z8e92zN5t87w7bYr7lt+m8197XliXEu+0s9RgnGwGaZ296BIRz6NOoJYTa43n06LU1I1+Z4d6lPdzUFrSR0GBaMhUSurUBtOin3yWiMhg1VHX/KwqGc4als5GyCVXy8HGrA/0zQPOhetxrlhEVAdK/xBt7CZvByj1Rcc7AgMBAAGjEzARMA8GA1UdEwQIMAYBAf8CAQAwDQYJKoZIhvcNAQELBQADggEBAJq/hogSRqzPWTwX4wTn/DVSNdWwFLv53qep9YrSMJ8ZsfbfK9Es4VP4dBLRQAVMJ0Z5mW1I6d/n0KayTanuUBvemYdxPi/qQNSs8UJcllqdhqWzmzAg6a0LxrMnEeKzPBPD6q8PwQ7tYP+B4sBN9tnnsnyPgti9ZiNZn5FwXZliHXseQ7FE9/SqHlLw5LXW3YtKjuti6RmuV6fq3j+D4oeC5vb1mKgIyoTqGN6ze57v8RHi+pQ8Q+kmoUn/L3Z2YmFe4SKN/4WoyXr8TdejpThGOCGCAd3565s5gOx5QfSQX11P8NZKO8hcN0tme3VzmGpHK0Z/6MTmdpNaTwQ6odk=" - ]; - -const MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE = -16384; - -function parseReport(request) { - // read the report from the request - let inputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); - inputStream.init(request.bodyInputStream, 0x01, 0004, 0); - - let body = ""; - if (inputStream) { - while (inputStream.available()) { - body = body + inputStream.read(inputStream.available()); - } - } - // parse the report - return JSON.parse(body); -} - -function handleRequest(request, response) { - let report = {}; - let certChain = []; - - switch (request.queryString) { - case "succeed": - report = parseReport(request); - certChain = report.failedCertChain; - - // ensure the cert chain is what we expect - for (idx in certChain) { - if (certChain[idx] !== EXPECTED_CHAIN[idx]) { - // if the chain differs, send an error response to cause test - // failure - response.setStatusLine("1.1", 500, "Server error"); - response.write("<html>The report contained an unexpected chain</html>"); - return; - } - } - - if (report.errorCode !== MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE) { - response.setStatusLine("1.1", 500, "Server error"); - response.write("<html>The report contained an unexpected error code</html>"); - return; - } - - // if all is as expected, send the 201 the client expects - response.setStatusLine("1.1", 201, "Created"); - response.write("<html>OK</html>"); - break; - case "nocert": - report = parseReport(request); - certChain = report.failedCertChain; - - if (certChain && certChain.length > 0) { - // We're not expecting a chain; if there is one, send an error - response.setStatusLine("1.1", 500, "Server error"); - response.write("<html>The report contained an unexpected chain</html>"); - return; - } - - // if all is as expected, send the 201 the client expects - response.setStatusLine("1.1", 201, "Created"); - response.write("<html>OK</html>"); - break; - case "badcert": - report = parseReport(request); - certChain = report.failedCertChain; - - if (!certChain || certChain.length != 2) { - response.setStatusLine("1.1", 500, "Server error"); - response.write("<html>The report contained an unexpected chain</html>"); - return; - } - - // if all is as expected, send the 201 the client expects - response.setStatusLine("1.1", 201, "Created"); - response.write("<html>OK</html>"); - break; - case "error": - response.setStatusLine("1.1", 500, "Server error"); - response.write("<html>server error</html>"); - break; - default: - response.setStatusLine("1.1", 500, "Server error"); - response.write("<html>succeed, nocert or error expected (got " + request.queryString + ")</html>"); - break; - } -} diff --git a/browser/base/content/test/general/subtst_contextmenu.html b/browser/base/content/test/general/subtst_contextmenu.html deleted file mode 100644 index 1768f399f..000000000 --- a/browser/base/content/test/general/subtst_contextmenu.html +++ /dev/null @@ -1,73 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Subtest for browser context menu</title> -</head> -<body> -Browser context menu subtest. - -<div id="test-text">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</div> -<a id="test-link" href="http://mozilla.com">Click the monkey!</a> -<a id="test-mailto" href="mailto:codemonkey@mozilla.com">Mail the monkey!</a><br> -<input id="test-input"><br> -<img id="test-image" src="ctxmenu-image.png"> -<canvas id="test-canvas" width="100" height="100" style="background-color: blue"></canvas> -<video controls id="test-video-ok" src="video.ogg" width="100" height="100" style="background-color: green"></video> -<video id="test-audio-in-video" src="audio.ogg" width="100" height="100" style="background-color: red"></video> -<video controls id="test-video-bad" src="bogus.duh" width="100" height="100" style="background-color: orange"></video> -<video controls id="test-video-bad2" width="100" height="100" style="background-color: yellow"> - <source src="bogus.duh" type="video/durrrr;"> -</video> -<iframe id="test-iframe" width="98" height="98" style="border: 1px solid black"></iframe> -<iframe id="test-video-in-iframe" src="video.ogg" width="98" height="98" style="border: 1px solid black"></iframe> -<iframe id="test-audio-in-iframe" src="audio.ogg" width="98" height="98" style="border: 1px solid black"></iframe> -<iframe id="test-image-in-iframe" src="ctxmenu-image.png" width="98" height="98" style="border: 1px solid black"></iframe> -<textarea id="test-textarea">chssseesbbbie</textarea> <!-- a weird word which generates only one suggestion --> -<div id="test-contenteditable" contenteditable="true">chssseefsbbbie</div> <!-- a more weird word which generates no suggestions --> -<div id="test-contenteditable-spellcheck-false" contenteditable="true" spellcheck="false">test</div> <!-- No Check Spelling menu item --> -<div id="test-dom-full-screen">DOM full screen FTW</div> -<div contextmenu="myMenu"> - <p id="test-pagemenu" hopeless="true">I've got a context menu!</p> - <menu id="myMenu" type="context"> - <menuitem label="Plain item" onclick="document.getElementById('test-pagemenu').removeAttribute('hopeless');"></menuitem> - <menuitem label="Disabled item" disabled></menuitem> - <menuitem> Item w/ textContent</menuitem> - <menu> - <menuitem type="checkbox" label="Checkbox" checked></menuitem> - </menu> - <menu> - <menuitem type="radio" label="Radio1" checked></menuitem> - <menuitem type="radio" label="Radio2"></menuitem> - <menuitem type="radio" label="Radio3"></menuitem> - </menu> - <menu> - <menuitem label="Item w/ icon" icon="favicon.ico"></menuitem> - <menuitem label="Item w/ bad icon" icon="data://www.mozilla.org/favicon.ico"></menuitem> - </menu> - <menu label="Submenu"> - <menuitem type="radio" label="Radio1" radiogroup="rg"></menuitem> - <menuitem type="radio" label="Radio2" checked radiogroup="rg"></menuitem> - <menuitem type="radio" label="Radio3" radiogroup="rg"></menuitem> - <menu> - <menuitem type="checkbox" label="Checkbox"></menuitem> - </menu> - </menu> - <menu hidden> - <menuitem label="Bogus item"></menuitem> - </menu> - <menu> - </menu> - <menuitem label="Hidden item" hidden></menuitem> - <menuitem></menuitem> - </menu> -</div> -<div id="test-select-text">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</div> -<div id="test-select-text-link">http://mozilla.com</div> -<a id="test-image-link" href="#"><img src="ctxmenu-image.png"></a> -<input id="test-select-input-text" type="text" value="input"> -<input id="test-select-input-text-type-password" type="password" value="password"> -<embed id="test-plugin" style="width: 200px; height: 200px;" type="application/x-test"></embed> -<img id="test-longdesc" src="ctxmenu-image.png" longdesc="http://www.mozilla.org"></embed> -<iframe id="test-srcdoc" width="98" height="98" srcdoc="Hello World" style="border: 1px solid black"></iframe> -</body> -</html> diff --git a/browser/base/content/test/general/subtst_contextmenu_input.html b/browser/base/content/test/general/subtst_contextmenu_input.html deleted file mode 100644 index c5be977ea..000000000 --- a/browser/base/content/test/general/subtst_contextmenu_input.html +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE HTML>
-<html>
-<head>
- <title>Subtest for browser context menu</title>
-</head>
-<body>
- Browser context menu subtest.
- <input id="input_text">
- <input id="input_spellcheck_no_value">
- <input id="input_spellcheck_incorrect" spellcheck="true" value="prodkjfgigrty">
- <input id="input_spellcheck_correct" spellcheck="true" value="foo">
- <input id="input_disabled" disabled="true">
- <input id="input_password">
- <input id="input_email" type="email">
- <input id="input_tel" type="tel">
- <input id="input_url" type="url">
- <input id="input_number" type="number">
- <input id="input_date" type="date">
- <input id="input_time" type="time">
- <input id="input_color" type="color">
- <input id="input_range" type="range">
- <input id="input_search" type="search">
- <input id="input_datetime" type="datetime">
- <input id="input_month" type="month">
- <input id="input_week" type="week">
- <input id="input_datetime-local" type="datetime-local">
- <input id="input_readonly" readonly="true">
-</body>
-</html>
diff --git a/browser/base/content/test/general/subtst_contextmenu_xul.xul b/browser/base/content/test/general/subtst_contextmenu_xul.xul deleted file mode 100644 index 5a2ab42e8..000000000 --- a/browser/base/content/test/general/subtst_contextmenu_xul.xul +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0"?> -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - 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/. --> - -<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - xmlns:html="http://www.w3.org/1999/xhtml"> - <label id="test-xul-text-link-label" class="text-link" value="XUL text-link label" href="https://www.mozilla.com"/> -</page> diff --git a/browser/base/content/test/general/svg_image.html b/browser/base/content/test/general/svg_image.html deleted file mode 100644 index 7ab17c33a..000000000 --- a/browser/base/content/test/general/svg_image.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML> -<html> - <head> - <title>Test for page info svg images</title> - </head> - <body> - <svg width="20" height="20"> - <image xlink:href="title_test.svg" width="20" height="20"> - </svg> - </body> -</html> diff --git a/browser/base/content/test/general/test-mixedcontent-securityerrors.html b/browser/base/content/test/general/test-mixedcontent-securityerrors.html deleted file mode 100644 index cb8cfdaaf..000000000 --- a/browser/base/content/test/general/test-mixedcontent-securityerrors.html +++ /dev/null @@ -1,21 +0,0 @@ -<!-- - Bug 875456 - Log mixed content messages from the Mixed Content Blocker to the - Security Pane in the Web Console ---> - -<!DOCTYPE HTML> -<html dir="ltr" xml:lang="en-US" lang="en-US"> - <head> - <meta charset="utf8"> - <title>Mixed Content test - http on https</title> - <script src="testscript.js"></script> - <!-- - Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ - --> - </head> - <body> - <iframe src="http://example.com"></iframe> - <img src="http://example.com/tests/image/test/mochitest/blue.png"></img> - </body> -</html> diff --git a/browser/base/content/test/general/test_bug364677.html b/browser/base/content/test/general/test_bug364677.html deleted file mode 100644 index 67b9729d1..000000000 --- a/browser/base/content/test/general/test_bug364677.html +++ /dev/null @@ -1,32 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=364677 ---> -<head> - <title>Test for Bug 364677</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=364677">Mozilla Bug 364677</a> -<p id="display"><iframe id="testFrame" src="bug364677-data.xml"></iframe></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -<script class="testbody" type="text/javascript"> - -/** Test for Bug 364677 **/ -SimpleTest.waitForExplicitFinish(); - -addLoadEvent(function() { - is(SpecialPowers.wrap($("testFrame")).contentDocument.documentElement.id, "feedHandler", - "Feed served as text/xml without a channel/link should have been sniffed"); -}); -addLoadEvent(SimpleTest.finish); -</script> -</pre> -</body> -</html> - diff --git a/browser/base/content/test/general/test_bug395533.html b/browser/base/content/test/general/test_bug395533.html deleted file mode 100644 index ad6209047..000000000 --- a/browser/base/content/test/general/test_bug395533.html +++ /dev/null @@ -1,38 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=395533 ---> -<head> - <title>Test for Bug 395533</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=395533">Mozilla Bug 395533</a> -<p id="display"><iframe id="testFrame" src="bug395533-data.txt"></iframe></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -<script class="testbody" type="text/javascript"> - -/** Test for Bug 395533 **/ -SimpleTest.waitForExplicitFinish(); - -addLoadEvent(function() { - // Need privs because the feed seems to have an about:feeds principal or some - // such. It's not same-origin with us in any case. - is(SpecialPowers.wrap($("testFrame")).contentDocument.documentElement.id, "", - "Text got sniffed as a feed?"); -}); -addLoadEvent(SimpleTest.finish); - - - - -</script> -</pre> -</body> -</html> - diff --git a/browser/base/content/test/general/test_bug435035.html b/browser/base/content/test/general/test_bug435035.html deleted file mode 100644 index a6624db15..000000000 --- a/browser/base/content/test/general/test_bug435035.html +++ /dev/null @@ -1 +0,0 @@ -<img src="http://example.com/browser/browser/base/content/test/general/moz.png"> diff --git a/browser/base/content/test/general/test_bug462673.html b/browser/base/content/test/general/test_bug462673.html deleted file mode 100644 index d864990e4..000000000 --- a/browser/base/content/test/general/test_bug462673.html +++ /dev/null @@ -1,18 +0,0 @@ -<html> -<head> -<script> -var w; -function openIt() { - w = window.open("", "window2"); -} -function closeIt() { - if (w) { - w.close(); - w = null; - } -} -</script> -</head> -<body onload="openIt();" onunload="closeIt();"> -</body> -</html> diff --git a/browser/base/content/test/general/test_bug628179.html b/browser/base/content/test/general/test_bug628179.html deleted file mode 100644 index d35e17a7c..000000000 --- a/browser/base/content/test/general/test_bug628179.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>Test for closing the Find bar in subdocuments</title> - </head> - <body> - <iframe id=iframe src="http://example.com/" width=320 height=240></iframe> - </body> -</html> - diff --git a/browser/base/content/test/general/test_bug839103.html b/browser/base/content/test/general/test_bug839103.html deleted file mode 100644 index 3639d4bda..000000000 --- a/browser/base/content/test/general/test_bug839103.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Document for Bug 839103</title> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> - <style></style> -</head> -<body> -</body> -</html> diff --git a/browser/base/content/test/general/test_bug959531.html b/browser/base/content/test/general/test_bug959531.html deleted file mode 100644 index e749b198a..000000000 --- a/browser/base/content/test/general/test_bug959531.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>Test for content page with settings button</title> - </head> - <body> - <button name="settings" id="settings">Settings</button> - </body> -</html> diff --git a/browser/base/content/test/general/test_mcb_double_redirect_image.html b/browser/base/content/test/general/test_mcb_double_redirect_image.html deleted file mode 100644 index 1b54774ec..000000000 --- a/browser/base/content/test/general/test_mcb_double_redirect_image.html +++ /dev/null @@ -1,23 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 7-9 for Bug 1082837 - See file browser_mcb_redirect.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=1082837 ---> -<head> - <meta charset="utf-8"> - <title>Bug 1082837</title> - <script> - function image_loaded() { - document.getElementById("mctestdiv").innerHTML = "image loaded"; - } - function image_blocked() { - document.getElementById("mctestdiv").innerHTML = "image blocked"; - } - </script> -</head> -<body> - <div id="mctestdiv"></div> - <img src="https://example.com/browser/browser/base/content/test/general/test_mcb_redirect.sjs?image_redirect_http_sjs" onload="image_loaded()" onerror="image_blocked()" ></image> -</body> -</html> diff --git a/browser/base/content/test/general/test_mcb_redirect.html b/browser/base/content/test/general/test_mcb_redirect.html deleted file mode 100644 index 88af791a3..000000000 --- a/browser/base/content/test/general/test_mcb_redirect.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 1 for Bug 418354 - See file browser_mcb_redirect.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=418354 ---> -<head> - <meta charset="utf-8"> - <title>Bug 418354</title> -</head> -<body> - <div id="mctestdiv">script blocked</div> - <script src="https://example.com/browser/browser/base/content/test/general/test_mcb_redirect.sjs?script" ></script> -</body> -</html> diff --git a/browser/base/content/test/general/test_mcb_redirect.js b/browser/base/content/test/general/test_mcb_redirect.js deleted file mode 100644 index 48538c940..000000000 --- a/browser/base/content/test/general/test_mcb_redirect.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - * Once the mixed content blocker is disabled for the page, this scripts loads - * and updates the text inside the div container. - */ -document.getElementById("mctestdiv").innerHTML = "script executed"; diff --git a/browser/base/content/test/general/test_mcb_redirect.sjs b/browser/base/content/test/general/test_mcb_redirect.sjs deleted file mode 100644 index 9a1811dfa..000000000 --- a/browser/base/content/test/general/test_mcb_redirect.sjs +++ /dev/null @@ -1,22 +0,0 @@ -function handleRequest(request, response) { - var page = "<!DOCTYPE html><html><body>bug 418354 and bug 1082837</body></html>"; - - if (request.queryString === "script") { - var redirect = "http://example.com/browser/browser/base/content/test/general/test_mcb_redirect.js"; - response.setHeader("Cache-Control", "no-cache", false); - } else if (request.queryString === "image_http") { - var redirect = "http://example.com/tests/image/test/mochitest/blue.png"; - response.setHeader("Cache-Control", "max-age=3600", false); - } else if (request.queryString === "image_redirect_http_sjs") { - var redirect = "http://example.com/browser/browser/base/content/test/general/test_mcb_redirect.sjs?image_redirect_https"; - response.setHeader("Cache-Control", "max-age=3600", false); - } else if (request.queryString === "image_redirect_https") { - var redirect = "https://example.com/tests/image/test/mochitest/blue.png"; - response.setHeader("Cache-Control", "max-age=3600", false); - } - - response.setHeader("Content-Type", "text/html", false); - response.setStatusLine(request.httpVersion, "302", "Found"); - response.setHeader("Location", redirect, false); - response.write(page); -} diff --git a/browser/base/content/test/general/test_mcb_redirect_image.html b/browser/base/content/test/general/test_mcb_redirect_image.html deleted file mode 100644 index c70cd8987..000000000 --- a/browser/base/content/test/general/test_mcb_redirect_image.html +++ /dev/null @@ -1,23 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 3-6 for Bug 1082837 - See file browser_mcb_redirect.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=1082837 ---> -<head> - <meta charset="utf-8"> - <title>Bug 1082837</title> - <script> - function image_loaded() { - document.getElementById("mctestdiv").innerHTML = "image loaded"; - } - function image_blocked() { - document.getElementById("mctestdiv").innerHTML = "image blocked"; - } - </script> -</head> -<body> - <div id="mctestdiv"></div> - <img src="https://example.com/browser/browser/base/content/test/general/test_mcb_redirect.sjs?image_http" onload="image_loaded()" onerror="image_blocked()" ></image> -</body> -</html> diff --git a/browser/base/content/test/general/test_no_mcb_on_http_site_font.css b/browser/base/content/test/general/test_no_mcb_on_http_site_font.css deleted file mode 100644 index 68a6954cc..000000000 --- a/browser/base/content/test/general/test_no_mcb_on_http_site_font.css +++ /dev/null @@ -1,10 +0,0 @@ -@font-face { - font-family: testFont; - src: url(http://example.com/browser/devtools/client/fontinspector/test/browser_font.woff); -} -body { - font-family: Arial; -} -div { - font-family: testFont; -} diff --git a/browser/base/content/test/general/test_no_mcb_on_http_site_font.html b/browser/base/content/test/general/test_no_mcb_on_http_site_font.html deleted file mode 100644 index 28a9cb2c0..000000000 --- a/browser/base/content/test/general/test_no_mcb_on_http_site_font.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 2 for Bug 909920 - See file browser_no_mcb_on_http_site.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=909920 ---> -<head> - <meta charset="utf-8"> - <title>Test 2 for Bug 909920</title> - <link rel="stylesheet" type="text/css" href="https://example.com/browser/browser/base/content/test/general/test_no_mcb_on_http_site_font.css" /> -<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - -<script type="text/javascript"> - function checkLoadStates() { - var ui = SpecialPowers.wrap(window) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell) - .securityUI; - - var loadedMixedActive = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT); - is(loadedMixedActive, false, "OK: Should not load mixed active content!"); - - var blockedMixedActive = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT); - is(blockedMixedActive, false, "OK: Should not block mixed active content!"); - - var loadedMixedDisplay = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT); - is(loadedMixedDisplay, false, "OK: Should not load mixed display content!"); - - var blockedMixedDisplay = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_DISPLAY_CONTENT); - is(blockedMixedDisplay, false, "OK: Should not block mixed display content!"); - - var newValue = "Verifying MCB does not trigger warning/error for an http page with https css that includes http font"; - document.getElementById("testDiv").innerHTML = newValue; - } -</script> -</head> -<body onload="checkLoadStates()"> - <div class="testDiv" id="testDiv"> - Testing MCB does not trigger warning/error for an http page with https css that includes http font - </div> -</body> -</html> diff --git a/browser/base/content/test/general/test_no_mcb_on_http_site_font2.css b/browser/base/content/test/general/test_no_mcb_on_http_site_font2.css deleted file mode 100644 index f73b573b4..000000000 --- a/browser/base/content/test/general/test_no_mcb_on_http_site_font2.css +++ /dev/null @@ -1 +0,0 @@ -@import url(http://example.com/browser/browser/base/content/test/general/test_no_mcb_on_http_site_font.css); diff --git a/browser/base/content/test/general/test_no_mcb_on_http_site_font2.html b/browser/base/content/test/general/test_no_mcb_on_http_site_font2.html deleted file mode 100644 index 2b3164902..000000000 --- a/browser/base/content/test/general/test_no_mcb_on_http_site_font2.html +++ /dev/null @@ -1,48 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 3 for Bug 909920 - See file browser_no_mcb_on_http_site.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=909920 ---> -<head> - <meta charset="utf-8"> - <title>Test 3 for Bug 909920</title> - <link rel="stylesheet" type="text/css" href="https://example.com/browser/browser/base/content/test/general/test_no_mcb_on_http_site_font2.css" /> -<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - -<script type="text/javascript"> - function checkLoadStates() { - var ui = SpecialPowers.wrap(window) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell) - .securityUI; - - var loadedMixedActive = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT); - is(loadedMixedActive, false, "OK: Should not load mixed active content!"); - - var blockedMixedActive = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT); - is(blockedMixedActive, false, "OK: Should not block mixed active content!"); - - var loadedMixedDisplay = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT); - is(loadedMixedDisplay, false, "OK: Should not load mixed display content!"); - - var blockedMixedDisplay = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_DISPLAY_CONTENT); - is(blockedMixedDisplay, false, "OK: Should not block mixed display content!"); - - var newValue = "Verifying MCB does not trigger warning/error for an http page "; - newValue += "with https css that imports another http css which includes http font"; - document.getElementById("testDiv").innerHTML = newValue; - } -</script> -</head> -<body onload="checkLoadStates()"> - <div class="testDiv" id="testDiv"> - Testing MCB does not trigger warning/error for an http page with https css that imports another http css which includes http font - </div> -</body> -</html> diff --git a/browser/base/content/test/general/test_no_mcb_on_http_site_img.css b/browser/base/content/test/general/test_no_mcb_on_http_site_img.css deleted file mode 100644 index d045e21ba..000000000 --- a/browser/base/content/test/general/test_no_mcb_on_http_site_img.css +++ /dev/null @@ -1,3 +0,0 @@ -#testDiv { - background: url(http://example.com/tests/image/test/mochitest/blue.png) -} diff --git a/browser/base/content/test/general/test_no_mcb_on_http_site_img.html b/browser/base/content/test/general/test_no_mcb_on_http_site_img.html deleted file mode 100644 index 741573260..000000000 --- a/browser/base/content/test/general/test_no_mcb_on_http_site_img.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- - Test 1 for Bug 909920 - See file browser_no_mcb_on_http_site.js for description. - https://bugzilla.mozilla.org/show_bug.cgi?id=909920 ---> -<head> - <meta charset="utf-8"> - <title>Test 1 for Bug 909920</title> - <link rel="stylesheet" type="text/css" href="https://example.com/browser/browser/base/content/test/general/test_no_mcb_on_http_site_img.css" /> -<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - -<script type="text/javascript"> - function checkLoadStates() { - var ui = SpecialPowers.wrap(window) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell) - .securityUI; - - var loadedMixedActive = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT); - is(loadedMixedActive, false, "OK: Should not load mixed active content!"); - - var blockedMixedActive = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT); - is(blockedMixedActive, false, "OK: Should not block mixed active content!"); - - var loadedMixedDisplay = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT); - is(loadedMixedDisplay, false, "OK: Should not load mixed display content!"); - - var blockedMixedDisplay = ui && - !!(ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_BLOCKED_MIXED_DISPLAY_CONTENT); - is(blockedMixedDisplay, false, "OK: Should not block mixed display content!"); - - var newValue = "Verifying MCB does not trigger warning/error for an http page with https css that includes http image"; - document.getElementById("testDiv").innerHTML = newValue; - } -</script> -</head> -<body onload="checkLoadStates()"> - <div class="testDiv" id="testDiv"> - Testing MCB does not trigger warning/error for an http page with https css that includes http image - </div> -</body> -</html> diff --git a/browser/base/content/test/general/test_offlineNotification.html b/browser/base/content/test/general/test_offlineNotification.html deleted file mode 100644 index 4f78184b4..000000000 --- a/browser/base/content/test/general/test_offlineNotification.html +++ /dev/null @@ -1,129 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=462856 ---> -<head> - <title>Test offline app notification</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="offlineByDefault.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> -<p id="display"> -<!-- Load the test frame twice from the same domain, - to make sure we get notifications for both --> -<iframe name="testFrame" src="offlineChild.html"></iframe> -<iframe name="testFrame2" src="offlineChild2.html"></iframe> -<!-- Load from another domain to make sure we get a second allow/deny - notification --> -<iframe name="testFrame3" src="http://example.com/tests/browser/base/content/test/general/offlineChild.html"></iframe> - -<iframe id="eventsTestFrame" src="offlineEvent.html"></iframe> - -<div id="content" style="display: none"> -</div> -<pre id="test"> -<script class="testbody" type="text/javascript"> - -SimpleTest.waitForExplicitFinish(); -const Cc = SpecialPowers.Cc; - -var numFinished = 0; - -window.addEventListener("message", function(event) { - is(event.data, "success", "Child was successfully cached."); - - if (++numFinished == 3) { - // Clean up after ourself - var pm = Cc["@mozilla.org/permissionmanager;1"]. - getService(SpecialPowers.Ci.nsIPermissionManager); - var ioService = Cc["@mozilla.org/network/io-service;1"] - .getService(SpecialPowers.Ci.nsIIOService); - var uri1 = ioService.newURI(frames.testFrame.location, null, null); - var uri2 = ioService.newURI(frames.testFrame3.location, null, null); - - var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(SpecialPowers.Ci.nsIScriptSecurityManager); - var principal1 = ssm.createCodebasePrincipal(uri1, {}); - var principal2 = ssm.createCodebasePrincipal(uri2, {}); - - pm.removeFromPrincipal(principal1, "offline-app"); - pm.removeFromPrincipal(principal2, "offline-app"); - - offlineByDefault.reset(); - - SimpleTest.finish(); - } - }, false); - -var count = 0; -var expectedEvent = ""; -function eventHandler(evt) { - ++count; - is(evt.type, expectedEvent, "Wrong event!"); -} - -function testEventHandling() { - var events = [ "checking", - "error", - "noupdate", - "downloading", - "progress", - "updateready", - "cached", - "obsolete"]; - var w = document.getElementById("eventsTestFrame").contentWindow; - var e; - for (var i = 0; i < events.length; ++i) { - count = 0; - expectedEvent = events[i]; - e = w.document.createEvent("event"); - e.initEvent(expectedEvent, true, true); - w.applicationCache["on" + expectedEvent] = eventHandler; - w.applicationCache.addEventListener(expectedEvent, eventHandler, true); - w.applicationCache.dispatchEvent(e); - is(count, 2, "Wrong number events!"); - w.applicationCache["on" + expectedEvent] = null; - w.applicationCache.removeEventListener(expectedEvent, eventHandler, true); - w.applicationCache.dispatchEvent(e); - is(count, 2, "Wrong number events!"); - } - - // Test some random event. - count = 0; - expectedEvent = "foo"; - e = w.document.createEvent("event"); - e.initEvent(expectedEvent, true, true); - w.applicationCache.addEventListener(expectedEvent, eventHandler, true); - w.applicationCache.dispatchEvent(e); - is(count, 1, "Wrong number events!"); - w.applicationCache.removeEventListener(expectedEvent, eventHandler, true); - w.applicationCache.dispatchEvent(e); - is(count, 1, "Wrong number events!"); -} - -function loaded() { - testEventHandling(); - - // Click the notification panel's "Allow" button. This should kick - // off updates, which will eventually lead to getting messages from - // the children. - var wm = SpecialPowers.Cc["@mozilla.org/appshell/window-mediator;1"]. - getService(SpecialPowers.Ci.nsIWindowMediator); - var win = wm.getMostRecentWindow("navigator:browser"); - var panel = win.PopupNotifications.panel; - is(panel.childElementCount, 2, "2 notifications being displayed"); - panel.firstElementChild.button.click(); - - // should have dismissed one of the notifications. - is(panel.childElementCount, 1, "1 notification now being displayed"); - panel.firstElementChild.button.click(); -} - -SimpleTest.waitForFocus(loaded); - -</script> -</pre> -</body> -</html> diff --git a/browser/base/content/test/general/test_offline_gzip.html b/browser/base/content/test/general/test_offline_gzip.html deleted file mode 100644 index a18d6604e..000000000 --- a/browser/base/content/test/general/test_offline_gzip.html +++ /dev/null @@ -1,21 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=501422 - -When content which was transported over the network with -Content-Type: gzip is added to the offline -cache, it can be fetched from the cache successfully. ---> -<head> - <title>Test gzipped offline resources</title> - <meta charset="utf-8"> -</head> -<body> -<p id="display"> -<iframe name="testFrame" src="gZipOfflineChild.html"></iframe> - -<div id="content" style="display: none"> -</div> -</body> -</html> diff --git a/browser/base/content/test/general/test_process_flags_chrome.html b/browser/base/content/test/general/test_process_flags_chrome.html deleted file mode 100644 index adcbf0340..000000000 --- a/browser/base/content/test/general/test_process_flags_chrome.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> - -<html> -<body> -<p>chrome: test page</p> -<p><a href="chrome://mochitests/content/browser/browser/base/content/test/general/test_process_flags_chrome.html">chrome</a></p> -<p><a href="chrome://mochitests-any/content/browser/browser/base/content/test/general/test_process_flags_chrome.html">canremote</a></p> -<p><a href="chrome://mochitests-content/content/browser/browser/base/content/test/general/test_process_flags_chrome.html">mustremote</a></p> -</body> -</html> diff --git a/browser/base/content/test/general/test_remoteTroubleshoot.html b/browser/base/content/test/general/test_remoteTroubleshoot.html deleted file mode 100644 index 7ba1c5268..000000000 --- a/browser/base/content/test/general/test_remoteTroubleshoot.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE HTML> -<html> -<script> -// This test is run multiple times, once with only strings allowed through the -// WebChannel, and once with objects allowed. This function allows us to handle -// both cases without too much pain. -function makeDetails(object) { - if (window.location.search.indexOf("object") >= 0) { - return object; - } - return JSON.stringify(object) -} -// Add a listener for responses to our remote requests. -window.addEventListener("WebChannelMessageToContent", function (event) { - if (event.detail.id == "remote-troubleshooting") { - // Send what we got back to the test. - var backEvent = new window.CustomEvent("WebChannelMessageToChrome", { - detail: makeDetails({ - id: "test-remote-troubleshooting-backchannel", - message: { - message: event.detail.message, - }, - }), - }); - window.dispatchEvent(backEvent); - // and stick it in our DOM just for good measure/diagnostics. - document.getElementById("troubleshooting").textContent = - JSON.stringify(event.detail.message, null, 2); - } -}); - -// Make a request for the troubleshooting data as we load. -window.onload = function() { - var event = new window.CustomEvent("WebChannelMessageToChrome", { - detail: makeDetails({ - id: "remote-troubleshooting", - message: { - command: "request", - }, - }), - }); - window.dispatchEvent(event); -} -</script> - -<body> - <pre id="troubleshooting"/> -</body> - -</html> diff --git a/browser/base/content/test/general/title_test.svg b/browser/base/content/test/general/title_test.svg deleted file mode 100644 index 7638fd5cc..000000000 --- a/browser/base/content/test/general/title_test.svg +++ /dev/null @@ -1,59 +0,0 @@ -<svg width="640px" height="480px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title>This is a root SVG element's title</title> - <foreignObject> - <html xmlns="http://www.w3.org/1999/xhtml"> - <body> - <svg xmlns="http://www.w3.org/2000/svg" id="svg1"> - <title>This is a non-root SVG element title</title> - </svg> - </body> - </html> - </foreignObject> - <text id="text1" x="10px" y="32px" font-size="24px"> - This contains only <title> - <title> - - - This is a title - - </title> - </text> - <text id="text2" x="10px" y="96px" font-size="24px"> - This contains only <desc> - <desc>This is a desc</desc> - </text> - <text id="text3" x="10px" y="128px" font-size="24px" title="ignored for SVG"> - This contains nothing. - </text> - <a id="link1" xlink:href="#"> - This link contains <title> - <title> - This is a title - </title> - <text id="text4" x="10px" y="192px" font-size="24px"> - </text> - </a> - <a id="link2" xlink:href="#"> - <text x="10px" y="192px" font-size="24px"> - This text contains <title> - <title> - This is a title - </title> - </text> - </a> - <a id="link3" xlink:href="#" xlink:title="This is an xlink:title attribute"> - <text x="10px" y="224px" font-size="24px"> - This link contains <title> & xlink:title attr. - <title>This is a title</title> - </text> - </a> - <a id="link4" xlink:href="#" xlink:title="This is an xlink:title attribute"> - <text x="10px" y="256px" font-size="24px"> - This link contains xlink:title attr. - </text> - </a> - <text id="text5" x="10px" y="160px" font-size="24px" - xlink:title="This is an xlink:title attribute but it isn't on a link" > - This contains nothing. - </text> -</svg> diff --git a/browser/base/content/test/general/trackingPage.html b/browser/base/content/test/general/trackingPage.html deleted file mode 100644 index 17f0e459e..000000000 --- a/browser/base/content/test/general/trackingPage.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE HTML> -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - 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/. --> -<html dir="ltr" xml:lang="en-US" lang="en-US"> - <head> - <meta charset="utf8"> - </head> - <body> - <iframe src="http://tracking.example.com/"></iframe> - </body> -</html> diff --git a/browser/base/content/test/general/unknownContentType_file.pif b/browser/base/content/test/general/unknownContentType_file.pif deleted file mode 100644 index 9353d1312..000000000 --- a/browser/base/content/test/general/unknownContentType_file.pif +++ /dev/null @@ -1 +0,0 @@ -Dummy content for unknownContentType_dialog_layout_data.pif diff --git a/browser/base/content/test/general/unknownContentType_file.pif^headers^ b/browser/base/content/test/general/unknownContentType_file.pif^headers^ deleted file mode 100644 index 09b22facc..000000000 --- a/browser/base/content/test/general/unknownContentType_file.pif^headers^ +++ /dev/null @@ -1 +0,0 @@ -Content-Type: application/octet-stream diff --git a/browser/base/content/test/general/video.ogg b/browser/base/content/test/general/video.ogg Binary files differdeleted file mode 100644 index ac7ece351..000000000 --- a/browser/base/content/test/general/video.ogg +++ /dev/null diff --git a/browser/base/content/test/general/web_video.html b/browser/base/content/test/general/web_video.html deleted file mode 100644 index 467fb0ce1..000000000 --- a/browser/base/content/test/general/web_video.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> - <head> - <title>Document with Web Video</title> - </head> - <body> - This document has some web video in it. - <br> - <video src="web_video1.ogv" id="video1"> </video> - </body> -</html> diff --git a/browser/base/content/test/general/web_video1.ogv b/browser/base/content/test/general/web_video1.ogv Binary files differdeleted file mode 100644 index 093158432..000000000 --- a/browser/base/content/test/general/web_video1.ogv +++ /dev/null diff --git a/browser/base/content/test/general/web_video1.ogv^headers^ b/browser/base/content/test/general/web_video1.ogv^headers^ deleted file mode 100644 index 4511e9255..000000000 --- a/browser/base/content/test/general/web_video1.ogv^headers^ +++ /dev/null @@ -1,3 +0,0 @@ -Content-Disposition: filename="web-video1-expectedName.ogv" -Content-Type: video/ogg - diff --git a/browser/base/content/test/general/zoom_test.html b/browser/base/content/test/general/zoom_test.html deleted file mode 100644 index bf80490ca..000000000 --- a/browser/base/content/test/general/zoom_test.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=416661 ---> - <head> - <title>Test for zoom setting</title> - - </head> - <body> - <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=416661">Bug 416661</a> - <p>Site specific zoom settings should not apply to image documents.</p> - </body> -</html> |