From 565d0479c35b79b72b95301e5a11e2d0458fd687 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 29 Jan 2013 13:12:13 -0500 Subject: [PATCH] Bug 817477 - Remove support for global private browsing mode; r=jdm,glandium --HG-- rename : browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js.in => browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js rename : browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js.in => browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js --- .../modules/{setup.js.in => setup.js} | 19 - .../modules/{tasks.js.in => tasks.js} | 32 - browser/app/profile/firefox.js | 5 - browser/base/content/browser-appmenu.inc | 10 - browser/base/content/browser-context.inc | 2 - browser/base/content/browser-menubar.inc | 13 - browser/base/content/browser-sets.inc | 4 - browser/base/content/browser-social.js | 29 +- browser/base/content/browser.js | 274 +------- browser/base/content/macBrowserOverlay.xul | 2 - browser/base/content/nsContextMenu.js | 4 - browser/base/content/tabbrowser.xml | 15 +- browser/base/content/test/Makefile.in | 33 +- .../base/content/test/browser_bug763468.js | 81 --- .../base/content/test/browser_bug767836.js | 98 --- .../base/content/test/browser_save_link.js | 128 ---- .../content/test/browser_save_private_link.js | 116 ---- .../test/browser_tabMatchesInAwesomebar.js | 323 ---------- browser/base/content/test/newtab/Makefile.in | 11 +- .../newtab/browser_newtab_private_browsing.js | 54 -- browser/base/content/test/social/Makefile.in | 11 +- .../test/social/browser_social_globalPB.js | 147 ----- browser/base/content/utilityOverlay.js | 11 - browser/components/build/Makefile.in | 5 - browser/components/build/nsModule.cpp | 16 - .../downloads/src/DownloadsCommon.jsm | 52 -- .../downloads/src/DownloadsStartup.js | 25 +- browser/components/nsBrowserContentHandler.js | 9 - .../components/places/content/controller.js | 16 +- browser/components/places/content/places.js | 46 -- .../components/places/src/PlacesUIUtils.jsm | 6 - .../components/preferences/in-content/jar.mn | 4 +- .../preferences/in-content/privacy.js | 18 - .../preferences/in-content/privacy.xul | 8 - .../preferences/in-content/tests/Makefile.in | 18 - .../in-content/tests/browser_bug567487.js | 73 --- .../in-content/tests/browser_privacypane_1.js | 6 +- .../in-content/tests/browser_privacypane_2.js | 33 - .../in-content/tests/browser_privacypane_3.js | 6 +- .../in-content/tests/browser_privacypane_4.js | 6 +- .../in-content/tests/browser_privacypane_5.js | 6 +- .../in-content/tests/browser_privacypane_6.js | 26 - .../in-content/tests/browser_privacypane_7.js | 27 - .../in-content/tests/browser_privacypane_8.js | 6 +- .../in-content/tests/privacypane_tests.js | 491 --------------- browser/components/preferences/jar.mn | 4 +- browser/components/preferences/privacy.js | 18 - browser/components/preferences/privacy.xul | 8 - .../components/preferences/tests/Makefile.in | 18 - .../preferences/tests/browser_bug567487.js | 70 --- .../tests/browser_privacypane_1.js | 6 +- .../tests/browser_privacypane_2.js | 34 - .../tests/browser_privacypane_3.js | 6 +- .../tests/browser_privacypane_4.js | 6 +- .../tests/browser_privacypane_5.js | 6 +- .../tests/browser_privacypane_6.js | 27 - .../tests/browser_privacypane_7.js | 28 - .../tests/browser_privacypane_8.js | 6 +- .../preferences/tests/privacypane_tests.js | 499 --------------- .../content/aboutPrivateBrowsing.xhtml | 41 -- .../privatebrowsing/src/Makefile.in | 20 - .../src/nsPrivateBrowsingService.js | 593 ------------------ .../src/nsPrivateBrowsingService.manifest | 17 - .../src/nsPrivateBrowsingServiceWrapper.cpp | 93 --- .../src/nsPrivateBrowsingServiceWrapper.h | 24 - .../privatebrowsing/test/Makefile.in | 9 - .../privatebrowsing/test/browser/Makefile.in | 15 - .../test/browser/global/Makefile.in | 56 -- ..._privatebrowsing_DownloadLastDirWithCPS.js | 259 -------- ...rowser_privatebrowsing_certexceptionsui.js | 55 -- ...wser_privatebrowsing_cookieacceptdialog.js | 81 --- .../global/browser_privatebrowsing_crh.js | 30 - ...browser_privatebrowsing_downloadLastDir.js | 99 --- ...owser_privatebrowsing_downloadLastDir_c.js | 114 ---- ..._privatebrowsing_downloadLastDir_toggle.js | 76 --- .../browser_privatebrowsing_geoprompt.js | 50 -- ...rowser_privatebrowsing_geoprompt_page.html | 13 - .../browser_privatebrowsing_localStorage.js | 26 - ...ivatebrowsing_localStorage_before_after.js | 41 -- ...owsing_localStorage_before_after_page.html | 11 - ...wsing_localStorage_before_after_page2.html | 10 - ...er_privatebrowsing_localStorage_page1.html | 10 - ...er_privatebrowsing_localStorage_page2.html | 10 - ...ser_privatebrowsing_openLocationLastURL.js | 63 -- .../global/browser_privatebrowsing_opendir.js | 109 ---- .../browser_privatebrowsing_openlocation.js | 78 --- .../browser_privatebrowsing_placestitle.js | 77 --- .../browser_privatebrowsing_popupblocker.js | 68 -- ...browser_privatebrowsing_protocolhandler.js | 54 -- ..._privatebrowsing_protocolhandler_page.html | 13 - .../global/browser_privatebrowsing_theming.js | 32 - .../global/browser_privatebrowsing_ui.js | 102 --- .../browser_privatebrowsing_urlbarfocus.js | 62 -- .../browser_privatebrowsing_windowtitle.js | 97 --- ...wser_privatebrowsing_windowtitle_page.html | 9 - .../global/browser_privatebrowsing_zoom.js | 62 -- .../browser_privatebrowsing_zoomrestore.js | 55 -- .../test/browser/global/ctxmenu-image.png | Bin 5401 -> 0 bytes .../test/browser/global/ctxmenu.html | 9 - .../test/browser/global/head.js | 40 -- .../test/browser/global/popup.html | 11 - .../test/browser/global/title.sjs | 22 - .../test/browser/obsolete/Makefile.in | 38 -- .../browser/obsolete/browser_console_clear.js | 59 -- .../browser_privatebrowsing_beforeunload.js | 138 ---- ...wser_privatebrowsing_commandline_toggle.js | 127 ---- .../browser_privatebrowsing_fastswitch.js | 59 -- .../browser_privatebrowsing_findbar.js | 49 -- .../browser_privatebrowsing_forgetthissite.js | 129 ---- .../browser_privatebrowsing_import.js | 70 --- ...owser_privatebrowsing_newwindow_stopcmd.js | 29 - .../browser_privatebrowsing_pageinfo.js | 70 --- .../browser_privatebrowsing_popupmode.js | 80 --- .../browser_privatebrowsing_searchbar.js | 65 -- ...wser_privatebrowsing_sslsite_transition.js | 44 -- .../browser_privatebrowsing_transition.js | 64 -- .../browser_privatebrowsing_urlbarundo.js | 32 - .../browser_privatebrowsing_viewsource.js | 140 ----- .../test/browser/obsolete/head.js | 25 - .../test/unit/do_test_0-privatebrowsing.js | 217 ------- .../test/unit/do_test_placesTitleNoUpdate.js | 60 -- .../unit/do_test_privatebrowsing_autostart.js | 41 -- .../do_test_privatebrowsing_commandline.js | 89 --- .../test/unit/do_test_privatebrowsing_exit.js | 60 -- .../unit/do_test_privatebrowsing_telemetry.js | 42 -- .../test/unit/head_privatebrowsing.js | 70 --- .../test/unit/tail_privatebrowsing.js | 8 - .../test/unit/test_0-privatebrowsing.js | 12 - .../unit/test_0-privatebrowsingwrapper.js | 12 - .../test/unit/test_aboutprivatebrowsing.js | 53 -- .../test/unit/test_placesTitleNoUpdate.js | 12 - .../unit/test_privatebrowsing_autostart.js | 11 - .../unit/test_privatebrowsing_commandline.js | 11 - .../test/unit/test_privatebrowsing_exit.js | 12 - .../unit/test_privatebrowsing_telemetry.js | 11 - .../test_privatebrowsingwrapper_autostart.js | 11 - ...test_privatebrowsingwrapper_commandline.js | 11 - .../unit/test_privatebrowsingwrapper_exit.js | 12 - ...vatebrowsingwrapper_placesTitleNoUpdate.js | 12 - .../test_privatebrowsingwrapper_telemetry.js | 11 - .../test/unit/test_transition_nooffline.js | 38 -- .../privatebrowsing/test/unit/xpcshell.ini | 18 - browser/components/search/test/Makefile.in | 11 +- .../search/test/browser_private_search.js | 101 --- .../sessionstore/src/SessionStore.jsm | 121 +--- .../sessionstore/src/nsSessionStartup.js | 6 - .../components/sessionstore/test/Makefile.in | 20 +- .../sessionstore/test/browser_248970_a.js | 132 ---- .../sessionstore/test/browser_248970_b.js | 175 ------ .../sessionstore/test/browser_354894.js | 515 --------------- .../test/browser_394759_privatebrowsing.js | 140 ----- browser/components/tabview/test/Makefile.in | 21 +- .../tabview/test/browser_tabview_bug624265.js | 155 ----- .../tabview/test/browser_tabview_bug624727.js | 130 ---- .../tabview/test/browser_tabview_bug650280.js | 67 -- .../tabview/test/browser_tabview_bug679853.js | 32 - .../test/browser_tabview_privatebrowsing.js | 159 ----- browser/components/tabview/test/head.js | 18 - browser/components/tabview/ui.js | 72 --- browser/confvars.sh | 1 - browser/devtools/commandline/test/Makefile.in | 11 +- .../test/browser_cmd_screenshot.js | 179 ------ browser/devtools/styleeditor/test/Makefile.in | 11 +- .../test/browser_styleeditor_private.js | 51 -- browser/devtools/webconsole/test/Makefile.in | 6 - ..._webconsole_bug_618311_private_browsing.js | 150 ----- browser/installer/package-manifest.in | 5 - .../chrome/browser/aboutPrivateBrowsing.dtd | 13 - .../locales/en-US/chrome/browser/browser.dtd | 5 - .../en-US/chrome/browser/browser.properties | 12 - .../en-US/chrome/browser/taskbar.properties | 4 - browser/modules/RecentWindow.jsm | 5 - browser/modules/Social.jsm | 19 - browser/modules/WindowsJumpLists.jsm | 45 -- browser/themes/gnomestripe/browser.css | 2 - browser/themes/pinstripe/browser.css | 2 - browser/themes/winstripe/browser.css | 2 - config/writemozinfo.py | 3 - configure.in | 6 - content/base/src/nsCCUncollectableMarker.cpp | 2 - docshell/base/nsDocShell.cpp | 18 - docshell/base/nsDownloadHistory.cpp | 17 - docshell/test/chrome/Makefile.in | 7 +- dom/indexedDB/test/Makefile.in | 11 +- dom/indexedDB/test/browser_privateBrowsing.js | 67 -- dom/plugins/test/mochitest/Makefile.in | 9 - .../test/mochitest/test_privatemode.xul | 98 --- dom/tests/browser/Makefile.in | 23 +- .../browser/browser_ConsoleStoragePBTest.js | 93 --- .../browser_geolocation_privatebrowsing.js | 50 -- dom/tests/mochitest/localstorage/Makefile.in | 17 +- dom/tests/mochitest/localstorage/pbSwitch.js | 40 -- .../test_localStorageBasePrivateBrowsing.html | 233 ------- ...test_localStorageQuotaPrivateBrowsing.html | 137 ---- .../windowwatcher/src/nsWindowWatcher.cpp | 14 - extensions/cookie/test/unit/head_cookies.js | 4 - extensions/cookie/test/unit/test_bug468700.js | 57 -- extensions/cookie/test/unit/xpcshell.ini | 2 - layout/forms/test/Makefile.in | 13 +- layout/forms/test/test_bug536567.html | 170 ----- mobile/android/confvars.sh | 2 - netwerk/base/public/Makefile.in | 7 +- .../base/public/nsIPrivateBrowsingService.idl | 53 -- netwerk/build/nsNetCID.h | 13 - .../ssl/tests/mochitest/browser/Makefile.in | 5 - .../stricttransportsecurity/Makefile.in | 6 - .../test_sts_privatebrowsing.html | 233 ------- .../manager/ssl/tests/unit/test_bug627234.js | 64 -- .../ssl/tests/unit/test_sts_preloadlist.js | 216 ------- security/manager/ssl/tests/unit/xpcshell.ini | 5 - services/sync/modules/engines/tabs.js | 11 - .../console/content/consoleBindings.xml | 2 - .../downloads/nsDownloadManager.cpp | 227 ++----- .../components/downloads/nsDownloadManager.h | 2 - .../test/unit/test_private_resume_global.js | 129 ---- .../test_privatebrowsing_cancel_global.js | 266 -------- .../test/unit/test_privatebrowsing_global.js | 315 ---------- .../downloads/test/unit/xpcshell.ini | 9 - .../components/passwordmgr/test/Makefile.in | 21 +- .../passwordmgr/test/test_privbrowsing.html | 275 -------- .../passwordmgr/test/test_prompt.html | 24 - .../components/places/AsyncFaviconHelpers.cpp | 27 - toolkit/components/places/Helpers.cpp | 21 - toolkit/components/places/Helpers.h | 5 - toolkit/components/places/History.cpp | 2 - .../components/places/nsAnnotationService.cpp | 12 - .../components/places/nsFaviconService.cpp | 2 - toolkit/components/places/nsNavHistory.cpp | 6 - toolkit/components/places/nsPlacesMacros.h | 6 - toolkit/components/places/tests/Makefile.in | 6 - .../places/tests/browser/Makefile.in | 20 +- .../browser_favicon_privatebrowsing.js | 49 -- .../browser_visituri_privatebrowsing.js | 78 --- .../test_setAndFetchFaviconForPage.js | 112 ---- ...test_setAndFetchFaviconForPage_failures.js | 173 ----- .../places/tests/favicons/xpcshell.ini | 6 - .../tests/mochitest/test_bug_461710.html | 213 ------- .../places/tests/unit/test_248970.js | 234 ------- .../components/places/tests/unit/xpcshell.ini | 2 - toolkit/components/satchel/test/Makefile.in | 6 - .../satchel/test/browser/Makefile.in | 5 - .../satchel/test/test_privbrowsing.html | 80 --- toolkit/components/social/MozSocialAPI.jsm | 15 +- toolkit/components/startup/nsAppStartup.cpp | 6 - toolkit/components/telemetry/Histograms.json | 24 - toolkit/components/telemetry/TelemetryPing.js | 16 - toolkit/content/PrivateBrowsingUtils.jsm | 10 - .../mozapps/downloads/downloads.properties | 5 - .../mozapps/downloads/content/downloads.js | 43 -- .../mozapps/downloads/content/downloads.xul | 3 - .../downloads/tests/chrome/Makefile.in | 6 - .../chrome/test_privatebrowsing_title.xul | 114 ---- .../update/test/unit/test_bug497578.js | 114 ---- toolkit/mozapps/update/test/unit/xpcshell.ini | 2 - widget/tests/Makefile.in | 7 +- widget/tests/test_bug462106.xul | 105 ---- xpfe/appshell/src/nsAppShellService.cpp | 27 +- xpfe/appshell/src/nsAppShellService.h | 2 - xpfe/appshell/src/test/Makefile.in | 2 - 259 files changed, 118 insertions(+), 14651 deletions(-) rename browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/{setup.js.in => setup.js} (97%) rename browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/{tasks.js.in => tasks.js} (97%) delete mode 100644 browser/base/content/test/browser_bug763468.js delete mode 100644 browser/base/content/test/browser_bug767836.js delete mode 100644 browser/base/content/test/browser_save_link.js delete mode 100644 browser/base/content/test/browser_save_private_link.js delete mode 100644 browser/base/content/test/browser_tabMatchesInAwesomebar.js delete mode 100644 browser/base/content/test/newtab/browser_newtab_private_browsing.js delete mode 100644 browser/base/content/test/social/browser_social_globalPB.js delete mode 100644 browser/components/preferences/in-content/tests/browser_bug567487.js delete mode 100644 browser/components/preferences/in-content/tests/browser_privacypane_2.js delete mode 100644 browser/components/preferences/in-content/tests/browser_privacypane_6.js delete mode 100644 browser/components/preferences/in-content/tests/browser_privacypane_7.js delete mode 100644 browser/components/preferences/in-content/tests/privacypane_tests.js delete mode 100644 browser/components/preferences/tests/browser_bug567487.js delete mode 100644 browser/components/preferences/tests/browser_privacypane_2.js delete mode 100644 browser/components/preferences/tests/browser_privacypane_6.js delete mode 100644 browser/components/preferences/tests/browser_privacypane_7.js delete mode 100644 browser/components/preferences/tests/privacypane_tests.js delete mode 100644 browser/components/privatebrowsing/src/nsPrivateBrowsingService.js delete mode 100644 browser/components/privatebrowsing/src/nsPrivateBrowsingService.manifest delete mode 100644 browser/components/privatebrowsing/src/nsPrivateBrowsingServiceWrapper.cpp delete mode 100644 browser/components/privatebrowsing/src/nsPrivateBrowsingServiceWrapper.h delete mode 100644 browser/components/privatebrowsing/test/browser/global/Makefile.in delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_DownloadLastDirWithCPS.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_certexceptionsui.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_cookieacceptdialog.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_crh.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir_c.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir_toggle.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt_page.html delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page.html delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page2.html delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page1.html delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page2.html delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_openLocationLastURL.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_opendir.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_openlocation.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_placestitle.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_popupblocker.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler_page.html delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_theming.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_ui.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_urlbarfocus.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle_page.html delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoom.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoomrestore.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/ctxmenu-image.png delete mode 100644 browser/components/privatebrowsing/test/browser/global/ctxmenu.html delete mode 100644 browser/components/privatebrowsing/test/browser/global/head.js delete mode 100644 browser/components/privatebrowsing/test/browser/global/popup.html delete mode 100644 browser/components/privatebrowsing/test/browser/global/title.sjs delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/Makefile.in delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_console_clear.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_beforeunload.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_commandline_toggle.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_fastswitch.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_findbar.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_forgetthissite.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_import.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_newwindow_stopcmd.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_pageinfo.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_popupmode.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_searchbar.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_sslsite_transition.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_transition.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_urlbarundo.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_viewsource.js delete mode 100644 browser/components/privatebrowsing/test/browser/obsolete/head.js delete mode 100644 browser/components/privatebrowsing/test/unit/do_test_0-privatebrowsing.js delete mode 100644 browser/components/privatebrowsing/test/unit/do_test_placesTitleNoUpdate.js delete mode 100644 browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_autostart.js delete mode 100644 browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_commandline.js delete mode 100644 browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_exit.js delete mode 100644 browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_telemetry.js delete mode 100644 browser/components/privatebrowsing/test/unit/head_privatebrowsing.js delete mode 100644 browser/components/privatebrowsing/test/unit/tail_privatebrowsing.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_0-privatebrowsing.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_0-privatebrowsingwrapper.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_aboutprivatebrowsing.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_placesTitleNoUpdate.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_privatebrowsing_autostart.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_privatebrowsing_commandline.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_privatebrowsing_exit.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_privatebrowsing_telemetry.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_autostart.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_commandline.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_exit.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_placesTitleNoUpdate.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_telemetry.js delete mode 100644 browser/components/privatebrowsing/test/unit/test_transition_nooffline.js delete mode 100644 browser/components/privatebrowsing/test/unit/xpcshell.ini delete mode 100644 browser/components/search/test/browser_private_search.js delete mode 100644 browser/components/sessionstore/test/browser_248970_a.js delete mode 100644 browser/components/sessionstore/test/browser_248970_b.js delete mode 100644 browser/components/sessionstore/test/browser_354894.js delete mode 100644 browser/components/sessionstore/test/browser_394759_privatebrowsing.js delete mode 100644 browser/components/tabview/test/browser_tabview_bug624265.js delete mode 100644 browser/components/tabview/test/browser_tabview_bug624727.js delete mode 100644 browser/components/tabview/test/browser_tabview_bug650280.js delete mode 100644 browser/components/tabview/test/browser_tabview_bug679853.js delete mode 100644 browser/components/tabview/test/browser_tabview_privatebrowsing.js delete mode 100644 browser/devtools/commandline/test/browser_cmd_screenshot.js delete mode 100644 browser/devtools/styleeditor/test/browser_styleeditor_private.js delete mode 100644 browser/devtools/webconsole/test/browser_webconsole_bug_618311_private_browsing.js delete mode 100644 dom/indexedDB/test/browser_privateBrowsing.js delete mode 100644 dom/plugins/test/mochitest/test_privatemode.xul delete mode 100644 dom/tests/browser/browser_ConsoleStoragePBTest.js delete mode 100644 dom/tests/browser/browser_geolocation_privatebrowsing.js delete mode 100644 dom/tests/mochitest/localstorage/pbSwitch.js delete mode 100644 dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing.html delete mode 100644 dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing.html delete mode 100644 extensions/cookie/test/unit/test_bug468700.js delete mode 100644 layout/forms/test/test_bug536567.html delete mode 100644 netwerk/base/public/nsIPrivateBrowsingService.idl delete mode 100644 security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing.html delete mode 100644 security/manager/ssl/tests/unit/test_bug627234.js delete mode 100644 security/manager/ssl/tests/unit/test_sts_preloadlist.js delete mode 100644 toolkit/components/downloads/test/unit/test_private_resume_global.js delete mode 100644 toolkit/components/downloads/test/unit/test_privatebrowsing_cancel_global.js delete mode 100644 toolkit/components/downloads/test/unit/test_privatebrowsing_global.js delete mode 100644 toolkit/components/passwordmgr/test/test_privbrowsing.html delete mode 100644 toolkit/components/places/tests/browser/browser_favicon_privatebrowsing.js delete mode 100644 toolkit/components/places/tests/browser/browser_visituri_privatebrowsing.js delete mode 100644 toolkit/components/places/tests/favicons/test_setAndFetchFaviconForPage.js delete mode 100644 toolkit/components/places/tests/favicons/test_setAndFetchFaviconForPage_failures.js delete mode 100644 toolkit/components/places/tests/mochitest/test_bug_461710.html delete mode 100644 toolkit/components/places/tests/unit/test_248970.js delete mode 100644 toolkit/components/satchel/test/test_privbrowsing.html delete mode 100644 toolkit/mozapps/downloads/tests/chrome/test_privatebrowsing_title.xul delete mode 100644 toolkit/mozapps/update/test/unit/test_bug497578.js delete mode 100644 widget/tests/test_bug462106.xul diff --git a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js.in b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js similarity index 97% rename from browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js.in rename to browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js index d75cad49c75d..e3ce6b0b1fee 100644 --- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js.in +++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js @@ -172,10 +172,6 @@ let TestPilotSetup = { "testpilot:task:dataAutoSubmitted", this._onTaskDataAutoSubmitted, self); // Set up observation for application shutdown. this._obs.add("quit-application", this.globalShutdown, self); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - // Set up observation for enter/exit private browsing: - this._obs.add("private-browsing", this.onPrivateBrowsingMode, self); -#endif // Set up timers to remind user x minutes after startup // and once per day thereafter. Use nsITimer so it doesn't belong to @@ -245,9 +241,6 @@ let TestPilotSetup = { this._obs.remove( "testpilot:task:dataAutoSubmitted", this._onTaskDataAutoSubmitted, self); this._obs.remove("quit-application", this.globalShutdown, self); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - this._obs.remove("private-browsing", this.onPrivateBrowsingMode, self); -#endif this._loader.unload(); this._shortTimer.cancel(); this._longTimer.cancel(); @@ -261,18 +254,6 @@ let TestPilotSetup = { return wm.getMostRecentWindow("navigator:browser"); }, -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - onPrivateBrowsingMode: function TPS_onPrivateBrowsingMode(topic, data) { - for (let i = 0; i < this.taskList.length; i++) { - if (data == "enter") { - this.taskList[i].onEnterPrivateBrowsing(); - } else if (data == "exit") { - this.taskList[i].onExitPrivateBrowsing(); - } - } - }, -#endif - onWindowUnload: function TPS__onWindowRegistered(window) { this._logger.trace("Called TestPilotSetup.onWindow unload!"); for (let i = 0; i < this.taskList.length; i++) { diff --git a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js.in b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js similarity index 97% rename from browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js.in rename to browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js index 71c1cd2837dc..3c2b8e68e9f9 100644 --- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js.in +++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js @@ -162,14 +162,6 @@ var TestPilotTask = { // Called by extension core when Firefox is shutting down. }, -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - onEnterPrivateBrowsing: function TestPilotTask_onEnterPrivate() { - }, - - onExitPrivateBrowsing: function TestPilotTask_onExitPrivate() { - }, -#endif - onNewWindow: function TestPilotTask_onNewWindow(window) { }, @@ -534,30 +526,6 @@ TestPilotExperiment.prototype = { } }, -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - onEnterPrivateBrowsing: function TestPilotExperiment_onEnterPrivate() { - this._logger.trace("Task is entering private browsing."); - if (this.experimentIsRunning()) { - try { - this._handlers.onEnterPrivateBrowsing(); - } catch(e) { - this._dataStore.logException("onEnterPrivateBrowsing: " + e); - } - } - }, - - onExitPrivateBrowsing: function TestPilotExperiment_onExitPrivate() { - this._logger.trace("Task is exiting private browsing."); - if (this.experimentIsRunning()) { - try { - this._handlers.onExitPrivateBrowsing(); - } catch(e) { - this._dataStore.logException("onExitPrivateBrowsing: " + e); - } - } - }, -#endif - getStudyMetadata: function TestPilotExperiment_getStudyMetadata() { try { if (this._handlers.getStudyMetadata) { diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index bbb9967ddc55..35a9e83f5301 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -878,11 +878,6 @@ pref("security.alternate_certificate_error_page", "certerror"); // Whether to start the private browsing mode at application startup pref("browser.privatebrowsing.autostart", false); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -// Whether we should skip prompting before starting the private browsing mode -pref("browser.privatebrowsing.dont_prompt_on_enter", false); -#endif - // Don't try to alter this pref, it'll be reset the next time you use the // bookmarking dialog pref("browser.bookmarks.editDialog.firstEditField", "namePicker"); diff --git a/browser/base/content/browser-appmenu.inc b/browser/base/content/browser-appmenu.inc index 190ec26cacbd..3d911672f06a 100644 --- a/browser/base/content/browser-appmenu.inc +++ b/browser/base/content/browser-appmenu.inc @@ -34,21 +34,11 @@ key="openFileKb"/> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -#else - -#endif -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -#endif -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -#endif -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - -#endif -#else - oncommand="gPrivateBrowsingUI.toggleMode();"/> -#endif diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js index 7313b4ea5d90..d67de80b1ce3 100644 --- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -18,11 +18,6 @@ let SocialUI = { Services.obs.addObserver(this, "social:recommend-info-changed", false); Services.obs.addObserver(this, "social:frameworker-error", false); Services.obs.addObserver(this, "social:provider-set", false); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - // this observer is necessary so things are also correctly updated - // when per-window PB isn't active - Services.obs.addObserver(this, "private-browsing", false); -#endif Services.prefs.addObserver("social.sidebar.open", this, false); Services.prefs.addObserver("social.toast-notifications.enabled", this, false); @@ -46,9 +41,6 @@ let SocialUI = { Services.obs.removeObserver(this, "social:recommend-info-changed"); Services.obs.removeObserver(this, "social:frameworker-error"); Services.obs.removeObserver(this, "social:provider-set"); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.removeObserver(this, "private-browsing"); -#endif Services.prefs.removeObserver("social.sidebar.open", this); Services.prefs.removeObserver("social.toast-notifications.enabled", this); @@ -140,14 +132,6 @@ let SocialUI = { SocialToolbar.updateButton(); } break; - -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - case "private-browsing": - this._updateEnabledState(); - this._updateActiveUI(); - SocialToolbar.init(); - break; -#endif } } catch (e) { Components.utils.reportError(e + "\n" + e.stack); @@ -173,11 +157,8 @@ let SocialUI = { _updateActiveUI: function SocialUI_updateActiveUI() { // The "active" UI isn't dependent on there being a provider, just on // social being "active" (but also chromeless/PB) - let enabled = Social.active && !this._chromeless -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - && !PrivateBrowsingUtils.isWindowPrivate(window) -#endif - ; + let enabled = Social.active && !this._chromeless && + !PrivateBrowsingUtils.isWindowPrivate(window); let broadcaster = document.getElementById("socialActiveBroadcaster"); broadcaster.hidden = !enabled; @@ -328,11 +309,7 @@ let SocialUI = { get enabled() { // Returns whether social is enabled *for this window*. - if (this._chromeless -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - || PrivateBrowsingUtils.isWindowPrivate(window) -#endif - ) + if (this._chromeless || PrivateBrowsingUtils.isWindowPrivate(window)) return false; return !!(Social.active && Social.provider && Social.provider.enabled); }, diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index f815193deb17..3ece44e54ba8 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1330,11 +1330,8 @@ var gBrowserInit = { ss.init(window); // Enable the Restore Last Session command if needed - if (ss.canRestoreLastSession -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - && !PrivateBrowsingUtils.isWindowPrivate(window) -#endif - ) + if (ss.canRestoreLastSession && + !PrivateBrowsingUtils.isWindowPrivate(window)) goSetCommandEnabled("Browser:RestoreLastSession", true); PlacesToolbarHelper.init(); @@ -1551,10 +1548,6 @@ var gBrowserInit = { PlacesStarButton.uninit(); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - gPrivateBrowsingUI.uninit(); -#endif - TabsOnTop.uninit(); TabsInTitlebar.uninit(); @@ -1700,10 +1693,6 @@ var gBrowserInit = { } BrowserOffline.uninit(); - -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - gPrivateBrowsingUI.uninit(); -#endif }, #endif @@ -2510,11 +2499,8 @@ function BrowserOnAboutPageLoad(document) { let ss = Components.classes["@mozilla.org/browser/sessionstore;1"]. getService(Components.interfaces.nsISessionStore); - if (ss.canRestoreLastSession -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - && !PrivateBrowsingUtils.isWindowPrivate(window) -#endif - ) + if (ss.canRestoreLastSession && + !PrivateBrowsingUtils.isWindowPrivate(window)) document.getElementById("launcher").setAttribute("session", "true"); // Inject search engine and snippets URL. @@ -3535,11 +3521,7 @@ function OpenBrowserWindow(options) var wintype = document.documentElement.getAttribute('windowtype'); var extraFeatures = ""; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (options && options.private) { -#else - if (gPrivateBrowsingUI.privateBrowsingEnabled) { -#endif extraFeatures = ",private"; // Force the new window to load about:privatebrowsing instead of the default home page defaultArgs = "about:privatebrowsing"; @@ -6920,15 +6902,6 @@ function getTabModalPromptBox(aWindow) { function getBrowser() gBrowser; function getNavToolbox() gNavToolbox; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - -# We define a new gPrivateBrowsingUI object, as the per-window PB implementation -# is completely different to the global PB one. Specifically, the per-window -# PB implementation does not expose many APIs on the gPrivateBrowsingUI object, -# and only uses it as a way to initialize and uninitialize private browsing -# windows. While we could use #ifdefs all around the global PB mode code to -# make it work in both modes, the amount of duplicated code is small and the -# code is much more readable this way. let gPrivateBrowsingUI = { init: function PBUI_init() { // Do nothing for normal windows @@ -6965,243 +6938,6 @@ let gPrivateBrowsingUI = { } }; -#else - -let gPrivateBrowsingUI = { - _privateBrowsingService: null, - _searchBarValue: null, - _findBarValue: null, - _inited: false, - - init: function PBUI_init() { - Services.obs.addObserver(this, "private-browsing", false); - Services.obs.addObserver(this, "private-browsing-transition-complete", false); - - this._privateBrowsingService = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - if (this.privateBrowsingEnabled) - this.onEnterPrivateBrowsing(true); - - this._inited = true; - }, - - uninit: function PBUI_unint() { - if (!this._inited) - return; - - Services.obs.removeObserver(this, "private-browsing"); - Services.obs.removeObserver(this, "private-browsing-transition-complete"); - }, - - get _disableUIOnToggle() { - if (PrivateBrowsingUtils.permanentPrivateBrowsing) - return false; - - try { - return !gPrefService.getBoolPref("browser.privatebrowsing.keep_current_session"); - } - catch (e) { - return true; - } - }, - - observe: function PBUI_observe(aSubject, aTopic, aData) { - if (aTopic == "private-browsing") { - if (aData == "enter") - this.onEnterPrivateBrowsing(); - else if (aData == "exit") - this.onExitPrivateBrowsing(); - } - else if (aTopic == "private-browsing-transition-complete") { - if (this._disableUIOnToggle) { - document.getElementById("Tools:PrivateBrowsing") - .removeAttribute("disabled"); - } - } - }, - - _shouldEnter: function PBUI__shouldEnter() { - try { - // Never prompt if the session is not going to be closed, or if user has - // already requested not to be prompted. - if (gPrefService.getBoolPref("browser.privatebrowsing.dont_prompt_on_enter") || - gPrefService.getBoolPref("browser.privatebrowsing.keep_current_session")) - return true; - } - catch (ex) { } - - var bundleService = Services.strings; - var pbBundle = bundleService.createBundle("chrome://browser/locale/browser.properties"); - var brandBundle = bundleService.createBundle("chrome://branding/locale/brand.properties"); - - var appName = brandBundle.GetStringFromName("brandShortName"); -# On Mac, use the header as the title. -#ifdef XP_MACOSX - var dialogTitle = pbBundle.GetStringFromName("privateBrowsingMessageHeader"); - var header = ""; -#else - var dialogTitle = pbBundle.GetStringFromName("privateBrowsingDialogTitle"); - var header = pbBundle.GetStringFromName("privateBrowsingMessageHeader") + "\n\n"; -#endif - var message = pbBundle.formatStringFromName("privateBrowsingMessage", [appName], 1); - - var ps = Services.prompt; - - var flags = ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_0 + - ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_1 + - ps.BUTTON_POS_0_DEFAULT; - - var neverAsk = {value:false}; - var button0Title = pbBundle.GetStringFromName("privateBrowsingYesTitle"); - var button1Title = pbBundle.GetStringFromName("privateBrowsingNoTitle"); - var neverAskText = pbBundle.GetStringFromName("privateBrowsingNeverAsk"); - - var result; - var choice = ps.confirmEx(null, dialogTitle, header + message, - flags, button0Title, button1Title, null, - neverAskText, neverAsk); - - switch (choice) { - case 0: // Start Private Browsing - result = true; - if (neverAsk.value) - gPrefService.setBoolPref("browser.privatebrowsing.dont_prompt_on_enter", true); - break; - case 1: // Keep - result = false; - break; - } - - return result; - }, - - onEnterPrivateBrowsing: function PBUI_onEnterPrivateBrowsing(aOnWindowOpen) { - if (BrowserSearch.searchBar) - this._searchBarValue = BrowserSearch.searchBar.textbox.value; - - if (gFindBarInitialized) - this._findBarValue = gFindBar.getElement("findbar-textbox").value; - - this._setPBMenuTitle("stop"); - - // Disable the Clear Recent History... menu item when in PB mode - // temporary fix until bug 463607 is fixed - document.getElementById("Tools:Sanitize").setAttribute("disabled", "true"); - - let docElement = document.documentElement; - if (PrivateBrowsingUtils.permanentPrivateBrowsing) { - // Disable the menu item in auto-start mode - document.getElementById("privateBrowsingItem") - .setAttribute("disabled", "true"); -#ifdef MENUBAR_CAN_AUTOHIDE - document.getElementById("appmenu_privateBrowsing") - .setAttribute("disabled", "true"); -#endif - document.getElementById("Tools:PrivateBrowsing") - .setAttribute("disabled", "true"); - if (window.location.href == getBrowserURL()) - docElement.setAttribute("privatebrowsingmode", "permanent"); - } - else if (window.location.href == getBrowserURL()) { - // Adjust the window's title - docElement.setAttribute("title", - docElement.getAttribute("title_privatebrowsing")); - docElement.setAttribute("titlemodifier", - docElement.getAttribute("titlemodifier_privatebrowsing")); - docElement.setAttribute("privatebrowsingmode", "temporary"); - gBrowser.updateTitlebar(); - } - - if (!aOnWindowOpen && this._disableUIOnToggle) - document.getElementById("Tools:PrivateBrowsing") - .setAttribute("disabled", "true"); - }, - - onExitPrivateBrowsing: function PBUI_onExitPrivateBrowsing() { - if (BrowserSearch.searchBar) { - let searchBox = BrowserSearch.searchBar.textbox; - searchBox.reset(); - if (this._searchBarValue) { - searchBox.value = this._searchBarValue; - this._searchBarValue = null; - } - } - - if (gURLBar) { - gURLBar.editor.transactionManager.clear(); - } - - // Re-enable the Clear Recent History... menu item on exit of PB mode - // temporary fix until bug 463607 is fixed - document.getElementById("Tools:Sanitize").removeAttribute("disabled"); - - if (gFindBarInitialized) { - let findbox = gFindBar.getElement("findbar-textbox"); - findbox.reset(); - if (this._findBarValue) { - findbox.value = this._findBarValue; - this._findBarValue = null; - } - } - - this._setPBMenuTitle("start"); - - if (window.location.href == getBrowserURL()) { - // Adjust the window's title - let docElement = document.documentElement; - docElement.setAttribute("title", - docElement.getAttribute("title_normal")); - docElement.setAttribute("titlemodifier", - docElement.getAttribute("titlemodifier_normal")); - docElement.removeAttribute("privatebrowsingmode"); - } - - // Enable the menu item in after exiting the auto-start mode - document.getElementById("privateBrowsingItem") - .removeAttribute("disabled"); -#ifdef MENUBAR_CAN_AUTOHIDE - document.getElementById("appmenu_privateBrowsing") - .removeAttribute("disabled"); -#endif - document.getElementById("Tools:PrivateBrowsing") - .removeAttribute("disabled"); - - gLastOpenDirectory.reset(); - - if (this._disableUIOnToggle) - document.getElementById("Tools:PrivateBrowsing") - .setAttribute("disabled", "true"); - }, - - _setPBMenuTitle: function PBUI__setPBMenuTitle(aMode) { - let pbMenuItem = document.getElementById("privateBrowsingItem"); - pbMenuItem.setAttribute("label", pbMenuItem.getAttribute(aMode + "label")); - pbMenuItem.setAttribute("accesskey", pbMenuItem.getAttribute(aMode + "accesskey")); -#ifdef MENUBAR_CAN_AUTOHIDE - let appmenupbMenuItem = document.getElementById("appmenu_privateBrowsing"); - appmenupbMenuItem.setAttribute("label", appmenupbMenuItem.getAttribute(aMode + "label")); - appmenupbMenuItem.setAttribute("accesskey", appmenupbMenuItem.getAttribute(aMode + "accesskey")); -#endif - }, - - toggleMode: function PBUI_toggleMode() { - // prompt the users on entering the private mode, if needed - if (!this.privateBrowsingEnabled) - if (!this._shouldEnter()) - return; - - this._privateBrowsingService.privateBrowsingEnabled = - !this.privateBrowsingEnabled; - }, - - get privateBrowsingEnabled() { - return this._privateBrowsingService.privateBrowsingEnabled; - } -}; - -#endif - /** * Switch to a tab that has a given URI, and focusses its browser window. @@ -7218,14 +6954,12 @@ let gPrivateBrowsingUI = { function switchToTabHavingURI(aURI, aOpenNew) { // This will switch to the tab in aWindow having aURI, if present. function switchIfURIInWindow(aWindow) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // Only switch to the tab if neither the source and desination window are // private. if (PrivateBrowsingUtils.isWindowPrivate(window) || PrivateBrowsingUtils.isWindowPrivate(aWindow)) { return false; } -#endif let browsers = aWindow.gBrowser.browsers; for (let i = 0; i < browsers.length; i++) { diff --git a/browser/base/content/macBrowserOverlay.xul b/browser/base/content/macBrowserOverlay.xul index 2afc6fdbeb98..c1ace1391751 100644 --- a/browser/base/content/macBrowserOverlay.xul +++ b/browser/base/content/macBrowserOverlay.xul @@ -56,9 +56,7 @@ -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -#endif diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index 7c912bb4e5d3..77abe9f53443 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -137,13 +137,9 @@ nsContextMenu.prototype = { } var shouldShow = this.onSaveableLink || isMailtoInternal || this.onPlainTextLink; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING var isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window); this.showItem("context-openlink", shouldShow && !isWindowPrivate); this.showItem("context-openlinkprivate", shouldShow); -#else - this.showItem("context-openlink", shouldShow); -#endif this.showItem("context-openlinkintab", shouldShow); this.showItem("context-openlinkincurrent", this.onPlainTextLink); this.showItem("context-sep-open", shouldShow); diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 8579644e5194..59bbaedee459 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -624,13 +624,10 @@ autocomplete.unregisterOpenPage(this.mBrowser.registeredOpenURI); delete this.mBrowser.registeredOpenURI; } - if (!isBlankPageURL(aLocation.spec) -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - // Tabs in private windows aren't registered as "Open" so - // that they don't appear as switch-to-tab candidates. - && !PrivateBrowsingUtils.isWindowPrivate(window) -#endif - ) { + // Tabs in private windows aren't registered as "Open" so + // that they don't appear as switch-to-tab candidates. + if (!isBlankPageURL(aLocation.spec) && + !PrivateBrowsingUtils.isWindowPrivate(window)) { autocomplete.registerOpenPage(aLocation); this.mBrowser.registeredOpenURI = aLocation; } @@ -1905,13 +1902,11 @@ '); - }, - function() { - info("Running step 7 - remove tab immediately"); - let tab = gBrowser.addTab("about:logo"); - gBrowser.removeTab(tab); - ensure_opentabs_match_db(nextStep); - }, - function() { - info("Running step 8 - check swapBrowsersAndCloseOther preserves registered switch-to-tab result"); - let tabToKeep = gBrowser.addTab(); - let tab = gBrowser.addTab(); - tab.linkedBrowser.addEventListener("load", function () { - tab.linkedBrowser.removeEventListener("load", arguments.callee, true); - gBrowser.swapBrowsersAndCloseOther(tabToKeep, tab); - ensure_opentabs_match_db(function () { - gBrowser.removeTab(tabToKeep); - ensure_opentabs_match_db(nextStep); - }); - }, true); - tab.linkedBrowser.loadURI("about:mozilla"); - }, - function() { - info("Running step 9 - enter private browsing mode, without keeping session"); - let ps = Services.prefs; - ps.setBoolPref("browser.privatebrowsing.keep_current_session", false); - ps.setBoolPref("browser.tabs.warnOnClose", false); - - Services.obs.addObserver(function(aSubject, aTopic, aData) { - Services.obs.removeObserver(arguments.callee, "private-browsing-transition-complete"); - - for (let i = 0; i < gBrowser.tabs.length; i++) - waitForRestoredTab(gBrowser.tabs[i]); - }, "private-browsing-transition-complete", false); - - gPrivateBrowsing.privateBrowsingEnabled = true; - }, - function() { - info("Running step 10 - open tabs in private browsing mode"); - for (let i = 0; i < 3; i++) { - let tab = gBrowser.addTab(); - loadTab(tab, TEST_URL_BASES[0] + (++gTabCounter)); - } - }, - function() { - info("Running step 11 - close tabs in private browsing mode"); - gBrowser.removeCurrentTab(); - ensure_opentabs_match_db(nextStep); - }, - function() { - info("Running step 12 - leave private browsing mode"); - - Services.obs.addObserver(function(aSubject, aTopic, aData) { - Services.obs.removeObserver(arguments.callee, "private-browsing-transition-complete"); - - let ps = Services.prefs; - ps.clearUserPref("browser.privatebrowsing.keep_current_session"); - ps.clearUserPref("browser.tabs.warnOnClose"); - - for (let i = 1; i < gBrowser.tabs.length; i++) - waitForRestoredTab(gBrowser.tabs[i]); - - }, "private-browsing-transition-complete", false); - - gPrivateBrowsing.privateBrowsingEnabled = false; - }, - function() { - info("Running step 13 - close all tabs"); - - Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand"); - - gBrowser.addTab("about:blank", {skipAnimation: true}); - while (gBrowser.tabs.length > 1) { - info("Removing tab: " + gBrowser.tabs[0].linkedBrowser.currentURI.spec); - gBrowser.selectTabAtIndex(0); - gBrowser.removeCurrentTab(); - } - ensure_opentabs_match_db(nextStep); - } -]; - - - -function test() { - waitForExplicitFinish(); - nextStep(); -} - -function loadTab(tab, url) { - // Because adding visits is async, we will not be notified immediately. - let visited = gPrivateBrowsing.privateBrowsingEnabled; - let loaded = false; - - function maybeCheckResults() { - if (visited && loaded && --gTabWaitCount == 0) { - ensure_opentabs_match_db(nextStep); - } - } - - tab.linkedBrowser.addEventListener("load", function () { - tab.linkedBrowser.removeEventListener("load", arguments.callee, true); - loaded = true; - maybeCheckResults(); - }, true); - - if (!visited) { - Services.obs.addObserver( - function (aSubject, aTopic, aData) { - if (url != aSubject.QueryInterface(Ci.nsIURI).spec) - return; - Services.obs.removeObserver(arguments.callee, aTopic); - visited = true; - maybeCheckResults(); - }, - "uri-visit-saved", - false - ); - } - - gTabWaitCount++; - info("Loading page: " + url); - tab.linkedBrowser.loadURI(url); -} - -function waitForRestoredTab(tab) { - gTabWaitCount++; - - tab.linkedBrowser.addEventListener("load", function () { - tab.linkedBrowser.removeEventListener("load", arguments.callee, true); - if (--gTabWaitCount == 0) { - ensure_opentabs_match_db(nextStep); - } - }, true); -} - - -function nextStep() { - if (gTestSteps.length == 0) { - while (gBrowser.tabs.length > 1) { - gBrowser.selectTabAtIndex(1); - gBrowser.removeCurrentTab(); - } - - waitForClearHistory(finish); - - return; - } - - var stepFunc = gTestSteps.shift(); - stepFunc(); -} - -function ensure_opentabs_match_db(aCallback) { - var tabs = {}; - - var winEnum = Services.wm.getEnumerator("navigator:browser"); - while (winEnum.hasMoreElements()) { - let browserWin = winEnum.getNext(); - // skip closed-but-not-destroyed windows - if (browserWin.closed) - continue; - - for (let i = 0; i < browserWin.gBrowser.tabContainer.childElementCount; i++) { - let browser = browserWin.gBrowser.getBrowserAtIndex(i); - let url = browser.currentURI.spec; - if (browserWin.isBlankPageURL(url)) - continue; - if (!(url in tabs)) - tabs[url] = 1; - else - tabs[url]++; - } - } - - checkAutocompleteResults(tabs, aCallback); -} - -/** - * Clears history invoking callback when done. - */ -function waitForClearHistory(aCallback) { - const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished"; - let observer = { - observe: function(aSubject, aTopic, aData) { - Services.obs.removeObserver(this, TOPIC_EXPIRATION_FINISHED); - aCallback(); - } - }; - Services.obs.addObserver(observer, TOPIC_EXPIRATION_FINISHED, false); - - PlacesUtils.bhistory.removeAllPages(); -} - -function checkAutocompleteResults(aExpected, aCallback) -{ - gController.input = { - timeout: 10, - textValue: "", - searches: ["history"], - searchParam: "enable-actions", - popupOpen: false, - minResultsForPopup: 0, - invalidate: function() {}, - disableAutoComplete: false, - completeDefaultIndex: false, - get popup() { return this; }, - onSearchBegin: function() {}, - onSearchComplete: function () - { - info("Found " + gController.matchCount + " matches."); - // Check to see the expected uris and titles match up (in any order) - for (let i = 0; i < gController.matchCount; i++) { - let uri = gController.getValueAt(i).replace(/^moz-action:[^,]+,/i, ""); - - info("Search for '" + uri + "' in open tabs."); - ok(uri in aExpected, "Registered open page found in autocomplete."); - // Remove the found entry from expected results. - delete aExpected[uri]; - } - - // Make sure there is no reported open page that is not open. - for (let entry in aExpected) { - ok(false, "'" + entry + "' not found in autocomplete."); - } - - executeSoon(aCallback); - }, - setSelectedIndex: function() {}, - get searchCount() { return this.searches.length; }, - getSearchAt: function(aIndex) this.searches[aIndex], - QueryInterface: XPCOMUtils.generateQI([ - Ci.nsIAutoCompleteInput, - Ci.nsIAutoCompletePopup, - ]) - }; - - info("Searching open pages."); - gController.startSearch(Services.prefs.getCharPref("browser.urlbar.restrict.openpage")); -} diff --git a/browser/base/content/test/newtab/Makefile.in b/browser/base/content/test/newtab/Makefile.in index 02a44e40ad86..c3410e26b196 100644 --- a/browser/base/content/test/newtab/Makefile.in +++ b/browser/base/content/test/newtab/Makefile.in @@ -30,18 +30,9 @@ _BROWSER_FILES = \ browser_newtab_bug735987.js \ browser_newtab_bug752841.js \ browser_newtab_bug765628.js \ + browser_newtab_perwindow_private_browsing.js \ head.js \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -_BROWSER_FILES += \ - browser_newtab_perwindow_private_browsing.js \ - $(NULL) -else -_BROWSER_FILES += \ - browser_newtab_private_browsing.js \ - $(NULL) -endif - libs:: $(_BROWSER_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir) diff --git a/browser/base/content/test/newtab/browser_newtab_private_browsing.js b/browser/base/content/test/newtab/browser_newtab_private_browsing.js deleted file mode 100644 index 6ef8283e3868..000000000000 --- a/browser/base/content/test/newtab/browser_newtab_private_browsing.js +++ /dev/null @@ -1,54 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* - * These tests ensure that all changes made to the new tab page in private - * browsing mode are discarded after switching back to normal mode again. - * The private browsing mode should start with the current grid shown in normal - * mode. - */ -let pb = Cc["@mozilla.org/privatebrowsing;1"] - .getService(Ci.nsIPrivateBrowsingService); - -function runTests() { - // prepare the grid - yield setLinks("0,1,2,3,4,5,6,7,8,9"); - ok(!pb.privateBrowsingEnabled, "private browsing is disabled"); - - yield addNewTabPageTab(); - pinCell(0); - checkGrid("0p,1,2,3,4,5,6,7,8"); - - // enter private browsing mode - yield togglePrivateBrowsing(); - ok(pb.privateBrowsingEnabled, "private browsing is enabled"); - - yield addNewTabPageTab(); - checkGrid("0p,1,2,3,4,5,6,7,8"); - - // modify the grid while we're in pb mode - yield blockCell(1); - checkGrid("0p,2,3,4,5,6,7,8"); - - yield unpinCell(0); - checkGrid("0,2,3,4,5,6,7,8"); - - // exit private browsing mode - yield togglePrivateBrowsing(); - ok(!pb.privateBrowsingEnabled, "private browsing is disabled"); - - // check that the grid is the same as before entering pb mode - yield addNewTabPageTab(); - checkGrid("0,2,3,4,5,6,7,8") -} - -function togglePrivateBrowsing() { - let topic = "private-browsing-transition-complete"; - - Services.obs.addObserver(function observe() { - Services.obs.removeObserver(observe, topic); - executeSoon(TestRunner.next); - }, topic, false); - - pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled; -} diff --git a/browser/base/content/test/social/Makefile.in b/browser/base/content/test/social/Makefile.in index 9e6ae6ca1f98..f6e2438b8f17 100644 --- a/browser/base/content/test/social/Makefile.in +++ b/browser/base/content/test/social/Makefile.in @@ -12,6 +12,7 @@ include $(DEPTH)/config/autoconf.mk _BROWSER_FILES = \ head.js \ + browser_social_perwindowPB.js \ browser_social_toolbar.js \ browser_social_shareButton.js \ browser_social_sidebar.js \ @@ -30,16 +31,6 @@ _BROWSER_FILES = \ social_worker.js \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -_BROWSER_FILES += \ - browser_social_perwindowPB.js \ - $(NULL) -else -_BROWSER_FILES += \ - browser_social_globalPB.js \ - $(NULL) -endif - include $(topsrcdir)/config/rules.mk libs:: $(_BROWSER_FILES) diff --git a/browser/base/content/test/social/browser_social_globalPB.js b/browser/base/content/test/social/browser_social_globalPB.js deleted file mode 100644 index fbc49f3d609d..000000000000 --- a/browser/base/content/test/social/browser_social_globalPB.js +++ /dev/null @@ -1,147 +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/. */ - -// a place for miscellaneous social tests - - -const pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - -function waitForPortMessage(port, topic, callback) { - port.onmessage = function(evt) { - if (evt.data.topic == topic) - callback(evt.data); - } -} - -function portClosed(port) { - try { - port.postMessage({topic: "ping"}); - return false; // worked - port can't be closed! - } catch (ex) { - return true; - } -} - -function test() { - waitForExplicitFinish(); - - let manifest = { // normal provider - name: "provider 1", - origin: "https://example.com", - sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html", - workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", - iconURL: "https://example.com/browser/browser/base/content/test/moz.png" - }; - runSocialTestWithProvider(manifest, function (finishcb) { - runSocialTests(tests, undefined, undefined, finishcb); - }); -} - -var tests = { - testPrivateBrowsing: function(next) { - let port = Social.provider.getWorkerPort(); - ok(port, "provider has a port"); - port.postMessage({topic: "test-init"}); - port.onmessage = function (e) { - let topic = e.data.topic; - switch (topic) { - case "got-sidebar-message": - ok(true, "got sidebar message"); - port.close(); - togglePrivateBrowsing(function () { - ok(!Social.enabled, "Social shuts down during private browsing"); - togglePrivateBrowsing(function () { - ok(Social.provider.getWorkerPort(), "port still obtainable after PB") - ok(Social.enabled, "Social enabled after private browsing"); - next(); - }); - }); - break; - } - }; - }, - - testPrivateBrowsingSocialDisabled: function(next) { - // test PB from the perspective of entering PB without social enabled - // we expect social to be enabled at the start of the test, we need - // to disable it before testing PB transitions. - ok(Social.enabled, "social is still enabled"); - let port = Social.provider.getWorkerPort(); - ok(port, "provider has a port"); - port.postMessage({topic: "test-init"}); - port.onmessage = function (e) { - let topic = e.data.topic; - switch (topic) { - case "got-sidebar-message": - ok(true, "got sidebar message"); - port.close(); - Social.enabled = false; - break; - } - } - - // wait for disable, then do some pb toggling. We expect social to remain - // disabled through these tests - Services.obs.addObserver(function observer(aSubject, aTopic) { - Services.obs.removeObserver(observer, aTopic); - ok(!Social.enabled, "Social is not enabled"); - togglePrivateBrowsing(function () { - ok(!Social.enabled, "Social not available during private browsing"); - togglePrivateBrowsing(function () { - ok(!Social.enabled, "Social is not enabled after private browsing"); - // reenable social for next social test - Social.enabled = true; - next(); - }); - }); - }, "social:pref-changed", false); - }, - - testPrivateBrowsingExitReloads: function(next) { - let port = Social.provider.getWorkerPort(); - waitForPortMessage(port, "got-sidebar-message", function(data) { - ok(!portClosed(port), "port not closed before PB transition"); - togglePrivateBrowsing(function () { - ok(!Social.enabled, "Social shuts down during private browsing"); - // check the port we had before is dead. - ok(portClosed(port), "port closed after PB transition"); - // enable it and stick a value in the window object. - Social.enabled = true; - port = Social.provider.getWorkerPort(); - waitForPortMessage(port, "got-sidebar-message", function(data) { - // now just stuff a value in the sidebar - it should end - // up being removed when we leave PB mode via the sidebar - // being reloaded. - let sbw = document.getElementById("social-sidebar-browser").contentWindow; - sbw.wrappedJSObject.foo = "bar"; - // Now toggle PB mode back to off. - togglePrivateBrowsing(function () { - ok(Social.enabled, "Social still enabled after leaving private browsing"); - ok(portClosed(port), "port closed after PB transition"); - port = Social.provider.getWorkerPort(); - waitForPortMessage(port, "got-sidebar-message", function() { - sbw = document.getElementById("social-sidebar-browser").contentWindow; - is(sbw.wrappedJSObject.foo, undefined, "should have lost window variable when exiting") - next(); - }); - port.postMessage({topic: "test-init"}); - }); - }); - port.postMessage({topic: "test-init"}); - }); - }); - port.postMessage({topic: "test-init"}); - }, - -} - -function togglePrivateBrowsing(aCallback) { - Services.obs.addObserver(function observe(subject, topic, data) { - Services.obs.removeObserver(observe, topic); - executeSoon(aCallback); - }, "private-browsing-transition-complete", false); - - pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled; -} diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js index 6607c26c5a52..0316b6c4fc69 100644 --- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -10,9 +10,6 @@ Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); XPCOMUtils.defineLazyGetter(this, "BROWSER_NEW_TAB_URL", function () { const PREF = "browser.newtab.url"; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - const TOPIC = "private-browsing-transition-complete"; -#endif function getNewTabPageURL() { if (!Services.prefs.prefHasUserValue(PREF)) { @@ -28,16 +25,10 @@ XPCOMUtils.defineLazyGetter(this, "BROWSER_NEW_TAB_URL", function () { } Services.prefs.addObserver(PREF, update, false); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.addObserver(update, TOPIC, false); -#endif addEventListener("unload", function onUnload() { removeEventListener("unload", onUnload); Services.prefs.removeObserver(PREF, update); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.removeObserver(update, TOPIC); -#endif }); return getNewTabPageURL(); @@ -275,11 +266,9 @@ function openLinkIn(url, where, params) { sa.AppendElement(allowThirdPartyFixupSupports); let features = "chrome,dialog=no,all"; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (aIsPrivate) { features += ",private"; } -#endif Services.ww.openWindow(w || window, getBrowserURL(), null, features, sa); return; diff --git a/browser/components/build/Makefile.in b/browser/components/build/Makefile.in index 97a89903a7ce..d922c1ca5de7 100644 --- a/browser/components/build/Makefile.in +++ b/browser/components/build/Makefile.in @@ -44,11 +44,6 @@ SHARED_LIBRARY_LIBS = \ ../dirprovider/$(LIB_PREFIX)browserdir_s.$(LIB_SUFFIX) \ $(NULL) -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -LOCAL_INCLUDES += -I$(srcdir)/../privatebrowsing/src -SHARED_LIBRARY_LIBS += ../privatebrowsing/src/$(LIB_PREFIX)privatebrowsing_s.$(LIB_SUFFIX) -endif - ifneq (,$(filter windows cocoa gtk2, $(MOZ_WIDGET_TOOLKIT))) SHARED_LIBRARY_LIBS += ../shell/src/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX) endif diff --git a/browser/components/build/nsModule.cpp b/browser/components/build/nsModule.cpp index 21925adbe05b..a47bbf11477f 100644 --- a/browser/components/build/nsModule.cpp +++ b/browser/components/build/nsModule.cpp @@ -25,9 +25,6 @@ #include "AboutRedirector.h" #include "nsIAboutModule.h" -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -#include "nsPrivateBrowsingServiceWrapper.h" -#endif #include "nsNetCID.h" using namespace mozilla::browser; @@ -49,10 +46,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsIEHistoryEnumerator) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFeedSniffer) -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrivateBrowsingServiceWrapper, Init) -#endif - NS_DEFINE_NAMED_CID(NS_BROWSERDIRECTORYPROVIDER_CID); #if defined(XP_WIN) NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID); @@ -66,9 +59,6 @@ NS_DEFINE_NAMED_CID(NS_WINIEHISTORYENUMERATOR_CID); #elif defined(XP_MACOSX) NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID); #endif -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -NS_DEFINE_NAMED_CID(NS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID); -#endif static const mozilla::Module::CIDEntry kBrowserCIDs[] = { { &kNS_BROWSERDIRECTORYPROVIDER_CID, false, NULL, DirectoryProviderConstructor }, @@ -83,9 +73,6 @@ static const mozilla::Module::CIDEntry kBrowserCIDs[] = { { &kNS_WINIEHISTORYENUMERATOR_CID, false, NULL, nsIEHistoryEnumeratorConstructor }, #elif defined(XP_MACOSX) { &kNS_SHELLSERVICE_CID, false, NULL, nsMacShellServiceConstructor }, -#endif -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - { &kNS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID, false, NULL, nsPrivateBrowsingServiceWrapperConstructor }, #endif { NULL } }; @@ -124,9 +111,6 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = { { NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID }, #elif defined(XP_MACOSX) { NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID }, -#endif -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - { NS_PRIVATE_BROWSING_SERVICE_CONTRACTID, &kNS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID }, #endif { NULL } }; diff --git a/browser/components/downloads/src/DownloadsCommon.jsm b/browser/components/downloads/src/DownloadsCommon.jsm index c6662aa10cbd..dd64cff492bd 100644 --- a/browser/components/downloads/src/DownloadsCommon.jsm +++ b/browser/components/downloads/src/DownloadsCommon.jsm @@ -186,15 +186,11 @@ this.DownloadsCommon = { * The browser window which owns the download button. */ getData: function DC_getData(aWindow) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) { return PrivateDownloadsData; } else { return DownloadsData; } -#else - return DownloadsData; -#endif }, /** @@ -239,15 +235,11 @@ this.DownloadsCommon = { * the window in question. */ getIndicatorData: function DC_getIndicatorData(aWindow) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) { return PrivateDownloadsIndicatorData; } else { return DownloadsIndicatorData; } -#else - return DownloadsIndicatorData; -#endif }, /** @@ -262,7 +254,6 @@ this.DownloadsCommon = { */ getSummary: function DC_getSummary(aWindow, aNumToExclude) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) { if (this._privateSummary) { return this._privateSummary; @@ -274,12 +265,6 @@ this.DownloadsCommon = { } return this._summary = new DownloadsSummaryData(false, aNumToExclude); } -#else - if (this._summary) { - return this._summary; - } - return this._summary = new DownloadsSummaryData(false, aNumToExclude); -#endif }, _summary: null, _privateSummary: null, @@ -559,12 +544,6 @@ function DownloadsDataCtor(aPrivate) { // prevent race conditions when populating the list asynchronously. this.dataItems = {}; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - // While operating in Private Browsing Mode, persistent data items are parked - // here until we return to the normal mode. - this._persistentDataItems = {}; -#endif - // Array of view objects that should be notified when the available download // data changes. this._views = []; @@ -585,10 +564,6 @@ DownloadsDataCtor.prototype = { // Start receiving real-time events. aDownloadManagerService.addPrivacyAwareListener(this); Services.obs.addObserver(this, "download-manager-remove-download-guid", false); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.addObserver(this, "download-manager-database-type-changed", - false); -#endif }, /** @@ -599,9 +574,6 @@ DownloadsDataCtor.prototype = { this._terminateDataAccess(); // Stop receiving real-time events. -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.removeObserver(this, "download-manager-database-type-changed"); -#endif Services.obs.removeObserver(this, "download-manager-remove-download-guid"); Services.downloads.removeListener(this); }, @@ -917,26 +889,6 @@ DownloadsDataCtor.prototype = { } } break; - -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - case "download-manager-database-type-changed": - let pbs = Cc["@mozilla.org/privatebrowsing;1"] - .getService(Ci.nsIPrivateBrowsingService); - if (pbs.privateBrowsingEnabled) { - // Save a reference to the persistent store before terminating access. - this._persistentDataItems = this.dataItems; - this.clear(); - } else { - // Terminate data access, then restore the persistent store. - this.clear(); - this.dataItems = this._persistentDataItems; - this._persistentDataItems = null; - } - // Reinitialize the views with the current items. View data has been - // already invalidated by the previous calls. - this._views.forEach(this._updateView, this); - break; -#endif } }, @@ -945,13 +897,11 @@ DownloadsDataCtor.prototype = { onDownloadStateChange: function DD_onDownloadStateChange(aOldState, aDownload) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (aDownload.isPrivate != this._isPrivate) { // Ignore the downloads with a privacy status other than what we are // tracking. return; } -#endif // When a new download is added, it may have the same identifier of a // download that we previously deleted during this session, and we also @@ -1031,13 +981,11 @@ DownloadsDataCtor.prototype = { aCurTotalProgress, aMaxTotalProgress, aDownload) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (aDownload.isPrivate != this._isPrivate) { // Ignore the downloads with a privacy status other than what we are // tracking. return; } -#endif let dataItem = this._getOrAddDataItem(aDownload, false); if (!dataItem) { diff --git a/browser/components/downloads/src/DownloadsStartup.js b/browser/components/downloads/src/DownloadsStartup.js index 4edbc8e9cf22..9122e44b82c4 100644 --- a/browser/components/downloads/src/DownloadsStartup.js +++ b/browser/components/downloads/src/DownloadsStartup.js @@ -31,22 +31,13 @@ XPCOMUtils.defineLazyModuleGetter(this, "DownloadsCommon", XPCOMUtils.defineLazyServiceGetter(this, "gSessionStartup", "@mozilla.org/browser/sessionstartup;1", "nsISessionStartup"); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -XPCOMUtils.defineLazyServiceGetter(this, "gPrivateBrowsingService", - "@mozilla.org/privatebrowsing;1", - "nsIPrivateBrowsingService"); -#endif const kObservedTopics = [ "sessionstore-windows-restored", "sessionstore-browser-state-restored", "download-manager-initialized", "download-manager-change-retention", -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING "last-pb-context-exited", -#else - "private-browsing-transition-complete", -#endif "browser-lastwindow-close-granted", "quit-application", "profile-change-teardown", @@ -145,14 +136,6 @@ DownloadsStartup.prototype = { } break; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - case "private-browsing-transition-complete": - // Ensure that persistent data is reloaded only when the database - // connection is available again. - this._ensureDataLoaded(); - break; -#endif - case "browser-lastwindow-close-granted": // When using the panel interface, downloads that are already completed // should be removed when the last full browser window is closed. This @@ -166,7 +149,6 @@ DownloadsStartup.prototype = { } break; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING case "last-pb-context-exited": // Similar to the above notification, but for private downloads. if (this._downloadsServiceInitialized && @@ -174,7 +156,6 @@ DownloadsStartup.prototype = { Services.downloads.cleanUpPrivate(); } break; -#endif case "quit-application": // When the application is shutting down, we must free all resources in @@ -276,11 +257,7 @@ DownloadsStartup.prototype = { */ _ensureDataLoaded: function DS_ensureDataLoaded() { - if (!this._downloadsServiceInitialized -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - || gPrivateBrowsingService.privateBrowsingEnabled -#endif - ) { + if (!this._downloadsServiceInitialized) { return; } diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js index deae222e99c1..22270a001a60 100644 --- a/browser/components/nsBrowserContentHandler.js +++ b/browser/components/nsBrowserContentHandler.js @@ -511,17 +511,12 @@ nsBrowserContentHandler.prototype = { } if (cmdLine.handleFlag("silent", false)) cmdLine.preventDefault = true; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (cmdLine.handleFlag("private-window", false)) { openWindow(null, this.chromeURL, "_blank", "chrome,dialog=no,private,all" + this.getFeatures(cmdLine), "about:privatebrowsing"); cmdLine.preventDefault = true; } -#else - if (cmdLine.findFlag("private-toggle", false) >= 0) - cmdLine.preventDefault = true; -#endif var searchParam = cmdLine.handleFlagWithParam("search", false); if (searchParam) { @@ -531,11 +526,7 @@ nsBrowserContentHandler.prototype = { // The global PB Service consumes this flag, so only eat it in per-window // PB builds. -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (cmdLine.handleFlag("private", false)) { -#else - if (cmdLine.findFlag("private", false) >= 0) { -#endif PrivateBrowsingUtils.enterTemporaryAutoStartMode(); } diff --git a/browser/components/places/content/controller.js b/browser/components/places/content/controller.js index 0f809604bce0..34f0bfa9b41f 100644 --- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -139,13 +139,8 @@ PlacesController.prototype = { // Otherwise fallback to cmd_delete check. case "cmd_delete": case "placesCmd_delete": - return this._hasRemovableSelection(false); case "placesCmd_deleteDataHost": - return this._hasRemovableSelection(false) -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - && !PlacesUIUtils.privateBrowsing.privateBrowsingEnabled -#endif - ; + return this._hasRemovableSelection(false); case "placesCmd_moveBookmarks": return this._hasRemovableSelection(true); case "cmd_copy": @@ -604,14 +599,7 @@ PlacesController.prototype = { // We allow pasting into tag containers, so special case that. var hideIfNoIP = item.getAttribute("hideifnoinsertionpoint") == "true" && noIp && !(ip && ip.isTag && item.id == "placesContext_paste"); -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - var hideIfPB = false; -#else - var hideIfPB = item.getAttribute("hideifprivatebrowsing") == "true" && - PlacesUIUtils.privateBrowsing.privateBrowsingEnabled; -#endif - item.hidden = hideIfNoIP || hideIfPB || - !this._shouldShowMenuItem(item, metadata); + item.hidden = hideIfNoIP || !this._shouldShowMenuItem(item, metadata); if (!item.hidden) { visibleItemsBeforeSep = true; diff --git a/browser/components/places/content/places.js b/browser/components/places/content/places.js index 0a0df78a8e36..9ce3fd00318a 100644 --- a/browser/components/places/content/places.js +++ b/browser/components/places/content/places.js @@ -75,10 +75,6 @@ var PlacesOrganizer = { document.getElementById("placesContext") .removeChild(document.getElementById("placesContext_show:info")); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - gPrivateBrowsingListener.init(); -#endif - ContentArea.focus(); }, @@ -111,9 +107,6 @@ var PlacesOrganizer = { }, destroy: function PO_destroy() { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - gPrivateBrowsingListener.uninit(); -#endif }, _location: null, @@ -1198,45 +1191,6 @@ var ViewMenu = { } } -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -/** - * Disables the "Import and Backup->Import From Another Browser" menu item - * in private browsing mode. - */ -let gPrivateBrowsingListener = { - _cmd_import: null, - - init: function PO_PB_init() { - this._cmd_import = document.getElementById("OrganizerCommand_browserImport"); - - let pbs = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - if (pbs.privateBrowsingEnabled) - this.updateUI(true); - - Services.obs.addObserver(this, "private-browsing", false); - }, - - uninit: function PO_PB_uninit() { - Services.obs.removeObserver(this, "private-browsing"); - }, - - observe: function PO_PB_observe(aSubject, aTopic, aData) { - if (aData == "enter") - this.updateUI(true); - else if (aData == "exit") - this.updateUI(false); - }, - - updateUI: function PO_PB_updateUI(PBmode) { - if (PBmode) - this._cmd_import.setAttribute("disabled", "true"); - else - this._cmd_import.removeAttribute("disabled"); - } -}; -#endif - let ContentArea = { _specialViews: new Map(), diff --git a/browser/components/places/src/PlacesUIUtils.jsm b/browser/components/places/src/PlacesUIUtils.jsm index f6275722ec27..3ce758424771 100644 --- a/browser/components/places/src/PlacesUIUtils.jsm +++ b/browser/components/places/src/PlacesUIUtils.jsm @@ -1009,12 +1009,6 @@ XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ellipsis", function() { Ci.nsIPrefLocalizedString).data; }); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "privateBrowsing", - "@mozilla.org/privatebrowsing;1", - "nsIPrivateBrowsingService"); -#endif - XPCOMUtils.defineLazyServiceGetter(this, "URIFixup", "@mozilla.org/docshell/urifixup;1", "nsIURIFixup"); diff --git a/browser/components/preferences/in-content/jar.mn b/browser/components/preferences/in-content/jar.mn index b84d69d23ade..a4271f1202dd 100644 --- a/browser/components/preferences/in-content/jar.mn +++ b/browser/components/preferences/in-content/jar.mn @@ -10,8 +10,8 @@ browser.jar: content/browser/preferences/in-content/main.js * content/browser/preferences/in-content/tabs.xul * content/browser/preferences/in-content/tabs.js -* content/browser/preferences/in-content/privacy.xul -* content/browser/preferences/in-content/privacy.js + content/browser/preferences/in-content/privacy.xul + content/browser/preferences/in-content/privacy.js * content/browser/preferences/in-content/advanced.xul * content/browser/preferences/in-content/advanced.js content/browser/preferences/in-content/applications.xul diff --git a/browser/components/preferences/in-content/privacy.js b/browser/components/preferences/in-content/privacy.js index 85cb886910ee..ed6d2bcfa4b4 100644 --- a/browser/components/preferences/in-content/privacy.js +++ b/browser/components/preferences/in-content/privacy.js @@ -276,7 +276,6 @@ var gPrivacyPane = { observe: function PPP_observe(aSubject, aTopic, aData) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (!gPrivacyPane._shouldPromptForRestart) { // We're performing a revert. Just let it happen. gPrivacyPane._shouldPromptForRestart = true; @@ -318,23 +317,6 @@ var gPrivacyPane = { let rememberHistoryCheckbox = document.getElementById("rememberHistory"); rememberHistory.checked = pref.value; } -#else - // Toggle the private browsing mode without switching the session - let prefValue = document.getElementById("browser.privatebrowsing.autostart").value; - let keepCurrentSession = document.getElementById("browser.privatebrowsing.keep_current_session"); - keepCurrentSession.value = true; - - let privateBrowsingService = Components.classes["@mozilla.org/privatebrowsing;1"]. - getService(Components.interfaces.nsIPrivateBrowsingService); - - // If activating from within the private browsing mode, reset the - // private session - if (prefValue && privateBrowsingService.privateBrowsingEnabled) - privateBrowsingService.privateBrowsingEnabled = false; - privateBrowsingService.privateBrowsingEnabled = prefValue; - - keepCurrentSession.reset(); -#endif } }, diff --git a/browser/components/preferences/in-content/privacy.xul b/browser/components/preferences/in-content/privacy.xul index 08a618936396..e1d1a0a59bdf 100644 --- a/browser/components/preferences/in-content/privacy.xul +++ b/browser/components/preferences/in-content/privacy.xul @@ -61,16 +61,8 @@ -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - -#endif diff --git a/browser/components/preferences/in-content/tests/Makefile.in b/browser/components/preferences/in-content/tests/Makefile.in index a51e388ea172..6d185c7ed948 100644 --- a/browser/components/preferences/in-content/tests/Makefile.in +++ b/browser/components/preferences/in-content/tests/Makefile.in @@ -17,31 +17,13 @@ _BROWSER_FILES = \ browser_bug410900.js \ browser_bug731866.js \ browser_connection.js \ - $(NULL) - -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -_BROWSER_FILES += \ - privacypane_tests.js \ - browser_bug567487.js \ browser_privacypane_1.js \ - browser_privacypane_2.js \ browser_privacypane_3.js \ browser_privacypane_4.js \ browser_privacypane_5.js \ - browser_privacypane_6.js \ - browser_privacypane_7.js \ browser_privacypane_8.js \ - $(NULL) -else -_BROWSER_FILES += \ privacypane_tests_perwindow.js \ - browser_privacypane_1.js \ - browser_privacypane_3.js \ - browser_privacypane_4.js \ - browser_privacypane_5.js \ - browser_privacypane_8.js \ $(NULL) -endif ifdef MOZ_SERVICES_HEALTHREPORT _BROWSER_FILES += browser_healthreport.js diff --git a/browser/components/preferences/in-content/tests/browser_bug567487.js b/browser/components/preferences/in-content/tests/browser_bug567487.js deleted file mode 100644 index 7373644bb088..000000000000 --- a/browser/components/preferences/in-content/tests/browser_bug567487.js +++ /dev/null @@ -1,73 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - waitForExplicitFinish(); - resetPreferences(); - - function observer(win, topic, data) { - if (topic != "main-pane-loaded") - return; - - Services.obs.removeObserver(observer, "main-pane-loaded"); - runTest(win); - } - Services.obs.addObserver(observer, "main-pane-loaded", false); - - gBrowser.selectedTab = gBrowser.addTab("about:preferences"); -} - -function runTest(win) { - win.gotoPref("general"); - let doc = win.document; - let pbAutoStartPref = doc.getElementById("browser.privatebrowsing.autostart"); - let startupPref = doc.getElementById("browser.startup.page"); - let menu = doc.getElementById("browserStartupPage"); - let option = doc.getElementById("browserStartupLastSession"); - let defOption = doc.getElementById("browserStartupHomePage"); - let otherOption = doc.getElementById("browserStartupBlank"); - - ok(!pbAutoStartPref.value, "Sanity check"); - is(startupPref.value, startupPref.defaultValue, "Sanity check"); - - // First, check to make sure that setting pbAutoStartPref disables the menu item - pbAutoStartPref.value = true; - is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " + - "should disable the 'Show my tabs and windows from last time' option"); - pbAutoStartPref.value = false; - - // Now ensure the correct behavior when pbAutoStartPref is set with option enabled - startupPref.value = option.getAttribute("value"); - is(menu.selectedItem, option, "Sanity check"); - pbAutoStartPref.value = true; - is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " + - "should disable the 'Show my tabs and windows from last time' option"); - is(menu.selectedItem, defOption, "The 'Show home page' option should be selected"); - is(startupPref.value, option.getAttribute("value"), "But the value of the startup " + - "pref itself shouldn't change"); - menu.selectedItem = otherOption; - menu.doCommand(); - is(startupPref.value, otherOption.getAttribute("value"), "And we should be able to " + - "chnage it!"); - pbAutoStartPref.value = false; - - // Now, ensure that with 'Show my windows and tabs from last time' enabled, toggling - // pbAutoStartPref would restore that value in the menulist. - startupPref.value = option.getAttribute("value"); - is(menu.selectedItem, option, "Sanity check"); - pbAutoStartPref.value = true; - is(menu.selectedItem, defOption, "The 'Show home page' option should be selected"); - pbAutoStartPref.value = false; - is(menu.selectedItem, option, "The correct value should be restored"); - - // cleanup - resetPreferences(); - gBrowser.removeCurrentTab(); - win.close(); - finish(); -} - -function resetPreferences() { - Services.prefs.clearUserPref("browser.startup.page"); - Services.prefs.clearUserPref("browser.privatebrowsing.autostart"); -} diff --git a/browser/components/preferences/in-content/tests/browser_privacypane_1.js b/browser/components/preferences/in-content/tests/browser_privacypane_1.js index 592026754f4f..8694230d1e70 100644 --- a/browser/components/preferences/in-content/tests/browser_privacypane_1.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_1.js @@ -11,11 +11,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_pane_visibility, diff --git a/browser/components/preferences/in-content/tests/browser_privacypane_2.js b/browser/components/preferences/in-content/tests/browser_privacypane_2.js deleted file mode 100644 index 0ac71721d88f..000000000000 --- a/browser/components/preferences/in-content/tests/browser_privacypane_2.js +++ /dev/null @@ -1,33 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - - let rootDir = getRootDirectory(gTestPath); - let jar = getJar(rootDir); - if (jar) { - let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path + '/'; - } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } - - run_test_subset([ - test_historymode_retention("remember", undefined), - test_historymode_retention("dontremember", "remember"), - test_historymode_retention("custom", "dontremember"), - // custom without any micro-prefs changed won't retain - test_historymode_retention("remember", "dontremember"), - test_historymode_retention("custom", "remember"), - // custom without any micro-prefs changed won't retain - test_historymode_retention("remember", "remember"), - - // reset all preferences to their default values once we're done - reset_preferences - ]); -} diff --git a/browser/components/preferences/in-content/tests/browser_privacypane_3.js b/browser/components/preferences/in-content/tests/browser_privacypane_3.js index 2e5977a9273c..b333037de7ec 100644 --- a/browser/components/preferences/in-content/tests/browser_privacypane_3.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_3.js @@ -10,11 +10,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_custom_retention("rememberHistory", "remember"), diff --git a/browser/components/preferences/in-content/tests/browser_privacypane_4.js b/browser/components/preferences/in-content/tests/browser_privacypane_4.js index 2012e4092cb4..9308a7f21e0e 100644 --- a/browser/components/preferences/in-content/tests/browser_privacypane_4.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_4.js @@ -10,11 +10,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_custom_retention("acceptCookies", "remember"), diff --git a/browser/components/preferences/in-content/tests/browser_privacypane_5.js b/browser/components/preferences/in-content/tests/browser_privacypane_5.js index 98cb92a25c52..72ef235566f0 100644 --- a/browser/components/preferences/in-content/tests/browser_privacypane_5.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_5.js @@ -10,11 +10,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_locbar_suggestion_retention(-1, undefined), diff --git a/browser/components/preferences/in-content/tests/browser_privacypane_6.js b/browser/components/preferences/in-content/tests/browser_privacypane_6.js deleted file mode 100644 index 0008da5d07b5..000000000000 --- a/browser/components/preferences/in-content/tests/browser_privacypane_6.js +++ /dev/null @@ -1,26 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let rootDir = getRootDirectory(gTestPath); - let jar = getJar(rootDir); - if (jar) { - let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path + '/'; - } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } - - run_test_subset([ - test_privatebrowsing_toggle, - enter_private_browsing, // once again, test with PB initially enabled - test_privatebrowsing_toggle, - - // don't reset preferences, will pick up where we left off in browser_privacypane_7.js - ]); -} diff --git a/browser/components/preferences/in-content/tests/browser_privacypane_7.js b/browser/components/preferences/in-content/tests/browser_privacypane_7.js deleted file mode 100644 index b51d2e483dd5..000000000000 --- a/browser/components/preferences/in-content/tests/browser_privacypane_7.js +++ /dev/null @@ -1,27 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let rootDir = getRootDirectory(gTestPath); - let jar = getJar(rootDir); - if (jar) { - let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path + '/'; - } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } - - run_test_subset([ - test_privatebrowsing_ui, - enter_private_browsing, // once again, test with PB initially enabled - test_privatebrowsing_ui, - - // reset all preferences to their default values once we're done - reset_preferences - ]); -} diff --git a/browser/components/preferences/in-content/tests/browser_privacypane_8.js b/browser/components/preferences/in-content/tests/browser_privacypane_8.js index 11d270b6435d..6cd134ed3f8f 100644 --- a/browser/components/preferences/in-content/tests/browser_privacypane_8.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_8.js @@ -10,11 +10,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ // history mode should be initialized to remember diff --git a/browser/components/preferences/in-content/tests/privacypane_tests.js b/browser/components/preferences/in-content/tests/privacypane_tests.js deleted file mode 100644 index bfe7742db7c3..000000000000 --- a/browser/components/preferences/in-content/tests/privacypane_tests.js +++ /dev/null @@ -1,491 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -function runTestOnPrivacyPrefPane(testFunc) { - - gBrowser.tabContainer.addEventListener("TabOpen", function(aEvent) { - gBrowser.tabContainer.removeEventListener("TabOpen", arguments.callee, true); - let browser = aEvent.originalTarget.linkedBrowser; - browser.addEventListener("Initialized", function(aEvent) { - browser.removeEventListener("Initialized", arguments.callee, true); - is(browser.contentWindow.location.href, "about:preferences", "Checking if the preferences tab was opened"); - testFunc(browser.contentWindow); - gBrowser.removeCurrentTab(); - testRunner.runNext(); - }, true); - }, true); - - gBrowser.selectedTab = gBrowser.addTab("about:preferences"); -} - -function controlChanged(element) { - element.doCommand(); -} - -function test_pane_visibility(win) { - let modes = { - "remember": "historyRememberPane", - "dontremember": "historyDontRememberPane", - "custom": "historyCustomPane" - }; - - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let historypane = win.document.getElementById("historyPane"); - ok(historypane, "history mode pane should exist"); - - for (let mode in modes) { - historymode.value = mode; - controlChanged(historymode); - is(historypane.selectedPanel, win.document.getElementById(modes[mode]), - "The correct pane should be selected for the " + mode + " mode"); - } -} - -function test_dependent_elements(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - let controls = [ - win.document.getElementById("rememberHistory"), - win.document.getElementById("rememberForms"), - win.document.getElementById("keepUntil"), - win.document.getElementById("keepCookiesUntil"), - win.document.getElementById("alwaysClear"), - ]; - controls.forEach(function(control) { - ok(control, "the dependent controls should exist"); - }); - let independents = [ - win.document.getElementById("acceptCookies"), - win.document.getElementById("acceptThirdParty"), - ]; - independents.forEach(function(control) { - ok(control, "the independent controls should exist"); - }); - let cookieexceptions = win.document.getElementById("cookieExceptions"); - ok(cookieexceptions, "the cookie exceptions button should exist"); - let keepuntil = win.document.getElementById("keepCookiesUntil"); - ok(keepuntil, "the keep cookies until menulist should exist"); - let alwaysclear = win.document.getElementById("alwaysClear"); - ok(alwaysclear, "the clear data on close checkbox should exist"); - let rememberhistory = win.document.getElementById("rememberHistory"); - ok(rememberhistory, "the remember history checkbox should exist"); - let rememberforms = win.document.getElementById("rememberForms"); - ok(rememberforms, "the remember forms checkbox should exist"); - let alwaysclearsettings = win.document.getElementById("clearDataSettings"); - ok(alwaysclearsettings, "the clear data settings button should exist"); - - function expect_disabled(disabled) { - controls.forEach(function(control) { - is(control.disabled, disabled, - control.getAttribute("id") + " should " + (disabled ? "" : "not ") + "be disabled"); - }); - is(keepuntil.value, disabled ? 2 : 0, - "the keep cookies until menulist value should be as expected"); - if (disabled) { - ok(!alwaysclear.checked, - "the clear data on close checkbox value should be as expected"); - ok(!rememberhistory.checked, - "the remember history checkbox value should be as expected"); - ok(!rememberforms.checked, - "the remember forms checkbox value should be as expected"); - } - } - function check_independents(expected) { - independents.forEach(function(control) { - is(control.disabled, expected, - control.getAttribute("id") + " should " + (expected ? "" : "not ") + "be disabled"); - }); - - ok(!cookieexceptions.disabled, - "the cookie exceptions button should never be disabled"); - ok(alwaysclearsettings.disabled, - "the clear data settings button should always be disabled"); - } - - // controls should only change in custom mode - historymode.value = "remember"; - controlChanged(historymode); - expect_disabled(false); - check_independents(false); - - // setting the mode to custom shouldn't change anything - historymode.value = "custom"; - controlChanged(historymode); - expect_disabled(false); - check_independents(false); - - // controls should only change in custom mode - historymode.value = "dontremember"; - controlChanged(historymode); - expect_disabled(false); - check_independents(false); - - // controls should only change in custom mode - historymode.value = "custom"; - controlChanged(historymode); - expect_disabled(true); - check_independents(false); - - // dependent controls should follow pbautostart - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(false); - check_independents(false); - - // dependent controls should follow pbautostart - pbautostart.checked = true; - controlChanged(pbautostart); - expect_disabled(true); - check_independents(false); -} - -function test_dependent_cookie_elements(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - let controls = [ - win.document.getElementById("acceptThirdParty"), - win.document.getElementById("keepUntil"), - win.document.getElementById("keepCookiesUntil"), - ]; - controls.forEach(function(control) { - ok(control, "the dependent cookie controls should exist"); - }); - let acceptcookies = win.document.getElementById("acceptCookies"); - ok(acceptcookies, "the accept cookies checkbox should exist"); - - function expect_disabled(disabled) { - controls.forEach(function(control) { - is(control.disabled, disabled, - control.getAttribute("id") + " should " + (disabled ? "" : "not ") + "be disabled"); - }); - } - - historymode.value = "custom"; - controlChanged(historymode); - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(false); - - acceptcookies.checked = false; - controlChanged(acceptcookies); - expect_disabled(true); - - // pbautostart shouldn't change anything now - pbautostart.checked = true; - controlChanged(pbautostart); - expect_disabled(true); - - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(true); - - acceptcookies.checked = true; - controlChanged(acceptcookies); - expect_disabled(false); - - let accessthirdparty = controls.shift(); - pbautostart.checked = true; - controlChanged(pbautostart); - expect_disabled(true); - ok(!accessthirdparty.disabled, "access third party button should be enabled"); - - acceptcookies.checked = false; - controlChanged(acceptcookies); - expect_disabled(true); - ok(accessthirdparty.disabled, "access third party button should be disabled"); - - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(true); - ok(accessthirdparty.disabled, "access third party button should be disabled"); - - acceptcookies.checked = true; - controlChanged(acceptcookies); - expect_disabled(false); - ok(!accessthirdparty.disabled, "access third party button should be enabled"); -} - -function test_dependent_clearonclose_elements(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - let alwaysclear = win.document.getElementById("alwaysClear"); - ok(alwaysclear, "the clear data on close checkbox should exist"); - let alwaysclearsettings = win.document.getElementById("clearDataSettings"); - ok(alwaysclearsettings, "the clear data settings button should exist"); - - function expect_disabled(disabled) { - is(alwaysclearsettings.disabled, disabled, - "the clear data settings should " + (disabled ? "" : "not ") + "be disabled"); - } - - historymode.value = "custom"; - controlChanged(historymode); - pbautostart.checked = false; - controlChanged(pbautostart); - alwaysclear.checked = false; - controlChanged(alwaysclear); - expect_disabled(true); - - alwaysclear.checked = true; - controlChanged(alwaysclear); - expect_disabled(false); - - pbautostart.checked = true; - controlChanged(pbautostart); - expect_disabled(true); - - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(false); - - alwaysclear.checked = false; - controlChanged(alwaysclear); - expect_disabled(true); -} - -function test_dependent_prefs(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let controls = [ - win.document.getElementById("rememberHistory"), - win.document.getElementById("rememberForms"), - win.document.getElementById("acceptCookies"), - win.document.getElementById("acceptThirdParty"), - ]; - controls.forEach(function(control) { - ok(control, "the micro-management controls should exist"); - }); - - function expect_checked(checked) { - controls.forEach(function(control) { - is(control.checked, checked, - control.getAttribute("id") + " should " + (checked ? "not " : "") + "be checked"); - }); - } - - // controls should be checked in remember mode - historymode.value = "remember"; - controlChanged(historymode); - expect_checked(true); - - // even if they're unchecked in custom mode - historymode.value = "custom"; - controlChanged(historymode); - controls.forEach(function(control) { - control.checked = false; - controlChanged(control); - }); - expect_checked(false); - historymode.value = "remember"; - controlChanged(historymode); - expect_checked(true); -} - -function test_historymode_retention(mode, expect) { - return function(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - - if (expect !== undefined) { - is(historymode.value, expect, - "history mode is expected to remain " + expect); - } - - historymode.value = mode; - controlChanged(historymode); - }; -} - -function test_custom_retention(controlToChange, expect, valueIncrement) { - return function(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - - if (expect !== undefined) { - is(historymode.value, expect, - "history mode is expected to remain " + expect); - } - - historymode.value = "custom"; - controlChanged(historymode); - - controlToChange = win.document.getElementById(controlToChange); - ok(controlToChange, "the control to change should exist"); - switch (controlToChange.localName) { - case "checkbox": - controlToChange.checked = !controlToChange.checked; - break; - case "textbox": - controlToChange.value = parseInt(controlToChange.value) + valueIncrement; - break; - case "menulist": - controlToChange.value = valueIncrement; - break; - } - controlChanged(controlToChange); - }; -} - -function test_locbar_suggestion_retention(mode, expect) { - return function(win) { - let locbarsuggest = win.document.getElementById("locationBarSuggestion"); - ok(locbarsuggest, "location bar suggestion menulist should exist"); - - if (expect !== undefined) { - is(locbarsuggest.value, expect, - "location bar suggestion is expected to remain " + expect); - } - - locbarsuggest.value = mode; - controlChanged(locbarsuggest); - }; -} - -function test_privatebrowsing_toggle(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - - let pbService = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - // initial state - historymode.value = "remember"; - controlChanged(historymode); - - // switch to dontremember mode - historymode.value = "dontremember"; - controlChanged(historymode); - ok(pbService.privateBrowsingEnabled, "private browsing should be activated"); - - // switch to remember mode - historymode.value = "remember"; - controlChanged(historymode); - ok(!pbService.privateBrowsingEnabled, "private browsing should be deactivated"); - - // switch to custom mode - historymode.value = "custom"; - controlChanged(historymode); - ok(!pbService.privateBrowsingEnabled, "private browsing should remain deactivated"); - - // check the autostart checkbox - pbautostart.checked = true; - controlChanged(pbautostart); - ok(pbService.privateBrowsingEnabled, "private browsing should be activated"); - - // uncheck the autostart checkbox - pbautostart.checked = false; - controlChanged(pbautostart); - ok(!pbService.privateBrowsingEnabled, "private browsing should be deactivated"); -} - -function test_privatebrowsing_ui(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - - let pbmenuitem = document.getElementById("privateBrowsingItem"); - ok(pbmenuitem, "the private browsing menu item should exist"); - let pbcommand = document.getElementById("Tools:PrivateBrowsing"); - ok(pbcommand, "the private browsing command should exist"); - - // initial state - historymode.value = "remember"; - controlChanged(historymode); - ok(!pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should not be initially disabled"); - ok(!pbcommand.hasAttribute("disabled"), - "private browsing command should not be initially disabled"); - - // switch to dontremember mode - historymode.value = "dontremember"; - controlChanged(historymode); - ok(pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should be disabled"); - ok(pbcommand.hasAttribute("disabled"), - "private browsing command should be disabled"); - - // switch to remember mode - historymode.value = "remember"; - controlChanged(historymode); - ok(!pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should be enabled"); - ok(!pbcommand.hasAttribute("disabled"), - "private browsing command should be enabled"); - - // switch to custom mode - historymode.value = "custom"; - controlChanged(historymode); - ok(!pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should remain enabled"); - ok(!pbcommand.hasAttribute("disabled"), - "private browsing command should remain enabled"); - - // check the autostart checkbox - pbautostart.checked = true; - controlChanged(pbautostart); - ok(pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should be disabled"); - ok(pbcommand.hasAttribute("disabled"), - "private browsing command should be disabled"); - - // uncheck the autostart checkbox - pbautostart.checked = false; - controlChanged(pbautostart); - ok(!pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should be enabled"); - ok(!pbcommand.hasAttribute("disabled"), - "private browsing command should be enabled"); -} - -function enter_private_browsing(win) { - let pbService = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - win.document.getElementById("browser.privatebrowsing.keep_current_session") - .value = true; - pbService.privateBrowsingEnabled = true; -} - -function reset_preferences(win) { - let prefs = win.document.querySelectorAll("#privacyPreferences > preference"); - for (let i = 0; i < prefs.length; ++i) - if (prefs[i].hasUserValue) - prefs[i].reset(); -} - -let testRunner; -function run_test_subset(subset) { - Services.prefs.setBoolPref("browser.preferences.instantApply", true); - - waitForExplicitFinish(); - registerCleanupFunction(function() { - // Reset pref to its default - Services.prefs.clearUserPref("browser.preferences.instantApply"); - }); - - testRunner = { - tests: subset, - counter: 0, - runNext: function() { - if (this.counter == this.tests.length) { - finish(); - } else { - let self = this; - setTimeout(function() { - runTestOnPrivacyPrefPane(self.tests[self.counter++]); - }, 0); - } - } - }; - - testRunner.runNext(); -} diff --git a/browser/components/preferences/jar.mn b/browser/components/preferences/jar.mn index ba5b8416946e..dc63cace5344 100644 --- a/browser/components/preferences/jar.mn +++ b/browser/components/preferences/jar.mn @@ -32,8 +32,8 @@ browser.jar: * content/browser/preferences/permissions.xul content/browser/preferences/permissions.js * content/browser/preferences/preferences.xul -* content/browser/preferences/privacy.xul -* content/browser/preferences/privacy.js + content/browser/preferences/privacy.xul + content/browser/preferences/privacy.js content/browser/preferences/sanitize.xul content/browser/preferences/security.xul content/browser/preferences/security.js diff --git a/browser/components/preferences/privacy.js b/browser/components/preferences/privacy.js index 896923d9ed41..d33b37457f08 100644 --- a/browser/components/preferences/privacy.js +++ b/browser/components/preferences/privacy.js @@ -279,7 +279,6 @@ var gPrivacyPane = { observe: function PPP_observe(aSubject, aTopic, aData) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (!gPrivacyPane._shouldPromptForRestart) { // We're performing a revert. Just let it happen. gPrivacyPane._shouldPromptForRestart = true; @@ -321,23 +320,6 @@ var gPrivacyPane = { let rememberHistoryCheckbox = document.getElementById("rememberHistory"); rememberHistory.checked = pref.value; } -#else - // Toggle the private browsing mode without switching the session - let prefValue = document.getElementById("browser.privatebrowsing.autostart").value; - let keepCurrentSession = document.getElementById("browser.privatebrowsing.keep_current_session"); - keepCurrentSession.value = true; - - let privateBrowsingService = Components.classes["@mozilla.org/privatebrowsing;1"]. - getService(Components.interfaces.nsIPrivateBrowsingService); - - // If activating from within the private browsing mode, reset the - // private session - if (prefValue && privateBrowsingService.privateBrowsingEnabled) - privateBrowsingService.privateBrowsingEnabled = false; - privateBrowsingService.privateBrowsingEnabled = prefValue; - - keepCurrentSession.reset(); -#endif } }, diff --git a/browser/components/preferences/privacy.xul b/browser/components/preferences/privacy.xul index c8619bcb6c6b..dc55703ae6df 100644 --- a/browser/components/preferences/privacy.xul +++ b/browser/components/preferences/privacy.xul @@ -73,16 +73,8 @@ -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - -#endif diff --git a/browser/components/preferences/tests/Makefile.in b/browser/components/preferences/tests/Makefile.in index 8cc7a7e19134..17de1a5a7a87 100644 --- a/browser/components/preferences/tests/Makefile.in +++ b/browser/components/preferences/tests/Makefile.in @@ -18,31 +18,13 @@ _BROWSER_FILES = \ browser_bug705422.js \ browser_permissions.js \ browser_chunk_permissions.js \ - $(NULL) - -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -_BROWSER_FILES += \ - privacypane_tests.js \ - browser_bug567487.js \ browser_privacypane_1.js \ - browser_privacypane_2.js \ browser_privacypane_3.js \ browser_privacypane_4.js \ browser_privacypane_5.js \ - browser_privacypane_6.js \ - browser_privacypane_7.js \ browser_privacypane_8.js \ - $(NULL) -else -_BROWSER_FILES += \ privacypane_tests_perwindow.js \ - browser_privacypane_1.js \ - browser_privacypane_3.js \ - browser_privacypane_4.js \ - browser_privacypane_5.js \ - browser_privacypane_8.js \ $(NULL) -endif ifdef MOZ_SERVICES_HEALTHREPORT _BROWSER_FILES += browser_healthreport.js diff --git a/browser/components/preferences/tests/browser_bug567487.js b/browser/components/preferences/tests/browser_bug567487.js deleted file mode 100644 index 0d04351e48cb..000000000000 --- a/browser/components/preferences/tests/browser_bug567487.js +++ /dev/null @@ -1,70 +0,0 @@ -function test() { - waitForExplicitFinish(); - resetPreferences(); - - function observer(win, topic, data) { - if (topic != "main-pane-loaded") - return; - - Services.obs.removeObserver(observer, "main-pane-loaded"); - runTest(win); - } - Services.obs.addObserver(observer, "main-pane-loaded", false); - - openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences", - "chrome,titlebar,toolbar,centerscreen,dialog=no", "paneMain"); -} - -function runTest(win) { - let doc = win.document; - let pbAutoStartPref = doc.getElementById("browser.privatebrowsing.autostart"); - let startupPref = doc.getElementById("browser.startup.page"); - let menu = doc.getElementById("browserStartupPage"); - let option = doc.getElementById("browserStartupLastSession"); - let defOption = doc.getElementById("browserStartupHomePage"); - let otherOption = doc.getElementById("browserStartupBlank"); - - ok(!pbAutoStartPref.value, "Sanity check"); - is(startupPref.value, startupPref.defaultValue, "Sanity check"); - - // First, check to make sure that setting pbAutoStartPref disables the menu item - pbAutoStartPref.value = true; - is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " + - "should disable the 'Show my tabs and windows from last time' option"); - pbAutoStartPref.value = false; - - // Now ensure the correct behavior when pbAutoStartPref is set with option enabled - startupPref.value = option.getAttribute("value"); - is(menu.selectedItem, option, "Sanity check"); - pbAutoStartPref.value = true; - is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " + - "should disable the 'Show my tabs and windows from last time' option"); - is(menu.selectedItem, defOption, "The 'Show home page' option should be selected"); - is(startupPref.value, option.getAttribute("value"), "But the value of the startup " + - "pref itself shouldn't change"); - menu.selectedItem = otherOption; - menu.doCommand(); - is(startupPref.value, otherOption.getAttribute("value"), "And we should be able to " + - "chnage it!"); - pbAutoStartPref.value = false; - - // Now, ensure that with 'Show my windows and tabs from last time' enabled, toggling - // pbAutoStartPref would restore that value in the menulist. - startupPref.value = option.getAttribute("value"); - is(menu.selectedItem, option, "Sanity check"); - pbAutoStartPref.value = true; - is(menu.selectedItem, defOption, "The 'Show home page' option should be selected"); - pbAutoStartPref.value = false; - is(menu.selectedItem, option, "The correct value should be restored"); - - // cleanup - resetPreferences(); - - win.close(); - finish(); -} - -function resetPreferences() { - Services.prefs.clearUserPref("browser.startup.page"); - Services.prefs.clearUserPref("browser.privatebrowsing.autostart"); -} diff --git a/browser/components/preferences/tests/browser_privacypane_1.js b/browser/components/preferences/tests/browser_privacypane_1.js index cb114382b60d..f478b1acabca 100644 --- a/browser/components/preferences/tests/browser_privacypane_1.js +++ b/browser/components/preferences/tests/browser_privacypane_1.js @@ -12,11 +12,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_pane_visibility, diff --git a/browser/components/preferences/tests/browser_privacypane_2.js b/browser/components/preferences/tests/browser_privacypane_2.js deleted file mode 100644 index 73e74ddd8145..000000000000 --- a/browser/components/preferences/tests/browser_privacypane_2.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() { - let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - - let rootDir = getRootDirectory(gTestPath); - let jar = getJar(rootDir); - if (jar) { - let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path + '/'; - } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } - - run_test_subset([ - test_historymode_retention("remember", undefined), - test_historymode_retention("dontremember", "remember"), - test_historymode_retention("custom", "dontremember"), - // custom without any micro-prefs changed won't retain - test_historymode_retention("remember", "dontremember"), - test_historymode_retention("custom", "remember"), - // custom without any micro-prefs changed won't retain - test_historymode_retention("remember", "remember"), - - // reset all preferences to their default values once we're done - reset_preferences - ]); -} diff --git a/browser/components/preferences/tests/browser_privacypane_3.js b/browser/components/preferences/tests/browser_privacypane_3.js index 21cfa713f1c4..8ef887a35b6a 100644 --- a/browser/components/preferences/tests/browser_privacypane_3.js +++ b/browser/components/preferences/tests/browser_privacypane_3.js @@ -11,11 +11,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_custom_retention("rememberHistory", "remember"), diff --git a/browser/components/preferences/tests/browser_privacypane_4.js b/browser/components/preferences/tests/browser_privacypane_4.js index 372ea8654698..3a947eaf7978 100644 --- a/browser/components/preferences/tests/browser_privacypane_4.js +++ b/browser/components/preferences/tests/browser_privacypane_4.js @@ -11,11 +11,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_custom_retention("acceptCookies", "remember"), diff --git a/browser/components/preferences/tests/browser_privacypane_5.js b/browser/components/preferences/tests/browser_privacypane_5.js index 778a3b70fb06..48a4feb91d42 100644 --- a/browser/components/preferences/tests/browser_privacypane_5.js +++ b/browser/components/preferences/tests/browser_privacypane_5.js @@ -11,11 +11,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_locbar_suggestion_retention(-1, undefined), diff --git a/browser/components/preferences/tests/browser_privacypane_6.js b/browser/components/preferences/tests/browser_privacypane_6.js deleted file mode 100644 index 0d7df5a98bb8..000000000000 --- a/browser/components/preferences/tests/browser_privacypane_6.js +++ /dev/null @@ -1,27 +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 loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let rootDir = getRootDirectory(gTestPath); - let jar = getJar(rootDir); - if (jar) { - let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path + '/'; - } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } - - run_test_subset([ - test_privatebrowsing_toggle, - enter_private_browsing, // once again, test with PB initially enabled - test_privatebrowsing_toggle, - - // don't reset preferences, will pick up where we left off in browser_privacypane_7.js - ]); -} diff --git a/browser/components/preferences/tests/browser_privacypane_7.js b/browser/components/preferences/tests/browser_privacypane_7.js deleted file mode 100644 index 34c3550a9642..000000000000 --- a/browser/components/preferences/tests/browser_privacypane_7.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 loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. - getService(Ci.mozIJSSubScriptLoader); - let rootDir = getRootDirectory(gTestPath); - let jar = getJar(rootDir); - if (jar) { - let tmpdir = extractJarToTmp(jar); - rootDir = "file://" + tmpdir.path + '/'; - } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } - - run_test_subset([ - test_privatebrowsing_ui, - enter_private_browsing, // once again, test with PB initially enabled - test_privatebrowsing_ui, - - // reset all preferences to their default values once we're done - reset_preferences - ]); -} diff --git a/browser/components/preferences/tests/browser_privacypane_8.js b/browser/components/preferences/tests/browser_privacypane_8.js index 91ce70175807..bb21d6646a2e 100644 --- a/browser/components/preferences/tests/browser_privacypane_8.js +++ b/browser/components/preferences/tests/browser_privacypane_8.js @@ -11,11 +11,7 @@ function test() { let tmpdir = extractJarToTmp(jar); rootDir = "file://" + tmpdir.path + '/'; } - try { - loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); - } catch(x) { - loader.loadSubScript(rootDir + "privacypane_tests.js", this); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ // history mode should be initialized to remember diff --git a/browser/components/preferences/tests/privacypane_tests.js b/browser/components/preferences/tests/privacypane_tests.js deleted file mode 100644 index cfbce4232505..000000000000 --- a/browser/components/preferences/tests/privacypane_tests.js +++ /dev/null @@ -1,499 +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 runTestOnPrivacyPrefPane(testFunc) { - let observer = { - observe: function(aSubject, aTopic, aData) { - if (aTopic == "domwindowopened") { - Services.ww.unregisterNotification(this); - - let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); - win.addEventListener("load", function() { - win.removeEventListener("load", arguments.callee, false); - testFunc(dialog.document.defaultView); - - Services.ww.registerNotification(observer); - dialog.close(); - }, false); - } else if (aTopic == "domwindowclosed") { - Services.ww.unregisterNotification(this); - testRunner.runNext(); - } - } - }; - Services.ww.registerNotification(observer); - - let dialog = openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences", - "chrome,titlebar,toolbar,centerscreen,dialog=no", "panePrivacy"); -} - -function controlChanged(element) { - element.doCommand(); -} - -function test_pane_visibility(win) { - let modes = { - "remember": "historyRememberPane", - "dontremember": "historyDontRememberPane", - "custom": "historyCustomPane" - }; - - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let historypane = win.document.getElementById("historyPane"); - ok(historypane, "history mode pane should exist"); - - for (let mode in modes) { - historymode.value = mode; - controlChanged(historymode); - is(historypane.selectedPanel, win.document.getElementById(modes[mode]), - "The correct pane should be selected for the " + mode + " mode"); - } -} - -function test_dependent_elements(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - let controls = [ - win.document.getElementById("rememberHistory"), - win.document.getElementById("rememberForms"), - win.document.getElementById("keepUntil"), - win.document.getElementById("keepCookiesUntil"), - win.document.getElementById("alwaysClear"), - ]; - controls.forEach(function(control) { - ok(control, "the dependent controls should exist"); - }); - let independents = [ - win.document.getElementById("acceptCookies"), - win.document.getElementById("acceptThirdParty"), - ]; - independents.forEach(function(control) { - ok(control, "the independent controls should exist"); - }); - let cookieexceptions = win.document.getElementById("cookieExceptions"); - ok(cookieexceptions, "the cookie exceptions button should exist"); - let keepuntil = win.document.getElementById("keepCookiesUntil"); - ok(keepuntil, "the keep cookies until menulist should exist"); - let alwaysclear = win.document.getElementById("alwaysClear"); - ok(alwaysclear, "the clear data on close checkbox should exist"); - let rememberhistory = win.document.getElementById("rememberHistory"); - ok(rememberhistory, "the remember history checkbox should exist"); - let rememberforms = win.document.getElementById("rememberForms"); - ok(rememberforms, "the remember forms checkbox should exist"); - let alwaysclearsettings = win.document.getElementById("clearDataSettings"); - ok(alwaysclearsettings, "the clear data settings button should exist"); - - function expect_disabled(disabled) { - controls.forEach(function(control) { - is(control.disabled, disabled, - control.getAttribute("id") + " should " + (disabled ? "" : "not ") + "be disabled"); - }); - is(keepuntil.value, disabled ? 2 : 0, - "the keep cookies until menulist value should be as expected"); - if (disabled) { - ok(!alwaysclear.checked, - "the clear data on close checkbox value should be as expected"); - ok(!rememberhistory.checked, - "the remember history checkbox value should be as expected"); - ok(!rememberforms.checked, - "the remember forms checkbox value should be as expected"); - } - } - function check_independents(expected) { - independents.forEach(function(control) { - is(control.disabled, expected, - control.getAttribute("id") + " should " + (expected ? "" : "not ") + "be disabled"); - }); - ok(!cookieexceptions.disabled, - "the cookie exceptions button should never be disabled"); - ok(alwaysclearsettings.disabled, - "the clear data settings button should always be disabled"); - } - - // controls should only change in custom mode - historymode.value = "remember"; - controlChanged(historymode); - expect_disabled(false); - check_independents(false); - - // setting the mode to custom shouldn't change anything - historymode.value = "custom"; - controlChanged(historymode); - expect_disabled(false); - check_independents(false); - - // controls should only change in custom mode - historymode.value = "dontremember"; - controlChanged(historymode); - expect_disabled(false); - check_independents(false); - - // controls should only change in custom mode - historymode.value = "custom"; - controlChanged(historymode); - expect_disabled(true); - check_independents(false); - - // dependent controls should follow pbautostart - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(false); - check_independents(false); - - // dependent controls should follow pbautostart - pbautostart.checked = true; - controlChanged(pbautostart); - expect_disabled(true); - check_independents(false); -} - -function test_dependent_cookie_elements(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - let controls = [ - win.document.getElementById("acceptThirdParty"), - win.document.getElementById("keepUntil"), - win.document.getElementById("keepCookiesUntil"), - ]; - controls.forEach(function(control) { - ok(control, "the dependent cookie controls should exist"); - }); - let acceptcookies = win.document.getElementById("acceptCookies"); - ok(acceptcookies, "the accept cookies checkbox should exist"); - - function expect_disabled(disabled) { - controls.forEach(function(control) { - is(control.disabled, disabled, - control.getAttribute("id") + " should " + (disabled ? "" : "not ") + "be disabled"); - }); - } - - historymode.value = "custom"; - controlChanged(historymode); - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(false); - - acceptcookies.checked = false; - controlChanged(acceptcookies); - expect_disabled(true); - - // pbautostart shouldn't change anything now - pbautostart.checked = true; - controlChanged(pbautostart); - expect_disabled(true); - - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(true); - - acceptcookies.checked = true; - controlChanged(acceptcookies); - expect_disabled(false); - - let accessthirdparty = controls.shift(); - pbautostart.checked = true; - controlChanged(pbautostart); - expect_disabled(true); - ok(!accessthirdparty.disabled, "access third party button should be enabled"); - - acceptcookies.checked = false; - controlChanged(acceptcookies); - expect_disabled(true); - ok(accessthirdparty.disabled, "access third party button should be disabled"); - - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(true); - ok(accessthirdparty.disabled, "access third party button should be disabled"); - - acceptcookies.checked = true; - controlChanged(acceptcookies); - expect_disabled(false); - ok(!accessthirdparty.disabled, "access third party button should be enabled"); -} - -function test_dependent_clearonclose_elements(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - let alwaysclear = win.document.getElementById("alwaysClear"); - ok(alwaysclear, "the clear data on close checkbox should exist"); - let alwaysclearsettings = win.document.getElementById("clearDataSettings"); - ok(alwaysclearsettings, "the clear data settings button should exist"); - - function expect_disabled(disabled) { - is(alwaysclearsettings.disabled, disabled, - "the clear data settings should " + (disabled ? "" : "not ") + "be disabled"); - } - - historymode.value = "custom"; - controlChanged(historymode); - pbautostart.checked = false; - controlChanged(pbautostart); - alwaysclear.checked = false; - controlChanged(alwaysclear); - expect_disabled(true); - - alwaysclear.checked = true; - controlChanged(alwaysclear); - expect_disabled(false); - - pbautostart.checked = true; - controlChanged(pbautostart); - expect_disabled(true); - - pbautostart.checked = false; - controlChanged(pbautostart); - expect_disabled(false); - - alwaysclear.checked = false; - controlChanged(alwaysclear); - expect_disabled(true); -} - -function test_dependent_prefs(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let controls = [ - win.document.getElementById("rememberHistory"), - win.document.getElementById("rememberForms"), - win.document.getElementById("acceptCookies"), - win.document.getElementById("acceptThirdParty"), - ]; - controls.forEach(function(control) { - ok(control, "the micro-management controls should exist"); - }); - - function expect_checked(checked) { - controls.forEach(function(control) { - is(control.checked, checked, - control.getAttribute("id") + " should " + (checked ? "not " : "") + "be checked"); - }); - } - - // controls should be checked in remember mode - historymode.value = "remember"; - controlChanged(historymode); - expect_checked(true); - - // even if they're unchecked in custom mode - historymode.value = "custom"; - controlChanged(historymode); - controls.forEach(function(control) { - control.checked = false; - controlChanged(control); - }); - expect_checked(false); - historymode.value = "remember"; - controlChanged(historymode); - expect_checked(true); -} - -function test_historymode_retention(mode, expect) { - return function(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - - if (expect !== undefined) { - is(historymode.value, expect, - "history mode is expected to remain " + expect); - } - - historymode.value = mode; - controlChanged(historymode); - }; -} - -function test_custom_retention(controlToChange, expect, valueIncrement) { - return function(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - - if (expect !== undefined) { - is(historymode.value, expect, - "history mode is expected to remain " + expect); - } - - historymode.value = "custom"; - controlChanged(historymode); - - controlToChange = win.document.getElementById(controlToChange); - ok(controlToChange, "the control to change should exist"); - switch (controlToChange.localName) { - case "checkbox": - controlToChange.checked = !controlToChange.checked; - break; - case "textbox": - controlToChange.value = parseInt(controlToChange.value) + valueIncrement; - break; - case "menulist": - controlToChange.value = valueIncrement; - break; - } - controlChanged(controlToChange); - }; -} - -function test_locbar_suggestion_retention(mode, expect) { - return function(win) { - let locbarsuggest = win.document.getElementById("locationBarSuggestion"); - ok(locbarsuggest, "location bar suggestion menulist should exist"); - - if (expect !== undefined) { - is(locbarsuggest.value, expect, - "location bar suggestion is expected to remain " + expect); - } - - locbarsuggest.value = mode; - controlChanged(locbarsuggest); - }; -} - -function test_privatebrowsing_toggle(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - - let pbService = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - // initial state - historymode.value = "remember"; - controlChanged(historymode); - - // switch to dontremember mode - historymode.value = "dontremember"; - controlChanged(historymode); - ok(pbService.privateBrowsingEnabled, "private browsing should be activated"); - - // switch to remember mode - historymode.value = "remember"; - controlChanged(historymode); - ok(!pbService.privateBrowsingEnabled, "private browsing should be deactivated"); - - // switch to custom mode - historymode.value = "custom"; - controlChanged(historymode); - ok(!pbService.privateBrowsingEnabled, "private browsing should remain deactivated"); - - // check the autostart checkbox - pbautostart.checked = true; - controlChanged(pbautostart); - ok(pbService.privateBrowsingEnabled, "private browsing should be activated"); - - // uncheck the autostart checkbox - pbautostart.checked = false; - controlChanged(pbautostart); - ok(!pbService.privateBrowsingEnabled, "private browsing should be deactivated"); -} - -function test_privatebrowsing_ui(win) { - let historymode = win.document.getElementById("historyMode"); - ok(historymode, "history mode menulist should exist"); - let pbautostart = win.document.getElementById("privateBrowsingAutoStart"); - ok(pbautostart, "the private browsing auto-start checkbox should exist"); - - let pbmenuitem = document.getElementById("privateBrowsingItem"); - ok(pbmenuitem, "the private browsing menu item should exist"); - let pbcommand = document.getElementById("Tools:PrivateBrowsing"); - ok(pbcommand, "the private browsing command should exist"); - - // initial state - historymode.value = "remember"; - controlChanged(historymode); - ok(!pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should not be initially disabled"); - ok(!pbcommand.hasAttribute("disabled"), - "private browsing command should not be initially disabled"); - - // switch to dontremember mode - historymode.value = "dontremember"; - controlChanged(historymode); - ok(pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should be disabled"); - ok(pbcommand.hasAttribute("disabled"), - "private browsing command should be disabled"); - - // switch to remember mode - historymode.value = "remember"; - controlChanged(historymode); - ok(!pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should be enabled"); - ok(!pbcommand.hasAttribute("disabled"), - "private browsing command should be enabled"); - - // switch to custom mode - historymode.value = "custom"; - controlChanged(historymode); - ok(!pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should remain enabled"); - ok(!pbcommand.hasAttribute("disabled"), - "private browsing command should remain enabled"); - - // check the autostart checkbox - pbautostart.checked = true; - controlChanged(pbautostart); - ok(pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should be disabled"); - ok(pbcommand.hasAttribute("disabled"), - "private browsing command should be disabled"); - - // uncheck the autostart checkbox - pbautostart.checked = false; - controlChanged(pbautostart); - ok(!pbmenuitem.hasAttribute("disabled"), - "private browsing menu item should be enabled"); - ok(!pbcommand.hasAttribute("disabled"), - "private browsing command should be enabled"); -} - -function enter_private_browsing(win) { - let pbService = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - win.document.getElementById("browser.privatebrowsing.keep_current_session") - .value = true; - pbService.privateBrowsingEnabled = true; -} - -function reset_preferences(win) { - let prefs = win.document.getElementsByTagName("preference"); - for (let i = 0; i < prefs.length; ++i) - if (prefs[i].hasUserValue) - prefs[i].reset(); -} - -let testRunner; -function run_test_subset(subset) { - let instantApplyOrig = Services.prefs.getBoolPref("browser.preferences.instantApply"); - Services.prefs.setBoolPref("browser.preferences.instantApply", true); - - waitForExplicitFinish(); - - testRunner = { - tests: subset, - counter: 0, - runNext: function() { - if (this.counter == this.tests.length) { - // cleanup - Services.prefs.setBoolPref("browser.preferences.instantApply", instantApplyOrig); - finish(); - } else { - let self = this; - setTimeout(function() { - runTestOnPrivacyPrefPane(self.tests[self.counter++]); - }, 0); - } - } - }; - - testRunner.runNext(); -} diff --git a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml index 4cb878c262fc..95744cf5ffd8 100644 --- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml +++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml @@ -13,18 +13,10 @@ %globalDTD; %browserDTD; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING #ifdef XP_MACOSX #else &brandShortName;&fileMenu.label;"> -#endif -#else -#ifdef XP_MACOSX - -#else - &brandShortName;&toolsMenu.label;"> -#endif #endif %privatebrowsingpageDTD; @@ -39,15 +31,9 @@ body.private .showNormal { display: none; } -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING body.appMenuButtonVisible .fileMenu { display: none; } -#else - body.appMenuButtonVisible .toolsMenu { - display: none; - } -#endif body.appMenuButtonInvisible .appMenuButton { display: none; } @@ -108,15 +94,9 @@ "appMenuButtonInvisible"); }, false); -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING function openPrivateWindow() { mainWindow.OpenBrowserWindow({private: true}); } -#else - function togglePrivateBrowsing() { - mainWindow.gPrivateBrowsingUI.toggleMode(); - } -#endif ]]> @@ -137,48 +117,27 @@
-#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING

&privatebrowsingpage.perwindow.issueDesc;

&privatebrowsingpage.perwindow.issueDesc.normal;

-#else -

&privatebrowsingpage.issueDesc;

-

&privatebrowsingpage.issueDesc.normal;

-#endif
-#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING

&privatebrowsingpage.perwindow.description;

-#else -

&privatebrowsingpage.description;

-#endif
-#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
-#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING

&privatebrowsingpage.howToStop3;

&privatebrowsingpage.howToStart3;

-#else -

&privatebrowsingpage.howToStop2;

-

&privatebrowsingpage.howToStart2;

-#endif
diff --git a/browser/components/privatebrowsing/src/Makefile.in b/browser/components/privatebrowsing/src/Makefile.in index b4fb5b44a23c..789cea98f958 100644 --- a/browser/components/privatebrowsing/src/Makefile.in +++ b/browser/components/privatebrowsing/src/Makefile.in @@ -15,29 +15,9 @@ LIBRARY_NAME = privatebrowsing_s FORCE_STATIC_LIB = 1 USE_STATIC_LIBS = 1 -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - EXTRA_COMPONENTS = \ nsPrivateBrowsingServiceObsolete.manifest \ nsPrivateBrowsingServiceObsolete.js \ $(NULL) -else - -CPPSRCS = \ - nsPrivateBrowsingServiceWrapper.cpp \ - $(NULL) - -LOCAL_INCLUDES = -I$(srcdir)/../../build - -EXTRA_COMPONENTS = \ - nsPrivateBrowsingService.manifest \ - $(NULL) - -EXTRA_PP_COMPONENTS = \ - nsPrivateBrowsingService.js \ - $(NULL) - -endif - include $(topsrcdir)/config/rules.mk diff --git a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js b/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js deleted file mode 100644 index 21d85fa004cf..000000000000 --- a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js +++ /dev/null @@ -1,593 +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/. - -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -Components.utils.import("resource://gre/modules/Services.jsm"); - -#ifndef XP_WIN -#define BROKEN_WM_Z_ORDER -#endif - -//////////////////////////////////////////////////////////////////////////////// -//// Constants - -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; -const Cr = Components.results; - -const STATE_IDLE = 0; -const STATE_TRANSITION_STARTED = 1; -const STATE_WAITING_FOR_RESTORE = 2; -const STATE_RESTORE_FINISHED = 3; - -//////////////////////////////////////////////////////////////////////////////// -//// PrivateBrowsingService - -function PrivateBrowsingService() { - this._obs = Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService); - this._obs.addObserver(this, "profile-after-change", true); - this._obs.addObserver(this, "quit-application-granted", true); - this._obs.addObserver(this, "private-browsing", true); - this._obs.addObserver(this, "command-line-startup", true); - this._obs.addObserver(this, "sessionstore-browser-state-restored", true); - - // List of nsIXULWindows we are going to be closing during the transition - this._windowsToClose = []; -} - -PrivateBrowsingService.prototype = { - // Preferences Service - get _prefs() { - let prefs = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); - this.__defineGetter__("_prefs", function() prefs); - return this._prefs; - }, - - // Whether the private browsing mode is currently active or not. - _inPrivateBrowsing: false, - - // Saved browser state before entering the private mode. - _savedBrowserState: null, - - // Whether we're in the process of shutting down - _quitting: false, - - // How to treat the non-private session - _saveSession: true, - - // The current status of the private browsing service - _currentStatus: STATE_IDLE, - - // Whether the private browsing mode has been started automatically (ie. always-on) - _autoStarted: false, - - // List of view source window URIs for restoring later - _viewSrcURLs: [], - - // Whether private browsing has been turned on from the command line - _lastChangedByCommandLine: false, - - // Telemetry measurements - _enterTimestamps: {}, - _exitTimestamps: {}, - - // XPCOM registration - classID: Components.ID("{c31f4883-839b-45f6-82ad-a6a9bc5ad599}"), - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrivateBrowsingService, - Ci.nsIObserver, - Ci.nsISupportsWeakReference, - Ci.nsICommandLineHandler]), - - _unload: function PBS__destroy() { - // Force an exit from the private browsing mode on shutdown - this._quitting = true; - if (this._inPrivateBrowsing) - this.privateBrowsingEnabled = false; - }, - - _setPerWindowPBFlag: function PBS__setPerWindowPBFlag(aWindow, aFlag) { - aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .treeOwner - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIXULWindow) - .docShell.QueryInterface(Ci.nsILoadContext) - .usePrivateBrowsing = aFlag; - }, - - _adjustPBFlagOnExistingWindows: function PBS__adjustPBFlagOnExistingWindows() { - var windowsEnum = Services.wm.getEnumerator(null); - while (windowsEnum.hasMoreElements()) { - var window = windowsEnum.getNext(); - this._setPerWindowPBFlag(window, this._inPrivateBrowsing); - } - }, - - _onBeforePrivateBrowsingModeChange: function PBS__onBeforePrivateBrowsingModeChange() { - // If we're about to enter PB mode, adjust the flags now - if (this._inPrivateBrowsing) { - this._adjustPBFlagOnExistingWindows(); - } - - // nothing needs to be done here if we're enabling at startup - if (!this._autoStarted) { - let ss = Cc["@mozilla.org/browser/sessionstore;1"]. - getService(Ci.nsISessionStore); - let blankState = JSON.stringify({ - "windows": [{ - "tabs": [{ - "entries": [{ - "url": "about:blank" - }] - }], - "_closedTabs": [] - }] - }); - - if (this._inPrivateBrowsing) { - // save the whole browser state in order to restore all windows/tabs later - if (this._saveSession && !this._savedBrowserState) { - if (this._getBrowserWindow()) - this._savedBrowserState = ss.getBrowserState(); - else // no open browser windows, just restore a blank state on exit - this._savedBrowserState = blankState; - } - } - - this._closePageInfoWindows(); - - // save view-source windows URIs and close them - let viewSrcWindowsEnum = Services.wm.getEnumerator("navigator:view-source"); - while (viewSrcWindowsEnum.hasMoreElements()) { - let win = viewSrcWindowsEnum.getNext(); - if (this._inPrivateBrowsing) { - let plainURL = win.gBrowser.currentURI.spec; - if (plainURL.indexOf("view-source:") == 0) { - plainURL = plainURL.substr(12); - this._viewSrcURLs.push(plainURL); - } - } - win.close(); - } - - if (!this._quitting && this._saveSession) { - let browserWindow = this._getBrowserWindow(); - - // if there are open browser windows, load a dummy session to get a distinct - // separation between private and non-private sessions - if (browserWindow) { - // set an empty session to transition from/to pb mode, see bug 476463 - ss.setBrowserState(blankState); - - // just in case the only remaining window after setBrowserState is different. - // it probably shouldn't be with the current sessionstore impl, but we shouldn't - // rely on behaviour the API doesn't guarantee - browserWindow = this._getBrowserWindow(); - let browser = browserWindow.gBrowser; - - // this ensures a clean slate from which to transition into or out of - // private browsing - browser.addTab(); - browser.getBrowserForTab(browser.tabContainer.firstChild).stop(); - browser.removeTab(browser.tabContainer.firstChild); - browserWindow.getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .treeOwner - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIXULWindow) - .docShell.contentViewer.resetCloseWindow(); - } - } - } - else - this._saveSession = false; - - // If we're about to leave PB mode, adjust the flags now - if (!this._inPrivateBrowsing) { - this._adjustPBFlagOnExistingWindows(); - } - }, - - _onAfterPrivateBrowsingModeChange: function PBS__onAfterPrivateBrowsingModeChange() { - // nothing to do here if we're enabling at startup or the current session is being - // used - if (!this._autoStarted && this._saveSession) { - let ss = Cc["@mozilla.org/browser/sessionstore;1"]. - getService(Ci.nsISessionStore); - // if we have transitioned out of private browsing mode and the session is - // to be restored, do it now - if (!this._inPrivateBrowsing) { - this._currentStatus = STATE_WAITING_FOR_RESTORE; - if (!this._getBrowserWindow()) { - ss.init(null); - } - ss.setBrowserState(this._savedBrowserState); - this._savedBrowserState = null; - - this._closePageInfoWindows(); - - // re-open all view-source windows - let windowWatcher = Cc["@mozilla.org/embedcomp/window-watcher;1"]. - getService(Ci.nsIWindowWatcher); - this._viewSrcURLs.forEach(function(uri) { - let args = Cc["@mozilla.org/supports-array;1"]. - createInstance(Ci.nsISupportsArray); - let str = Cc["@mozilla.org/supports-string;1"]. - createInstance(Ci.nsISupportsString); - str.data = uri; - args.AppendElement(str); - args.AppendElement(null); // charset - args.AppendElement(null); // page descriptor - args.AppendElement(null); // line number - let forcedCharset = Cc["@mozilla.org/supports-PRBool;1"]. - createInstance(Ci.nsISupportsPRBool); - forcedCharset.data = false; - args.AppendElement(forcedCharset); - windowWatcher.openWindow(null, "chrome://global/content/viewSource.xul", - "_blank", "all,dialog=no", args); - }); - this._viewSrcURLs = []; - } - else { - // otherwise, if we have transitioned into private browsing mode, load - // about:privatebrowsing - let privateBrowsingState = { - "windows": [{ - "tabs": [{ - "entries": [{ - "url": "about:privatebrowsing" - }] - }], - "_closedTabs": [] - }] - }; - // Transition into private browsing mode - this._currentStatus = STATE_WAITING_FOR_RESTORE; - if (!this._getBrowserWindow()) { - ss.init(null); - } - ss.setBrowserState(JSON.stringify(privateBrowsingState)); - } - } - }, - - _notifyIfTransitionComplete: function PBS__notifyIfTransitionComplete() { - switch (this._currentStatus) { - case STATE_TRANSITION_STARTED: - // no session store operation was needed, so just notify of transition completion - case STATE_RESTORE_FINISHED: - // restore has been completed - this._currentStatus = STATE_IDLE; - this._obs.notifyObservers(null, "private-browsing-transition-complete", ""); - this._recordTransitionTime("completed"); - break; - case STATE_WAITING_FOR_RESTORE: - // too soon to notify... - break; - case STATE_IDLE: - // no need to notify - break; - default: - // unexpected state observed - Cu.reportError("Unexpected private browsing status reached: " + - this._currentStatus); - break; - } - }, - - _recordTransitionTime: function PBS__recordTransitionTime(aPhase) { - // To record the time spent in private browsing transitions, note that we - // cannot use the TelemetryStopwatch module, because it reports its results - // immediately when the timer is stopped. In this case, we need to delay - // the actual histogram update after we are out of private browsing mode. - if (this._inPrivateBrowsing) { - this._enterTimestamps[aPhase] = Date.now(); - } else { - if (this._quitting) { - // If we are quitting the browser, we don't care collecting the data, - // because we wouldn't be able to record it with telemetry. - return; - } - this._exitTimestamps[aPhase] = Date.now(); - if (aPhase == "completed") { - // After we finished exiting the private browsing mode, we can finally - // record the telemetry data, for the enter and the exit processes. - this._reportTelemetry(); - } - } - }, - - _reportTelemetry: function PBS__reportTelemetry() { - function reportTelemetryEntry(aHistogramId, aValue) { - try { - Services.telemetry.getHistogramById(aHistogramId).add(aValue); - } catch (ex) { - Cu.reportError(ex); - } - } - - reportTelemetryEntry( - "PRIVATE_BROWSING_TRANSITION_ENTER_PREPARATION_MS", - this._enterTimestamps.prepared - this._enterTimestamps.started); - reportTelemetryEntry( - "PRIVATE_BROWSING_TRANSITION_ENTER_TOTAL_MS", - this._enterTimestamps.completed - this._enterTimestamps.started); - reportTelemetryEntry( - "PRIVATE_BROWSING_TRANSITION_EXIT_PREPARATION_MS", - this._exitTimestamps.prepared - this._exitTimestamps.started); - reportTelemetryEntry( - "PRIVATE_BROWSING_TRANSITION_EXIT_TOTAL_MS", - this._exitTimestamps.completed - this._exitTimestamps.started); - }, - - _canEnterPrivateBrowsingMode: function PBS__canEnterPrivateBrowsingMode() { - let cancelEnter = Cc["@mozilla.org/supports-PRBool;1"]. - createInstance(Ci.nsISupportsPRBool); - cancelEnter.data = false; - this._obs.notifyObservers(cancelEnter, "private-browsing-cancel-vote", "enter"); - return !cancelEnter.data; - }, - - _canLeavePrivateBrowsingMode: function PBS__canLeavePrivateBrowsingMode() { - let cancelLeave = Cc["@mozilla.org/supports-PRBool;1"]. - createInstance(Ci.nsISupportsPRBool); - cancelLeave.data = false; - this._obs.notifyObservers(cancelLeave, "private-browsing-cancel-vote", "exit"); - if (!cancelLeave.data) { - this._obs.notifyObservers(cancelLeave, "last-pb-context-exiting", null); - } - return !cancelLeave.data; - }, - - _getBrowserWindow: function PBS__getBrowserWindow() { - var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. - getService(Ci.nsIWindowMediator); - - var win = wm.getMostRecentWindow("navigator:browser"); - - // We don't just return |win| now because of bug 528706. - - if (!win) - return null; - if (!win.closed) - return win; - -#ifdef BROKEN_WM_Z_ORDER - win = null; - var windowsEnum = wm.getEnumerator("navigator:browser"); - // this is oldest to newest, so this gets a bit ugly - while (windowsEnum.hasMoreElements()) { - let nextWin = windowsEnum.getNext(); - if (!nextWin.closed) - win = nextWin; - } - return win; -#else - var windowsEnum = wm.getZOrderDOMWindowEnumerator("navigator:browser", true); - while (windowsEnum.hasMoreElements()) { - win = windowsEnum.getNext(); - if (!win.closed) - return win; - } - return null; -#endif - }, - - _ensureCanCloseWindows: function PBS__ensureCanCloseWindows() { - // whether we should save and close the current session - this._saveSession = true; - try { - if (this._prefs.getBoolPref("browser.privatebrowsing.keep_current_session")) { - this._saveSession = false; - return; - } - } catch (ex) {} - - let windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"]. - getService(Ci.nsIWindowMediator); - let windowsEnum = windowMediator.getEnumerator("navigator:browser"); - - while (windowsEnum.hasMoreElements()) { - let win = windowsEnum.getNext(); - if (win.closed) - continue; - let xulWin = win.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIDocShellTreeItem). - treeOwner.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIXULWindow); - if (xulWin.docShell.contentViewer.permitUnload(true)) - this._windowsToClose.push(xulWin); - else - throw Cr.NS_ERROR_ABORT; - } - }, - - _closePageInfoWindows: function PBS__closePageInfoWindows() { - let pageInfoEnum = Cc["@mozilla.org/appshell/window-mediator;1"]. - getService(Ci.nsIWindowMediator). - getEnumerator("Browser:page-info"); - while (pageInfoEnum.hasMoreElements()) { - let win = pageInfoEnum.getNext(); - win.close(); - } - }, - - // nsIObserver - - observe: function PBS_observe(aSubject, aTopic, aData) { - switch (aTopic) { - case "profile-after-change": - // If the autostart prefs has been set, simulate entering the - // private browsing mode upon startup. - // This won't interfere with the session store component, because - // that component will be initialized on final-ui-startup. - if (!this._autoStarted) { - this._autoStarted = this._prefs.getBoolPref("browser.privatebrowsing.autostart"); - if (this._autoStarted) - this.privateBrowsingEnabled = true; - } - this._obs.removeObserver(this, "profile-after-change"); - break; - case "quit-application-granted": - this._unload(); - break; - case "private-browsing": - if (!this._inPrivateBrowsing) { - // Clear the error console - let consoleService = Cc["@mozilla.org/consoleservice;1"]. - getService(Ci.nsIConsoleService); - consoleService.logStringMessage(null); // trigger the listeners - consoleService.reset(); - } - break; - case "command-line-startup": - this._obs.removeObserver(this, "command-line-startup"); - aSubject.QueryInterface(Ci.nsICommandLine); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - if (aSubject.findFlag("private", false) >= 0) { - // Don't need to go into PB mode if it's already set to autostart - if (this._autoStarted) - aSubject.handleFlag("private", false); - - this.privateBrowsingEnabled = true; - this._autoStarted = true; - this._lastChangedByCommandLine = true; - } - else -#endif - if (aSubject.findFlag("private-toggle", false) >= 0) { - this._lastChangedByCommandLine = true; - } - break; - case "sessionstore-browser-state-restored": - if (this._currentStatus == STATE_WAITING_FOR_RESTORE) { - this._currentStatus = STATE_RESTORE_FINISHED; - this._notifyIfTransitionComplete(); - } - break; - } - }, - - // nsICommandLineHandler - - handle: function PBS_handle(aCmdLine) { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - if (aCmdLine.handleFlag("private", false)) - aCmdLine.preventDefault = true; // It has already been handled - else -#endif - if (aCmdLine.handleFlag("private-toggle", false)) { - if (this._autoStarted) { - throw Cr.NS_ERROR_ABORT; - } - this.privateBrowsingEnabled = !this.privateBrowsingEnabled; - this._lastChangedByCommandLine = true; - } - }, - - get helpInfo() { - return " -private Enable private browsing mode.\n" + - " -private-toggle Toggle private browsing mode.\n"; - }, - - // nsIPrivateBrowsingService - - /** - * Return the current status of private browsing. - */ - get privateBrowsingEnabled() { - return this._inPrivateBrowsing; - }, - - /** - * Enter or leave private browsing mode. - */ - set privateBrowsingEnabled(val) { - // Allowing observers to set the private browsing status from their - // notification handlers is not desired, because it will change the - // status of the service while it's in the process of another transition. - // So, we detect a reentrant call here and throw an error. - // This is documented in nsIPrivateBrowsingService.idl. - if (this._currentStatus != STATE_IDLE) - throw Cr.NS_ERROR_FAILURE; - - if (val == this._inPrivateBrowsing) - return; - - try { - if (val) { - if (!this._canEnterPrivateBrowsingMode()) - return; - } - else { - if (!this._canLeavePrivateBrowsingMode()) - return; - } - - this._ensureCanCloseWindows(); - - // start the transition now that we know that we can - this._currentStatus = STATE_TRANSITION_STARTED; - - this._autoStarted = this._prefs.getBoolPref("browser.privatebrowsing.autostart"); - this._inPrivateBrowsing = val != false; - - this._recordTransitionTime("started"); - - let data = val ? "enter" : "exit"; - - let quitting = Cc["@mozilla.org/supports-PRBool;1"]. - createInstance(Ci.nsISupportsPRBool); - quitting.data = this._quitting; - - // notify observers of the pending private browsing mode change - this._obs.notifyObservers(quitting, "private-browsing-change-granted", data); - - // destroy the current session and start initial cleanup - this._onBeforePrivateBrowsingModeChange(); - - this._obs.notifyObservers(quitting, "private-browsing", data); - - this._recordTransitionTime("prepared"); - - // load the appropriate session - this._onAfterPrivateBrowsingModeChange(); - } catch (ex) { - // We aborted the transition to/from private browsing, we must restore the - // beforeunload handling on all the windows for which we switched it off. - for (let i = 0; i < this._windowsToClose.length; i++) - this._windowsToClose[i].docShell.contentViewer.resetCloseWindow(); - // We don't log an error when the transition is canceled from beforeunload - if (ex != Cr.NS_ERROR_ABORT) - Cu.reportError("Exception thrown while processing the " + - "private browsing mode change request: " + ex.toString()); - } finally { - this._windowsToClose = []; - this._notifyIfTransitionComplete(); - this._lastChangedByCommandLine = false; - } - }, - - /** - * Whether private browsing has been started automatically. - */ - get autoStarted() { - return this._inPrivateBrowsing && this._autoStarted; - }, - - /** - * Whether the latest transition was initiated from the command line. - */ - get lastChangedByCommandLine() { - return this._lastChangedByCommandLine; - } -}; - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PrivateBrowsingService]); diff --git a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.manifest b/browser/components/privatebrowsing/src/nsPrivateBrowsingService.manifest deleted file mode 100644 index 2b1d3394a2f8..000000000000 --- a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.manifest +++ /dev/null @@ -1,17 +0,0 @@ -# WebappRT doesn't need these instructions, and they don't necessarily work -# with it, but it does use a GRE directory that the GRE shares with Firefox, -# so in order to prevent the instructions from being processed for WebappRT, -# we need to restrict them to the applications that depend on them, i.e.: -# -# b2g: {3c2e2abc-06d4-11e1-ac3b-374f68613e61} -# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384} -# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110} -# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66} -# -# In theory we should do this for all these instructions, but in practice it is -# sufficient to do it for the app-startup one, and the file is simpler that way. - -component {c31f4883-839b-45f6-82ad-a6a9bc5ad599} nsPrivateBrowsingService.js -contract @mozilla.org/privatebrowsing;1 {c31f4883-839b-45f6-82ad-a6a9bc5ad599} -category command-line-handler m-privatebrowsing @mozilla.org/privatebrowsing;1 -category app-startup nsPrivateBrowsingService service,@mozilla.org/privatebrowsing;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66} diff --git a/browser/components/privatebrowsing/src/nsPrivateBrowsingServiceWrapper.cpp b/browser/components/privatebrowsing/src/nsPrivateBrowsingServiceWrapper.cpp deleted file mode 100644 index fe2bcaa8a043..000000000000 --- a/browser/components/privatebrowsing/src/nsPrivateBrowsingServiceWrapper.cpp +++ /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/. */ - -#include "nsPrivateBrowsingServiceWrapper.h" -#include "nsServiceManagerUtils.h" -#include "jsapi.h" -#include "nsIJSContextStack.h" - -class JSStackGuard -{ -public: - JSStackGuard(); - ~JSStackGuard(); - -private: - nsCOMPtr mJSStack; -}; - -NS_IMPL_ISUPPORTS2(nsPrivateBrowsingServiceWrapper, nsIPrivateBrowsingService, nsIObserver) - -nsresult -nsPrivateBrowsingServiceWrapper::Init() -{ - nsresult rv; - mPBService = do_GetService("@mozilla.org/privatebrowsing;1", &rv); - return rv; -} - -JSStackGuard::JSStackGuard() - : mJSStack(nullptr) -{ - nsresult rv; - mJSStack = do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv); - - if (NS_SUCCEEDED(rv) && mJSStack) { - rv = mJSStack->Push(nullptr); - if (NS_FAILED(rv)) - mJSStack = nullptr; - } -} - -JSStackGuard::~JSStackGuard() -{ - if (mJSStack) { - JSContext *cx; - mJSStack->Pop(&cx); - NS_ASSERTION(cx == nullptr, "JSContextStack mismatch"); - } -} - -NS_IMETHODIMP -nsPrivateBrowsingServiceWrapper::GetPrivateBrowsingEnabled(bool *aPrivateBrowsingEnabled) -{ - if (!aPrivateBrowsingEnabled) - return NS_ERROR_NULL_POINTER; - JSStackGuard guard; - return mPBService->GetPrivateBrowsingEnabled(aPrivateBrowsingEnabled); -} - -NS_IMETHODIMP -nsPrivateBrowsingServiceWrapper::SetPrivateBrowsingEnabled(bool aPrivateBrowsingEnabled) -{ - JSStackGuard guard; - return mPBService->SetPrivateBrowsingEnabled(aPrivateBrowsingEnabled); -} - -NS_IMETHODIMP -nsPrivateBrowsingServiceWrapper::GetAutoStarted(bool *aAutoStarted) -{ - if (!aAutoStarted) - return NS_ERROR_NULL_POINTER; - JSStackGuard guard; - return mPBService->GetAutoStarted(aAutoStarted); -} - -NS_IMETHODIMP -nsPrivateBrowsingServiceWrapper::GetLastChangedByCommandLine(bool *aReason) -{ - if (!aReason) - return NS_ERROR_NULL_POINTER; - JSStackGuard guard; - return mPBService->GetLastChangedByCommandLine(aReason); -} - -NS_IMETHODIMP -nsPrivateBrowsingServiceWrapper::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) -{ - JSStackGuard guard; - nsCOMPtr observer(do_QueryInterface(mPBService)); - NS_ENSURE_TRUE(observer, NS_ERROR_FAILURE); - return observer->Observe(aSubject, aTopic, aData); -} diff --git a/browser/components/privatebrowsing/src/nsPrivateBrowsingServiceWrapper.h b/browser/components/privatebrowsing/src/nsPrivateBrowsingServiceWrapper.h deleted file mode 100644 index 39639afbcbbf..000000000000 --- a/browser/components/privatebrowsing/src/nsPrivateBrowsingServiceWrapper.h +++ /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/. */ - -#include "nsCOMPtr.h" -#include "nsIPrivateBrowsingService.h" -#include "nsIObserver.h" -#include "mozilla/Attributes.h" - -class nsIJSContextStack; - -class nsPrivateBrowsingServiceWrapper MOZ_FINAL : public nsIPrivateBrowsingService, - public nsIObserver -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIPRIVATEBROWSINGSERVICE - NS_DECL_NSIOBSERVER - - nsresult Init(); - -private: - nsCOMPtr mPBService; -}; diff --git a/browser/components/privatebrowsing/test/Makefile.in b/browser/components/privatebrowsing/test/Makefile.in index 0dacef55175a..e8869dfe06b7 100644 --- a/browser/components/privatebrowsing/test/Makefile.in +++ b/browser/components/privatebrowsing/test/Makefile.in @@ -12,15 +12,6 @@ include $(DEPTH)/config/autoconf.mk MODULE = test_privatebrowsing -# Most xpcshell PB tests use the global PB service, which means that we should -# not attempt to run them in regular builds. We should look at the list and -# decide which ones of them should be ported to the browser/perwindow suite -# in the future. - -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -XPCSHELL_TESTS = unit -endif - DIRS += browser \ $(NULL) diff --git a/browser/components/privatebrowsing/test/browser/Makefile.in b/browser/components/privatebrowsing/test/browser/Makefile.in index 4220d3a990c7..c5c45626b4d0 100644 --- a/browser/components/privatebrowsing/test/browser/Makefile.in +++ b/browser/components/privatebrowsing/test/browser/Makefile.in @@ -12,21 +12,6 @@ include $(DEPTH)/config/autoconf.mk MODULE = test_privatebrowsing -# We have three category of browser-chrome tests: -# global: these tests focus on the global PB service implementation. -# perwindow: these tests focus on the per-window PB implementation. -# obsolete: these tests focus on the global mode, but the functionality -# that they are testing is specific to the global mode, and -# will never have a per-window counterpart. -# -# As a transition plan, we have divided the existing tests into the -# global and obsolete categories, and we'll then focus on rewriting the -# global tests to test the per-window mode. - -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING DIRS += perwindow -else -DIRS += global obsolete -endif include $(topsrcdir)/config/rules.mk diff --git a/browser/components/privatebrowsing/test/browser/global/Makefile.in b/browser/components/privatebrowsing/test/browser/global/Makefile.in deleted file mode 100644 index 57d0448f424d..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/Makefile.in +++ /dev/null @@ -1,56 +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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ -relativesrcdir = @relativesrcdir@ - -include $(DEPTH)/config/autoconf.mk - -MOCHITEST_BROWSER_FILES = \ - head.js \ - browser_privatebrowsing_certexceptionsui.js \ - browser_privatebrowsing_crh.js \ - browser_privatebrowsing_downloadLastDir.js \ - browser_privatebrowsing_downloadLastDir_c.js \ - browser_privatebrowsing_downloadLastDir_toggle.js \ - browser_privatebrowsing_DownloadLastDirWithCPS.js \ - browser_privatebrowsing_geoprompt.js \ - browser_privatebrowsing_geoprompt_page.html \ - browser_privatebrowsing_localStorage.js \ - browser_privatebrowsing_localStorage_before_after.js \ - browser_privatebrowsing_localStorage_before_after_page.html \ - browser_privatebrowsing_localStorage_before_after_page2.html \ - browser_privatebrowsing_localStorage_page1.html \ - browser_privatebrowsing_localStorage_page2.html \ - browser_privatebrowsing_opendir.js \ - browser_privatebrowsing_openlocation.js \ - browser_privatebrowsing_openLocationLastURL.js \ - browser_privatebrowsing_placestitle.js \ - browser_privatebrowsing_popupblocker.js \ - browser_privatebrowsing_protocolhandler.js \ - browser_privatebrowsing_protocolhandler_page.html \ - browser_privatebrowsing_theming.js \ - browser_privatebrowsing_ui.js \ - browser_privatebrowsing_urlbarfocus.js \ - browser_privatebrowsing_windowtitle.js \ - browser_privatebrowsing_windowtitle_page.html \ - browser_privatebrowsing_zoom.js \ - browser_privatebrowsing_zoomrestore.js \ - ctxmenu.html \ - ctxmenu-image.png \ - popup.html \ - title.sjs \ - $(NULL) - -# Turn off private browsing tests that perma-timeout on Linux. -ifneq (Linux,$(OS_ARCH)) -MOCHITEST_BROWSER_FILES += \ - browser_privatebrowsing_cookieacceptdialog.js \ - $(NULL) -endif - -include $(topsrcdir)/config/rules.mk diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_DownloadLastDirWithCPS.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_DownloadLastDirWithCPS.js deleted file mode 100644 index 874b1fa91dfe..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_DownloadLastDirWithCPS.js +++ /dev/null @@ -1,259 +0,0 @@ -/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */ - -let gTests; -function test() { - waitForExplicitFinish(); - gTests = runTest(); - moveAlong(); -} - -function moveAlong() { - try { - gTests.next(); - } catch (x if x instanceof StopIteration) { - finish(); - } -} - -function waitForPB() { - function observer(aSubject, aTopic, aData) { - Services.obs.removeObserver(observer, "last-pb-context-exited", false); - executeSoon(moveAlong); - } - Services.obs.addObserver(observer, "last-pb-context-exited", false); -} - -function runTest() { - let tmpScope = {}; - Cu.import("resource://gre/modules/DownloadLastDir.jsm", tmpScope); - let gDownloadLastDir = new tmpScope.DownloadLastDir(window); - Cu.import("resource://gre/modules/Services.jsm"); - Cu.import("resource://gre/modules/FileUtils.jsm", tmpScope); - let FileUtils = tmpScope.FileUtils; - - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - function clearHistory() { - // simulate clearing the private data - Services.obs.notifyObservers(null, "browser:purge-session-history", ""); - } - - is(typeof gDownloadLastDir, "object", "gDownloadLastDir should be a valid object"); - is(gDownloadLastDir.file, null, "LastDir pref should be null to start with"); - - let tmpDir = FileUtils.getDir("TmpD", [], true); - - let uri1 = Services.io.newURI("http://test1.com/", null, null); - let uri2 = Services.io.newURI("http://test2.com/", null, null); - let uri3 = Services.io.newURI("http://test3.com/", null, null); - let uri4 = Services.io.newURI("http://test4.com/", null, null); - - function newDir() { - let dir = tmpDir.clone(); - dir.append("testdir"); - dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0700); - return dir; - } - - let dir1 = newDir(); - let dir2 = newDir(); - let dir3 = newDir(); - try { - { // set up last dir - gDownloadLastDir.setFile(null, tmpDir); - is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to the tmpDir"); - isnot(gDownloadLastDir.file, tmpDir, "gDownloadLastDir.file should not be pointing to tmpDir"); - } - - { // set uri1 to dir1, all should now return dir1 - // also check that a new object is returned - gDownloadLastDir.setFile(uri1, dir1); - is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should return dir1"); - isnot(gDownloadLastDir.file, dir1, "gDownloadLastDir.file should not return dir1"); - is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1"); // set in CPS - isnot(gDownloadLastDir.getFile(uri1), dir1, "getFile on uri1 should not return dir1"); - is(gDownloadLastDir.getFile(uri2).path, dir1.path, "uri2 should return dir1"); // fallback - isnot(gDownloadLastDir.getFile(uri2), dir1, "getFile on uri2 should not return dir1"); - is(gDownloadLastDir.getFile(uri3).path, dir1.path, "uri3 should return dir1"); // fallback - isnot(gDownloadLastDir.getFile(uri3), dir1, "getFile on uri3 should not return dir1"); - is(gDownloadLastDir.getFile(uri4).path, dir1.path, "uri4 should return dir1"); // fallback - isnot(gDownloadLastDir.getFile(uri4), dir1, "getFile on uri4 should not return dir1"); - } - - { // set uri2 to dir2, all except uri1 should now return dir2 - gDownloadLastDir.setFile(uri2, dir2); - is(gDownloadLastDir.file.path, dir2.path, "gDownloadLastDir should point to dir2"); - is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1"); // set in CPS - is(gDownloadLastDir.getFile(uri2).path, dir2.path, "uri2 should return dir2"); // set in CPS - is(gDownloadLastDir.getFile(uri3).path, dir2.path, "uri3 should return dir2"); // fallback - is(gDownloadLastDir.getFile(uri4).path, dir2.path, "uri4 should return dir2"); // fallback - } - - { // set uri3 to dir3, all except uri1 and uri2 should now return dir3 - gDownloadLastDir.setFile(uri3, dir3); - is(gDownloadLastDir.file.path, dir3.path, "gDownloadLastDir should point to dir3"); - is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1"); // set in CPS - is(gDownloadLastDir.getFile(uri2).path, dir2.path, "uri2 should return dir2"); // set in CPS - is(gDownloadLastDir.getFile(uri3).path, dir3.path, "uri3 should return dir3"); // set in CPS - is(gDownloadLastDir.getFile(uri4).path, dir3.path, "uri4 should return dir4"); // fallback - } - - { // set uri1 to dir2, all except uri3 should now return dir2 - gDownloadLastDir.setFile(uri1, dir2); - is(gDownloadLastDir.file.path, dir2.path, "gDownloadLastDir should point to dir2"); - is(gDownloadLastDir.getFile(uri1).path, dir2.path, "uri1 should return dir2"); // set in CPS - is(gDownloadLastDir.getFile(uri2).path, dir2.path, "uri2 should return dir2"); // set in CPS - is(gDownloadLastDir.getFile(uri3).path, dir3.path, "uri3 should return dir3"); // set in CPS - is(gDownloadLastDir.getFile(uri4).path, dir2.path, "uri4 should return dir2"); // fallback - } - - { // check clearHistory removes all data - clearHistory(); - is(gDownloadLastDir.file, null, "clearHistory removes all data"); - is(Services.contentPrefs.hasPref(uri1, "browser.download.lastDir", null), false, "LastDir preference should be absent"); - is(gDownloadLastDir.getFile(uri1), null, "uri1 should point to null"); - is(gDownloadLastDir.getFile(uri2), null, "uri2 should point to null"); - is(gDownloadLastDir.getFile(uri3), null, "uri3 should point to null"); - is(gDownloadLastDir.getFile(uri4), null, "uri4 should point to null"); - } - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - { // check data set outside PB mode is remembered - gDownloadLastDir.setFile(null, tmpDir); - pb.privateBrowsingEnabled = true; - is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to tmpDir inside PB mode"); - is(gDownloadLastDir.getFile(uri1).path, tmpDir.path, "uri1 should return tmpDir inside PB mode"); - - waitForPB(); - pb.privateBrowsingEnabled = false; - yield; - is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to tmpDir outside PB mode"); - is(gDownloadLastDir.getFile(uri1).path, tmpDir.path, "uri1 should return tmpDir outside PB mode"); - - clearHistory(); - } - - { // check data set using CPS outside PB mode is remembered - gDownloadLastDir.setFile(uri1, dir1); - pb.privateBrowsingEnabled = true; - is(gDownloadLastDir.file.path, dir1.path, "LastDir should point to dir1 inside PB mode"); - is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1 inside PB mode"); - - waitForPB(); - pb.privateBrowsingEnabled = false; - yield; - is(gDownloadLastDir.file.path, dir1.path, "LastDir should point to dir1 outside PB mode"); - is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1 outside PB mode"); - - clearHistory(); - } - - { // check data set inside PB mode is forgotten - pb.privateBrowsingEnabled = true; - gDownloadLastDir.setFile(null, tmpDir); - is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should return tmpDir inside PB mode"); - is(gDownloadLastDir.getFile(uri1).path, tmpDir.path, "uri1 should return tmpDir inside PB mode"); - - waitForPB(); - pb.privateBrowsingEnabled = false; - yield; - is(gDownloadLastDir.file, null, "LastDir should be null outside PB mode"); - is(gDownloadLastDir.getFile(uri1), null, "uri1 should return null outside PB mode"); - - clearHistory(); - } - - { // check data set using CPS inside PB mode is forgotten - pb.privateBrowsingEnabled = true; - gDownloadLastDir.setFile(uri1, dir1); - is(gDownloadLastDir.file.path, dir1.path, "LastDir should point to dir1 inside PB mode"); - is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1 inside PB mode"); - - waitForPB(); - pb.privateBrowsingEnabled = false; - yield; - is(gDownloadLastDir.file, null, "LastDir should point to null outside PB mode"); - is(gDownloadLastDir.getFile(uri1), null, "uri1 should return null outside PB mode"); - - clearHistory(); - } - - { // check data set outside PB mode but changed inside is remembered correctly - gDownloadLastDir.setFile(uri1, dir1); - pb.privateBrowsingEnabled = true; - gDownloadLastDir.setFile(uri1, dir2); - is(gDownloadLastDir.file.path, dir2.path, "LastDir should point to dir2 inside PB mode"); - is(gDownloadLastDir.getFile(uri1).path, dir2.path, "uri1 should return dir2 inside PB mode"); - - waitForPB(); - pb.privateBrowsingEnabled = false; - yield; - is(gDownloadLastDir.file.path, dir1.path, "LastDir should point to dir1 outside PB mode"); - is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1 outside PB mode"); - - // check that the last dir store got cleared - pb.privateBrowsingEnabled = true; - is(gDownloadLastDir.file.path, dir1.path, "LastDir should be cleared"); - is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1"); - - waitForPB(); - pb.privateBrowsingEnabled = false; - yield; - clearHistory(); - } - - { // check clearHistory inside PB mode clears data outside PB mode - pb.privateBrowsingEnabled = true; - gDownloadLastDir.setFile(uri1, dir2); - - clearHistory(); - is(gDownloadLastDir.file, null, "LastDir should be null afer clearing history"); - is(gDownloadLastDir.getFile(uri1), null, "uri1 should return null"); - - waitForPB(); - pb.privateBrowsingEnabled = false; - yield; - is(gDownloadLastDir.file, null, "LastDir should be null"); - is(gDownloadLastDir.getFile(uri1), null, "uri1 should return null"); - } - - { // check that disabling CPS works - Services.prefs.setBoolPref("browser.download.lastDir.savePerSite", false); - - gDownloadLastDir.setFile(uri1, dir1); - is(gDownloadLastDir.file.path, dir1.path, "LastDir should be set to dir1"); - is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1"); - is(gDownloadLastDir.getFile(uri2).path, dir1.path, "uri2 should return dir1"); - is(gDownloadLastDir.getFile(uri3).path, dir1.path, "uri3 should return dir1"); - is(gDownloadLastDir.getFile(uri4).path, dir1.path, "uri4 should return dir1"); - - gDownloadLastDir.setFile(uri2, dir2); - is(gDownloadLastDir.file.path, dir2.path, "LastDir should be set to dir2"); - is(gDownloadLastDir.getFile(uri1).path, dir2.path, "uri1 should return dir2"); - is(gDownloadLastDir.getFile(uri2).path, dir2.path, "uri2 should return dir2"); - is(gDownloadLastDir.getFile(uri3).path, dir2.path, "uri3 should return dir2"); - is(gDownloadLastDir.getFile(uri4).path, dir2.path, "uri4 should return dir2"); - - Services.prefs.clearUserPref("browser.download.lastDir.savePerSite"); - } - - { // check that passing null to setFile clears the stored value - gDownloadLastDir.setFile(uri3, dir3); - is(gDownloadLastDir.getFile(uri3).path, dir3.path, "LastDir should be set to dir3"); - gDownloadLastDir.setFile(uri3, null); - is(gDownloadLastDir.getFile(uri3), null, "uri3 should return null"); - } - } finally { - dir1.remove(true); - dir2.remove(true); - dir3.remove(true); - Services.prefs.clearUserPref("browser.download.lastDir.savePerSite"); - Services.prefs.clearUserPref("browser.download.lastDir"); - gDownloadLastDir.cleanupPrivateFile(); - } -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_certexceptionsui.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_certexceptionsui.js deleted file mode 100644 index 858f0942f024..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_certexceptionsui.js +++ /dev/null @@ -1,55 +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 makes sure that certificate exceptions UI behaves correctly -// inside the private browsing mode, based on whether it's opened from the prefs -// window or from the SSL error page (see bug 461627). - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - const EXCEPTIONS_DLG_URL = 'chrome://pippki/content/exceptionDialog.xul'; - const EXCEPTIONS_DLG_FEATURES = 'chrome,centerscreen'; - const INVALID_CERT_LOCATION = 'https://nocert.example.com/'; - waitForExplicitFinish(); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - doTest(); - - // Test the certificate exceptions dialog - function doTest() { - let params = { - exceptionAdded : false, - location: INVALID_CERT_LOCATION, - prefetchCert: true, - }; - function testCheckbox() { - win.removeEventListener("load", testCheckbox, false); - Services.obs.addObserver(function (aSubject, aTopic, aData) { - Services.obs.removeObserver(arguments.callee, "cert-exception-ui-ready", false); - ok(win.gCert, "The certificate information should be available now"); - - let checkbox = win.document.getElementById("permanent"); - ok(checkbox.hasAttribute("disabled"), - "the permanent checkbox should be disabled when handling the private browsing mode"); - ok(!checkbox.hasAttribute("checked"), - "the permanent checkbox should not be checked when handling the private browsing mode"); - win.close(); - cleanup(); - }, "cert-exception-ui-ready", false); - } - var win = openDialog(EXCEPTIONS_DLG_URL, "", EXCEPTIONS_DLG_FEATURES, params); - win.addEventListener("load", testCheckbox, false); - } - - function cleanup() { - // leave the private browsing mode - pb.privateBrowsingEnabled = false; - finish(); - } -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_cookieacceptdialog.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_cookieacceptdialog.js deleted file mode 100644 index d86bd536e5f8..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_cookieacceptdialog.js +++ /dev/null @@ -1,81 +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 makes sure that private browsing mode disables the "remember" -// option in the cookie accept dialog. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - let cp = Cc["@mozilla.org/embedcomp/cookieprompt-service;1"]. - getService(Ci.nsICookiePromptService); - - waitForExplicitFinish(); - - function checkRememberOption(expectedDisabled, callback) { - function observer(aSubject, aTopic, aData) { - if (aTopic != "domwindowopened") - return; - - Services.ww.unregisterNotification(observer); - let win = aSubject.QueryInterface(Ci.nsIDOMWindow); - win.addEventListener("load", function onLoad(event) { - win.removeEventListener("load", onLoad, false); - - executeSoon(function () { - let doc = win.document; - let remember = doc.getElementById("persistDomainAcceptance"); - ok(remember, "The remember checkbox should exist"); - - if (expectedDisabled) - is(remember.getAttribute("disabled"), "true", - "The checkbox should be disabled"); - else - ok(!remember.hasAttribute("disabled"), - "The checkbox should not be disabled"); - - win.close(); - callback(); - }); - }, false); - } - Services.ww.registerNotification(observer); - - let remember = {}; - const time = (new Date("Jan 1, 2030")).getTime() / 1000; - let cookie = { - name: "foo", - value: "bar", - isDomain: true, - host: "mozilla.org", - path: "/baz", - isSecure: false, - expires: time, - status: 0, - policy: 0, - isSession: false, - expiry: time, - isHttpOnly: true, - QueryInterface: function(iid) { - const validIIDs = [Ci.nsISupports, - Ci.nsICookie, - Ci.nsICookie2]; - for (var i = 0; i < validIIDs.length; ++i) - if (iid == validIIDs[i]) - return this; - throw Cr.NS_ERROR_NO_INTERFACE; - } - }; - cp.cookieDialog(window, cookie, "mozilla.org", 10, false, remember); - } - - checkRememberOption(false, function() { - pb.privateBrowsingEnabled = true; - checkRememberOption(true, function() { - pb.privateBrowsingEnabled = false; - checkRememberOption(false, finish); - }); - }); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_crh.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_crh.js deleted file mode 100644 index cf336fff93e9..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_crh.js +++ /dev/null @@ -1,30 +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 makes sure that the Clear Recent History menu item and command -// is disabled inside the private browsing mode. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - let crhCommand = document.getElementById("Tools:Sanitize"); - - // make sure the command is not disabled to begin with - ok(!crhCommand.hasAttribute("disabled"), - "Clear Recent History command should not be disabled outside of the private browsing mode"); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - ok(crhCommand.hasAttribute("disabled"), - "Clear Recent History command should be disabled inside of the private browsing mode"); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - ok(!crhCommand.hasAttribute("disabled"), - "Clear Recent History command should not be disabled after leaving the private browsing mode"); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir.js deleted file mode 100644 index 2260de4d0c7d..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir.js +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */ - -function test() { - let tempScope = {}; - let downloadModule = {}; - Cu.import("resource://gre/modules/Services.jsm"); - Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule); - Cu.import("resource://gre/modules/FileUtils.jsm", tempScope); - let FileUtils = tempScope.FileUtils; - let MockFilePicker = SpecialPowers.MockFilePicker; - let gDownloadLastDir = new downloadModule.DownloadLastDir(window); - - let launcher = { - source: Services.io.newURI("http://test1.com/file", null, null) - }; - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - MockFilePicker.init(window); - MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK; - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let prefs = Services.prefs.getBranch("browser.download."); - let launcherDialog = Cc["@mozilla.org/helperapplauncherdialog;1"]. - getService(Ci.nsIHelperAppLauncherDialog); - let tmpDir = FileUtils.getDir("TmpD", [], true); - function newDirectory() { - let dir = tmpDir.clone(); - dir.append("testdir"); - dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0700); - return dir; - } - function newFileInDirectory(dir) { - let file = dir.clone(); - file.append("testfile"); - file.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0600); - return file; - } - - let dir1 = newDirectory(); - let dir2 = newDirectory(); - let dir3 = newDirectory(); - let file1 = newFileInDirectory(dir1); - let file2 = newFileInDirectory(dir2); - let file3 = newFileInDirectory(dir3); - - // cleanup functions registration - registerCleanupFunction(function () { - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - Services.prefs.clearUserPref("browser.download.lastDir"); - [dir1, dir2, dir3].forEach(function(dir) dir.remove(true)); - MockFilePicker.cleanup(); - gDownloadLastDir.cleanupPrivateFile(); - delete FileUtils; - }); - - let context = gBrowser.selectedBrowser.contentWindow; - - prefs.setComplexValue("lastDir", Ci.nsIFile, tmpDir); - MockFilePicker.returnFiles = [file1]; - let file = launcherDialog.promptForSaveToFile(launcher, context, null, null, null); - ok(!!file, "promptForSaveToFile correctly returned a file"); - // file picker should start with browser.download.lastDir - is(MockFilePicker.displayDirectory.path, tmpDir.path, "File picker should start with browser.download.lastDir"); - // browser.download.lastDir should be modified before entering the private browsing mode - is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should be modified before entering the PB mode"); - // gDownloadLastDir should be usable outside of the private browsing mode - is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should be usable outside of the PB mode"); - - pb.privateBrowsingEnabled = true; - is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should be that set before entering PB mode"); - MockFilePicker.returnFiles = [file2]; - MockFilePicker.displayDirectory = null; - file = launcherDialog.promptForSaveToFile(launcher, context, null, null, null); - ok(!!file, "promptForSaveToFile correctly returned a file"); - // file picker should start with browser.download.lastDir as set before entering the private browsing mode - is(MockFilePicker.displayDirectory.path, dir1.path, "Start with LastDir as set before entering the PB mode"); - // browser.download.lastDir should not be modified inside the private browsing mode - is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should not be modified inside the PB mode"); - // but gDownloadLastDir should be modified - is(gDownloadLastDir.file.path, dir2.path, "gDownloadLastDir should be modified inside PB mode"); - - pb.privateBrowsingEnabled = false; - // gDownloadLastDir should be cleared after leaving the private browsing mode - is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should be cleared after leaving the PB mode"); - MockFilePicker.returnFiles = [file3]; - MockFilePicker.displayDirectory = null; - file = launcherDialog.promptForSaveToFile(launcher, context, null, null, null); - ok(!!file, "promptForSaveToFile correctly returned a file"); - // file picker should start with browser.download.lastDir as set before entering the private browsing mode - is(MockFilePicker.displayDirectory.path, dir1.path, "Start with LastDir as set before entering the PB mode"); - // browser.download.lastDir should be modified after leaving the private browsing mode - is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir3.path, "LastDir should be modified after leaving the PB mode"); - // gDownloadLastDir should be usable after leaving the private browsing mode - is(gDownloadLastDir.file.path, dir3.path, "gDownloadLastDir should be usable after leaving the PB mode"); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir_c.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir_c.js deleted file mode 100644 index b0a4b507eb55..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir_c.js +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */ - -function test() { - let tmpScope = {}; - let downloadModule = {}; - Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule); - Cu.import("resource://gre/modules/FileUtils.jsm", tmpScope); - let FileUtils = tmpScope.FileUtils; - Cu.import("resource://gre/modules/Services.jsm"); - let MockFilePicker = SpecialPowers.MockFilePicker; - let gDownloadLastDir = new downloadModule.DownloadLastDir(window); - - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - MockFilePicker.init(window); - MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK; - - //let stringBundleToRestore = ContentAreaUtils.stringBundle; - let validateFileNameToRestore = validateFileName; - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let prefs = Services.prefs.getBranch("browser.download."); - let tmpDir = FileUtils.getDir("TmpD", [], true); - function newDirectory() { - let dir = tmpDir.clone(); - dir.append("testdir"); - dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0700); - return dir; - } - - function newFileInDirectory(dir) { - let file = dir.clone(); - file.append("testfile"); - file.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0600); - return file; - } - - let dir1 = newDirectory(); - let dir2 = newDirectory(); - let dir3 = newDirectory(); - let file1 = newFileInDirectory(dir1); - let file2 = newFileInDirectory(dir2); - let file3 = newFileInDirectory(dir3); - - // cleanup function registration - registerCleanupFunction(function () { - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - Services.prefs.clearUserPref("browser.download.lastDir"); - [dir1, dir2, dir3].forEach(function(dir) dir.remove(true)); - MockFilePicker.cleanup(); - //ContentAreaUtils.stringBundle = stringBundleToRestore; - validateFileName = validateFileNameToRestore; - gDownloadLastDir.cleanupPrivateFile(); - delete FileUtils; - }); - - // Overwrite stringBundle to return an object masquerading as a string bundle - /*delete ContentAreaUtils.stringBundle; - ContentAreaUtils.stringBundle = { - GetStringFromName: function() "" - };*/ - - // Overwrite validateFileName to validate everything - validateFileName = function(foo) foo; - - let params = { - //fpTitleKey: "test", - fileInfo: new FileInfo("test.txt", "test.txt", "test", "txt", "http://mozilla.org/test.txt"), - contentType: "text/plain", - saveMode: SAVEMODE_FILEONLY, - saveAsType: kSaveAsType_Complete, - file: null - }; - - prefs.setComplexValue("lastDir", Ci.nsIFile, tmpDir); - MockFilePicker.returnFiles = [file1]; - MockFilePicker.displayDirectory = null; - ok(getTargetFile(params), "Show the file picker dialog with given params"); - // file picker should start with browser.download.lastDir - is(MockFilePicker.displayDirectory.path, tmpDir.path, "file picker should start with browser.download.lastDir"); - // browser.download.lastDir should be modified before entering the private browsing mode - is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should be modified before entering PB mode"); - // gDownloadLastDir should be usable outside of the private browsing mode - is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should be usable outside of the PB mode"); - - pb.privateBrowsingEnabled = true; - is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should be that set before PB mode"); - MockFilePicker.returnFiles = [file2]; - MockFilePicker.displayDirectory = null; - ok(getTargetFile(params), "Show the file picker dialog with the given params"); - // file picker should start with browser.download.lastDir as set before entering the private browsing mode - is(MockFilePicker.displayDirectory.path, dir1.path, "File picker should start with LastDir set before entering PB mode"); - // browser.download.lastDir should not be modified inside the private browsing mode - is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should not be modified inside PB mode"); - // but gDownloadLastDir should be modified - is(gDownloadLastDir.file.path, dir2.path, "gDownloadLastDir should be modified"); - - pb.privateBrowsingEnabled = false; - // gDownloadLastDir should be cleared after leaving the private browsing mode - is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should be cleared after leaving PB mode"); - MockFilePicker.returnFiles = [file3]; - MockFilePicker.displayDirectory = null; - ok(getTargetFile(params), "Show the file picker dialog with the given params"); - // file picker should start with browser.download.lastDir as set before entering the private browsing mode - is(MockFilePicker.displayDirectory.path, dir1.path, "File picker should start with LastDir set before PB mode"); - // browser.download.lastDir should be modified after leaving the private browsing mode - is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir3.path, "LastDir should be modified after leaving PB mode"); - // gDownloadLastDir should be usable after leaving the private browsing mode - is(gDownloadLastDir.file.path, dir3.path, "gDownloadLastDir should be usable after leaving PB mode"); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir_toggle.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir_toggle.js deleted file mode 100644 index 1613dfc38885..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_downloadLastDir_toggle.js +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */ - -function test() { - var tmpScope = {}; - let downloadModule = {}; - Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule); - Cu.import("resource://gre/modules/FileUtils.jsm", tmpScope); - Cu.import("resource://gre/modules/Services.jsm"); - let FileUtils = tmpScope.FileUtils; - let gDownloadLastDir = new downloadModule.DownloadLastDir(window); - - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - function clearHistory() { - // simulate clearing the private data - Services.obs.notifyObservers(null, "browser:purge-session-history", ""); - } - - is(typeof gDownloadLastDir, "object", "gDownloadLastDir should be a valid object"); - is(gDownloadLastDir.file, null, "gDownloadLastDir.file should be null to start with"); - let tmpDir = FileUtils.getDir("TmpD", [], true); - let newDir = tmpDir.clone(); - - registerCleanupFunction(function () { - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - Services.prefs.clearUserPref("browser.download.lastDir"); - newDir.remove(true); - gDownloadLastDir.cleanupPrivateFile(); - delete FileUtils; - }); - - newDir.append("testdir"); - newDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0700); - - gDownloadLastDir.file = tmpDir; - is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to the temporary directory"); - isnot(gDownloadLastDir.file, tmpDir, "gDownloadLastDir.file should not be pointing to the tmpDir"); - - gDownloadLastDir.file = 1; // not an nsIFile - is(gDownloadLastDir.file, null, "gDownloadLastDir.file should be null"); - gDownloadLastDir.file = tmpDir; - - clearHistory(); - is(gDownloadLastDir.file, null, "gDownloadLastDir.file should be null"); - gDownloadLastDir.file = tmpDir; - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - pb.privateBrowsingEnabled = true; - is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to the temporary directory"); - isnot(gDownloadLastDir.file, tmpDir, "gDownloadLastDir.file should not be pointing to the tmpDir"); - - pb.privateBrowsingEnabled = false; - is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to the tmpDir"); - pb.privateBrowsingEnabled = true; - - gDownloadLastDir.file = newDir; - is(gDownloadLastDir.file.path, newDir.path, "gDownloadLastDir should be modified in PB mode"); - isnot(gDownloadLastDir.file, newDir, "gDownloadLastDir should not point to the newDir"); - - pb.privateBrowsingEnabled = false; - is(gDownloadLastDir.file.path, tmpDir.path, "gDownloadLastDir should point to the earlier directory outside PB mode"); - isnot(gDownloadLastDir.file, tmpDir, "gDownloadLastDir should not be modifief outside PB mode"); - - pb.privateBrowsingEnabled = true; - isnot(gDownloadLastDir.file, null, "gDownloadLastDir should not be null inside PB mode"); - clearHistory(); - is(gDownloadLastDir.file, null, "gDownloadLastDir should be null after clearing history"); - - pb.privateBrowsingEnabled = false; - is(gDownloadLastDir.file, null, "gDownloadLastDir should be null outside PB mode"); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt.js deleted file mode 100644 index 2ef8e08aa59d..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt.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/. */ - -// This test makes sure that the geolocation prompt does not show a remember -// control inside the private browsing mode. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - const testPageURL = "http://mochi.test:8888/browser/" + - "browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt_page.html"; - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function () { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - let notification = PopupNotifications.getNotification("geolocation"); - ok(notification, "Notification should exist"); - ok(notification.secondaryActions.length > 1, "Secondary actions should exist (always/never remember)"); - notification.remove(); - - gBrowser.removeCurrentTab(); - - // enter the private browsing mode - pb.privateBrowsingEnabled = true; - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function () { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - // Make sure the notification is correctly displayed without a remember control - let notification = PopupNotifications.getNotification("geolocation"); - ok(notification, "Notification should exist"); - is(notification.secondaryActions.length, 0, "Secondary actions shouldn't exist (always/never remember)"); - notification.remove(); - - gBrowser.removeCurrentTab(); - - // cleanup - pb.privateBrowsingEnabled = false; - finish(); - }, true); - content.location = testPageURL; - }, true); - content.location = testPageURL; -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt_page.html b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt_page.html deleted file mode 100644 index 36d5e3ceccff..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt_page.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Geolocation invoker - - - - - diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage.js deleted file mode 100644 index 327370b356aa..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage.js +++ /dev/null @@ -1,26 +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 pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - waitForExplicitFinish(); - pb.privateBrowsingEnabled = true; - let tab = gBrowser.selectedTab = gBrowser.addTab(); - let browser = gBrowser.selectedBrowser; - browser.addEventListener('load', function() { - browser.removeEventListener('load', arguments.callee, true); - let tab2 = gBrowser.selectedTab = gBrowser.addTab(); - browser.contentWindow.location = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/' + - 'browser_privatebrowsing_localStorage_page2.html'; - browser.addEventListener('load', function() { - browser.removeEventListener('load', arguments.callee, true); - is(browser.contentWindow.document.title, '2', "localStorage should contain 2 items"); - pb.privateBrowsingEnabled = false; - finish(); - }, true); - }, true); - browser.loadURI('http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/' + - 'browser_privatebrowsing_localStorage_page1.html'); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after.js deleted file mode 100644 index 2b8897b303e1..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after.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/. */ - -// Ensure that a storage instance used by both private and public sessions at different times does not -// allow any data to leak due to cached values. - -// Step 1: Load browser_privatebrowsing_localStorage_before_after_page.html in a private tab, causing a storage -// item to exist. Close the tab. -// Step 2: Load the same page in a non-private tab, ensuring that the storage instance reports only one item -// existing. - -function test() { - let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/'; - waitForExplicitFinish(); - - // We wait for a GC to ensure that all previous PB docshells in this test suite are destroyed - // so that the PB localStorage instance is clean. - Components.utils.schedulePreciseGC(function() { - let tab = gBrowser.selectedTab = gBrowser.addTab(); - let browser = gBrowser.selectedBrowser; - browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true; - browser.addEventListener('load', function() { - browser.removeEventListener('load', arguments.callee, true); - is(browser.contentWindow.document.title, '1', "localStorage should contain 1 item"); - browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false; - - gBrowser.selectedTab = gBrowser.addTab(); - let browser2 = gBrowser.selectedBrowser; - gBrowser.removeTab(tab); - browser2.addEventListener('load', function() { - browser2.removeEventListener('load', arguments.callee, true); - is(browser2.contentWindow.document.title, 'null|0', 'localStorage should contain 0 items'); - gBrowser.removeCurrentTab(); - finish(); - }, true); - browser2.loadURI(prefix + 'browser_privatebrowsing_localStorage_before_after_page2.html'); - }, true); - browser.loadURI(prefix + 'browser_privatebrowsing_localStorage_before_after_page.html'); - }); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page.html b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page.html deleted file mode 100644 index 143fea4e72a6..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page2.html b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page2.html deleted file mode 100644 index 9a7e2da630dd..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page2.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page1.html b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page1.html deleted file mode 100644 index 3e79a01bf8e7..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page1.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page2.html b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page2.html deleted file mode 100644 index 8c9b28fd8050..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page2.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_openLocationLastURL.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_openLocationLastURL.js deleted file mode 100644 index 3b4ce94164d2..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_openLocationLastURL.js +++ /dev/null @@ -1,63 +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() { - const URL_1 = "mozilla.org"; - const URL_2 = "mozilla.com"; - - let openLocationLastURL = getLocationModule(); - let privateBrowsingService = - Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - function clearHistory() { - Services.obs.notifyObservers(null, "browser:purge-session-history", ""); - } - function testURL(aTestNumber, aValue) { - is(openLocationLastURL.value, aValue, - "Test: " + aTestNumber + ": Validate last url value."); - } - - // Clean to start testing. - is(typeof openLocationLastURL, "object", "Validate type of last url."); - openLocationLastURL.reset(); - testURL(1, ""); - - // Test without private browsing. - openLocationLastURL.value = URL_1; - testURL(2, URL_1); - openLocationLastURL.value = ""; - testURL(3, ""); - openLocationLastURL.value = URL_2; - testURL(4, URL_2); - clearHistory(); - testURL(5, ""); - - // Test changing private browsing. - openLocationLastURL.value = URL_2; - privateBrowsingService.privateBrowsingEnabled = true; - testURL(6, ""); - privateBrowsingService.privateBrowsingEnabled = false; - testURL(7, URL_2); - privateBrowsingService.privateBrowsingEnabled = true; - openLocationLastURL.value = URL_1; - testURL(8, URL_1); - privateBrowsingService.privateBrowsingEnabled = false; - testURL(9, URL_2); - privateBrowsingService.privateBrowsingEnabled = true; - openLocationLastURL.value = URL_1; - testURL(10, URL_1); - - // Test cleaning history. - clearHistory(); - testURL(11, ""); - privateBrowsingService.privateBrowsingEnabled = false; - testURL(12, ""); -} - -function getLocationModule() { - let openLocationModule = {}; - Cu.import("resource:///modules/openLocationLastURL.jsm", openLocationModule); - return new openLocationModule.OpenLocationLastURL(window); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_opendir.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_opendir.js deleted file mode 100644 index 446d254dc7c1..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_opendir.js +++ /dev/null @@ -1,109 +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 makes sure that the last open directory used inside the private -// browsing mode is not remembered after leaving that mode. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - let ds = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties); - let dir1 = ds.get("ProfD", Ci.nsIFile); - let dir2 = ds.get("TmpD", Ci.nsIFile); - let file = dir2.clone(); - file.append("pbtest.file"); - file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600); - - const kPrefName = "browser.open.lastDir"; - - function setupCleanSlate() { - gLastOpenDirectory.reset(); - gPrefService.clearUserPref(kPrefName); - } - - setupCleanSlate(); - - // Test 1: general workflow test - - // initial checks - ok(!gLastOpenDirectory.path, - "Last open directory path should be initially empty"); - gLastOpenDirectory.path = dir2; - is(gLastOpenDirectory.path.path, dir2.path, - "The path should be successfully set"); - gLastOpenDirectory.path = null; - is(gLastOpenDirectory.path.path, dir2.path, - "The path should be not change when assigning it to null"); - gLastOpenDirectory.path = dir1; - is(gLastOpenDirectory.path.path, dir1.path, - "The path should be successfully outside of the private browsing mode"); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - is(gLastOpenDirectory.path.path, dir1.path, - "The path should not change when entering the private browsing mode"); - gLastOpenDirectory.path = dir2; - is(gLastOpenDirectory.path.path, dir2.path, - "The path should successfully change inside the private browsing mode"); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - is(gLastOpenDirectory.path.path, dir1.path, - "The path should be reset to the same path as before entering the private browsing mode"); - - setupCleanSlate(); - - // Test 2: the user first tries to open a file inside the private browsing mode - - pb.privateBrowsingEnabled = true; - ok(!gLastOpenDirectory.path, - "No original path should exist inside the private browsing mode"); - gLastOpenDirectory.path = dir1; - is(gLastOpenDirectory.path.path, dir1.path, - "The path should be successfully set inside the private browsing mode"); - pb.privateBrowsingEnabled = false; - ok(!gLastOpenDirectory.path, - "The path set inside the private browsing mode should not leak when leaving that mode"); - - setupCleanSlate(); - - // Test 3: the last open directory is set from a previous session, it should be used - // in normal mode - - gPrefService.setComplexValue(kPrefName, Ci.nsILocalFile, dir1); - is(gLastOpenDirectory.path.path, dir1.path, - "The pref set from last session should take effect outside the private browsing mode"); - - setupCleanSlate(); - - // Test 4: the last open directory is set from a previous session, it should be used - // in private browsing mode mode - - gPrefService.setComplexValue(kPrefName, Ci.nsILocalFile, dir1); - pb.privateBrowsingEnabled = true; - is(gLastOpenDirectory.path.path, dir1.path, - "The pref set from last session should take effect inside the private browsing mode"); - pb.privateBrowsingEnabled = false; - is(gLastOpenDirectory.path.path, dir1.path, - "The pref set from last session should remain in effect after leaving the private browsing mode"); - - setupCleanSlate(); - - // Test 5: setting the path to a file shouldn't work - - gLastOpenDirectory.path = file; - ok(!gLastOpenDirectory.path, - "Setting the path to a file shouldn't work when it's originally null"); - gLastOpenDirectory.path = dir1; - gLastOpenDirectory.path = file; - is(gLastOpenDirectory.path.path, dir1.path, - "Setting the path to a file shouldn't work when it's not originally null"); - - // cleanup - file.remove(false); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_openlocation.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_openlocation.js deleted file mode 100644 index 6edb3884db67..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_openlocation.js +++ /dev/null @@ -1,78 +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 makes sure that Open Location dialog is usable inside the private browsing -// mode without leaving any trace of the URLs visited. - -function test() { - // initialization - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - waitForExplicitFinish(); - - function openLocation(url, autofilled, callback) { - function observer(aSubject, aTopic, aData) { - switch (aTopic) { - case "domwindowopened": - let dialog = aSubject.QueryInterface(Ci.nsIDOMWindow); - dialog.addEventListener("load", function () { - dialog.removeEventListener("load", arguments.callee, false); - - let browser = gBrowser.selectedBrowser; - browser.addEventListener("load", function() { - browser.removeEventListener("load", arguments.callee, true); - - is(browser.currentURI.spec, url, - "The correct URL should be loaded via the open location dialog"); - executeSoon(callback); - }, true); - - SimpleTest.waitForFocus(function() { - let input = dialog.document.getElementById("dialog.input"); - is(input.value, autofilled, "The input field should be correctly auto-filled"); - input.focus(); - for (let i = 0; i < url.length; ++i) - EventUtils.synthesizeKey(url[i], {}, dialog); - EventUtils.synthesizeKey("VK_RETURN", {}, dialog); - }, dialog); - }, false); - break; - - case "domwindowclosed": - Services.ww.unregisterNotification(arguments.callee); - break; - } - } - - Services.ww.registerNotification(observer); - gPrefService.setIntPref("general.open_location.last_window_choice", 0); - openDialog("chrome://browser/content/openLocation.xul", "_blank", - "chrome,titlebar", window); - } - - - if (gPrefService.prefHasUserValue("general.open_location.last_url")) - gPrefService.clearUserPref("general.open_location.last_url"); - - openLocation("http://example.com/", "", function() { - openLocation("http://example.org/", "http://example.com/", function() { - // enter private browsing mode - pb.privateBrowsingEnabled = true; - openLocation("about:logo", "", function() { - openLocation("about:buildconfig", "about:logo", function() { - // exit private browsing mode - pb.privateBrowsingEnabled = false; - openLocation("about:blank", "http://example.org/", function() { - gPrefService.clearUserPref("general.open_location.last_url"); - if (gPrefService.prefHasUserValue("general.open_location.last_window_choice")) - gPrefService.clearUserPref("general.open_location.last_window_choice"); - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - }); - }); - }); - }); - }); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_placestitle.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_placestitle.js deleted file mode 100644 index 1fc55f8c8c61..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_placestitle.js +++ /dev/null @@ -1,77 +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 makes sure that the title of existing history entries does not -// change inside the private browsing mode. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - let cm = Cc["@mozilla.org/cookiemanager;1"]. - getService(Ci.nsICookieManager); - waitForExplicitFinish(); - ignoreAllUncaughtExceptions(); - - const TEST_URL = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/title.sjs"; - - function waitForCleanup(aCallback) { - // delete all cookies - cm.removeAll(); - // delete all history items - waitForClearHistory(aCallback); - } - - let observer = { - pass: 1, - onTitleChanged: function(aURI, aPageTitle) { - if (aURI.spec != TEST_URL) - return; - switch (this.pass++) { - case 1: // the first time that the page is loaded - is(aPageTitle, "No Cookie", "The page should be loaded without any cookie for the first time"); - gBrowser.selectedTab = gBrowser.addTab(TEST_URL); - break; - case 2: // the second time that the page is loaded - is(aPageTitle, "Cookie", "The page should be loaded with a cookie for the second time"); - waitForCleanup(function () { - gBrowser.selectedTab = gBrowser.addTab(TEST_URL); - }); - break; - case 3: // before entering the private browsing mode - is(aPageTitle, "No Cookie", "The page should be loaded without any cookie again"); - // enter private browsing mode - pb.privateBrowsingEnabled = true; - gBrowser.selectedTab = gBrowser.addTab(TEST_URL); - executeSoon(function() { - PlacesUtils.history.removeObserver(observer); - pb.privateBrowsingEnabled = false; - while (gBrowser.browsers.length > 1) { - gBrowser.removeCurrentTab(); - } - waitForCleanup(finish); - }); - break; - default: - ok(false, "Unexpected pass: " + (this.pass - 1)); - } - }, - - onBeginUpdateBatch: function () {}, - onEndUpdateBatch: function () {}, - onVisit: function () {}, - onBeforeDeleteURI: function () {}, - onDeleteURI: function () {}, - onClearHistory: function () {}, - onPageChanged: function () {}, - onDeleteVisits: function() {}, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver]) - }; - PlacesUtils.history.addObserver(observer, false); - - waitForCleanup(function () { - gBrowser.selectedTab = gBrowser.addTab(TEST_URL); - }); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_popupblocker.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_popupblocker.js deleted file mode 100644 index d70690dda1ec..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_popupblocker.js +++ /dev/null @@ -1,68 +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 makes sure that private browsing mode disables the remember option -// for the popup blocker menu. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - let oldPopupPolicy = gPrefService.getBoolPref("dom.disable_open_during_load"); - gPrefService.setBoolPref("dom.disable_open_during_load", true); - - const TEST_URI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/popup.html"; - - waitForExplicitFinish(); - - function testPopupBlockerMenuItem(expectedDisabled, callback) { - gBrowser.addEventListener("DOMUpdatePageReport", function() { - gBrowser.removeEventListener("DOMUpdatePageReport", arguments.callee, false); - executeSoon(function() { - let notification = gBrowser.getNotificationBox().getNotificationWithValue("popup-blocked"); - - ok(notification, "The notification box should be displayed"); - - function checkMenuItem(callback) { - dump("CMI: in\n"); - document.addEventListener("popupshown", function(event) { - dump("CMI: popupshown\n"); - document.removeEventListener("popupshown", arguments.callee, false); - - if (expectedDisabled) - is(document.getElementById("blockedPopupAllowSite").getAttribute("disabled"), "true", - "The allow popups menu item should be disabled"); - - event.originalTarget.hidePopup(); - dump("CMI: calling back\n"); - callback(); - dump("CMI: called back\n"); - }, false); - dump("CMI: out\n"); - } - - checkMenuItem(function() { - gBrowser.removeTab(tab); - callback(); - }); - notification.querySelector("button").doCommand(); - }); - }, false); - - let tab = gBrowser.addTab(TEST_URI); - gBrowser.selectedTab = tab; - } - - testPopupBlockerMenuItem(false, function() { - pb.privateBrowsingEnabled = true; - testPopupBlockerMenuItem(true, function() { - pb.privateBrowsingEnabled = false; - testPopupBlockerMenuItem(false, function() { - gPrefService.setBoolPref("dom.disable_open_during_load", oldPopupPolicy); - finish(); - }); - }); - }); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler.js deleted file mode 100644 index 56934920b75c..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler.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/. */ - -// This test makes sure that the web pages can't register protocol handlers -// inside the private browsing mode. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - const testPageURL = "http://example.com/browser/" + - "browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler_page.html"; - waitForExplicitFinish(); - - const notificationValue = "Protocol Registration: testprotocol"; - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function () { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - setTimeout(function() { - // Make sure the notification is correctly displayed with a remember control - let notificationBox = gBrowser.getNotificationBox(); - let notification = notificationBox.getNotificationWithValue(notificationValue); - ok(notification, "Notification box should be displaying outside of private browsing mode"); - gBrowser.removeCurrentTab(); - - // enter the private browsing mode - pb.privateBrowsingEnabled = true; - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function () { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - setTimeout(function () { - // Make sure the notification is correctly displayed without a remember control - let notificationBox = gBrowser.getNotificationBox(); - let notification = notificationBox.getNotificationWithValue(notificationValue); - ok(!notification, "Notification box should not be displayed inside of private browsing mode"); - - gBrowser.removeCurrentTab(); - - // cleanup - pb.privateBrowsingEnabled = false; - finish(); - }, 100); // remember control is added in a setTimeout(0) call - }, true); - content.location = testPageURL; - }, 100); // remember control is added in a setTimeout(0) call - }, true); - content.location = testPageURL; -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler_page.html b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler_page.html deleted file mode 100644 index 74f846d54a7d..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler_page.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Protocol registrar page - - - - - diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_theming.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_theming.js deleted file mode 100644 index 8532bf9de481..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_theming.js +++ /dev/null @@ -1,32 +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 makes sure that privatebrowsingmode attribute of the window is correctly -// switched with private browsing mode changes. - -function test() { - // initialization - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - let docRoot = document.documentElement; - - ok(!docRoot.hasAttribute("privatebrowsingmode"), - "privatebrowsingmode should not be present in normal mode"); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - is(docRoot.getAttribute("privatebrowsingmode"), "temporary", - "privatebrowsingmode should be \"temporary\" inside the private browsing mode"); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - ok(!docRoot.hasAttribute("privatebrowsingmode"), - "privatebrowsingmode should not be present in normal mode"); - - // cleanup - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_ui.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_ui.js deleted file mode 100644 index 679383dd7639..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_ui.js +++ /dev/null @@ -1,102 +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 makes sure that the gPrivateBrowsingUI object, the Private Browsing -// menu item and its XUL element work correctly. - -function test() { - // initialization - waitForExplicitFinish(); - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - let observerData; - function observer(aSubject, aTopic, aData) { - if (aTopic == "private-browsing") - observerData = aData; - } - Services.obs.addObserver(observer, "private-browsing", false); - let pbMenuItem = document.getElementById("privateBrowsingItem"); - // add a new blank tab to ensure the title can be meaningfully compared later - gBrowser.selectedTab = gBrowser.addTab(); - let originalTitle = document.title; - - function testNewWindow(aCallback, expected) { - Services.obs.addObserver(function observer1(aSubject, aTopic, aData) { - aSubject.addEventListener("load", function() { - aSubject.removeEventListener("load", arguments.callee); - executeSoon(function() { - let ui = aSubject.gPrivateBrowsingUI; - is(ui.privateBrowsingEnabled, expected, "The privateBrowsingEnabled property on the new window is set correctly"); - is(PrivateBrowsingUtils.isWindowPrivate(aSubject), expected, "The private bit on the new window is set correctly"); - - Services.obs.addObserver(function observer2(aSubject, aTopic, aData) { - aCallback(); - Services.obs.removeObserver(observer2, "domwindowclosed"); - }, "domwindowclosed", false); - aSubject.close(); - }); - Services.obs.removeObserver(observer1, "domwindowopened"); - }, false); - }, "domwindowopened", false); - OpenBrowserWindow({private: PrivateBrowsingUtils.isWindowPrivate(window)}); - } - - // test the gPrivateBrowsingUI object - ok(gPrivateBrowsingUI, "The gPrivateBrowsingUI object exists"); - is(pb.privateBrowsingEnabled, false, "The private browsing mode should not be started initially"); - is(gPrivateBrowsingUI.privateBrowsingEnabled, false, "gPrivateBrowsingUI should expose the correct private browsing status"); - is(PrivateBrowsingUtils.isWindowPrivate(window), false, "PrivateBrowsingUtils should expose the correct per-window private browsing status"); - ok(pbMenuItem, "The Private Browsing menu item exists"); - is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("startlabel"), "The Private Browsing menu item should read \"Start Private Browsing\""); - testNewWindow(function() { - gPrivateBrowsingUI.toggleMode(); - is(pb.privateBrowsingEnabled, true, "The private browsing mode should be started"); - is(gPrivateBrowsingUI.privateBrowsingEnabled, true, "gPrivateBrowsingUI should expose the correct private browsing status"); - is(PrivateBrowsingUtils.isWindowPrivate(window), true, "PrivateBrowsingUtils should expose the correct per-window private browsing status"); - // check to see if the Private Browsing mode was activated successfully - is(observerData, "enter", "Private Browsing mode was activated using the gPrivateBrowsingUI object"); - is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("stoplabel"), "The Private Browsing menu item should read \"Stop Private Browsing\""); - testNewWindow(function() { - gPrivateBrowsingUI.toggleMode() - is(pb.privateBrowsingEnabled, false, "The private browsing mode should not be started"); - is(gPrivateBrowsingUI.privateBrowsingEnabled, false, "gPrivateBrowsingUI should expose the correct private browsing status"); - is(PrivateBrowsingUtils.isWindowPrivate(window), false, "PrivateBrowsingUtils should expose the correct per-window private browsing status"); - // check to see if the Private Browsing mode was deactivated successfully - is(observerData, "exit", "Private Browsing mode was deactivated using the gPrivateBrowsingUI object"); - is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("startlabel"), "The Private Browsing menu item should read \"Start Private Browsing\""); - - testNewWindow(function() { - // These are tests for the private bit setter. Note that the setter should - // not be used anywhere else for now! - setPrivateWindow(window, true); - is(PrivateBrowsingUtils.isWindowPrivate(window), true, "PrivateBrowsingUtils should accept the correct per-window private browsing status"); - setPrivateWindow(window, false); - is(PrivateBrowsingUtils.isWindowPrivate(window), false, "PrivateBrowsingUtils should accept the correct per-window private browsing status"); - - // now, test using the object - let cmd = document.getElementById("Tools:PrivateBrowsing"); - isnot(cmd, null, "XUL command object for the private browsing service exists"); - var func = new Function("", cmd.getAttribute("oncommand")); - func.call(cmd); - // check to see if the Private Browsing mode was activated successfully - is(observerData, "enter", "Private Browsing mode was activated using the command object"); - // check to see that the window title has been changed correctly - isnot(document.title, originalTitle, "Private browsing mode has correctly changed the title"); - func.call(cmd); - // check to see if the Private Browsing mode was deactivated successfully - is(observerData, "exit", "Private Browsing mode was deactivated using the command object"); - // check to see that the window title has been restored correctly - is(document.title, originalTitle, "Private browsing mode has correctly restored the title"); - - // cleanup - gBrowser.removeCurrentTab(); - Services.obs.removeObserver(observer, "private-browsing"); - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - - finish(); - }, false); - }, true); - }, false); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_urlbarfocus.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_urlbarfocus.js deleted file mode 100644 index 440fb1ae17b0..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_urlbarfocus.js +++ /dev/null @@ -1,62 +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 makes sure that the URL bar is focused when entering the private browsing mode. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - const TEST_URL = "data:text/plain,test"; - gBrowser.selectedTab = gBrowser.addTab(); - let browser = gBrowser.selectedBrowser; - browser.addEventListener("load", function() { - browser.removeEventListener("load", arguments.callee, true); - - // ensure that the URL bar is not focused initially - browser.focus(); - isnot(document.commandDispatcher.focusedElement, gURLBar.inputField, - "URL Bar should not be focused before entering the private browsing mode"); - // ensure that the URL bar is not empty initially - isnot(gURLBar.value, "", "URL Bar should no longer be empty after leaving the private browsing mode"); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - browser = gBrowser.selectedBrowser; - browser.addEventListener("load", function() { - browser.removeEventListener("load", arguments.callee, true); - - // setTimeout is needed here because the onload handler of about:privatebrowsing sets the focus - setTimeout(function() { - // ensure that the URL bar is focused inside the private browsing mode - is(document.commandDispatcher.focusedElement, gURLBar.inputField, - "URL Bar should be focused inside the private browsing mode"); - - // ensure that the URL bar is emptied inside the private browsing mode - is(gURLBar.value, "", "URL Bar should be empty inside the private browsing mode"); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - browser = gBrowser.selectedBrowser; - browser.addEventListener("load", function() { - browser.removeEventListener("load", arguments.callee, true); - - // ensure that the URL bar is no longer focused after leaving the private browsing mode - isnot(document.commandDispatcher.focusedElement, gURLBar.inputField, - "URL Bar should no longer be focused after leaving the private browsing mode"); - - // ensure that the URL bar is no longer empty after leaving the private browsing mode - isnot(gURLBar.value, "", "URL Bar should no longer be empty after leaving the private browsing mode"); - - gBrowser.removeCurrentTab(); - finish(); - }, true); - }, 0); - }, true); - }, true); - content.location = TEST_URL; - - waitForExplicitFinish(); -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle.js deleted file mode 100644 index 7a4069bdc9b1..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle.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/. */ - -// This test makes sure that the window title changes correctly while switching -// from and to private browsing mode. - -function test() { - // initialization - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - const testPageURL = "http://mochi.test:8888/browser/" + - "browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle_page.html"; - waitForExplicitFinish(); - requestLongerTimeout(2); - - // initialization of expected titles - let test_title = "Test title"; - let app_name = document.documentElement.getAttribute("title"); - const isOSX = ("nsILocalFileMac" in Ci); - let page_with_title; - let page_without_title; - let about_pb_title; - let pb_page_with_title; - let pb_page_without_title; - let pb_about_pb_title; - if (isOSX) { - page_with_title = test_title; - page_without_title = app_name; - about_pb_title = "Would you like to start Private Browsing?"; - pb_page_with_title = test_title + " - (Private Browsing)"; - pb_page_without_title = app_name + " - (Private Browsing)"; - pb_about_pb_title = pb_page_without_title; - } - else { - page_with_title = test_title + " - " + app_name; - page_without_title = app_name; - about_pb_title = "Would you like to start Private Browsing?" + " - " + app_name; - pb_page_with_title = test_title + " - " + app_name + " (Private Browsing)"; - pb_page_without_title = app_name + " (Private Browsing)"; - pb_about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)"; - } - - function testTabTitle(url, insidePB, expected_title, funcNext) { - pb.privateBrowsingEnabled = insidePB; - - let tab = gBrowser.selectedTab = gBrowser.addTab(); - let browser = gBrowser.selectedBrowser; - browser.stop(); - // ensure that the test is run after the titlebar has been updated - browser.addEventListener("pageshow", function () { - browser.removeEventListener("pageshow", arguments.callee, false); - executeSoon(function () { - is(document.title, expected_title, "The window title for " + url + - " is correct (" + (insidePB ? "inside" : "outside") + - " private browsing mode)"); - - let win = gBrowser.replaceTabWithWindow(tab); - win.addEventListener("load", function() { - win.removeEventListener("load", arguments.callee, false); - - executeSoon(function() { - is(win.document.title, expected_title, "The window title for " + url + - " detached tab is correct (" + (insidePB ? "inside" : "outside") + - " private browsing mode)"); - win.close(); - - setTimeout(funcNext, 0); - }); - }, false); - }); - }, false); - - browser.loadURI(url); - } - - function cleanup() { - pb.privateBrowsingEnabled = false; - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - } - - testTabTitle("about:blank", false, page_without_title, function() { - testTabTitle(testPageURL, false, page_with_title, function() { - testTabTitle("about:privatebrowsing", false, about_pb_title, function() { - testTabTitle("about:blank", true, pb_page_without_title, function() { - testTabTitle(testPageURL, true, pb_page_with_title, function() { - testTabTitle("about:privatebrowsing", true, pb_about_pb_title, cleanup); - }); - }); - }); - }); - }); - return; -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle_page.html b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle_page.html deleted file mode 100644 index 760bde7d148a..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle_page.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Test title - - - Test page for the window title test - - diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoom.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoom.js deleted file mode 100644 index f4eae6ef7144..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoom.js +++ /dev/null @@ -1,62 +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 makes sure that private browsing turns off doesn't cause zoom -// settings to be reset on tab switch (bug 464962) - -function test() { - // initialization - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - let tabAbout = gBrowser.addTab(); - gBrowser.selectedTab = tabAbout; - - waitForExplicitFinish(); - - let aboutBrowser = gBrowser.getBrowserForTab(tabAbout); - aboutBrowser.addEventListener("load", function onAboutBrowserLoad() { - aboutBrowser.removeEventListener("load", onAboutBrowserLoad, true); - let tabMozilla = gBrowser.addTab(); - gBrowser.selectedTab = tabMozilla; - - let mozillaBrowser = gBrowser.getBrowserForTab(tabMozilla); - mozillaBrowser.addEventListener("load", function onMozillaBrowserLoad() { - mozillaBrowser.removeEventListener("load", onMozillaBrowserLoad, true); - let mozillaZoom = ZoomManager.zoom; - - // change the zoom on the mozilla page - FullZoom.enlarge(); - // make sure the zoom level has been changed - isnot(ZoomManager.zoom, mozillaZoom, "Zoom level can be changed"); - mozillaZoom = ZoomManager.zoom; - - // switch to about: tab - gBrowser.selectedTab = tabAbout; - - // switch back to mozilla tab - gBrowser.selectedTab = tabMozilla; - - // make sure the zoom level has not changed - is(ZoomManager.zoom, mozillaZoom, - "Entering private browsing should not reset the zoom on a tab"); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - // cleanup - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - FullZoom.reset(); - gBrowser.removeTab(tabMozilla); - gBrowser.removeTab(tabAbout); - finish(); - }, true); - mozillaBrowser.contentWindow.location = "about:mozilla"; - }, true); - aboutBrowser.contentWindow.location = "about:"; -} diff --git a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoomrestore.js b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoomrestore.js deleted file mode 100644 index 21da2afb9f43..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoomrestore.js +++ /dev/null @@ -1,55 +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 makes sure that about:privatebrowsing does not appear zoomed in -// if there is already a zoom site pref for about:blank (bug 487656). - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - waitForExplicitFinish(); - - let tabBlank = gBrowser.selectedTab; - let blankBrowser = gBrowser.getBrowserForTab(tabBlank); - blankBrowser.addEventListener("load", function() { - blankBrowser.removeEventListener("load", arguments.callee, true); - - // change the zoom on the blank page - FullZoom.enlarge(); - isnot(ZoomManager.zoom, 1, "Zoom level for about:blank should be changed"); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - let tabAboutPB = gBrowser.selectedTab; - let browserAboutPB = gBrowser.getBrowserForTab(tabAboutPB); - browserAboutPB.addEventListener("load", function() { - browserAboutPB.removeEventListener("load", arguments.callee, true); - setTimeout(function() { - // make sure the zoom level is set to 1 - is(ZoomManager.zoom, 1, "Zoom level for about:privatebrowsing should be reset"); - finishTest(); - }, 0); - }, true); - }, true); - blankBrowser.loadURI("about:blank"); -} - -function finishTest() { - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - // leave private browsing mode - pb.privateBrowsingEnabled = false; - let tabBlank = gBrowser.selectedTab; - let blankBrowser = gBrowser.getBrowserForTab(tabBlank); - blankBrowser.addEventListener("load", function() { - blankBrowser.removeEventListener("load", arguments.callee, true); - - executeSoon(function() { - // cleanup - FullZoom.reset(); - finish(); - }); - }, true); -} diff --git a/browser/components/privatebrowsing/test/browser/global/ctxmenu-image.png b/browser/components/privatebrowsing/test/browser/global/ctxmenu-image.png deleted file mode 100644 index 4c3be508477eb19cd08ddf4d0f568a06a4ec7a45..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5401 zcmWldUu+x6eaC+@`zOm484PJsC8-t|9#_g9EgeW%V$=3zmhv&HlYCg&JcYK?fZCH> zQI>!tErOyzfgwc+v@92ES*J+nG+3T>4sGiWmMsf;q;2Y|Q*2bHvt0Y`wQ0GBTWAAU3Q{d~T2#d`M#0X41yKw#KBeb)P){PRb_-uq7+3jpD7hEE%Xe@4>d z3IghX>W2RBPtU7!c`G)Sjij1+H(u|LjJ(m~irW?n|SlBi|gv0JGOwku*mI3k6cIJ&jWx*DTzvbX`0$xLJg%qm@B&>G%? z@_dwj-Qb7Ppr>VAW`;fG zi+7(h$&TdE`}sZpe~!bA>)F<%FqBL=i`H{ea?gJws_utU`Sh%BDhIDF3`GM8Gw;f3 zVot^T;}BcPPvQ%H%XnqfK;RWpP^UD|H;<)mVkyS}b0z#YCn5@Pa?0 zC&RKSKaA+&mK8&(raa6K;4i}GI6eYuk_-)-?9rKO{GhXbokCpCvez{BM6r=%Z3ms2 zloqu4?BlpK8~SZ9JcP965>~eJb*TW+#7<*Q+CM$W`xn+FDM#+ZNE5&T!eGHdAzn__ zPRf)=5o)wt_faiQhAdFD%1kFzW~(&>sI6kFhxqFiZPmAlCMgWG=6q!&TDzw&Fgz}A zkGki_=CZC+TIOsSM0g%r3YO0) z%xwi*|F*_-m%#NrN@182Kd0fGGB6}Tr^-h) zG?nY^8-qQ*Lt%}LCO%iDc$_tobk!K8GAH;*Cb>B6Wb{=i%B1_`B>2~HGJ%xJjM&4) z*J)LL!3Kr0@T@hD%c$}JMgFXLf);>I;~1FI(2 zF7^V+h%44LdH5C`nqA;D%V@clb4r<=0b$;*U!*7nLQT3`ndEDSerEtGgmG)}J^Ea} zRGFdT;o07&3^jp0>$Fe3$WL^>qqJ|I>_HnyRTAQ%L*&~;wtWsL4%>s|QlfB^f2E&@ z8dl6CGbb(%vh9ITIS}lxeRGI&2_Hpb)i*uVM4(e&J+ktdc?zeZF#FM0a1qrUc;UQK zuuebYgG)1PYVKf~N zUw^9^n7Sx6dhhetqNbl};{)?Z`FvK9=+%$+EMa#bxBV}(n5^WTXZn}2uj#LzX`7Fu zSN7W9kh9D1Nn#DkW59-PyQS(QHsnrOc|hxhE<)pik&7yqTQ##wPr5b3(VIAy=$ z@f))8;h605pDcXEyN$V94@=}0+5UL)Xr(6Yah0R5qIb{Z^;vRFLlgj6v?(ewRt~byElMH@83MQ`(kB%1W~S!hIIH?@tG`d5e#N@%PxYQ%=6d?{HQ09V(?wzso6#iKye_Ah}fv7b^qm z4#X((Z4S~*Pp$e1{2jc#6h^KXWG=jKahrP4P)Pt=fZVA_4evE5lh9nN~SUyaw_BO}nj0F~st9g9i_PA3OqPbHh^8NBkbCg^dfGN!Tx0P)(q@V+HRn8}(CIGG=d%P&@lh`Z;@4-} z;j_JUpVGUH!{p?5_v+njkBVVYNpNcviRnb%*?~uAa`VyLHh;om22xt2-7~5AuSDu+ z3}jb-gr4bZ9BR4Odb>7r-y=ivlZ<_`1z~SW3u*c}>rb6aK3BuNp4mOQ63X>27Qm{2y|6Qz zF2jk(;YB2y9cncF(d_BhEAHqA0T%6NG6h+Lx>zaVvZo8ze|f;gOsyY}DBi!1&KEDZ z)gp`PqV0(TbRpF~sZX{;?NmLuU5)zpIlddD!T$njx>GT>JWXM}wFk#dQb)&pW>L%6 zk!WiU8xdlgK@->9JQz>hxG)&6N zF*&1@1K$so{Vs%czMk8ld5aU?eY~rtsV_$tgW^EPp^b6+@r9m?@}#P=cuA%8pwm&r z;TlfSb#q7;A+u@}CxwG?#@8uKjWGV8Z$;jeQe1RS>oik6t;0y${GMVCHP~x;flrbX zF5ZEqg=}J19Tr04&wGK3_B{s@w9C3=7fXZIGLvMUD~3L`*+>;Oq?p?unjDH-LV-NR z?ZsIhO^?u+&PUH|$8@kQWl>#0w*$HdPuaJh$t@I-AT3Ccl34K5!g^ zb4I+qR8gC-i*-KcxX&0kqU0$z{eugp<%t)QYp@$X+Eu3;-V(!!$mnfg>$xpFDMVO| zDk=K3-tWz_Z{NR-o9icUa=cE|AF(5)APu%Dg^x!>3xP{Wn(|UI;Z*b52qAQo!`wMnlN$r6Q2BATieg`-gM4U?X;(2}Iekze$< zSs`{svNn7}N3$oUA+`Bvw>Z?&n{Z4BW!qFBh25Z1ml)d`+z-RhtZ#;V`OSFDR;Nz7 z=dJvMZtfm(wX~ML;9Qa-ZhTtN_=nd;4b9D%ryiT;tag(fu?voPM0DXT(jVeQ9BZ5x zj%k~--r?mOw-0E{=xE_^yT64QTUG`=b;QCZQuPxWa)*wTxDX~{LNgx3H1vtI-x+O% zJR5br<|7z;bhkd3yEZn>?5J4tB8SC>^dD^nQ)bk>MZ}}gX_&0{?M=fm$GC9G@Cri2 zkwr8^drG*y+84l!ub{F%r>NhT%BT-$nPcxahg%S8kf)^c98f1~ObH27C}!h~@rl9YCF)C8qwE^0tRtx|k@?LtKCfIYPxnDY z{~sc1wP>w-ua_#%NpAHMG*R)1m9{0@!^T5uBv>9Jjpaym$Jl@ke9Oyk``guomkP0n zDyoxVf1{(^?>%WgP@0o_{D=4C%F*&U`c@{M1-U_|MVs)yMD( z%AL{rgmqiVd0k=}GMdlLvucicWDe{35(Kn-lkVc-?}E!UXTtsf^&ww*bpb?%hEU^Z z^cJY7fh3b9go33U?Y4JLPjwb=w!wtV_jn*CfZ)ZBOpxx{+BK==%1`^`E7(l1q0N zzz&47C&#ZjG<>6zRo7+GTDd+WtXt1u&*7FXzHY5t5)C_545dSTY~#B(=o;${;?Z4A z%viheYBXlNo;>I==5@dL zU6Pvyabe7g*zsNMVz(Z;>#Rzgr1$~EXqpkQ+$wTgL@%0AkN;0 zyJ&%i2}6{0DD#K)G49(rgXS=7jscJvI__x|ULfDupElyJ;>x8lzrCH1?L;A&i#7cP z@9sqvU4KIk!4AhhGfrTfVNks*w(=h=d2U%gVy`8jzklHueB*YtM|G-7F zViI{xasv(Il3LkJx>b$5pI36Aa8^g?*ng- - - - Page containing an image - - - - - diff --git a/browser/components/privatebrowsing/test/browser/global/head.js b/browser/components/privatebrowsing/test/browser/global/head.js deleted file mode 100644 index 73257a5e3ba6..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/head.js +++ /dev/null @@ -1,40 +0,0 @@ -// Make sure that we clean up after each test if it times out, for example. -registerCleanupFunction(function() { - var pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - ok(!pb.privateBrowsingEnabled, "Private browsing should be terminated after finishing the test"); - pb.privateBrowsingEnabled = false; - try { - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - } catch(e) {} -}); - -/** - * Waits for completion of a clear history operation, before - * proceeding with aCallback. - * - * @param aCallback - * Function to be called when done. - */ -function waitForClearHistory(aCallback) { - Services.obs.addObserver(function observeCH(aSubject, aTopic, aData) { - Services.obs.removeObserver(observeCH, PlacesUtils.TOPIC_EXPIRATION_FINISHED); - aCallback(); - }, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false); - PlacesUtils.bhistory.removeAllPages(); -} - -/* - * Function created to put a window in PB mode. - * THIS IS DANGEROUS. DO NOT DO THIS OUTSIDE OF TESTS! - */ -function setPrivateWindow(aWindow, aEnable) { - return aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .treeOwner - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIXULWindow) - .docShell.QueryInterface(Ci.nsILoadContext) - .usePrivateBrowsing = aEnable; -} diff --git a/browser/components/privatebrowsing/test/browser/global/popup.html b/browser/components/privatebrowsing/test/browser/global/popup.html deleted file mode 100644 index 333a303469ee..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/popup.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - Page creating a popup - - - - - diff --git a/browser/components/privatebrowsing/test/browser/global/title.sjs b/browser/components/privatebrowsing/test/browser/global/title.sjs deleted file mode 100644 index 568e235be192..000000000000 --- a/browser/components/privatebrowsing/test/browser/global/title.sjs +++ /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/. */ - -// This provides the tests with a page with different titles based on whether -// a cookie is present or not. - -function handleRequest(request, response) { - response.setStatusLine(request.httpVersion, 200, "OK"); - response.setHeader("Content-Type", "text/html", false); - - var cookie = "name=value"; - var title = "No Cookie"; - if (request.hasHeader("Cookie") && request.getHeader("Cookie") == cookie) - title = "Cookie"; - else - response.setHeader("Set-Cookie", cookie, false); - - response.write(""); - response.write(title); - response.write("test page"); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/Makefile.in b/browser/components/privatebrowsing/test/browser/obsolete/Makefile.in deleted file mode 100644 index db00c282813b..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/Makefile.in +++ /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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ -relativesrcdir = @relativesrcdir@ - -include $(DEPTH)/config/autoconf.mk - -MOCHITEST_BROWSER_FILES = \ - head.js \ - browser_console_clear.js \ - browser_privatebrowsing_commandline_toggle.js \ - browser_privatebrowsing_fastswitch.js \ - browser_privatebrowsing_findbar.js \ - browser_privatebrowsing_forgetthissite.js \ - browser_privatebrowsing_import.js \ - browser_privatebrowsing_newwindow_stopcmd.js \ - browser_privatebrowsing_pageinfo.js \ - browser_privatebrowsing_popupmode.js \ - browser_privatebrowsing_searchbar.js \ - browser_privatebrowsing_sslsite_transition.js \ - $(filter disabled-since-it-no-longer-makes-sense, browser_privatebrowsing_transition.js) \ - browser_privatebrowsing_urlbarundo.js \ - browser_privatebrowsing_viewsource.js \ - $(NULL) - -# Turn off private browsing tests that perma-timeout on Linux. -ifneq (Linux,$(OS_ARCH)) -MOCHITEST_BROWSER_FILES += \ - browser_privatebrowsing_beforeunload.js \ - $(NULL) -endif - -include $(topsrcdir)/config/rules.mk diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_console_clear.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_console_clear.js deleted file mode 100644 index a4953395e343..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_console_clear.js +++ /dev/null @@ -1,59 +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 makes sure that the error console is cleared after leaving the -// private browsing mode. - -function test() { - // initialization - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - let consoleService = Cc["@mozilla.org/consoleservice;1"]. - getService(Ci.nsIConsoleService); - const EXIT_MESSAGE = "Message to signal the end of the test"; - waitForExplicitFinish(); - - let consoleObserver = { - observe: function (aMessage) { - if (!aMessage.message) - this.gotNull = true; - else if (aMessage.message == EXIT_MESSAGE) { - // make sure that the null message was received - ok(this.gotNull, "Console should be cleared after leaving the private mode"); - // make sure the console does not contain TEST_MESSAGE - ok(!messageExists(), "Message should not exist after leaving the private mode"); - - consoleService.unregisterListener(consoleObserver); - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - } - }, - gotNull: false - }; - consoleService.registerListener(consoleObserver); - - function messageExists() { - let messages = consoleService.getMessageArray() || []; - for (let i = 0; i < messages.length; ++i) { - if (messages[i].message == TEST_MESSAGE) - return true; - } - return false; - } - - const TEST_MESSAGE = "Test message from the private browsing test"; - // make sure that the console is not empty - consoleService.logStringMessage(TEST_MESSAGE); - ok(!consoleObserver.gotNull, "Console shouldn't be cleared yet"); - ok(messageExists(), "Message should exist before leaving the private mode"); - - pb.privateBrowsingEnabled = true; - ok(!consoleObserver.gotNull, "Console shouldn't be cleared yet"); - ok(messageExists(), "Message should exist after entering the private mode"); - pb.privateBrowsingEnabled = false; - - // signal the end of the test - consoleService.logStringMessage(EXIT_MESSAGE); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_beforeunload.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_beforeunload.js deleted file mode 100644 index 213134c1f587..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_beforeunload.js +++ /dev/null @@ -1,138 +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 makes sure that cancelling the unloading of a page with a beforeunload -// handler prevents the private browsing mode transition. - -function test() { - const TEST_PAGE_1 = "data:text/html,first"; - const TEST_PAGE_2 = "data:text/html,second"; - let pb = Cc["@mozilla.org/privatebrowsing;1"] - .getService(Ci.nsIPrivateBrowsingService); - - let rejectDialog = 0; - let acceptDialog = 0; - let confirmCalls = 0; - function promptObserver(aSubject, aTopic, aData) { - let dialogWin = aSubject.QueryInterface(Ci.nsIDOMWindow); - confirmCalls++; - if (acceptDialog-- > 0) - dialogWin.document.documentElement.getButton("accept").click(); - else if (rejectDialog-- > 0) - dialogWin.document.documentElement.getButton("cancel").click(); - } - - Services.obs.addObserver(promptObserver, "common-dialog-loaded", false); - - waitForExplicitFinish(); - let browser1 = gBrowser.addTab().linkedBrowser; - browser1.addEventListener("load", function() { - browser1.removeEventListener("load", arguments.callee, true); - - let browser2 = gBrowser.addTab().linkedBrowser; - browser2.addEventListener("load", function() { - browser2.removeEventListener("load", arguments.callee, true); - - rejectDialog = 1; - pb.privateBrowsingEnabled = true; - - ok(!pb.privateBrowsingEnabled, "Private browsing mode should not have been activated"); - is(confirmCalls, 1, "Only one confirm box should be shown"); - is(gBrowser.tabs.length, 3, - "No tabs should be closed because private browsing mode transition was canceled"); - is(gBrowser.tabContainer.firstChild.linkedBrowser.currentURI.spec, "about:blank", - "The first tab should be a blank tab"); - is(gBrowser.tabContainer.firstChild.nextSibling.linkedBrowser.currentURI.spec, TEST_PAGE_1, - "The middle tab should be the same one we opened"); - is(gBrowser.tabContainer.lastChild.linkedBrowser.currentURI.spec, TEST_PAGE_2, - "The last tab should be the same one we opened"); - is(rejectDialog, 0, "Only one confirm dialog should have been rejected"); - - confirmCalls = 0; - acceptDialog = 2; - pb.privateBrowsingEnabled = true; - - ok(pb.privateBrowsingEnabled, "Private browsing mode should have been activated"); - is(confirmCalls, 2, "Only two confirm boxes should be shown"); - is(gBrowser.tabs.length, 1, - "Incorrect number of tabs after transition into private browsing"); - gBrowser.selectedBrowser.addEventListener("load", function() { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - is(gBrowser.currentURI.spec, "about:privatebrowsing", - "Incorrect page displayed after private browsing transition"); - is(acceptDialog, 0, "Two confirm dialogs should have been accepted"); - - gBrowser.selectedBrowser.addEventListener("load", function() { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function() { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - confirmCalls = 0; - rejectDialog = 1; - pb.privateBrowsingEnabled = false; - - ok(pb.privateBrowsingEnabled, "Private browsing mode should not have been deactivated"); - is(confirmCalls, 1, "Only one confirm box should be shown"); - is(gBrowser.tabs.length, 2, - "No tabs should be closed because private browsing mode transition was canceled"); - is(gBrowser.tabContainer.firstChild.linkedBrowser.currentURI.spec, TEST_PAGE_1, - "The first tab should be the same one we opened"); - is(gBrowser.tabContainer.lastChild.linkedBrowser.currentURI.spec, TEST_PAGE_2, - "The last tab should be the same one we opened"); - is(rejectDialog, 0, "Only one confirm dialog should have been rejected"); - - // Ensure that all restored tabs are loaded without waiting for the - // user to bring them to the foreground, by resetting the related - // preference (see the "firefox.js" defaults file for details). - Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", false); - - confirmCalls = 0; - acceptDialog = 2; - pb.privateBrowsingEnabled = false; - - ok(!pb.privateBrowsingEnabled, "Private browsing mode should have been deactivated"); - is(confirmCalls, 2, "Only two confirm boxes should be shown"); - is(gBrowser.tabs.length, 3, - "Incorrect number of tabs after transition into private browsing"); - - let loads = 0; - function waitForLoad(event) { - gBrowser.removeEventListener("load", arguments.callee, true); - - if (++loads != 3) - return; - - is(gBrowser.tabContainer.firstChild.linkedBrowser.currentURI.spec, "about:blank", - "The first tab should be a blank tab"); - is(gBrowser.tabContainer.firstChild.nextSibling.linkedBrowser.currentURI.spec, TEST_PAGE_1, - "The middle tab should be the same one we opened"); - is(gBrowser.tabContainer.lastChild.linkedBrowser.currentURI.spec, TEST_PAGE_2, - "The last tab should be the same one we opened"); - is(acceptDialog, 0, "Two confirm dialogs should have been accepted"); - is(acceptDialog, 0, "Two prompts should have been raised"); - - acceptDialog = 2; - gBrowser.removeTab(gBrowser.tabContainer.lastChild); - gBrowser.removeTab(gBrowser.tabContainer.lastChild); - gBrowser.getBrowserAtIndex(gBrowser.tabContainer.selectedIndex).contentWindow.focus(); - - Services.obs.removeObserver(promptObserver, "common-dialog-loaded", false); - Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand"); - finish(); - } - for (let i = 0; i < gBrowser.browsers.length; ++i) - gBrowser.browsers[i].addEventListener("load", waitForLoad, true); - }, true); - gBrowser.selectedBrowser.loadURI(TEST_PAGE_2); - }, true); - gBrowser.selectedBrowser.loadURI(TEST_PAGE_1); - }, true); - }, true); - browser2.loadURI(TEST_PAGE_2); - }, true); - browser1.loadURI(TEST_PAGE_1); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_commandline_toggle.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_commandline_toggle.js deleted file mode 100644 index 8ceda9ed022f..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_commandline_toggle.js +++ /dev/null @@ -1,127 +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 makes sure that private browsing toggles correctly via the -private -// command line argument. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - waitForExplicitFinish(); - - function simulatePrivateCommandLineArgument() { - function testprivatecl() { - } - - testprivatecl.prototype = { - _arguments: ["private-toggle"], - get length() { - return this._arguments.length; - }, - getArgument: function getArgument(aIndex) { - return this._arguments[aIndex]; - }, - findFlag: function findFlag(aFlag, aCaseSensitive) { - for (let i = 0; i < this._arguments.length; ++i) - if (aCaseSensitive ? - (this._arguments[i] == aFlag) : - (this._arguments[i].toLowerCase() == aFlag.toLowerCase())) - return i; - return -1; - }, - removeArguments: function removeArguments(aStart, aEnd) { - this._arguments.splice(aStart, aEnd - aStart + 1); - }, - handleFlag: function handleFlag (aFlag, aCaseSensitive) { - let res = this.findFlag(aFlag, aCaseSensitive); - if (res > -1) { - this.removeArguments(res, res); - return true; - } - return false; - }, - handleFlagWithParam: function handleFlagWithParam(aFlag, aCaseSensitive) { - return null; - }, - STATE_INITIAL_LAUNCH: 0, - STATE_REMOTE_AUTO: 1, - STATE_REMOTE_EXPLICIT: 2, - get state() { - return this.STATE_REMOTE_AUTO; - }, - preventDefault: false, - workingDirectory: null, - windowContext: null, - resolveFile: function resolveFile (aArgument) { - return null; - }, - resolveURI: function resolveURI (aArgument) { - return null; - }, - QueryInterface: function(aIID) { - if (!aIID.equals(Ci.nsICommandLine) - && !aIID.equals(Ci.nsISupports)) - throw Cr.NS_ERROR_NO_INTERFACE; - return this; - } - }; - - let testcl = new testprivatecl(); - - let catMan = Cc["@mozilla.org/categorymanager;1"]. - getService(Ci.nsICategoryManager); - let categories = catMan.enumerateCategory("command-line-handler"); - while (categories.hasMoreElements()) { - let category = categories.getNext().QueryInterface(Ci.nsISupportsCString).data; - let contractID = catMan.getCategoryEntry("command-line-handler", category); - let handler = Cc[contractID].getService(Ci.nsICommandLineHandler); - handler.handle(testcl); - } - } - - function observer(aSubject, aTopic, aData) { - isnot(aTopic, "domwindowopened", "The -private-toggle argument should be silent"); - } - Services.ww.registerNotification(observer); - - let tab = gBrowser.selectedTab; - let browser = gBrowser.getBrowserForTab(tab); - browser.addEventListener("load", function () { - browser.removeEventListener("load", arguments.callee, true); - ok(!pb.privateBrowsingEnabled, "The private browsing mode should not be started"); - is(browser.contentWindow.location, "about:", "The correct page has been loaded"); - - simulatePrivateCommandLineArgument(); - is(pb.lastChangedByCommandLine, true, - "The status change reason should reflect the PB mode being set from the command line"); - tab = gBrowser.selectedTab; - browser = gBrowser.getBrowserForTab(tab); - browser.addEventListener("load", function() { - browser.removeEventListener("load", arguments.callee, true); - ok(pb.privateBrowsingEnabled, "The private browsing mode should be started"); - is(browser.contentWindow.location, "about:privatebrowsing", - "about:privatebrowsing should now be loaded"); - - simulatePrivateCommandLineArgument(); - is(pb.lastChangedByCommandLine, true, - "The status change reason should reflect the PB mode being set from the command line"); - tab = gBrowser.selectedTab; - browser = gBrowser.getBrowserForTab(tab); - browser.addEventListener("load", function() { - browser.removeEventListener("load", arguments.callee, true); - ok(!pb.privateBrowsingEnabled, "The private browsing mode should be stopped"); - is(browser.contentWindow.location, "about:", - "about: should now be loaded"); - - let newTab = gBrowser.addTab(); - gBrowser.removeTab(tab); - Services.ww.unregisterNotification(observer); - finish(); - }, true); - }, true); - }, true); - browser.loadURI("about:"); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_fastswitch.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_fastswitch.js deleted file mode 100644 index 4c646eea1bc1..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_fastswitch.js +++ /dev/null @@ -1,59 +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 makes sure that users are prevented from toggling the private -// browsing mode too quickly, hence be proctected from symptoms in bug 526194. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - let pbCmd = document.getElementById("Tools:PrivateBrowsing"); - waitForExplicitFinish(); - - let pass = 1; - function observer(aSubject, aTopic, aData) { - switch (aTopic) { - case "private-browsing-transition-complete": - if (pass++ == 1) { - setTimeout(function () { - ok(!pbCmd.hasAttribute("disabled"), - "The private browsing command should be re-enabled after entering the private browsing mode"); - - pb.privateBrowsingEnabled = false; - }, 100); - } - else { - setTimeout(function () { - ok(!pbCmd.hasAttribute("disabled"), - "The private browsing command should be re-enabled after exiting the private browsing mode"); - - finish(); - }, 100); - } - break; - } - Services.obs.removeObserver(observer, "private-browsing-transition-complete"); - } - let originalOnEnter = gPrivateBrowsingUI.onEnterPrivateBrowsing; - gPrivateBrowsingUI.onEnterPrivateBrowsing = function() { - originalOnEnter.apply(gPrivateBrowsingUI, arguments); - ok(pbCmd.hasAttribute("disabled"), - "The private browsing command should be disabled right after entering the private browsing mode"); - Services.obs.addObserver(observer, "private-browsing-transition-complete", false); - }; - let originalOnExit = gPrivateBrowsingUI.onExitPrivateBrowsing; - gPrivateBrowsingUI.onExitPrivateBrowsing = function() { - originalOnExit.apply(gPrivateBrowsingUI, arguments); - ok(pbCmd.hasAttribute("disabled"), - "The private browsing command should be disabled right after exiting the private browsing mode"); - Services.obs.addObserver(observer, "private-browsing-transition-complete", false); - }; - registerCleanupFunction(function() { - gPrivateBrowsingUI.onEnterPrivateBrowsing = originalOnEnter; - gPrivateBrowsingUI.onExitPrivateBrowsing = originalOnExit; - }); - - pb.privateBrowsingEnabled = true; -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_findbar.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_findbar.js deleted file mode 100644 index 9863a6416a99..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_findbar.js +++ /dev/null @@ -1,49 +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 makes sure that the find bar is cleared when leaving the -// private browsing mode. - -function test() { - // initialization - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - // fill in the find bar with something - const kTestSearchString = "privatebrowsing"; - let findBox = gFindBar.getElement("findbar-textbox"); - gFindBar.startFind(gFindBar.FIND_NORMAL); - - // sanity checks - is(findBox.editor.transactionManager.numberOfUndoItems, 0, - "No items in the undo list of the findbar control"); - is(findBox.value, "", - "findbar text is empty"); - - findBox.value = kTestSearchString; - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - is(findBox.value, kTestSearchString, - "entering the private browsing mode should not clear the findbar"); - ok(findBox.editor.transactionManager.numberOfUndoItems > 0, - "entering the private browsing mode should not reset the undo list of the findbar control"); - - // Change the find bar value inside the private browsing mode - findBox.value = "something else"; - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - is(findBox.value, kTestSearchString, - "leaving the private browsing mode should restore the findbar contents"); - is(findBox.editor.transactionManager.numberOfUndoItems, 1, - "leaving the private browsing mode should only leave 1 item in the undo list of the findbar control"); - - // cleanup - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - gFindBar.close(); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_forgetthissite.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_forgetthissite.js deleted file mode 100644 index 09036b62d93e..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_forgetthissite.js +++ /dev/null @@ -1,129 +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 makes sure that the Forget This Site command is hidden in private -// browsing mode. - -/** - * Clears history invoking callback when done. - */ -function waitForClearHistory(aCallback) { - const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished"; - let observer = { - observe: function(aSubject, aTopic, aData) { - Services.obs.removeObserver(this, TOPIC_EXPIRATION_FINISHED); - aCallback(); - } - }; - Services.obs.addObserver(observer, TOPIC_EXPIRATION_FINISHED, false); - - let hs = Cc["@mozilla.org/browser/nav-history-service;1"]. - getService(Ci.nsINavHistoryService); - hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages(); -} - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - waitForExplicitFinish(); - - // Add a history entry. - const TEST_URI = "http://www.mozilla.org/privatebrowsing"; - ok(PlacesUtils, "checking PlacesUtils, running in chrome context?"); - - let place = { - uri: PlacesUtils._uri(TEST_URI), - visits: [{ - visitDate: Date.now() * 1000, - transitionType: PlacesUtils.history.TRANSITION_TYPED - }] - } - PlacesUtils.asyncHistory.updatePlaces(place, { - handleError: function () ok(false, "couldn't add visit"), - handleResult: function () {}, - handleCompletion: function () { - ok(true, TEST_URI + " successfully marked visited"); - - testForgetThisSiteVisibility(true, function() { - // Enter private browsing mode - pb.privateBrowsingEnabled = true; - testForgetThisSiteVisibility(false, function() { - // Leave private browsing mode - pb.privateBrowsingEnabled = false; - testForgetThisSiteVisibility(true, function() { - // Cleanup - waitForClearHistory(finish); - }); - }); - }); - } - }); - - function testForgetThisSiteVisibility(expected, funcNext) { - function observer(aSubject, aTopic, aData) { - if (aTopic != "domwindowopened") - return; - - Services.ww.unregisterNotification(observer); - let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow); - SimpleTest.waitForFocus(function() { - executeSoon(function() { - // Select History in the left pane. - let PO = organizer.PlacesOrganizer; - PO.selectLeftPaneQuery('History'); - let histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode); - histContainer.containerOpen = true; - PO._places.selectNode(histContainer.getChild(0)); - // Select the first history entry. - let doc = organizer.document; - let tree = organizer.ContentTree.view; - let selection = tree.view.selection; - selection.clearSelection(); - selection.rangedSelect(0, 0, true); - is(tree.selectedNode.uri, TEST_URI, "The correct history item has been selected"); - // Open the context menu - let contextmenu = doc.getElementById("placesContext"); - contextmenu.addEventListener("popupshown", function() { - contextmenu.removeEventListener("popupshown", arguments.callee, true); - let forgetThisSite = doc.getElementById("placesContext_deleteHost"); - is(forgetThisSite.hidden, !expected, - "The Forget This Site menu item should " + (expected ? "not " : "") + "be hidden"); - let forgetThisSiteCmd = doc.getElementById("placesCmd_deleteDataHost"); - if (forgetThisSiteCmd.disabled, !expected, - "The Forget This Site command should " + (expected ? "not " : "") + "be disabled"); - // Close the context menu - contextmenu.hidePopup(); - // Wait for the Organizer window to actually be closed - function closeObserver(aSubject, aTopic, aData) { - if (aTopic != "domwindowclosed") - return; - Services.ww.unregisterNotification(closeObserver); - SimpleTest.waitForFocus(function() { - // Proceed - funcNext(); - }); - } - Services.ww.registerNotification(closeObserver); - // Close Library window. - organizer.close(); - }, true); - // Get cell coordinates - var x = {}, y = {}, width = {}, height = {}; - tree.treeBoxObject.getCoordsForCellItem(0, tree.columns[0], "text", - x, y, width, height); - // Initiate a context menu for the selected cell - EventUtils.synthesizeMouse(tree.body, x.value + width.value / 2, y.value + height.value / 2, {type: "contextmenu"}, organizer); - }); - }, organizer); - } - - Services.ww.registerNotification(observer); - Services.ww.openWindow(null, - "chrome://browser/content/places/places.xul", - "", - "chrome,toolbar=yes,dialog=no,resizable", - null); - } -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_import.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_import.js deleted file mode 100644 index 663f575afbbf..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_import.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/. */ - -// This test makes sure that the "Import and Backup->Import From Another Browser" -// menu item in the Places Organizer is disabled inside private browsing mode. - -let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - -function test() { - waitForExplicitFinish(); - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - // first test: open the library with PB disabled - pb.privateBrowsingEnabled = false; - openLibrary(testPBoff); -} - -function openLibrary(callback) { - var library = window.openDialog("chrome://browser/content/places/places.xul", - "", "chrome,toolbar=yes,dialog=no,resizable"); - waitForFocus(function () { - callback(library); - }, library); -} - -function testPBoff(win) { - // XXX want to test the #browserImport menuitem instead - let importMenuItem = win.document.getElementById("OrganizerCommand_browserImport"); - - // make sure the menu item is enabled outside PB mode when opening the Library - ok(!importMenuItem.hasAttribute("disabled"), - "Import From Another Browser menu item should be enabled outside PB mode when opening the Library"); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - ok(importMenuItem.hasAttribute("disabled"), - "Import From Another Browser menu item should be disabled after starting PB mode"); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - ok(!importMenuItem.hasAttribute("disabled"), - "Import From Another Browser menu item should not be disabled after leaving the PB mode"); - - win.close(); - - // launch the second test: open the Library with PB enabled - pb.privateBrowsingEnabled = true; - openLibrary(testPBon); -} - -function testPBon(win) { - let importMenuItem = win.document.getElementById("OrganizerCommand_browserImport"); - - // make sure the menu item is disabled in PB mode when opening the Library - ok(importMenuItem.hasAttribute("disabled"), - "Import From Another Browser menu item should be disabled in PB mode when opening the Libary"); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - ok(!importMenuItem.hasAttribute("disabled"), - "Import From Another Browser menu item should not be disabled after leaving PB mode"); - - win.close(); - - // cleanup - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_newwindow_stopcmd.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_newwindow_stopcmd.js deleted file mode 100644 index 979e171f369f..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_newwindow_stopcmd.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/. */ - -// This test makes sure that the stop private browsing command is enabled in -// new windows opened from the private browsing mode (bug 529667). - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - waitForExplicitFinish(); - - pb.privateBrowsingEnabled = true; - - let win = OpenBrowserWindow({private: PrivateBrowsingUtils.isWindowPrivate(window)}); - win.addEventListener("load", function() { - win.removeEventListener("load", arguments.callee, false); - executeSoon(function() { - let cmd = win.document.getElementById("Tools:PrivateBrowsing"); - ok(!cmd.hasAttribute("disabled"), - "The Private Browsing command in a new window should be enabled"); - - win.close(); - pb.privateBrowsingEnabled = false; - finish(); - }); - }, false); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_pageinfo.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_pageinfo.js deleted file mode 100644 index 0fc9abde22eb..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_pageinfo.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/. */ - -// This test makes sure that the page info dialogs will close when entering or -// exiting the private browsing mode. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - function runTest(aPBMode, aCallBack) { - let tab1 = gBrowser.addTab(); - gBrowser.selectedTab = tab1; - let browser1 = gBrowser.getBrowserForTab(tab1); - browser1.addEventListener("load", function () { - browser1.removeEventListener("load", arguments.callee, true); - - let pageInfo1 = BrowserPageInfo(); - pageInfo1.addEventListener("load", function () { - pageInfo1.removeEventListener("load", arguments.callee, false); - - let tab2 = gBrowser.addTab(); - gBrowser.selectedTab = tab2; - let browser2 = gBrowser.getBrowserForTab(tab2); - browser2.addEventListener("load", function () { - browser2.removeEventListener("load", arguments.callee, true); - - let pageInfo2 = BrowserPageInfo(); - pageInfo2.addEventListener("load", function () { - pageInfo2.removeEventListener("load", arguments.callee, false); - - pageInfo1.addEventListener("unload", function () { - pageInfo1.removeEventListener("unload", arguments.callee, false); - pageInfo1 = null; - ok(true, "Page info 1 being closed as expected"); - if (!pageInfo2) - aCallBack(); - }, false); - - pageInfo2.addEventListener("unload", function () { - pageInfo2.removeEventListener("unload", arguments.callee, false); - pageInfo2 = null; - ok(true, "Page info 2 being closed as expected"); - if (!pageInfo1) - aCallBack(); - }, false); - - pb.privateBrowsingEnabled = aPBMode; - }, false); - }, true); - browser2.loadURI("data:text/plain,Test Page 2"); - }, false); - }, true); - browser1.loadURI("data:text/html,Test Page 1"); - } - - runTest(true, function() { - runTest(false, function() { - gBrowser.removeCurrentTab(); - gBrowser.removeCurrentTab(); - - finish(); - }); - }); - - waitForExplicitFinish(); - ignoreAllUncaughtExceptions(); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_popupmode.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_popupmode.js deleted file mode 100644 index 3e4f5ae1bc08..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_popupmode.js +++ /dev/null @@ -1,80 +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 makes sure that the URL bar is enabled after entering the private -// browsing mode, even if it's disabled before that (see bug 495495). - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - let ss = Cc["@mozilla.org/browser/sessionstore;1"]. - getService(Ci.nsISessionStore); - - // clear the history of closed windows (that other tests have created) - // to avoid the issue in bug 596592 - // XXX remove this when bug 597071 is fixed - while (ss.getClosedWindowCount()) - ss.forgetClosedWindow(0); - - // backup our state - let stateBackup = ss.getWindowState(window); - - function pretendToBeAPopup(whatToPretend) { - let state = whatToPretend ? - '{"windows":[{"tabs":[{"entries":[],"attributes":{}}],"isPopup":true,"hidden":"toolbar"}]}' : - '{"windows":[{"tabs":[{"entries":[],"attributes":{}}],"isPopup":false}]}'; - ss.setWindowState(window, state, true); - if (whatToPretend) { - ok(gURLBar.readOnly, "pretendToBeAPopup correctly made the URL bar read-only"); - is(gURLBar.getAttribute("enablehistory"), "false", - "pretendToBeAPopup correctly disabled autocomplete on the URL bar"); - } - else { - ok(!gURLBar.readOnly, "pretendToBeAPopup correctly made the URL bar read-write"); - is(gURLBar.getAttribute("enablehistory"), "true", - "pretendToBeAPopup correctly enabled autocomplete on the URL bar"); - } - } - - // first, test the case of entering the PB mode when a popup window is active - - // pretend we're a popup window - pretendToBeAPopup(true); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - // make sure that the url bar status is correctly restored - ok(!gURLBar.readOnly, - "URL bar should not be read-only after entering the private browsing mode"); - is(gURLBar.getAttribute("enablehistory"), "true", - "URL bar autocomplete should be enabled after entering the private browsing mode"); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - // we're no longer a popup window - pretendToBeAPopup(false); - - // then, test the case of leaving the PB mode when a popup window is active - - // start from within the private browsing mode - pb.privateBrowsingEnabled = true; - - // pretend we're a popup window - pretendToBeAPopup(true); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - // make sure that the url bar status is correctly restored - ok(!gURLBar.readOnly, - "URL bar should not be read-only after leaving the private browsing mode"); - is(gURLBar.getAttribute("enablehistory"), "true", - "URL bar autocomplete should be enabled after leaving the private browsing mode"); - - // cleanup - ss.setWindowState(window, stateBackup, true); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_searchbar.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_searchbar.js deleted file mode 100644 index 7a104a1273e2..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_searchbar.js +++ /dev/null @@ -1,65 +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 makes sure that the search bar is cleared when leaving the -// private browsing mode. - -function test() { - // initialization - waitForExplicitFinish(); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - // fill in the search bar with something, twice to populate undo history - const kTestSearchString = "privatebrowsing"; - let searchBar = BrowserSearch.searchBar; - searchBar.value = kTestSearchString + "foo"; - searchBar.value = kTestSearchString; - - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - registerCleanupFunction(function () { - searchBar.textbox.reset(); - - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - }); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - is(searchBar.value, kTestSearchString, - "entering the private browsing mode should not clear the search bar"); - ok(searchBar.textbox.editor.transactionManager.numberOfUndoItems > 0, - "entering the private browsing mode should not reset the undo list of the searchbar control"); - - // Change the search bar value inside the private browsing mode - searchBar.value = "something else"; - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - is(searchBar.value, kTestSearchString, - "leaving the private browsing mode should restore the search bar contents"); - is(searchBar.textbox.editor.transactionManager.numberOfUndoItems, 1, - "leaving the private browsing mode should only leave 1 item in the undo list of the searchbar control"); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - const TEST_URL = - "data:text/html,"; - gBrowser.selectedTab = gBrowser.addTab(TEST_URL); - gBrowser.selectedBrowser.addEventListener("load", function(e) { - e.currentTarget.removeEventListener("load", arguments.callee, true); - - var browser = gBrowser.selectedBrowser; - is(typeof browser.engines, "undefined", - "An engine should not be discovered in private browsing mode"); - - gBrowser.removeTab(gBrowser.selectedTab); - pb.privateBrowsingEnabled = false; - - finish(); - }, true); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_sslsite_transition.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_sslsite_transition.js deleted file mode 100644 index f8d460ce5135..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_sslsite_transition.js +++ /dev/null @@ -1,44 +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 makes sure that SSL sites load correctly after leaving the -// Private Browsing mode (bug 463256 and bug 496335). - -function test() { - // initialization - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - const TEST_URL = "https://example.com/"; - - // load an SSL site in the first tab and wait for it to finish loading - gBrowser.selectedTab = gBrowser.addTab(); - let browser = gBrowser.selectedBrowser; - browser.addEventListener("load", function() { - browser.removeEventListener("load", arguments.callee, true); - - pb.privateBrowsingEnabled = true; - pb.privateBrowsingEnabled = false; - - // Note: if the page fails to load, the test will time out - browser.addEventListener("load", function() { - browser.removeEventListener("load", arguments.callee, true); - - is(content.location, TEST_URL, - "The original SSL page should be loaded at this stage"); - - gBrowser.removeCurrentTab(); - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - }, true); - - executeSoon(function () { - content.location = TEST_URL; - }); - }, true); - content.location = TEST_URL; - - waitForExplicitFinish(); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_transition.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_transition.js deleted file mode 100644 index fa932adb146e..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_transition.js +++ /dev/null @@ -1,64 +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/. */ - -// Tests the order of events and notifications when entering/exiting private -// browsing mode. This ensures that all private data is removed on exit, e.g. -// a cookie set in on unload handler, see bug 476463. -let cookieManager = Cc["@mozilla.org/cookiemanager;1"]. - getService(Ci.nsICookieManager2); -let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); -let observerNotified = 0, firstUnloadFired = 0, secondUnloadFired = 0; - -function pbObserver(aSubject, aTopic, aData) { - if (aTopic != "private-browsing") - return; - switch (aData) { - case "enter": - observerNotified++; - is(observerNotified, 1, "This should be the first notification"); - is(firstUnloadFired, 1, "The first unload event should have been processed by now"); - break; - case "exit": - Services.obs.removeObserver(pbObserver, "private-browsing"); - observerNotified++; - is(observerNotified, 2, "This should be the second notification"); - is(secondUnloadFired, 1, "The second unload event should have been processed by now"); - break; - } -} - -function test() { - waitForExplicitFinish(); - Services.obs.addObserver(pbObserver, "private-browsing", false); - is(gBrowser.tabs.length, 1, "There should only be one tab"); - let testTab = gBrowser.addTab(); - gBrowser.selectedTab = testTab; - testTab.linkedBrowser.addEventListener("unload", function () { - testTab.linkedBrowser.removeEventListener("unload", arguments.callee, true); - firstUnloadFired++; - is(observerNotified, 0, "The notification shouldn't have been sent yet"); - }, true); - - pb.privateBrowsingEnabled = true; - let testTab = gBrowser.addTab(); - gBrowser.selectedTab = testTab; - testTab.linkedBrowser.addEventListener("unload", function () { - testTab.linkedBrowser.removeEventListener("unload", arguments.callee, true); - secondUnloadFired++; - is(observerNotified, 1, "The notification shouldn't have been sent yet"); - cookieManager.add("example.com", "test/", "PB", "1", false, false, false, 1000000000000); - }, true); - - pb.privateBrowsingEnabled = false; - gBrowser.tabContainer.lastChild.linkedBrowser.addEventListener("unload", function () { - gBrowser.tabContainer.lastChild.linkedBrowser.removeEventListener("unload", arguments.callee, true); - let count = cookieManager.countCookiesFromHost("example.com"); - is(count, 0, "There shouldn't be any cookies once pb mode has exited"); - cookieManager.QueryInterface(Ci.nsICookieManager); - cookieManager.remove("example.com", "PB", "test/", false); - }, true); - gBrowser.removeCurrentTab(); - finish(); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_urlbarundo.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_urlbarundo.js deleted file mode 100644 index 4cf71509bc00..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_urlbarundo.js +++ /dev/null @@ -1,32 +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 makes sure that the undo history of the URL bar is cleared when -// leaving the private browsing mode. - -function test() { - // initialization - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - - // fill in the URL bar with something - gURLBar.value = "some test value"; - - ok(gURLBar.editor.transactionManager.numberOfUndoItems > 0, - "The undo history for the URL bar should not be empty"); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - is(gURLBar.editor.transactionManager.numberOfUndoItems, 0, - "The undo history of the URL bar should be cleared after leaving the private browsing mode"); - - // cleanup - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); -} - diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_viewsource.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_viewsource.js deleted file mode 100644 index 038235160a7f..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_viewsource.js +++ /dev/null @@ -1,140 +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 makes sure that entering the private browsing mode closes -// all view source windows, and leaving it restores them - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - let aboutBrowser = gBrowser.selectedBrowser; - aboutBrowser.addEventListener("load", function () { - aboutBrowser.removeEventListener("load", arguments.callee, true); - - function observer(aSubject, aTopic, aData) { - if (aTopic != "domwindowopened") - return; - - Services.ww.unregisterNotification(observer); - - let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); - win.addEventListener("load", function () { - win.removeEventListener("load", arguments.callee, false); - - let browser = win.gBrowser; - browser.addEventListener("load", function () { - browser.removeEventListener("load", arguments.callee, true); - - // view source window is loaded, proceed with the rest of the test - step1(); - }, true); - }, false); - } - Services.ww.registerNotification(observer); - - openViewSource(); - - function openViewSource() { - // invoke the View Source command - document.getElementById("View:PageSource").doCommand(); - } - - function step1() { - function observer(aSubject, aTopic, aData) { - if (aTopic == "domwindowclosed") { - ok(true, "Entering the private browsing mode should close the view source window"); - Services.ww.unregisterNotification(observer); - - step2(); - } else if (aTopic == "domwindowopened") { - ok(false, "Entering the private browsing mode should not open any view source window"); - } else if (aTopic == "private-browsing-transition-complete") { - Services.obs.removeObserver(observer, "private-browsing-transition-complete"); - step3(); - } - } - Services.ww.registerNotification(observer); - Services.obs.addObserver(observer, "private-browsing-transition-complete", false); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - } - - let events = 0, step2, step3; - step2 = step3 = function() { - if (++events == 2) - step4(); - } - - function step4() { - function observer(aSubject, aTopic, aData) { - if (aTopic != "domwindowopened") - return; - - Services.ww.unregisterNotification(observer); - - let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); - win.addEventListener("load", function () { - win.removeEventListener("load", arguments.callee, false); - - let browser = win.gBrowser; - browser.addEventListener("load", function () { - browser.removeEventListener("load", arguments.callee, true); - - // view source window inside private browsing mode opened - step5(); - }, true); - }, false); - } - Services.ww.registerNotification(observer); - - openViewSource(); - } - - function step5() { - let events = 0; - - function observer(aSubject, aTopic, aData) { - if (aTopic == "domwindowclosed") { - ok(true, "Leaving the private browsing mode should close the existing view source window"); - if (++events == 2) - Services.ww.unregisterNotification(observer); - } - else if (aTopic == "domwindowopened") { - ok(true, "Leaving the private browsing mode should restore the previous view source window"); - if (++events == 2) - Services.ww.unregisterNotification(observer); - - let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); - win.addEventListener("load", function () { - win.removeEventListener("load", arguments.callee, false); - - let browser = win.gBrowser; - browser.addEventListener("load", function () { - browser.removeEventListener("load", arguments.callee, true); - - is(win.content.location.href, "view-source:about:", - "The correct view source window should be restored"); - - // cleanup - win.close(); - gBrowser.removeCurrentTab(); - finish(); - }, true); - }, false); - } - } - Services.ww.registerNotification(observer); - - // exit private browsing mode - pb.privateBrowsingEnabled = false; - } - }, true); - aboutBrowser.loadURI("about:"); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/head.js b/browser/components/privatebrowsing/test/browser/obsolete/head.js deleted file mode 100644 index ea935fe72679..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/head.js +++ /dev/null @@ -1,25 +0,0 @@ -// Make sure that we clean up after each test if it times out, for example. -registerCleanupFunction(function() { - var pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - ok(!pb.privateBrowsingEnabled, "Private browsing should be terminated after finishing the test"); - pb.privateBrowsingEnabled = false; - try { - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - } catch(e) {} -}); - -/** - * Waits for completion of a clear history operation, before - * proceeding with aCallback. - * - * @param aCallback - * Function to be called when done. - */ -function waitForClearHistory(aCallback) { - Services.obs.addObserver(function observeCH(aSubject, aTopic, aData) { - Services.obs.removeObserver(observeCH, PlacesUtils.TOPIC_EXPIRATION_FINISHED); - aCallback(); - }, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false); - PlacesUtils.bhistory.removeAllPages(); -} diff --git a/browser/components/privatebrowsing/test/unit/do_test_0-privatebrowsing.js b/browser/components/privatebrowsing/test/unit/do_test_0-privatebrowsing.js deleted file mode 100644 index 67fb936f3332..000000000000 --- a/browser/components/privatebrowsing/test/unit/do_test_0-privatebrowsing.js +++ /dev/null @@ -1,217 +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 tests the private browsing service to make sure it implements its -// documented interface correctly. - -// This test should run before the rest of private browsing service unit tests, -// hence the naming used for this file. - -function do_test() { - // initialization - var os = Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService); - - // the contract ID should be available - do_check_true(PRIVATEBROWSING_CONTRACT_ID in Cc); - - // the interface should be available - do_check_true("nsIPrivateBrowsingService" in Ci); - - // it should be possible to initialize the component - try { - var pb = Cc[PRIVATEBROWSING_CONTRACT_ID]. - getService(Ci.nsIPrivateBrowsingService); - } catch (ex) { - LOG("exception thrown when trying to get the service: " + ex); - do_throw("private browsing service could not be initialized"); - } - - // private browsing should be turned off initially - do_check_false(pb.privateBrowsingEnabled); - // private browsing not auto-started - do_check_false(pb.autoStarted); - // and the status should have never been changed - do_check_eq(pb.lastChangedByCommandLine, false); - - // it should be possible to toggle its status - pb.privateBrowsingEnabled = true; - do_check_true(pb.privateBrowsingEnabled); - do_check_false(pb.autoStarted); - do_check_eq(pb.lastChangedByCommandLine, false); - pb.privateBrowsingEnabled = false; - do_check_false(pb.privateBrowsingEnabled); - do_check_false(pb.autoStarted); - do_check_eq(pb.lastChangedByCommandLine, false); - - // test the private-browsing notification - var observer = { - observe: function(aSubject, aTopic, aData) { - if (aTopic == kPrivateBrowsingNotification) - this.data = aData; - }, - data: null - }; - os.addObserver(observer, kPrivateBrowsingNotification, false); - pb.privateBrowsingEnabled = true; - do_check_eq(observer.data, kEnter); - pb.privateBrowsingEnabled = false; - do_check_eq(observer.data, kExit); - os.removeObserver(observer, kPrivateBrowsingNotification); - - // make sure that setting the private browsing mode from within an observer throws - observer = { - observe: function(aSubject, aTopic, aData) { - if (aTopic == kPrivateBrowsingNotification) { - try { - pb.privateBrowsingEnabled = (aData == kEnter); - do_throw("Setting privateBrowsingEnabled inside the " + aData + - " notification should throw"); - } catch (ex) { - if (!("result" in ex && ex.result == Cr.NS_ERROR_FAILURE)) - do_throw("Unexpected exception caught: " + ex); - } - } - } - }; - os.addObserver(observer, kPrivateBrowsingNotification, false); - pb.privateBrowsingEnabled = true; - do_check_true(pb.privateBrowsingEnabled); // the exception should not interfere with the mode change - pb.privateBrowsingEnabled = false; - do_check_false(pb.privateBrowsingEnabled); // the exception should not interfere with the mode change - os.removeObserver(observer, kPrivateBrowsingNotification); - - // make sure that getting the private browsing mode from within an observer doesn't throw - observer = { - observe: function(aSubject, aTopic, aData) { - if (aTopic == kPrivateBrowsingNotification) { - try { - var dummy = pb.privateBrowsingEnabled; - if (aData == kEnter) - do_check_true(dummy); - else if (aData == kExit) - do_check_false(dummy); - } catch (ex) { - do_throw("Unexpected exception caught: " + ex); - } - } - } - }; - os.addObserver(observer, kPrivateBrowsingNotification, false); - pb.privateBrowsingEnabled = true; - do_check_true(pb.privateBrowsingEnabled); // just a sanity check - pb.privateBrowsingEnabled = false; - do_check_false(pb.privateBrowsingEnabled); // just a sanity check - os.removeObserver(observer, kPrivateBrowsingNotification); - - // check that the private-browsing-cancel-vote notification is sent before the - // private-browsing notification - observer = { - observe: function(aSubject, aTopic, aData) { - switch (aTopic) { - case kPrivateBrowsingCancelVoteNotification: - case kPrivateBrowsingNotification: - this.notifications.push(aTopic + " " + aData); - } - }, - notifications: [] - }; - os.addObserver(observer, kPrivateBrowsingCancelVoteNotification, false); - os.addObserver(observer, kPrivateBrowsingNotification, false); - pb.privateBrowsingEnabled = true; - do_check_true(pb.privateBrowsingEnabled); // just a sanity check - pb.privateBrowsingEnabled = false; - do_check_false(pb.privateBrowsingEnabled); // just a sanity check - os.removeObserver(observer, kPrivateBrowsingNotification); - os.removeObserver(observer, kPrivateBrowsingCancelVoteNotification); - var reference_order = [ - kPrivateBrowsingCancelVoteNotification + " " + kEnter, - kPrivateBrowsingNotification + " " + kEnter, - kPrivateBrowsingCancelVoteNotification + " " + kExit, - kPrivateBrowsingNotification + " " + kExit - ]; - do_check_eq(observer.notifications.join(","), reference_order.join(",")); - - // make sure that the private-browsing-cancel-vote notification can be used - // to cancel the mode switch - observer = { - observe: function(aSubject, aTopic, aData) { - switch (aTopic) { - case kPrivateBrowsingCancelVoteNotification: - do_check_neq(aSubject, null); - try { - aSubject.QueryInterface(Ci.nsISupportsPRBool); - } catch (ex) { - do_throw("aSubject in " + kPrivateBrowsingCancelVoteNotification + - " should implement nsISupportsPRBool"); - } - do_check_false(aSubject.data); - aSubject.data = true; // cancel the mode switch - - // fall through - case kPrivateBrowsingNotification: - this.notifications.push(aTopic + " " + aData); - } - }, - nextPhase: function() { - this.notifications.push("enter phase " + (++this._phase)); - }, - notifications: [], - _phase: 0 - }; - os.addObserver(observer, kPrivateBrowsingCancelVoteNotification, false); - os.addObserver(observer, kPrivateBrowsingNotification, false); - pb.privateBrowsingEnabled = true; - do_check_false(pb.privateBrowsingEnabled); // should have been canceled - // temporarily disable the observer - os.removeObserver(observer, kPrivateBrowsingCancelVoteNotification); - observer.nextPhase(); - pb.privateBrowsingEnabled = true; // this time, should enter successfully - do_check_true(pb.privateBrowsingEnabled); // should have been canceled - // re-enable the observer - os.addObserver(observer, kPrivateBrowsingCancelVoteNotification, false); - pb.privateBrowsingEnabled = false; - do_check_true(pb.privateBrowsingEnabled); // should have been canceled - os.removeObserver(observer, kPrivateBrowsingCancelVoteNotification); - observer.nextPhase(); - pb.privateBrowsingEnabled = false; // this time, should exit successfully - do_check_false(pb.privateBrowsingEnabled); - os.removeObserver(observer, kPrivateBrowsingNotification); - reference_order = [ - kPrivateBrowsingCancelVoteNotification + " " + kEnter, - "enter phase 1", - kPrivateBrowsingNotification + " " + kEnter, - kPrivateBrowsingCancelVoteNotification + " " + kExit, - "enter phase 2", - kPrivateBrowsingNotification + " " + kExit, - ]; - do_check_eq(observer.notifications.join(","), reference_order.join(",")); - - // make sure that the private browsing transition complete notification is - // raised correctly. - observer = { - observe: function(aSubject, aTopic, aData) { - this.notifications.push(aTopic + " " + aData); - }, - notifications: [] - }; - os.addObserver(observer, kPrivateBrowsingNotification, false); - os.addObserver(observer, kPrivateBrowsingTransitionCompleteNotification, false); - pb.privateBrowsingEnabled = true; - pb.privateBrowsingEnabled = false; - os.removeObserver(observer, kPrivateBrowsingNotification); - os.removeObserver(observer, kPrivateBrowsingTransitionCompleteNotification); - reference_order = [ - kPrivateBrowsingNotification + " " + kEnter, - kPrivateBrowsingTransitionCompleteNotification + " ", - kPrivateBrowsingNotification + " " + kExit, - kPrivateBrowsingTransitionCompleteNotification + " ", - ]; - do_check_eq(observer.notifications.join(","), reference_order.join(",")); -} - -// Support running tests on both the service itself and its wrapper -function run_test() { - run_test_on_all_services(); -} diff --git a/browser/components/privatebrowsing/test/unit/do_test_placesTitleNoUpdate.js b/browser/components/privatebrowsing/test/unit/do_test_placesTitleNoUpdate.js deleted file mode 100644 index 8ecb0aee51ec..000000000000 --- a/browser/components/privatebrowsing/test/unit/do_test_placesTitleNoUpdate.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/. */ - -// Test to make sure that the visited page titles do not get updated inside the -// private browsing mode. - -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/PlacesUtils.jsm"); - -function do_test() -{ - let pb = Cc[PRIVATEBROWSING_CONTRACT_ID]. - getService(Ci.nsIPrivateBrowsingService); - - const TEST_URI = uri("http://mozilla.com/privatebrowsing"); - const TITLE_1 = "Title 1"; - const TITLE_2 = "Title 2"; - - do_test_pending(); - waitForClearHistory(function () { - let place = { - uri: TEST_URI, - title: TITLE_1, - visits: [{ - visitDate: Date.now() * 1000, - transitionType: Ci.nsINavHistoryService.TRANSITION_LINK - }] - }; - PlacesUtils.asyncHistory.updatePlaces(place, { - handleError: function () do_throw("Unexpected error in adding visit."), - handleResult: function () { }, - handleCompletion: function () afterAddFirstVisit() - }); - }); - - function afterAddFirstVisit() - { - do_check_eq(PlacesUtils.history.getPageTitle(TEST_URI), TITLE_1); - - waitForClearHistory(do_test_finished); - } -} - -// Support running tests on both the service itself and its wrapper -function run_test() { - run_test_on_all_services(); -} - -function waitForClearHistory(aCallback) { - let observer = { - observe: function(aSubject, aTopic, aData) { - Services.obs.removeObserver(this, PlacesUtils.TOPIC_EXPIRATION_FINISHED); - aCallback(); - } - }; - Services.obs.addObserver(observer, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false); - - PlacesUtils.bhistory.removeAllPages(); -} diff --git a/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_autostart.js b/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_autostart.js deleted file mode 100644 index 312a2772b1a1..000000000000 --- a/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_autostart.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/. */ - -// This test checks the browser.privatebrowsing.autostart preference. - -function do_test() { - // initialization - var prefsService = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); - prefsService.setBoolPref("browser.privatebrowsing.autostart", true); - do_check_true(prefsService.getBoolPref("browser.privatebrowsing.autostart")); - - var pb = Cc[PRIVATEBROWSING_CONTRACT_ID]. - getService(Ci.nsIPrivateBrowsingService). - QueryInterface(Ci.nsIObserver); - - // private browsing not auto-started yet - do_check_false(pb.autoStarted); - - // simulate startup to make the PB service read the prefs - pb.observe(null, "profile-after-change", ""); - - // the private mode should be entered automatically - do_check_true(pb.privateBrowsingEnabled); - - // private browsing is auto-started - do_check_true(pb.autoStarted); - - // leave private browsing mode - pb.privateBrowsingEnabled = false; - - // private browsing not auto-started - do_check_false(pb.autoStarted); - - // enter private browsing mode again - pb.privateBrowsingEnabled = true; - - // private browsing is auto-started - do_check_true(pb.autoStarted); -} diff --git a/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_commandline.js b/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_commandline.js deleted file mode 100644 index c902019d043f..000000000000 --- a/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_commandline.js +++ /dev/null @@ -1,89 +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 checks the browser -private command line option. - -function testprivatecl() { -} - -testprivatecl.prototype = { - _arguments: ["private", "silent"], - get length() { - return this._arguments.length; - }, - getArgument: function getArgument(aIndex) { - return this._arguments[aIndex]; - }, - findFlag: function findFlag(aFlag, aCaseSensitive) { - for (let i = 0; i < this._arguments.length; ++i) - if (aCaseSensitive ? - (this._arguments[i] == aFlag) : - (this._arguments[i].toLowerCase() == aFlag.toLowerCase())) - return i; - return -1; - }, - removeArguments: function removeArguments(aStart, aEnd) { - this._arguments.splice(aStart, aEnd - aStart + 1); - }, - handleFlag: function handleFlag (aFlag, aCaseSensitive) { - let res = this.findFlag(aFlag, aCaseSensitive); - if (res > -1) { - this.removeArguments(res, res); - return true; - } - return false; - }, - handleFlagWithParam: function handleFlagWithParam(aFlag, aCaseSensitive) { - return null; - }, - STATE_INITIAL_LAUNCH: 0, - STATE_REMOTE_AUTO: 1, - STATE_REMOTE_EXPLICIT: 2, - get state() { - return this.STATE_INITIAL_LAUNCH; - }, - preventDefault: false, - workingDirectory: null, - windowContext: null, - resolveFile: function resolveFile (aArgument) { - return null; - }, - resolveURI: function resolveURI (aArgument) { - return null; - }, - QueryInterface: function(aIID) { - if (!aIID.equals(Ci.nsICommandLine) - && !aIID.equals(Ci.nsISupports)) - throw Cr.NS_ERROR_NO_INTERFACE; - return this; - } -} - -function do_test() { - // initialization - let pb = Cc[PRIVATEBROWSING_CONTRACT_ID]. - getService(Ci.nsIPrivateBrowsingService). - QueryInterface(Ci.nsIObserver); - - let testcl = new testprivatecl(); - - pb.observe(testcl, "command-line-startup", null); - - let catMan = Cc["@mozilla.org/categorymanager;1"]. - getService(Ci.nsICategoryManager); - let categories = catMan.enumerateCategory("command-line-handler"); - while (categories.hasMoreElements()) { - let category = categories.getNext().QueryInterface(Ci.nsISupportsCString).data; - let contractID = catMan.getCategoryEntry("command-line-handler", category); - let handler = Cc[contractID].getService(Ci.nsICommandLineHandler); - handler.handle(testcl); - } - - // the private mode should be entered automatically - do_check_true(pb.privateBrowsingEnabled); - // and should appear as auto-started! - do_check_true(pb.autoStarted); - // and should be coming from the command line! - do_check_eq(pb.lastChangedByCommandLine, true); -} diff --git a/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_exit.js b/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_exit.js deleted file mode 100644 index 2bf70e6566aa..000000000000 --- a/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_exit.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/. */ - -// This test makes sure that the private browsing mode is left at application -// shutdown. - -function do_test() { - // initialization - var os = Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService); - var pb = Cc[PRIVATEBROWSING_CONTRACT_ID]. - getService(Ci.nsIPrivateBrowsingService); - - var expectedQuitting; - var called = 0; - var observer = { - observe: function(aSubject, aTopic, aData) { - if (aTopic == kPrivateBrowsingNotification && - aData == kExit) { - // increment the call counter - ++ called; - - do_check_neq(aSubject, null); - try { - aSubject.QueryInterface(Ci.nsISupportsPRBool); - } catch (ex) { - do_throw("aSubject was not null, but wasn't an nsISupportsPRBool"); - } - // check the "quitting" argument - do_check_eq(aSubject.data, expectedQuitting); - - // finish up the test - if (expectedQuitting) { - os.removeObserver(this, kPrivateBrowsingNotification); - do_test_finished(); - } - } - } - }; - - // set the observer - os.addObserver(observer, kPrivateBrowsingNotification, false); - - // enter the private browsing mode - pb.privateBrowsingEnabled = true; - - // exit the private browsing mode - expectedQuitting = false; - pb.privateBrowsingEnabled = false; - do_check_eq(called, 1); - - // enter the private browsing mode - pb.privateBrowsingEnabled = true; - - // Simulate an exit - expectedQuitting = true; - do_test_pending(); - os.notifyObservers(null, "quit-application-granted", null); -} diff --git a/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_telemetry.js b/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_telemetry.js deleted file mode 100644 index 64d7171d1d25..000000000000 --- a/browser/components/privatebrowsing/test/unit/do_test_privatebrowsing_telemetry.js +++ /dev/null @@ -1,42 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -XPCOMUtils.defineLazyServiceGetter(this, "gPrivateBrowsing", - PRIVATEBROWSING_CONTRACT_ID, - "nsIPrivateBrowsingService"); - -function waitForTransition(aEnabled, aCallback) { - Services.obs.addObserver(function PBT_transition(aSubject, aTopic, aData) { - Services.obs.removeObserver(PBT_transition, aTopic, false); - // Telemetry data is recorded just after the private browsing transition - // observers are notified, thus we must wait for this observer to return. - do_execute_soon(aCallback); - }, "private-browsing-transition-complete", false); - gPrivateBrowsing.privateBrowsingEnabled = aEnabled; -} - -function checkHistogram(aId) { - // Check that we have data either in the first bucket (that doesn't - // count towards the sum) or one of the other buckets, by checking - // the sum of the values. - let snapshot = Services.telemetry.getHistogramById(aId).snapshot(); - do_check_true(snapshot.sum > 0 || snapshot.counts[0] > 0); -} - -function do_test() { - do_test_pending(); - - waitForTransition(true, function PBT_enabled() { - waitForTransition(false, function PBT_disabled() { - checkHistogram("PRIVATE_BROWSING_TRANSITION_ENTER_PREPARATION_MS"); - checkHistogram("PRIVATE_BROWSING_TRANSITION_ENTER_TOTAL_MS"); - checkHistogram("PRIVATE_BROWSING_TRANSITION_EXIT_PREPARATION_MS"); - checkHistogram("PRIVATE_BROWSING_TRANSITION_EXIT_TOTAL_MS"); - - do_test_finished(); - }); - }); -} diff --git a/browser/components/privatebrowsing/test/unit/head_privatebrowsing.js b/browser/components/privatebrowsing/test/unit/head_privatebrowsing.js deleted file mode 100644 index 4dd37f91b1f4..000000000000 --- a/browser/components/privatebrowsing/test/unit/head_privatebrowsing.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/. */ - -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cr = Components.results; -const Cu = Components.utils; - -const kPrivateBrowsingNotification = "private-browsing"; -const kPrivateBrowsingCancelVoteNotification = "private-browsing-cancel-vote"; -const kPrivateBrowsingTransitionCompleteNotification = "private-browsing-transition-complete"; -const kEnter = "enter"; -const kExit = "exit"; - -function LOG(aMsg) { - aMsg = ("*** PRIVATEBROWSING TESTS: " + aMsg); - Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService). - logStringMessage(aMsg); - print(aMsg); -} - -function uri(spec) { - return Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService). - newURI(spec, null, null); -} - -var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); -var profileDir = do_get_profile(); - -// Do not attempt to restore any session since we don't have any windows -Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch). - setBoolPref("browser.privatebrowsing.keep_current_session", true); - -/** - * Removes any files that could make our tests fail. - */ -function cleanUp() -{ - let files = [ - "downloads.sqlite", - "places.sqlite", - "cookies.sqlite", - "signons.sqlite", - "permissions.sqlite" - ]; - - for (let i = 0; i < files.length; i++) { - let file = dirSvc.get("ProfD", Ci.nsIFile); - file.append(files[i]); - if (file.exists()) - file.remove(false); - } -} -cleanUp(); - -var PRIVATEBROWSING_CONTRACT_ID; -function run_test_on_all_services() { - var contractIDs = [ - "@mozilla.org/privatebrowsing;1", - "@mozilla.org/privatebrowsing-wrapper;1" - ]; - for (var i = 0; i < contractIDs.length; ++i) { - PRIVATEBROWSING_CONTRACT_ID = contractIDs[i]; - run_test_on_service(); - cleanUp(); - } -} diff --git a/browser/components/privatebrowsing/test/unit/tail_privatebrowsing.js b/browser/components/privatebrowsing/test/unit/tail_privatebrowsing.js deleted file mode 100644 index 2abfe3f05dc0..000000000000 --- a/browser/components/privatebrowsing/test/unit/tail_privatebrowsing.js +++ /dev/null @@ -1,8 +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/. */ - -// Be neat: clear the pref that we have set -Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch). - clearUserPref("browser.privatebrowsing.keep_current_session"); diff --git a/browser/components/privatebrowsing/test/unit/test_0-privatebrowsing.js b/browser/components/privatebrowsing/test/unit/test_0-privatebrowsing.js deleted file mode 100644 index c3eba0eeb1cb..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_0-privatebrowsing.js +++ /dev/null @@ -1,12 +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 tests the private browsing service to make sure it implements its -// documented interface correctly. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing;1"; - load("do_test_0-privatebrowsing.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_0-privatebrowsingwrapper.js b/browser/components/privatebrowsing/test/unit/test_0-privatebrowsingwrapper.js deleted file mode 100644 index b1385beb1932..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_0-privatebrowsingwrapper.js +++ /dev/null @@ -1,12 +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 tests the private browsing service to make sure it implements its -// documented interface correctly. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing-wrapper;1"; - load("do_test_0-privatebrowsing.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_aboutprivatebrowsing.js b/browser/components/privatebrowsing/test/unit/test_aboutprivatebrowsing.js deleted file mode 100644 index a8f316a824ac..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_aboutprivatebrowsing.js +++ /dev/null @@ -1,53 +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 makes sure that the about:privatebrowsing page is available inside -// and outside of the private mode. - -function is_about_privatebrowsing_available() { - try { - var ios = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService); - var channel = ios.newChannel("about:privatebrowsing", null, null); - var input = channel.open(); - var sinput = Cc["@mozilla.org/scriptableinputstream;1"]. - createInstance(Ci.nsIScriptableInputStream); - sinput.init(input); - while (true) - if (!sinput.read(1024).length) - break; - sinput.close(); - input.close(); - return true; - } catch (ex if ("result" in ex && ex.result == Cr.NS_ERROR_MALFORMED_URI)) { // expected - } - - return false; -} - -function run_test_on_service() { - // initialization - var pb = Cc[PRIVATEBROWSING_CONTRACT_ID]. - getService(Ci.nsIPrivateBrowsingService); - - // about:privatebrowsing should be available before entering the private mode - do_check_true(is_about_privatebrowsing_available()); - - // enter the private browsing mode - pb.privateBrowsingEnabled = true; - - // about:privatebrowsing should be available inside the private mode - do_check_true(is_about_privatebrowsing_available()); - - // exit the private browsing mode - pb.privateBrowsingEnabled = false; - - // about:privatebrowsing should be available after leaving the private mode - do_check_true(is_about_privatebrowsing_available()); -} - -// Support running tests on both the service itself and its wrapper -function run_test() { - run_test_on_all_services(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_placesTitleNoUpdate.js b/browser/components/privatebrowsing/test/unit/test_placesTitleNoUpdate.js deleted file mode 100644 index 658da9f29039..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_placesTitleNoUpdate.js +++ /dev/null @@ -1,12 +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 to make sure that the visited page titles do not get updated inside the -// private browsing mode. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing;1"; - load("do_test_placesTitleNoUpdate.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_privatebrowsing_autostart.js b/browser/components/privatebrowsing/test/unit/test_privatebrowsing_autostart.js deleted file mode 100644 index 20dea86a6846..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_privatebrowsing_autostart.js +++ /dev/null @@ -1,11 +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 checks the browser.privatebrowsing.autostart preference. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing;1"; - load("do_test_privatebrowsing_autostart.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_privatebrowsing_commandline.js b/browser/components/privatebrowsing/test/unit/test_privatebrowsing_commandline.js deleted file mode 100644 index ef22ba75c97f..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_privatebrowsing_commandline.js +++ /dev/null @@ -1,11 +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 checks the browser -private command line option. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing;1"; - load("do_test_privatebrowsing_commandline.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_privatebrowsing_exit.js b/browser/components/privatebrowsing/test/unit/test_privatebrowsing_exit.js deleted file mode 100644 index 549922948f0d..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_privatebrowsing_exit.js +++ /dev/null @@ -1,12 +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 makes sure that the private browsing mode is left at application -// shutdown. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing;1"; - load("do_test_privatebrowsing_exit.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_privatebrowsing_telemetry.js b/browser/components/privatebrowsing/test/unit/test_privatebrowsing_telemetry.js deleted file mode 100644 index 9ba79c4eda11..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_privatebrowsing_telemetry.js +++ /dev/null @@ -1,11 +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/. */ - -// Checks that telemetry data for private browsing transitions is recorded. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing;1"; - load("do_test_privatebrowsing_telemetry.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_autostart.js b/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_autostart.js deleted file mode 100644 index 2397771c6052..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_autostart.js +++ /dev/null @@ -1,11 +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 checks the browser.privatebrowsing.autostart preference. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing-wrapper;1"; - load("do_test_privatebrowsing_autostart.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_commandline.js b/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_commandline.js deleted file mode 100644 index 7902451fccd4..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_commandline.js +++ /dev/null @@ -1,11 +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 checks the browser -private command line option. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing-wrapper;1"; - load("do_test_privatebrowsing_commandline.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_exit.js b/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_exit.js deleted file mode 100644 index 3034e4299d8e..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_exit.js +++ /dev/null @@ -1,12 +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 makes sure that the private browsing mode is left at application -// shutdown. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing-wrapper;1"; - load("do_test_privatebrowsing_exit.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_placesTitleNoUpdate.js b/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_placesTitleNoUpdate.js deleted file mode 100644 index 2e2e727d6250..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_placesTitleNoUpdate.js +++ /dev/null @@ -1,12 +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 to make sure that the visited page titles do not get updated inside the -// private browsing mode. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing-wrapper;1"; - load("do_test_placesTitleNoUpdate.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_telemetry.js b/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_telemetry.js deleted file mode 100644 index c433c99d0512..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_privatebrowsingwrapper_telemetry.js +++ /dev/null @@ -1,11 +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/. */ - -// Checks that telemetry data for private browsing transitions is recorded. - -function run_test() { - PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing-wrapper;1"; - load("do_test_privatebrowsing_telemetry.js"); - do_test(); -} diff --git a/browser/components/privatebrowsing/test/unit/test_transition_nooffline.js b/browser/components/privatebrowsing/test/unit/test_transition_nooffline.js deleted file mode 100644 index 870c514b9f0d..000000000000 --- a/browser/components/privatebrowsing/test/unit/test_transition_nooffline.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/. */ - -// This tests the private browsing service to make sure it no longer switches -// the offline status (see bug 463256). - -function run_test_on_service() { - // initialization - var pb = Cc[PRIVATEBROWSING_CONTRACT_ID]. - getService(Ci.nsIPrivateBrowsingService); - var os = Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService); - - var observer = { - observe: function (aSubject, aTopic, aData) { - if (aTopic == "network:offline-status-changed") - this.events.push(aData); - }, - events: [] - }; - os.addObserver(observer, "network:offline-status-changed", false); - - // enter the private browsing mode, and wait for the about:pb page to load - pb.privateBrowsingEnabled = true; - do_check_eq(observer.events.length, 0); - - // leave the private browsing mode, and wait for the SSL page to load again - pb.privateBrowsingEnabled = false; - do_check_eq(observer.events.length, 0); - - os.removeObserver(observer, "network:offline-status-changed", false); -} - -// Support running tests on both the service itself and its wrapper -function run_test() { - run_test_on_all_services(); -} diff --git a/browser/components/privatebrowsing/test/unit/xpcshell.ini b/browser/components/privatebrowsing/test/unit/xpcshell.ini deleted file mode 100644 index 0123470ed1da..000000000000 --- a/browser/components/privatebrowsing/test/unit/xpcshell.ini +++ /dev/null @@ -1,18 +0,0 @@ -[DEFAULT] -head = head_privatebrowsing.js -tail = tail_privatebrowsing.js - -[test_0-privatebrowsing.js] -[test_0-privatebrowsingwrapper.js] -[test_aboutprivatebrowsing.js] -[test_placesTitleNoUpdate.js] -[test_privatebrowsing_autostart.js] -[test_privatebrowsing_commandline.js] -[test_privatebrowsing_exit.js] -[test_privatebrowsing_telemetry.js] -[test_privatebrowsingwrapper_autostart.js] -[test_privatebrowsingwrapper_commandline.js] -[test_privatebrowsingwrapper_exit.js] -[test_privatebrowsingwrapper_placesTitleNoUpdate.js] -[test_privatebrowsingwrapper_telemetry.js] -[test_transition_nooffline.js] diff --git a/browser/components/search/test/Makefile.in b/browser/components/search/test/Makefile.in index a133279ffe95..cc2d8f526feb 100644 --- a/browser/components/search/test/Makefile.in +++ b/browser/components/search/test/Makefile.in @@ -14,6 +14,7 @@ MOCHITEST_BROWSER_FILES = \ browser_405664.js \ browser_addEngine.js \ browser_contextmenu.js \ + browser_private_search_perwindowpb.js \ testEngine.xml \ testEngine_mozsearch.xml \ testEngine.src \ @@ -25,14 +26,4 @@ MOCHITEST_BROWSER_FILES = \ test.html \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ - browser_private_search_perwindowpb.js \ - $(NULL) -else -MOCHITEST_BROWSER_FILES += \ - browser_private_search.js \ - $(NULL) -endif - include $(topsrcdir)/config/rules.mk diff --git a/browser/components/search/test/browser_private_search.js b/browser/components/search/test/browser_private_search.js deleted file mode 100644 index baf5d0b432e8..000000000000 --- a/browser/components/search/test/browser_private_search.js +++ /dev/null @@ -1,101 +0,0 @@ -// This test performs a search in a public window, then a different -// search in a private window, and then checks in the public window -// whether there is an autocomplete entry for the private search. - -function onLoad(callback) { - gBrowser.addEventListener("DOMContentLoaded", function load() { - gBrowser.removeEventListener("DOMContentLoaded", load, false); - callback(); - }, false); -} - -function doPrivateTest(searchBar) { - gPrivateBrowsingUI.toggleMode(); - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - - searchBar.value = "p"; - searchBar.focus(); - let popup = searchBar.textbox.popup; - //searchBar.textbox.closePopup(); - - info("adding listener"); - popup.addEventListener("popupshowing", function showing() { - let entries = getMenuEntries(searchBar); - for (var i = 0; i < entries.length; i++) - isnot(entries[i], "private test", "shouldn't see private autocomplete entries"); - popup.removeEventListener("popupshowing", showing, false); - - searchBar.textbox.toggleHistoryPopup(); - executeSoon(function() { - searchBar.value = ""; - gBrowser.addTab(); - gBrowser.removeCurrentTab(); - content.location.href = "about:blank"; - var engine = Services.search.getEngineByName("Bug 426329"); - Services.search.removeEngine(engine); - finish(); - - }); - }, false); - - info("triggering popup"); - searchBar.textbox.showHistoryPopup(); -} - -function doTest() { - let searchBar = BrowserSearch.searchBar; - ok(searchBar, "got search bar"); - - onLoad(function() { - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - gPrivateBrowsingUI.toggleMode(); - - onLoad(function() { - doPrivateTest(searchBar); - }); - - searchBar.value = "private test"; - searchBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); - }); - - searchBar.value = "public test"; - searchBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); -} - -function test() { - waitForExplicitFinish(); - //gBrowser.addTab(); - //let testBrowser = gBrowser.selectedBrowser; - - function observer(aSub, aTopic, aData) { - switch (aData) { - case "engine-current": - ok(ss.currentEngine.name == "Bug 426329", "currentEngine set"); - doTest(); - break; - default: - break; - } - } - - var ss = Services.search; - Services.obs.addObserver(observer, "browser-search-engine-modified", false); - ss.addEngine("http://mochi.test:8888/browser/browser/components/search/test/426329.xml", - Ci.nsISearchEngine.DATA_XML, "data:image/x-icon,%00", - false); -} - -function getMenuEntries(searchBar) { - var entries = []; - var autocompleteMenu = searchBar.textbox.popup; - // Could perhaps pull values directly from the controller, but it seems - // more reliable to test the values that are actually in the tree? - var column = autocompleteMenu.tree.columns[0]; - var numRows = autocompleteMenu.tree.view.rowCount; - for (var i = 0; i < numRows; i++) { - entries.push(autocompleteMenu.tree.view.getValueAt(i, column)); - } - return entries; -} diff --git a/browser/components/sessionstore/src/SessionStore.jsm b/browser/components/sessionstore/src/SessionStore.jsm index a8f2073dfccf..e2ee8f3ec11d 100644 --- a/browser/components/sessionstore/src/SessionStore.jsm +++ b/browser/components/sessionstore/src/SessionStore.jsm @@ -37,9 +37,6 @@ const OBSERVING = [ "browser-lastwindow-close-granted", "quit-application", "browser:purge-session-history", "browser:purge-domain-data" -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - ,"private-browsing", "private-browsing-change-granted" -#endif ]; // XUL Window properties to (re)store @@ -273,11 +270,6 @@ let SessionStoreInternal = { // counts the number of crashes since the last clean start _recentCrashes: 0, -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - // whether we are in private browsing mode - _inPrivateBrowsing: false, -#endif - // whether the last window was closed and should be restored _restoreLastWindow: false, @@ -325,12 +317,7 @@ let SessionStoreInternal = { /* ........ Public Getters .............. */ get canRestoreLastSession() { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING return this._lastSessionState; -#else - // Always disallow restoring the previous session when in private browsing - return this._lastSessionState && !this._inPrivateBrowsing; -#endif }, set canRestoreLastSession(val) { @@ -354,12 +341,6 @@ let SessionStoreInternal = { Services.obs.addObserver(this, aTopic, true); }, this); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - var pbs = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - this._inPrivateBrowsing = pbs.privateBrowsingEnabled; -#endif - this._initPrefs(); // Do pref migration before we store any values and start observing changes @@ -620,14 +601,6 @@ let SessionStoreInternal = { case "timer-callback": // timer call back for delayed saving this.onTimerCallback(); break; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - case "private-browsing": - this.onPrivateBrowsing(aSubject, aData); - break; - case "private-browsing-change-granted": - this.onPrivateBrowsingChangeGranted(aData); - break; -#endif } }, @@ -709,10 +682,8 @@ let SessionStoreInternal = { // and create its internal data object this._internalWindows[aWindow.__SSi] = { hosts: {} } -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) this._windows[aWindow.__SSi].isPrivate = true; -#endif if (!this._isWindowLoaded(aWindow)) this._windows[aWindow.__SSi]._restoring = true; if (!aWindow.toolbar.visible) @@ -751,14 +722,9 @@ let SessionStoreInternal = { this.restoreWindow(aWindow, this._statesToRestore[aWindow.__SS_restoreID], true, followUp); } else if (this._restoreLastWindow && aWindow.toolbar.visible && - this._closedWindows.length -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - && !PrivateBrowsingUtils.isWindowPrivate(aWindow) -#else - && !this._inPrivateBrowsing -#endif - ) { - + this._closedWindows.length && + !PrivateBrowsingUtils.isWindowPrivate(aWindow)) { + // default to the most-recently closed window // don't use popup windows let closedWindowState = null; @@ -916,16 +882,10 @@ let SessionStoreInternal = { winData._shouldRestore = true; #endif -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // Save the window if it has multiple tabs or a single saveable tab and // it's not private. if (!winData.isPrivate && (winData.tabs.length > 1 || (winData.tabs.length == 1 && this._shouldSaveTabState(winData.tabs[0])))) { -#else - // save the window if it has multiple tabs or a single saveable tab - if (winData.tabs.length > 1 || - (winData.tabs.length == 1 && this._shouldSaveTabState(winData.tabs[0]))) { -#endif // we don't want to save the busy state delete winData.busy; @@ -1193,65 +1153,6 @@ let SessionStoreInternal = { this.saveState(); }, -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - /** - * On private browsing - * @param aSubject - * Window reference - * @param aData - * String whether to enter or exit private browsing - */ - onPrivateBrowsing: function ssi_onPrivateBrowsing(aSubject, aData) { - switch (aData) { - case "enter": - this._inPrivateBrowsing = true; - break; - case "exit": - aSubject.QueryInterface(Ci.nsISupportsPRBool); - let quitting = aSubject.data; - if (quitting) { - // save the backed up state with session set to stopped, - // otherwise resuming next time would look like a crash. - // Whether we restore the session upon resume will be determined by the - // usual startup prefs, so we will have the same behavior regardless of - // whether the browser was closed while in normal or private browsing mode. - if ("_stateBackup" in this) { - var oState = this._stateBackup; - oState.session = { state: STATE_STOPPED_STR }; - - this._saveStateObject(oState); - } - } - else - this._inPrivateBrowsing = false; - delete this._stateBackup; - break; - } - - this._clearRestoringWindows(); - }, - - /** - * On private browsing change granted - * @param aData - * String whether to enter or exit private browsing - */ - onPrivateBrowsingChangeGranted: function ssi_onPrivateBrowsingChangeGranted(aData) { - if (aData == "enter") { - this.saveState(true); - // We stringify & parse the current state so that we have have an object - // that won't change. _getCurrentState returns an object with references - // to objects that can change (specifically this._windows[x]). - this._stateBackup = JSON.parse(this._toJSONString(this._getCurrentState(true))); - } - // Make sure _tabsToRestore is cleared. It will be repopulated when - // entering/exiting private browsing (by calls to setBrowserState). - this._resetRestoringState(); - - this._clearRestoringWindows(); - }, -#endif - /** * set up listeners for a new tab * @param aWindow @@ -3688,11 +3589,7 @@ let SessionStoreInternal = { this._dirtyWindows[aWindow.__SSi] = true; } - if (!this._saveTimer -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - && !this._inPrivateBrowsing -#endif - ) { + if (!this._saveTimer) { // interval until the next disk operation is allowed var minimalDelay = this._lastSaveTime + this._interval - Date.now(); @@ -3714,12 +3611,6 @@ let SessionStoreInternal = { * Bool update all windows */ saveState: function ssi_saveState(aUpdateAll) { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - // if we're in private browsing mode, do nothing - if (this._inPrivateBrowsing) - return; -#endif - // If crash recovery is disabled, we only want to resume with pinned tabs // if we crash. let pinnedOnly = this._loadState == STATE_RUNNING && !this._resume_from_crash; @@ -3732,7 +3623,6 @@ let SessionStoreInternal = { return; } -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // Forget about private windows. for (let i = oState.windows.length - 1; i >= 0; i--) { if (oState.windows[i].isPrivate) { @@ -3747,7 +3637,6 @@ let SessionStoreInternal = { oState._closedWindows.splice(i, 1); } } -#endif #ifndef XP_MACOSX // We want to restore closed windows that are marked with _shouldRestore. @@ -3910,11 +3799,9 @@ let SessionStoreInternal = { features += "," + aFeature + "=" + winState[aFeature]; }); -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (winState.isPrivate) { features += ",private"; } -#endif var window = Services.ww.openWindow(null, this._prefBranch.getCharPref("chromeURL"), diff --git a/browser/components/sessionstore/src/nsSessionStartup.js b/browser/components/sessionstore/src/nsSessionStartup.js index d9080f720a88..8d37e5d13194 100644 --- a/browser/components/sessionstore/src/nsSessionStartup.js +++ b/browser/components/sessionstore/src/nsSessionStartup.js @@ -76,12 +76,6 @@ SessionStartup.prototype = { if (PrivateBrowsingUtils.permanentPrivateBrowsing) return; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - let pbs = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - if (pbs.lastChangedByCommandLine) - return; -#endif _SessionFile.read().then( this._onSessionFileRead.bind(this) ); diff --git a/browser/components/sessionstore/test/Makefile.in b/browser/components/sessionstore/test/Makefile.in index 395f2ac4a027..d10f9c62ca18 100644 --- a/browser/components/sessionstore/test/Makefile.in +++ b/browser/components/sessionstore/test/Makefile.in @@ -25,6 +25,7 @@ MOCHITEST_BROWSER_FILES = \ browser_form_restore_events_sample.html \ browser_formdata_format.js \ browser_formdata_format_sample.html \ + browser_248970_b_perwindowpb.js \ browser_248970_b_sample.html \ browser_339445.js \ browser_339445_sample.html \ @@ -32,10 +33,12 @@ MOCHITEST_BROWSER_FILES = \ browser_346337.js \ browser_346337_sample.html \ browser_350525.js \ + browser_354894_perwindowpb.js \ browser_367052.js \ browser_393716.js \ browser_394759_basic.js \ browser_394759_behavior.js \ + browser_394759_perwindowpb.js \ browser_394759_purge.js \ browser_408470.js \ browser_408470_sample.html \ @@ -132,27 +135,12 @@ MOCHITEST_BROWSER_FILES = \ browser_739531.js \ browser_739531_sample.html \ browser_739805.js \ + browser_819510_perwindowpb.js \ $(filter disabled-for-intermittent-failures--bug-766044, browser_459906_empty.html) \ $(filter disabled-for-intermittent-failures--bug-766044, browser_459906_sample.html) \ $(filter disabled-for-intermittent-failures--bug-765389, browser_461743_sample.html) \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ - browser_354894_perwindowpb.js \ - browser_394759_perwindowpb.js \ - browser_819510_perwindowpb.js \ - $(NULL) -else -MOCHITEST_BROWSER_FILES += \ - browser_248970_a.js \ - browser_248970_b.js \ - browser_248970_b_perwindowpb.js \ - browser_354894.js \ - browser_394759_privatebrowsing.js \ - $(NULL) -endif - # Disabled on Windows for frequent intermittent failures ifneq ($(OS_ARCH), WINNT) MOCHITEST_FILES += \ diff --git a/browser/components/sessionstore/test/browser_248970_a.js b/browser/components/sessionstore/test/browser_248970_a.js deleted file mode 100644 index 8c847e783a43..000000000000 --- a/browser/components/sessionstore/test/browser_248970_a.js +++ /dev/null @@ -1,132 +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() { - /** Test (A) for Bug 248970 **/ - - // test setup - waitForExplicitFinish(); - - // private browsing service - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let profilePath = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties). - get("ProfD", Ci.nsIFile); - - function getSessionstoreFile() { - let sessionStoreJS = profilePath.clone(); - sessionStoreJS.append("sessionstore.js"); - return sessionStoreJS; - } - - function getSessionstorejsModificationTime() { - let file = getSessionstoreFile(); - if (file.exists()) - return file.lastModifiedTime; - else - return -1; - } - - function waitForFileExistence(aMessage, aDoNext) { - const TOPIC = "sessionstore-state-write-complete"; - Services.obs.addObserver(function (aSubject, aTopic, aData) { - // Remove the observer so we do not leak. - Services.obs.removeObserver(arguments.callee, TOPIC); - - // Check that the file exists. - ok(getSessionstoreFile().exists(), aMessage); - - // Run our next set of work. - aDoNext(); - }, TOPIC, false); - } - - function actualTest() { - - ////////////////////////////////////////////////////////////////// - // Test (A) : No data recording while in private browsing mode // - ////////////////////////////////////////////////////////////////// - - // public session, add a new tab: (A) - const testURL_A = "http://example.org/"; - let tab_A = gBrowser.addTab(testURL_A); - - tab_A.linkedBrowser.addEventListener("load", function (aEvent) { - this.removeEventListener("load", arguments.callee, true); - - // remove sessionstore.js to make sure it's created again when entering - // the private browsing mode. - let sessionStoreJS = getSessionstoreFile(); - sessionStoreJS.remove(false); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - ok(pb.privateBrowsingEnabled, "private browsing enabled"); - - // sessionstore.js should be re-created at this point - waitForFileExistence("file should be created after private browsing entered", - function() { - // record the time stamp of sessionstore.js in the private session - let startPBModeTimeStamp = getSessionstorejsModificationTime(); - - // private browsing session, add new tab: (B) - const testURL_B = "http://test1.example.org/"; - let tab_B = gBrowser.addTab(testURL_B); - - tab_B.linkedBrowser.addEventListener("load", function (aEvent) { - this.removeEventListener("load", arguments.callee, true); - - // private browsing session, add new tab: (C) - const testURL_C = "http://mochi.test:8888/"; - let tab_C = gBrowser.addTab(testURL_C); - - tab_C.linkedBrowser.addEventListener("load", function (aEvent) { - this.removeEventListener("load", arguments.callee, true); - - // private browsing session, close tab: (C) - gBrowser.removeTab(tab_C); - - // private browsing session, close tab: (B) - gBrowser.removeTab(tab_B); - - // private browsing session, close tab: (A) - gBrowser.removeTab(tab_A); - - // record the timestamp of sessionstore.js at the end of the private session - if (gPrefService.prefHasUserValue("browser.sessionstore.interval")) - gPrefService.clearUserPref("browser.sessionstore.interval"); - gPrefService.setIntPref("browser.sessionstore.interval", 0); - let endPBModeTimeStamp = getSessionstorejsModificationTime(); - - // exit private browsing mode - pb.privateBrowsingEnabled = false; - ok(!pb.privateBrowsingEnabled, "private browsing disabled"); - - // compare timestamps: pre and post private browsing session - is(startPBModeTimeStamp, endPBModeTimeStamp, - "outside private browsing - sessionStore.js timestamp has not changed"); - - // cleanup - gPrefService.clearUserPref("browser.sessionstore.interval"); - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - }, true); - }, true); - }); // End of anonymous waitForFileExistence function. - }, true); - } - - // Remove the sessionstore.js file before setting the interval to 0 - let sessionStoreJS = getSessionstoreFile(); - if (sessionStoreJS.exists()) - sessionStoreJS.remove(false); - // Make sure that sessionstore.js can be forced to be created by setting - // the interval pref to 0 - gPrefService.setIntPref("browser.sessionstore.interval", 0); - // sessionstore.js should be re-created at this point - waitForFileExistence("file should be created after setting interval to 0", - actualTest); -} diff --git a/browser/components/sessionstore/test/browser_248970_b.js b/browser/components/sessionstore/test/browser_248970_b.js deleted file mode 100644 index 382c633eaeb3..000000000000 --- a/browser/components/sessionstore/test/browser_248970_b.js +++ /dev/null @@ -1,175 +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() { - /** Test (B) for Bug 248970 **/ - - function test(aLambda) { - try { - return aLambda() || true; - } catch(ex) { } - return false; - } - - var file = Components.classes["@mozilla.org/file/directory_service;1"] - .getService(Components.interfaces.nsIProperties) - .get("TmpD", Components.interfaces.nsIFile); - var filePath = file.path; - - let fieldList = { - "//input[@name='input']": Date.now().toString(), - "//input[@name='spaced 1']": Math.random().toString(), - "//input[3]": "three", - "//input[@type='checkbox']": true, - "//input[@name='uncheck']": false, - "//input[@type='radio'][1]": false, - "//input[@type='radio'][2]": true, - "//input[@type='radio'][3]": false, - "//select": 2, - "//select[@multiple]": [1, 3], - "//textarea[1]": "", - "//textarea[2]": "Some text... " + Math.random(), - "//textarea[3]": "Some more text\n" + new Date(), - "//input[@type='file']": filePath - }; - - function getElementByXPath(aTab, aQuery) { - let doc = aTab.linkedBrowser.contentDocument; - let xptype = Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE; - return doc.evaluate(aQuery, doc, null, xptype, null).singleNodeValue; - } - - function setFormValue(aTab, aQuery, aValue) { - let node = getElementByXPath(aTab, aQuery); - if (typeof aValue == "string") - node.value = aValue; - else if (typeof aValue == "boolean") - node.checked = aValue; - else if (typeof aValue == "number") - node.selectedIndex = aValue; - else - Array.forEach(node.options, function(aOpt, aIx) - (aOpt.selected = aValue.indexOf(aIx) > -1)); - } - - function compareFormValue(aTab, aQuery, aValue) { - let node = getElementByXPath(aTab, aQuery); - if (!node) - return false; - if (node instanceof Ci.nsIDOMHTMLInputElement) - return aValue == (node.type == "checkbox" || node.type == "radio" ? - node.checked : node.value); - if (node instanceof Ci.nsIDOMHTMLTextAreaElement) - return aValue == node.value; - if (!node.multiple) - return aValue == node.selectedIndex; - return Array.every(node.options, function(aOpt, aIx) - (aValue.indexOf(aIx) > -1) == aOpt.selected); - } - - // test setup - waitForExplicitFinish(); - - // private browsing service - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - ////////////////////////////////////////////////////////////////// - // Test (B) : Session data restoration between modes // - ////////////////////////////////////////////////////////////////// - - let rootDir = getRootDirectory(gTestPath); - const testURL = rootDir + "browser_248970_b_sample.html"; - const testURL2 = "http://mochi.test:8888/browser/" + - "browser/components/sessionstore/test/browser_248970_b_sample.html"; - - // get closed tab count - let count = ss.getClosedTabCount(window); - let max_tabs_undo = gPrefService.getIntPref("browser.sessionstore.max_tabs_undo"); - ok(0 <= count && count <= max_tabs_undo, - "getClosedTabCount should return zero or at most max_tabs_undo"); - - // setup a state for tab (A) so we can check later that is restored - let key = "key"; - let value = "Value " + Math.random(); - let state = { entries: [{ url: testURL }], extData: { key: value } }; - - // public session, add new tab: (A) - let tab_A = gBrowser.addTab(testURL); - ss.setTabState(tab_A, JSON.stringify(state)); - tab_A.linkedBrowser.addEventListener("load", function(aEvent) { - this.removeEventListener("load", arguments.callee, true); - - // make sure that the next closed tab will increase getClosedTabCount - gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", max_tabs_undo + 1) - - // populate tab_A with form data - for (let i in fieldList) - setFormValue(tab_A, i, fieldList[i]); - - // public session, close tab: (A) - gBrowser.removeTab(tab_A); - - // verify that closedTabCount increased - ok(ss.getClosedTabCount(window) > count, "getClosedTabCount has increased after closing a tab"); - - // verify tab: (A), in undo list - let tab_A_restored = test(function() ss.undoCloseTab(window, 0)); - ok(tab_A_restored, "a tab is in undo list"); - tab_A_restored.linkedBrowser.addEventListener("load", function(aEvent) { - this.removeEventListener("load", arguments.callee, true); - - is(testURL, this.currentURI.spec, "it's the same tab that we expect"); - gBrowser.removeTab(tab_A_restored); - - // enter private browsing mode - pb.privateBrowsingEnabled = true; - ok(pb.privateBrowsingEnabled, "private browsing enabled"); - - // setup a state for tab (B) so we can check that its duplicated properly - let key1 = "key1"; - let value1 = "Value " + Math.random(); - let state1 = { entries: [{ url: testURL2 }], extData: { key1: value1 } }; - - // private browsing session, new tab: (B) - let tab_B = gBrowser.addTab(testURL2); - ss.setTabState(tab_B, JSON.stringify(state1)); - tab_B.linkedBrowser.addEventListener("load", function(aEvent) { - this.removeEventListener("load", arguments.callee, true); - - // populate tab: (B) with different form data - for (let item in fieldList) - setFormValue(tab_B, item, fieldList[item]); - - // duplicate tab: (B) - let tab_C = gBrowser.duplicateTab(tab_B); - tab_C.linkedBrowser.addEventListener("load", function(aEvent) { - this.removeEventListener("load", arguments.callee, true); - - // verify the correctness of the duplicated tab - is(ss.getTabValue(tab_C, key1), value1, - "tab successfully duplicated - correct state"); - - for (let item in fieldList) - ok(compareFormValue(tab_C, item, fieldList[item]), - "The value for \"" + item + "\" was correctly duplicated"); - - // private browsing session, close tab: (C) and (B) - gBrowser.removeTab(tab_C); - gBrowser.removeTab(tab_B); - - // exit private browsing mode - pb.privateBrowsingEnabled = false; - ok(!pb.privateBrowsingEnabled, "private browsing disabled"); - - // cleanup - if (gPrefService.prefHasUserValue("browser.privatebrowsing.keep_current_session")) - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - }, true); - }, true); - }, true); - }, true); -} diff --git a/browser/components/sessionstore/test/browser_354894.js b/browser/components/sessionstore/test/browser_354894.js deleted file mode 100644 index 922bcf47ae13..000000000000 --- a/browser/components/sessionstore/test/browser_354894.js +++ /dev/null @@ -1,515 +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/. */ - -/** - * Checks that restoring the last browser window in session is actually - * working: - * 1.1) Open a new browser window - * 1.2) Add some tabs - * 1.3) Close that window - * 1.4) Opening another window - * --> State is restored - * - * 2.1) Open a new browser window - * 2.2) Add some tabs - * 2.3) Enter private browsing mode - * 2.4) Close the window while still in private browsing mode - * 2.5) Opening a new window - * --> State is not restored, because private browsing mode is still active - * 2.6) Leaving private browsing mode - * 2.7) Open another window - * --> State (that was before entering PBM) is restored - * - * 3.1) Open a new browser window - * 3.2) Add some tabs - * 3.4) Open some popups - * 3.5) Add another tab to one popup (so that it gets stored) and close it again - * 3.5) Close the browser window - * 3.6) Open another browser window - * --> State of the closed browser window, but not of the popup, is restored - * - * 4.1) Open a popup - * 4.2) Add another tab to the popup (so that it gets stored) and close it again - * 4.3) Open a window - * --> Nothing at all should be restored - * - * 5.1) Open two browser windows and close them again - * 5.2) undoCloseWindow() one - * 5.3) Open another browser window - * --> Nothing at all should be restored - * - * Checks the new notifications are correctly posted and processed, that is - * for each successful -requested a -granted is received, but omitted if - * -requested was cnceled - * Said notifications are: - * - browser-lastwindow-close-requested - * - browser-lastwindow-close-granted - * Tests are: - * 6) Cancel closing when first observe a -requested - * --> Window is kept open - * 7) Count the number of notifications - * --> count(-requested) == count(-granted) + 1 - * --> (The first -requested was canceled, so off-by-one) - * 8) (Mac only) Mac version of Test 5 additionally preparing Test 6 - * - * @see https://bugzilla.mozilla.org/show_bug.cgi?id=354894 - * @note It is implicitly tested that restoring the last window works when - * non-browser windows are around. The "Run Tests" window as well as the main - * browser window (wherein the test code gets executed) won't be considered - * browser windows. To achiveve this said main browser window has it's windowtype - * attribute modified so that it's not considered a browser window any longer. - * This is crucial, because otherwise there would be two browser windows around, - * said main test window and the one opened by the tests, and hence the new - * logic wouldn't be executed at all. - * @note Mac only tests the new notifications, as restoring the last window is - * not enabled on that platform (platform shim; the application is kept running - * although there are no windows left) - * @note There is a difference when closing a browser window with - * BrowserTryToCloseWindow() as opposed to close(). The former will make - * nsSessionStore restore a window next time it gets a chance and will post - * notifications. The latter won't. - */ - -function browserWindowsCount(expected, msg) { - if (typeof expected == "number") - expected = [expected, expected]; - let count = 0; - let e = Services.wm.getEnumerator("navigator:browser"); - while (e.hasMoreElements()) { - if (!e.getNext().closed) - ++count; - } - is(count, expected[0], msg + " (nsIWindowMediator)"); - let state = ss.getBrowserState(); - is(JSON.parse(state).windows.length, expected[1], msg + " (getBrowserState)"); -} - -function test() { - browserWindowsCount(1, "Only one browser window should be open initially"); - - waitForExplicitFinish(); - // This test takes some time to run, and it could timeout randomly. - // So we require a longer timeout. See bug 528219. - requestLongerTimeout(2); - - // Some urls that might be opened in tabs and/or popups - // Do not use about:blank: - // That one is reserved for special purposes in the tests - const TEST_URLS = ["about:mozilla", "about:buildconfig"]; - - // Number of -request notifications to except - // remember to adjust when adding new tests - const NOTIFICATIONS_EXPECTED = 6; - - // Window features of popup windows - const POPUP_FEATURES = "toolbar=no,resizable=no,status=no"; - - // Window features of browser windows - const CHROME_FEATURES = "chrome,all,dialog=no"; - - // Store the old window type for cleanup - let oldWinType = ""; - // Store the old tabs.warnOnClose pref so that we may reset it during - // cleanup - let oldWarnTabsOnClose = gPrefService.getBoolPref("browser.tabs.warnOnClose"); - - // Observe these, and also use to count the number of hits - let observing = { - "browser-lastwindow-close-requested": 0, - "browser-lastwindow-close-granted": 0 - }; - - /** - * Helper: Will observe and handle the notifications for us - */ - let hitCount = 0; - function observer(aCancel, aTopic, aData) { - // count so that we later may compare - observing[aTopic]++; - - // handle some tests - if (++hitCount == 1) { - // Test 6 - aCancel.QueryInterface(Ci.nsISupportsPRBool).data = true; - } - } - - /** - * Helper: Sets prefs as the testsuite requires - * @note Will be reset in cleanTestSuite just before finishing the tests - */ - function setPrefs() { - gPrefService.setIntPref("browser.startup.page", 3); - gPrefService.setBoolPref( - "browser.privatebrowsing.keep_current_session", - true - ); - gPrefService.setBoolPref("browser.tabs.warnOnClose", false); - } - - /** - * Helper: Sets up this testsuite - */ - function setupTestsuite(testFn) { - // Register our observers - for (let o in observing) - Services.obs.addObserver(observer, o, false); - - // Make the main test window not count as a browser window any longer - oldWinType = document.documentElement.getAttribute("windowtype"); - document.documentElement.setAttribute("windowtype", "navigator:testrunner"); - } - - /** - * Helper: Cleans up behind the testsuite - */ - function cleanupTestsuite(callback) { - // Finally remove observers again - for (let o in observing) - Services.obs.removeObserver(observer, o, false); - - // Reset the prefs we touched - [ - "browser.startup.page", - "browser.privatebrowsing.keep_current_session" - ].forEach(function (pref) { - if (gPrefService.prefHasUserValue(pref)) - gPrefService.clearUserPref(pref); - }); - gPrefService.setBoolPref("browser.tabs.warnOnClose", oldWarnTabsOnClose); - - // Reset the window type - document.documentElement.setAttribute("windowtype", oldWinType); - } - - /** - * Helper: sets the prefs and a new window with our test tabs - */ - function setupTestAndRun(testFn) { - // Prepare the prefs - setPrefs(); - - // Prepare a window; open it and add more tabs - let newWin = openDialog(location, "_blank", CHROME_FEATURES, "about:config"); - newWin.addEventListener("load", function(aEvent) { - newWin.removeEventListener("load", arguments.callee, false); - newWin.gBrowser.addEventListener("load", function(aEvent) { - newWin.gBrowser.removeEventListener("load", arguments.callee, true); - TEST_URLS.forEach(function (url) { - newWin.gBrowser.addTab(url); - }); - - executeSoon(function() testFn(newWin)); - }, true); - }, false); - } - - /** - * Test 1: Normal in-session restore - * @note: Non-Mac only - */ - function testOpenCloseNormal(nextFn) { - setupTestAndRun(function(newWin) { - // Close the window - // window.close doesn't push any close events, - // so use BrowserTryToCloseWindow - newWin.BrowserTryToCloseWindow(); - - // The first request to close is denied by our observer (Test 6) - ok(!newWin.closed, "First close request was denied"); - if (!newWin.closed) { - newWin.BrowserTryToCloseWindow(); - ok(newWin.closed, "Second close request was granted"); - } - - // Open a new window - // The previously closed window should be restored - newWin = openDialog(location, "_blank", CHROME_FEATURES); - newWin.addEventListener("load", function() { - this.removeEventListener("load", arguments.callee, true); - executeSoon(function() { - is(newWin.gBrowser.browsers.length, TEST_URLS.length + 1, - "Restored window in-session with otherpopup windows around"); - - // Cleanup - newWin.close(); - - // Next please - executeSoon(nextFn); - }); - }, true); - }); - } - - /** - * Test 2: PrivateBrowsing in-session restore - * @note: Non-Mac only - */ - function testOpenClosePrivateBrowsing(nextFn) { - setupTestAndRun(function(newWin) { - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - // Close the window - newWin.BrowserTryToCloseWindow(); - - // Enter private browsing mode - pb.privateBrowsingEnabled = true; - - // Open a new window. - // The previously closed window should NOT be restored - newWin = openDialog(location, "_blank", CHROME_FEATURES); - newWin.addEventListener("load", function() { - this.removeEventListener("load", arguments.callee, true); - executeSoon(function() { - is(newWin.gBrowser.browsers.length, 1, - "Did not restore in private browing mode"); - - // Cleanup - newWin.BrowserTryToCloseWindow(); - - // Exit private browsing mode again - pb.privateBrowsingEnabled = false; - - newWin = openDialog(location, "_blank", CHROME_FEATURES); - newWin.addEventListener("load", function() { - this.removeEventListener("load", arguments.callee, true); - executeSoon(function() { - is(newWin.gBrowser.browsers.length, TEST_URLS.length + 1, - "Restored after leaving private browsing again"); - - newWin.close(); - - // Next please - executeSoon(nextFn); - }); - }, true); - }); - }, true); - }); - } - - /** - * Test 3: Open some popup windows to check those aren't restored, but - * the browser window is - * @note: Non-Mac only - */ - function testOpenCloseWindowAndPopup(nextFn) { - setupTestAndRun(function(newWin) { - // open some popups - let popup = openDialog(location, "popup", POPUP_FEATURES, TEST_URLS[0]); - let popup2 = openDialog(location, "popup2", POPUP_FEATURES, TEST_URLS[1]); - popup2.addEventListener("load", function() { - popup2.removeEventListener("load", arguments.callee, false); - popup2.gBrowser.addEventListener("load", function() { - popup2.gBrowser.removeEventListener("load", arguments.callee, true); - popup2.gBrowser.addTab(TEST_URLS[0]); - // close the window - newWin.BrowserTryToCloseWindow(); - - // Close the popup window - // The test is successful when not this popup window is restored - // but instead newWin - popup2.close(); - - // open a new window the previously closed window should be restored to - newWin = openDialog(location, "_blank", CHROME_FEATURES); - newWin.addEventListener("load", function() { - this.removeEventListener("load", arguments.callee, true); - executeSoon(function() { - is(newWin.gBrowser.browsers.length, TEST_URLS.length + 1, - "Restored window and associated tabs in session"); - - // Cleanup - newWin.close(); - popup.close(); - - // Next please - executeSoon(nextFn); - }); - }, true); - }, true); - }, false); - }); - } - - /** - * Test 4: Open some popup window to check it isn't restored. - * Instead nothing at all should be restored - * @note: Non-Mac only - */ - function testOpenCloseOnlyPopup(nextFn) { - // prepare the prefs - setPrefs(); - - // This will cause nsSessionStore to restore a window the next time it - // gets a chance. - let popup = openDialog(location, "popup", POPUP_FEATURES, TEST_URLS[1]); - popup.addEventListener("load", function() { - this.removeEventListener("load", arguments.callee, true); - is(popup.gBrowser.browsers.length, 1, - "Did not restore the popup window (1)"); - popup.BrowserTryToCloseWindow(); - - // Real tests - popup = openDialog(location, "popup", POPUP_FEATURES, TEST_URLS[1]); - popup.addEventListener("load", function() { - popup.removeEventListener("load", arguments.callee, false); - popup.gBrowser.addEventListener("load", function() { - popup.gBrowser.removeEventListener("load", arguments.callee, true); - popup.gBrowser.addTab(TEST_URLS[0]); - - is(popup.gBrowser.browsers.length, 2, - "Did not restore to the popup window (2)"); - - // Close the popup window - // The test is successful when not this popup window is restored - // but instead a new window is opened without restoring anything - popup.close(); - - let newWin = openDialog(location, "_blank", CHROME_FEATURES, "about:blank"); - newWin.addEventListener("load", function() { - newWin.removeEventListener("load", arguments.callee, true); - executeSoon(function() { - isnot(newWin.gBrowser.browsers.length, 2, - "Did not restore the popup window"); - is(TEST_URLS.indexOf(newWin.gBrowser.browsers[0].currentURI.spec), -1, - "Did not restore the popup window (2)"); - - // Cleanup - newWin.close(); - - // Next please - executeSoon(nextFn); - }); - }, true); - }, true); - }, false); - }, true); - } - - /** - * Test 5: Open some windows and do undoCloseWindow. This should prevent any - * restoring later in the test - * @note: Non-Mac only - */ - function testOpenCloseRestoreFromPopup(nextFn) { - setupTestAndRun(function(newWin) { - setupTestAndRun(function(newWin2) { - newWin.BrowserTryToCloseWindow(); - newWin2.BrowserTryToCloseWindow(); - - browserWindowsCount([0, 1], "browser windows while running testOpenCloseRestoreFromPopup"); - - newWin = undoCloseWindow(0); - - newWin2 = openDialog(location, "_blank", CHROME_FEATURES); - newWin2.addEventListener("load", function() { - newWin2.removeEventListener("load", arguments.callee, true); - executeSoon(function() { - is(newWin2.gBrowser.browsers.length, 1, - "Did not restore, as undoCloseWindow() was last called"); - is(TEST_URLS.indexOf(newWin2.gBrowser.browsers[0].currentURI.spec), -1, - "Did not restore, as undoCloseWindow() was last called (2)"); - - browserWindowsCount([2, 3], "browser windows while running testOpenCloseRestoreFromPopup"); - - // Cleanup - newWin.close(); - newWin2.close(); - - browserWindowsCount([0, 1], "browser windows while running testOpenCloseRestoreFromPopup"); - - // Next please - executeSoon(nextFn); - }); - }, true); - }); - }); - } - - /** - * Test 7: Check whether the right number of notifications was received during - * the tests - */ - function testNotificationCount(nextFn) { - is(observing["browser-lastwindow-close-requested"], NOTIFICATIONS_EXPECTED, - "browser-lastwindow-close-requested notifications observed"); - - // -request must be one more as we cancel the first one we hit, - // and hence won't produce a corresponding -grant - // @see observer.observe - is(observing["browser-lastwindow-close-requested"], - observing["browser-lastwindow-close-granted"] + 1, - "Notification count for -request and -grant matches"); - - executeSoon(nextFn); - } - - /** - * Test 8: Test if closing can be denied on Mac - * Futhermore prepares the testNotificationCount test (Test 7) - * @note: Mac only - */ - function testMacNotifications(nextFn, iteration) { - iteration = iteration || 1; - setupTestAndRun(function(newWin) { - // close the window - // window.close doesn't push any close events, - // so use BrowserTryToCloseWindow - newWin.BrowserTryToCloseWindow(); - if (iteration == 1) { - ok(!newWin.closed, "First close attempt denied"); - if (!newWin.closed) { - newWin.BrowserTryToCloseWindow(); - ok(newWin.closed, "Second close attempt granted"); - } - } - - if (iteration < NOTIFICATIONS_EXPECTED - 1) { - executeSoon(function() testMacNotifications(nextFn, ++iteration)); - } - else { - executeSoon(nextFn); - } - }); - } - - // Execution starts here - - setupTestsuite(); - if (navigator.platform.match(/Mac/)) { - // Mac tests - testMacNotifications(function () { - testNotificationCount(function () { - cleanupTestsuite(); - browserWindowsCount(1, "Only one browser window should be open eventually"); - finish(); - }); - }); - } - else { - // Non-Mac Tests - testOpenCloseNormal(function () { - browserWindowsCount([0, 1], "browser windows after testOpenCloseNormal"); - testOpenClosePrivateBrowsing(function () { - browserWindowsCount([0, 1], "browser windows after testOpenClosePrivateBrowsing"); - testOpenCloseWindowAndPopup(function () { - browserWindowsCount([0, 1], "browser windows after testOpenCloseWindowAndPopup"); - testOpenCloseOnlyPopup(function () { - browserWindowsCount([0, 1], "browser windows after testOpenCloseOnlyPopup"); - testOpenCloseRestoreFromPopup(function () { - browserWindowsCount([0, 1], "browser windows after testOpenCloseRestoreFromPopup"); - testNotificationCount(function () { - cleanupTestsuite(); - browserWindowsCount(1, "browser windows after testNotificationCount"); - finish(); - }); - }); - }); - }); - }); - }); - } -} diff --git a/browser/components/sessionstore/test/browser_394759_privatebrowsing.js b/browser/components/sessionstore/test/browser_394759_privatebrowsing.js deleted file mode 100644 index 2418ec5ce77f..000000000000 --- a/browser/components/sessionstore/test/browser_394759_privatebrowsing.js +++ /dev/null @@ -1,140 +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() { - /** Private Browsing Test for Bug 394759 **/ - - waitForExplicitFinish(); - - // Set interval to a large time so state won't be written while we setup env. - gPrefService.setIntPref("browser.sessionstore.interval", 100000); - - // Set up the browser in a blank state. Popup windows in previous tests result - // in different states on different platforms. - let blankState = JSON.stringify({ - windows: [{ - tabs: [{ entries: [{ url: "about:blank" }] }], - _closedTabs: [] - }], - _closedWindows: [] - }); - ss.setBrowserState(blankState); - - // Wait for the sessionstore.js file to be written before going on. - // Note: we don't wait for the complete event, since if asyncCopy fails we - // would timeout. - Services.obs.addObserver(function (aSubject, aTopic, aData) { - Services.obs.removeObserver(arguments.callee, aTopic); - info("sessionstore.js is being written"); - executeSoon(continue_test); - }, "sessionstore-state-write", false); - - // Remove the sessionstore.js file before setting the interval to 0 - let profilePath = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties). - get("ProfD", Ci.nsIFile); - let sessionStoreJS = profilePath.clone(); - sessionStoreJS.append("sessionstore.js"); - if (sessionStoreJS.exists()) - sessionStoreJS.remove(false); - info("sessionstore.js was correctly removed: " + (!sessionStoreJS.exists())); - - // Make sure that sessionstore.js can be forced to be created by setting - // the interval pref to 0. - gPrefService.setIntPref("browser.sessionstore.interval", 0); -} - -function continue_test() { - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - // Ensure Private Browsing mode is disabled. - ok(!pb.privateBrowsingEnabled, "Private Browsing is disabled"); - - let closedWindowCount = ss.getClosedWindowCount(); - is(closedWindowCount, 0, "Correctly set window count"); - - // Prevent VM timers issues, cache now and increment it manually. - let now = Date.now(); - const TESTS = [ - { url: "about:config", - key: "bug 394759 Non-PB", - value: "uniq" + (++now) }, - { url: "about:mozilla", - key: "bug 394759 PB", - value: "uniq" + (++now) }, - ]; - - function openWindowAndTest(aTestIndex, aRunNextTestInPBMode) { - info("Opening new window"); - function onLoad(event) { - win.removeEventListener("load", onLoad, false); - info("New window has been loaded"); - win.gBrowser.addEventListener("load", function(aEvent) { - win.gBrowser.removeEventListener("load", arguments.callee, true); - info("New window browser has been loaded"); - executeSoon(function() { - // Add a tab. - win.gBrowser.addTab(); - - executeSoon(function() { - // Mark the window with some unique data to be restored later on. - ss.setWindowValue(win, TESTS[aTestIndex].key, TESTS[aTestIndex].value); - - win.close(); - - // Ensure that we incremented # of close windows. - is(ss.getClosedWindowCount(), closedWindowCount + 1, - "The closed window was added to the list"); - - // Ensure we added window to undo list. - let data = JSON.parse(ss.getClosedWindowData())[0]; - ok(JSON.stringify(data).indexOf(TESTS[aTestIndex].value) > -1, - "The closed window data was stored correctly"); - - if (aRunNextTestInPBMode) { - // Enter private browsing mode. - pb.privateBrowsingEnabled = true; - ok(pb.privateBrowsingEnabled, "private browsing enabled"); - - // Ensure that we have 0 undo windows when entering PB. - is(ss.getClosedWindowCount(), 0, - "Recently Closed Windows are removed when entering Private Browsing"); - is(ss.getClosedWindowData(), "[]", - "Recently Closed Windows data is cleared when entering Private Browsing"); - } - else { - // Exit private browsing mode. - pb.privateBrowsingEnabled = false; - ok(!pb.privateBrowsingEnabled, "private browsing disabled"); - - // Ensure that we still have the closed windows from before. - is(ss.getClosedWindowCount(), closedWindowCount + 1, - "The correct number of recently closed windows were restored " + - "when exiting PB mode"); - - let data = JSON.parse(ss.getClosedWindowData())[0]; - ok(JSON.stringify(data).indexOf(TESTS[aTestIndex - 1].value) > -1, - "The data associated with the recently closed window was " + - "restored when exiting PB mode"); - } - - if (aTestIndex == TESTS.length - 1) { - gPrefService.clearUserPref("browser.sessionstore.interval"); - finish(); - } - else { - // Run next test. - openWindowAndTest(aTestIndex + 1, !aRunNextTestInPBMode); - } - }); - }); - }, true); - } - // Open a window. - var win = openDialog(location, "", "chrome,all,dialog=no", TESTS[aTestIndex].url); - win.addEventListener("load", onLoad, false); - } - - openWindowAndTest(0, true); -} diff --git a/browser/components/tabview/test/Makefile.in b/browser/components/tabview/test/Makefile.in index b241337e679b..72e619f8bb78 100644 --- a/browser/components/tabview/test/Makefile.in +++ b/browser/components/tabview/test/Makefile.in @@ -68,7 +68,9 @@ _BROWSER_FILES = \ browser_tabview_bug619937.js \ browser_tabview_bug622835.js \ browser_tabview_bug623768.js \ + browser_tabview_bug624265_perwindowpb.js \ browser_tabview_bug624692.js \ + browser_tabview_bug624727_perwindowpb.js \ browser_tabview_bug624847.js \ browser_tabview_bug624931.js \ browser_tabview_bug624953.js \ @@ -106,6 +108,7 @@ _BROWSER_FILES = \ browser_tabview_bug649006.js \ browser_tabview_bug649307.js \ browser_tabview_bug649319.js \ + browser_tabview_bug650280_perwindowpb.js \ browser_tabview_bug650573.js \ browser_tabview_bug651311.js \ browser_tabview_bug654295.js \ @@ -147,6 +150,7 @@ _BROWSER_FILES = \ browser_tabview_group.js \ browser_tabview_launch.js \ browser_tabview_multiwindow_search.js \ + browser_tabview_privatebrowsing_perwindowpb.js \ browser_tabview_rtl.js \ browser_tabview_search.js \ browser_tabview_snapping.js \ @@ -162,23 +166,6 @@ _BROWSER_FILES = \ test_bug678374_icon16.png \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -_BROWSER_FILES += \ - browser_tabview_bug624265_perwindowpb.js \ - browser_tabview_bug624727_perwindowpb.js \ - browser_tabview_bug650280_perwindowpb.js \ - browser_tabview_privatebrowsing_perwindowpb.js \ - $(NULL) -else -_BROWSER_FILES += \ - browser_tabview_bug624265.js \ - browser_tabview_bug624727.js \ - browser_tabview_bug650280.js \ - browser_tabview_bug679853.js \ - browser_tabview_privatebrowsing.js \ - $(NULL) -endif - # browser_tabview_bug597980.js is disabled for leaking, see bug 711907 diff --git a/browser/components/tabview/test/browser_tabview_bug624265.js b/browser/components/tabview/test/browser_tabview_bug624265.js deleted file mode 100644 index 7c97e070c340..000000000000 --- a/browser/components/tabview/test/browser_tabview_bug624265.js +++ /dev/null @@ -1,155 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -let pb = Cc['@mozilla.org/privatebrowsing;1']. - getService(Ci.nsIPrivateBrowsingService); - -function test() { - let tests = []; - - let getContentWindow = function () { - return TabView.getContentWindow(); - } - - let assertOneSingleGroupItem = function () { - is(getContentWindow().GroupItems.groupItems.length, 1, 'There is one single groupItem'); - } - - let assertNumberOfVisibleTabs = function (numTabs) { - is(gBrowser.visibleTabs.length, numTabs, 'There should be ' + numTabs + ' visible tabs'); - } - - let next = function () { - while (gBrowser.tabs.length-1) - gBrowser.removeTab(gBrowser.tabs[1]); - - hideTabView(function () { - let callback = tests.shift(); - - if (!callback) - callback = finish; - - assertOneSingleGroupItem(); - callback(); - }); - } - - // ---------- - // [624265] testing undo close tab - let testUndoCloseTabs = function () { - gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true}); - gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true}); - - afterAllTabsLoaded(function () { - assertNumberOfVisibleTabs(3); - - gBrowser.removeTab(gBrowser.tabs[1]); - gBrowser.selectedTab = gBrowser.tabs[1]; - - restoreTab(function () { - assertNumberOfVisibleTabs(3); - assertOneSingleGroupItem(); - next(); - }); - }); - } - - // ---------- - // [623792] duplicating tab via middle click on reload button - let testDuplicateTab = function () { - gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true}); - - afterAllTabsLoaded(function () { - // Valid choices for 'where' are window|tabshifted|tab - duplicateTabIn(gBrowser.selectedTab, 'tab'); - - afterAllTabsLoaded(function () { - assertNumberOfVisibleTabs(3); - assertOneSingleGroupItem(); - next(); - }); - }); - } - - // ---------- - // [623792] duplicating tabs via middle click on forward/back buttons - let testBackForwardDuplicateTab = function () { - let tab = gBrowser.loadOneTab('http://mochi.test:8888/#1', {inBackground: true}); - gBrowser.selectedTab = tab; - - afterAllTabsLoaded(function () { - tab.linkedBrowser.loadURI('http://mochi.test:8888/#2'); - - afterAllTabsLoaded(function () { - ok(gBrowser.canGoBack, 'browser can go back in history'); - BrowserBack({button: 1}); - - afterAllTabsLoaded(function () { - assertNumberOfVisibleTabs(3); - - ok(gBrowser.canGoForward, 'browser can go forward in history'); - BrowserForward({button: 1}); - - afterAllTabsLoaded(function () { - assertNumberOfVisibleTabs(4); - assertOneSingleGroupItem(); - next(); - }); - }); - }); - }); - } - - // ---------- - // [624102] check state after return from private browsing - let testPrivateBrowsing = function () { - gBrowser.loadOneTab('http://mochi.test:8888/#1', {inBackground: true}); - gBrowser.loadOneTab('http://mochi.test:8888/#2', {inBackground: true}); - - let cw = getContentWindow(); - let box = new cw.Rect(20, 20, 250, 200); - let groupItem = new cw.GroupItem([], {bounds: box, immediately: true}); - cw.UI.setActive(groupItem); - - gBrowser.selectedTab = gBrowser.loadOneTab('http://mochi.test:8888/#3', {inBackground: true}); - gBrowser.loadOneTab('http://mochi.test:8888/#4', {inBackground: true}); - - afterAllTabsLoaded(function () { - assertNumberOfVisibleTabs(2); - - enterAndLeavePrivateBrowsing(function () { - assertNumberOfVisibleTabs(2); - gBrowser.selectedTab = gBrowser.tabs[0]; - closeGroupItem(cw.GroupItems.groupItems[1], next); - }); - }); - } - - waitForExplicitFinish(); - - // tests for #624265 - tests.push(testUndoCloseTabs); - - // tests for #623792 - tests.push(testDuplicateTab); - tests.push(testBackForwardDuplicateTab); - - // tests for #624102 - tests.push(testPrivateBrowsing); - - loadTabView(next); -} - -// ---------- -function loadTabView(callback) { - showTabView(function () { - hideTabView(callback); - }); -} - -// ---------- -function enterAndLeavePrivateBrowsing(callback) { - togglePrivateBrowsing(function () { - togglePrivateBrowsing(callback); - }); -} diff --git a/browser/components/tabview/test/browser_tabview_bug624727.js b/browser/components/tabview/test/browser_tabview_bug624727.js deleted file mode 100644 index 0663cb1c8460..000000000000 --- a/browser/components/tabview/test/browser_tabview_bug624727.js +++ /dev/null @@ -1,130 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -let pb = Cc['@mozilla.org/privatebrowsing;1']. - getService(Ci.nsIPrivateBrowsingService); - -function test() { - let cw; - - let createGroupItem = function () { - let bounds = new cw.Rect(20, 20, 400, 200); - let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true}); - cw.UI.setActive(groupItem); - - let groupItemId = groupItem.id; - registerCleanupFunction(function() { - let groupItem = cw.GroupItems.groupItem(groupItemId); - if (groupItem) - groupItem.close(); - }); - - for (let i=0; i<3; i++) - gBrowser.addTab('about:blank'); - } - - let assertTabViewIsHidden = function (prefix) { - ok(!TabView.isVisible(), prefix + ': tabview is hidden'); - } - - let assertNumberOfTabs = function (prefix, num) { - is(gBrowser.tabs.length, num, prefix + ': there are ' + num + ' tabs'); - } - - let assertNumberOfPinnedTabs = function (prefix, num) { - is(gBrowser._numPinnedTabs, num, prefix + ': there are ' + num + ' pinned tabs'); - } - - let assertNumberOfGroups = function (prefix, num) { - is(cw.GroupItems.groupItems.length, num, prefix + ': there are ' + num + ' groups'); - } - - let assertOneTabInGroup = function (prefix, groupItem) { - is(groupItem.getChildren().length, 1, prefix + ': group contains one tab'); - } - - let assertValidPrerequisites = function (prefix) { - assertNumberOfTabs(prefix, 1); - assertNumberOfPinnedTabs(prefix, 0); - assertTabViewIsHidden(prefix); - } - - let assertValidSetup = function (prefix) { - assertNumberOfGroups(prefix, 2); - assertNumberOfTabs(prefix, 4); - assertNumberOfPinnedTabs(prefix, 2); - - let [group1, group2] = cw.GroupItems.groupItems; - assertOneTabInGroup(prefix, group1); - assertOneTabInGroup(prefix, group2); - } - - let testStateAfterEnteringPB = function () { - let prefix = 'enter'; - ok(!pb.privateBrowsingEnabled, prefix + ': private browsing is disabled'); - registerCleanupFunction(function () { - pb.privateBrowsingEnabled = false; - }); - - togglePrivateBrowsing(function () { - assertTabViewIsHidden(prefix); - - showTabView(function () { - assertNumberOfGroups(prefix, 1); - assertNumberOfTabs(prefix, 1); - assertOneTabInGroup(prefix, cw.GroupItems.groupItems[0]); - hideTabView(testStateAfterLeavingPB); - }); - }); - } - - let testStateAfterLeavingPB = function () { - let prefix = 'leave'; - ok(pb.privateBrowsingEnabled, prefix + ': private browsing is enabled'); - - togglePrivateBrowsing(function () { - assertTabViewIsHidden(prefix); - - showTabView(function () { - assertValidSetup(prefix); - finishTest(); - }); - }); - } - - let finishTest = function () { - // remove pinned tabs - gBrowser.removeTab(gBrowser.tabs[0]); - gBrowser.removeTab(gBrowser.tabs[0]); - - cw.GroupItems.groupItems[1].closeAll(); - - hideTabView(function () { - assertValidPrerequisites('exit'); - assertNumberOfGroups('exit', 1); - finish(); - }); - } - - waitForExplicitFinish(); - registerCleanupFunction(function () TabView.hide()); - assertValidPrerequisites('start'); - - showTabView(function () { - cw = TabView.getContentWindow(); - assertNumberOfGroups('start', 1); - - createGroupItem(); - - afterAllTabsLoaded(function () { - // setup - let groupItems = cw.GroupItems.groupItems; - let [tabItem1, tabItem2, ] = groupItems[1].getChildren(); - gBrowser.pinTab(tabItem1.tab); - gBrowser.pinTab(tabItem2.tab); - - assertValidSetup('setup'); - hideTabView(testStateAfterEnteringPB); - }); - }); -} diff --git a/browser/components/tabview/test/browser_tabview_bug650280.js b/browser/components/tabview/test/browser_tabview_bug650280.js deleted file mode 100644 index 7f7e04b21338..000000000000 --- a/browser/components/tabview/test/browser_tabview_bug650280.js +++ /dev/null @@ -1,67 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - -function test() { - let cw; - - registerCleanupFunction(function() { - if (cw) - cw.Search.hide(); - - TabView.hide(); - pb.privateBrowsingEnabled = false; - }); - - let enableSearch = function (callback) { - if (cw.Search.isEnabled()) { - callback(); - return; - } - - cw.addEventListener("tabviewsearchenabled", function onSearchEnabled() { - cw.removeEventListener("tabviewsearchenabled", onSearchEnabled, false); - executeSoon(callback); - }, false); - - cw.Search.ensureShown(); - }; - - let getSearchboxValue = function () { - return cw.iQ("#searchbox").val(); - }; - - let prepareSearchbox = function (callback) { - ok(!cw.Search.isEnabled(), "search is disabled"); - - enableSearch(function () { - cw.iQ("#searchbox").val("moz"); - callback(); - }); - }; - - let searchAndSwitchPBMode = function (callback) { - prepareSearchbox(function () { - togglePrivateBrowsing(function () { - showTabView(function () { - ok(!cw.Search.isEnabled(), "search is disabled"); - is(getSearchboxValue(), "", "search box is empty"); - callback(); - }); - }); - }); - }; - - waitForExplicitFinish(); - - showTabView(function () { - cw = TabView.getContentWindow(); - searchAndSwitchPBMode(function () { - searchAndSwitchPBMode(function () { - hideTabView(finish); - }); - }); - }); -} diff --git a/browser/components/tabview/test/browser_tabview_bug679853.js b/browser/components/tabview/test/browser_tabview_bug679853.js deleted file mode 100644 index 59cb2d66c699..000000000000 --- a/browser/components/tabview/test/browser_tabview_bug679853.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(); - - // clean up after ourselves - registerCleanupFunction(function () { - while (gBrowser.tabs.length > 1) - gBrowser.removeTab(gBrowser.tabs[1]); - - hideTabView(); - }); - - // select the new tab - gBrowser.selectedTab = gBrowser.addTab(); - - showTabView(function () { - // enter private browsing mode - togglePrivateBrowsing(function () { - ok(!TabView.isVisible(), "tabview is hidden"); - - showTabView(function () { - // leave private browsing mode - togglePrivateBrowsing(function () { - ok(TabView.isVisible(), "tabview is visible"); - hideTabView(finish); - }); - }); - }); - }); -} diff --git a/browser/components/tabview/test/browser_tabview_privatebrowsing.js b/browser/components/tabview/test/browser_tabview_privatebrowsing.js deleted file mode 100644 index 906d94f70a6d..000000000000 --- a/browser/components/tabview/test/browser_tabview_privatebrowsing.js +++ /dev/null @@ -1,159 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -let contentWindow = null; -let normalURLs = []; -let pbTabURL = "about:privatebrowsing"; -let groupTitles = []; -let normalIteration = 0; - -let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - -// ----------- -function test() { - waitForExplicitFinish(); - - showTabView(onTabViewLoadedAndShown); -} - -// ----------- -function onTabViewLoadedAndShown() { - ok(TabView.isVisible(), "Tab View is visible"); - - // Establish initial state - contentWindow = TabView.getContentWindow(); - verifyCleanState("start"); - - // register a clean up for private browsing just in case - registerCleanupFunction(function() { - pb.privateBrowsingEnabled = false; - }); - - // create a group - let box = new contentWindow.Rect(20, 20, 180, 180); - let groupItem = new contentWindow.GroupItem([], {bounds: box, title: "test1"}); - let id = groupItem.id; - is(contentWindow.GroupItems.groupItems.length, 2, "we now have two groups"); - registerCleanupFunction(function() { - contentWindow.GroupItems.groupItem(id).close(); - }); - - // make it the active group so new tabs will be added to it - contentWindow.UI.setActive(groupItem); - - // collect the group titles - let count = contentWindow.GroupItems.groupItems.length; - for (let a = 0; a < count; a++) { - let gi = contentWindow.GroupItems.groupItems[a]; - groupTitles[a] = gi.getTitle(); - } - - contentWindow.gPrefBranch.setBoolPref("animate_zoom", false); - - // Create a second tab - gBrowser.addTab("about:mozilla"); - is(gBrowser.tabs.length, 2, "we now have 2 tabs"); - - registerCleanupFunction(function() { - gBrowser.removeTab(gBrowser.tabs[1]); - contentWindow.gPrefBranch.clearUserPref("animate_zoom"); - }); - - afterAllTabsLoaded(function() { - // Get normal tab urls - for (let a = 0; a < gBrowser.tabs.length; a++) - normalURLs.push(gBrowser.tabs[a].linkedBrowser.currentURI.spec); - - // verify that we're all set up for our test - verifyNormal(); - - // go into private browsing and make sure Tab View becomes hidden - togglePrivateBrowsing(function() { - whenTabViewIsHidden(function() { - ok(!TabView.isVisible(), "Tab View is no longer visible"); - verifyPB(); - - // exit private browsing and make sure Tab View is shown again - togglePrivateBrowsing(function() { - whenTabViewIsShown(function() { - ok(TabView.isVisible(), "Tab View is visible again"); - verifyNormal(); - - hideTabView(onTabViewHidden); - }); - }); - }); - }); - }); -} - -// ----------- -function onTabViewHidden() { - ok(!TabView.isVisible(), "Tab View is not visible"); - - // go into private browsing and make sure Tab View remains hidden - togglePrivateBrowsing(function() { - ok(!TabView.isVisible(), "Tab View is still not visible"); - verifyPB(); - - // turn private browsing back off - togglePrivateBrowsing(function() { - verifyNormal(); - - // end game - ok(!TabView.isVisible(), "we finish with Tab View not visible"); - registerCleanupFunction(verifyCleanState); // verify after all cleanups - - gBrowser.selectedTab = gBrowser.tabs[0]; - finish(); - }); - }); -} - -// ---------- -function verifyCleanState(mode) { - let prefix = "we " + (mode || "finish") + " with "; - is(gBrowser.tabs.length, 1, prefix + "one tab"); - is(contentWindow.GroupItems.groupItems.length, 1, prefix + "1 group"); - ok(gBrowser.tabs[0]._tabViewTabItem.parent == contentWindow.GroupItems.groupItems[0], - "the tab is in the group"); - ok(!pb.privateBrowsingEnabled, prefix + "private browsing off"); -} - -// ---------- -function verifyPB() { - ok(pb.privateBrowsingEnabled == true, "private browsing is on"); - is(gBrowser.tabs.length, 1, "we have 1 tab in private browsing"); - is(contentWindow.GroupItems.groupItems.length, 1, "we have 1 group in private browsing"); - ok(gBrowser.tabs[0]._tabViewTabItem.parent == contentWindow.GroupItems.groupItems[0], - "the tab is in the group"); - - let browser = gBrowser.tabs[0].linkedBrowser; - is(browser.currentURI.spec, pbTabURL, "correct URL for private browsing"); -} - -// ---------- -function verifyNormal() { - let prefix = "verify normal " + normalIteration + ": "; - normalIteration++; - - ok(pb.privateBrowsingEnabled == false, prefix + "private browsing is off"); - - let tabCount = gBrowser.tabs.length; - let groupCount = contentWindow.GroupItems.groupItems.length; - is(tabCount, 2, prefix + "we have 2 tabs"); - is(groupCount, 2, prefix + "we have 2 groups"); - ok(tabCount == groupCount, prefix + "same number of tabs as groups"); - for (let a = 0; a < tabCount; a++) { - let tab = gBrowser.tabs[a]; - is(tab.linkedBrowser.currentURI.spec, normalURLs[a], - prefix + "correct URL"); - - let groupItem = contentWindow.GroupItems.groupItems[a]; - is(groupItem.getTitle(), groupTitles[a], prefix + "correct group title"); - - ok(tab._tabViewTabItem.parent == groupItem, - prefix + "tab " + a + " is in group " + a); - } -} diff --git a/browser/components/tabview/test/head.js b/browser/components/tabview/test/head.js index 79f6e534c271..891c675b92bf 100644 --- a/browser/components/tabview/test/head.js +++ b/browser/components/tabview/test/head.js @@ -377,24 +377,6 @@ function restoreTab(callback, index, win) { }); } -// ---------- -function togglePrivateBrowsing(callback) { - let topic = "private-browsing-transition-complete"; - - Services.obs.addObserver(function observe() { - Services.obs.removeObserver(observe, topic); - - // use executeSoon() to let Panorama load its group data from the session - // before we call afterAllTabsLoaded() - executeSoon(function () afterAllTabsLoaded(callback)); - }, topic, false); - - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled; -} - // ---------- function goToNextGroup(win) { win = win || window; diff --git a/browser/components/tabview/ui.js b/browser/components/tabview/ui.js index cb70a84a89de..2aa9c9c3099f 100644 --- a/browser/components/tabview/ui.js +++ b/browser/components/tabview/ui.js @@ -64,17 +64,6 @@ let UI = { // the operation interactive. _maxInteractiveWait: 250, -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - // Variable: _privateBrowsing - // Keeps track of info related to private browsing, including: - // transitionMode - whether we're entering or exiting PB - // wasInTabView - whether TabView was visible before we went into PB - _privateBrowsing: { - transitionMode: "", - wasInTabView: false - }, -#endif - // Variable: _storageBusy // Tells whether the storage is currently busy or not. _storageBusy: false, @@ -597,13 +586,8 @@ let UI = { // ---------- // Function: storageBusy -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // Pauses the storage activity that conflicts with sessionstore updates. // Calls can be nested. -#else - // Pauses the storage activity that conflicts with sessionstore updates and - // private browsing mode switches. Calls can be nested. -#endif storageBusy: function UI_storageBusy() { if (this._storageBusy) return; @@ -656,49 +640,6 @@ let UI = { gWindow.removeEventListener("SSWindowStateReady", handleSSWindowStateReady, false); }); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - // Private Browsing: - // When transitioning to PB, we exit Panorama if necessary (making note of the - // fact that we were there so we can return after PB) and make sure we - // don't reenter Panorama due to all of the session restore tab - // manipulation (which otherwise we might). When transitioning away from - // PB, we reenter Panorama if we had been there directly before PB. - function pbObserver(subject, topic, data) { - if (topic == "private-browsing") { - // We could probably do this in private-browsing-change-granted, but - // this seems like a nicer spot, right in the middle of the process. - if (data == "enter") { - // If we are in Tab View, exit. - self._privateBrowsing.wasInTabView = self.isTabViewVisible(); - if (self.isTabViewVisible()) - self.goToTab(gBrowser.selectedTab); - } - } else if (topic == "private-browsing-change-granted") { - if (data == "enter" || data == "exit") { - Search.hide(); - self._privateBrowsing.transitionMode = data; - } - } else if (topic == "private-browsing-transition-complete") { - // We use .transitionMode here, as aData is empty. - if (self._privateBrowsing.transitionMode == "exit" && - self._privateBrowsing.wasInTabView) - self.showTabView(false); - - self._privateBrowsing.transitionMode = ""; - } - } - - Services.obs.addObserver(pbObserver, "private-browsing", false); - Services.obs.addObserver(pbObserver, "private-browsing-change-granted", false); - Services.obs.addObserver(pbObserver, "private-browsing-transition-complete", false); - - this._cleanupFunctions.push(function() { - Services.obs.removeObserver(pbObserver, "private-browsing"); - Services.obs.removeObserver(pbObserver, "private-browsing-change-granted"); - Services.obs.removeObserver(pbObserver, "private-browsing-transition-complete"); - }); -#endif - // TabOpen this._eventListeners.open = function (event) { let tab = event.target; @@ -723,11 +664,7 @@ let UI = { if (self._currentTab == tab) self._closedSelectedTabInTabView = true; } else { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // If we're currently in the process of session store update, -#else - // If we're currently in the process of entering private browsing, -#endif // we don't want to go to the Tab View UI. if (self._storageBusy) return; @@ -838,14 +775,8 @@ let UI = { if (this.isTabViewVisible()) { // We want to zoom in if: // 1) we didn't just restore a tab via Ctrl+Shift+T -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // 2) the currently selected tab is the last created tab and has a tabItem if (!this.restoredClosedTab && -#else - // 2) we're not in the middle of switching from/to private browsing - // 3) the currently selected tab is the last created tab and has a tabItem - if (!this.restoredClosedTab && !this._privateBrowsing.transitionMode && -#endif this._lastOpenedTab == tab && tab._tabViewTabItem) { tab._tabViewTabItem.zoomIn(true); this._lastOpenedTab = null; @@ -1031,9 +962,6 @@ let UI = { "fullScreen", #endif "closeWindow", "tabview", "undoCloseTab", "undoCloseWindow" -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - , "privatebrowsing" -#endif ].forEach(function(key) { let element = gWindow.document.getElementById("key_" + key); let code = element.getAttribute("key").toLocaleLowerCase().charCodeAt(0); diff --git a/browser/confvars.sh b/browser/confvars.sh index c8b6bf4ed8fb..70bbdadc4b69 100755 --- a/browser/confvars.sh +++ b/browser/confvars.sh @@ -55,4 +55,3 @@ MOZ_EXTENSION_MANAGER=1 MOZ_APP_STATIC_INI=1 MOZ_WEBAPP_RUNTIME=1 MOZ_MEDIA_NAVIGATOR=1 -MOZ_PER_WINDOW_PRIVATE_BROWSING=1 diff --git a/browser/devtools/commandline/test/Makefile.in b/browser/devtools/commandline/test/Makefile.in index 23164213d0d3..9f30ad81d2eb 100644 --- a/browser/devtools/commandline/test/Makefile.in +++ b/browser/devtools/commandline/test/Makefile.in @@ -27,6 +27,7 @@ MOCHITEST_BROWSER_FILES = \ browser_cmd_pref.js \ browser_cmd_restart.js \ browser_cmd_screenshot.html \ + browser_cmd_screenshot_perwindowpb.js \ browser_cmd_settings.js \ browser_gcli_canon.js \ browser_gcli_cli.js \ @@ -55,16 +56,6 @@ MOCHITEST_BROWSER_FILES = \ mockCommands.js \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ - browser_cmd_screenshot_perwindowpb.js \ - $(NULL) -else -MOCHITEST_BROWSER_FILES += \ - browser_cmd_screenshot.js \ - $(NULL) -endif - ifneq ($(OS_ARCH),WINNT) MOCHITEST_BROWSER_FILES += \ browser_dbg_cmd.html \ diff --git a/browser/devtools/commandline/test/browser_cmd_screenshot.js b/browser/devtools/commandline/test/browser_cmd_screenshot.js deleted file mode 100644 index c2a1887be718..000000000000 --- a/browser/devtools/commandline/test/browser_cmd_screenshot.js +++ /dev/null @@ -1,179 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Test that screenshot command works properly -const TEST_URI = "http://example.com/browser/browser/devtools/commandline/" + - "test/browser_cmd_screenshot.html"; - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; -let tempScope = {}; -Cu.import("resource://gre/modules/FileUtils.jsm", tempScope); -let FileUtils = tempScope.FileUtils; - -let pb = Cc["@mozilla.org/privatebrowsing;1"] - .getService(Ci.nsIPrivateBrowsingService); -function test() { - DeveloperToolbarTest.test(TEST_URI, [ testInput, testCapture ]); -} - -function testInput() { - helpers.setInput('screenshot'); - helpers.check({ - input: 'screenshot', - markup: 'VVVVVVVVVV', - status: 'VALID', - args: { - } - }); - - helpers.setInput('screenshot abc.png'); - helpers.check({ - input: 'screenshot abc.png', - markup: 'VVVVVVVVVVVVVVVVVV', - status: 'VALID', - args: { - filename: { value: "abc.png"}, - } - }); - - helpers.setInput('screenshot --fullpage'); - helpers.check({ - input: 'screenshot --fullpage', - markup: 'VVVVVVVVVVVVVVVVVVVVV', - status: 'VALID', - args: { - fullpage: { value: true}, - } - }); - - helpers.setInput('screenshot abc --delay 5'); - helpers.check({ - input: 'screenshot abc --delay 5', - markup: 'VVVVVVVVVVVVVVVVVVVVVVVV', - status: 'VALID', - args: { - filename: { value: "abc"}, - delay: { value: "5"}, - } - }); - - helpers.setInput('screenshot --selector img#testImage'); - helpers.check({ - input: 'screenshot --selector img#testImage', - markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', - status: 'VALID', - args: { - selector: { value: content.document.getElementById("testImage")}, - } - }); -} - -function testCapture() { - function checkTemporaryFile() { - // Create a temporary file. - let gFile = FileUtils.getFile("TmpD", ["TestScreenshotFile.png"]); - if (gFile.exists()) { - gFile.remove(false); - return true; - } - else { - return false; - } - } - - function checkClipboard() { - try { - let clipid = Ci.nsIClipboard; - let clip = Cc["@mozilla.org/widget/clipboard;1"].getService(clipid); - let trans = Cc["@mozilla.org/widget/transferable;1"] - .createInstance(Ci.nsITransferable); - trans.init(null); - trans.addDataFlavor("image/png"); - clip.getData(trans, clipid.kGlobalClipboard); - let str = new Object(); - let strLength = new Object(); - trans.getTransferData("image/png", str, strLength); - if (str.value && strLength.value > 0) { - return true; - } - } - catch (ex) {} - return false; - } - - let PBEntered = DeveloperToolbarTest.checkCalled(function() { - Services.obs.removeObserver(PBEntered, - "private-browsing-transition-complete", - false); - - Services.obs.addObserver(PBLeft, "last-pb-context-exited", false); - - DeveloperToolbarTest.exec({ - typed: "screenshot --clipboard", - args: { - delay: 0, - filename: " ", - fullpage: false, - clipboard: true, - node: null, - chrome: false, - }, - outputMatch: new RegExp("^Copied to clipboard.$"), - }); - - ok(checkClipboard(), "Screenshot present in clipboard in private browsing"); - - pb.privateBrowsingEnabled = false; - }); - - let PBLeft = DeveloperToolbarTest.checkCalled(function() { - Services.obs.removeObserver(PBLeft, "last-pb-context-exited", false); - executeSoon(function() { - ok(!checkClipboard(), "Screenshot taken in private browsing mode is not" + - " present outside of it in the clipboard"); - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - pb = null; - }); - }); - - let path = FileUtils.getFile("TmpD", ["TestScreenshotFile.png"]).path; - - DeveloperToolbarTest.exec({ - typed: "screenshot " + path, - args: { - delay: 0, - filename: "" + path, - fullpage: false, - clipboard: false, - node: null, - chrome: false, - }, - outputMatch: new RegExp("^Saved to "), - }); - - Services.obs.addObserver(PBEntered, "private-browsing-transition-complete", - false); - - executeSoon(function() { - ok(checkTemporaryFile(), "Screenshot got created"); - - DeveloperToolbarTest.exec({ - typed: "screenshot --fullpage --clipboard", - args: { - delay: 0, - filename: " ", - fullpage: true, - clipboard: true, - node: null, - chrome: false, - }, - outputMatch: new RegExp("^Copied to clipboard.$"), - }); - - ok(checkClipboard(), "Screenshot got created and copied"); - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - pb.privateBrowsingEnabled = true; - }); -} diff --git a/browser/devtools/styleeditor/test/Makefile.in b/browser/devtools/styleeditor/test/Makefile.in index a3339d3571f2..53a624b1d972 100644 --- a/browser/devtools/styleeditor/test/Makefile.in +++ b/browser/devtools/styleeditor/test/Makefile.in @@ -22,6 +22,7 @@ _BROWSER_TEST_FILES = \ browser_styleeditor_new.js \ browser_styleeditor_passedinsheet.js \ browser_styleeditor_pretty.js \ + browser_styleeditor_private_perwindowpb.js \ browser_styleeditor_readonly.js \ $(filter disabled-for-intermittent-failures--bug-707891, browser_styleeditor_reopen.js) \ browser_styleeditor_sv_keynav.js \ @@ -46,15 +47,5 @@ _BROWSER_TEST_FILES = \ test_private.css \ $(NULL) -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -_BROWSER_TEST_FILES += \ - browser_styleeditor_private.js \ - $(NULL) -else -_BROWSER_TEST_FILES += \ - browser_styleeditor_private_perwindowpb.js \ - $(NULL) -endif - libs:: $(_BROWSER_TEST_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir) diff --git a/browser/devtools/styleeditor/test/browser_styleeditor_private.js b/browser/devtools/styleeditor/test/browser_styleeditor_private.js deleted file mode 100644 index e3677e7c5d5b..000000000000 --- a/browser/devtools/styleeditor/test/browser_styleeditor_private.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/. */ - -// This test makes sure that the style editor does not store any -// content CSS files in the permanent cache when opened from PB mode. -function test() { - waitForExplicitFinish(); - - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - pb.privateBrowsingEnabled = true; - - function checkCache() { - checkDiskCacheFor(TEST_HOST); - pb.privateBrowsingEnabled = false; - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - } - - gBrowser.selectedTab = gBrowser.addTab(); - - gBrowser.selectedBrowser.addEventListener("load", function onLoad() { - gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); - cache.evictEntries(Ci.nsICache.STORE_ANYWHERE); - launchStyleEditorChrome(function(aChrome) { - if (aChrome.isContentAttached) { - onEditorAdded(aChrome, aChrome.editors[0]); - } else { - aChrome.addChromeListener({ - onEditorAdded: onEditorAdded - }); - } - }); - }, true); - - function onEditorAdded(aChrome, aEditor) { - aChrome.removeChromeListener(this); - - if (aEditor.isLoaded) { - checkCache(); - } else { - aEditor.addActionListener({ - onLoad: checkCache - }); - } - } - - content.location = 'http://' + TEST_HOST + '/browser/browser/devtools/styleeditor/test/test_private.html'; -} diff --git a/browser/devtools/webconsole/test/Makefile.in b/browser/devtools/webconsole/test/Makefile.in index f8f530c4efc0..79ce488d665b 100644 --- a/browser/devtools/webconsole/test/Makefile.in +++ b/browser/devtools/webconsole/test/Makefile.in @@ -123,12 +123,6 @@ MOCHITEST_BROWSER_FILES += \ $(NULL) endif -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ - browser_webconsole_bug_618311_private_browsing.js \ - $(NULL) -endif - MOCHITEST_BROWSER_FILES += \ test-console.html \ test-network.html \ diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_618311_private_browsing.js b/browser/devtools/webconsole/test/browser_webconsole_bug_618311_private_browsing.js deleted file mode 100644 index d606432cbdba..000000000000 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_618311_private_browsing.js +++ /dev/null @@ -1,150 +0,0 @@ -/* 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/. */ - -const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; - -let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - -function test() { - addTab("data:text/html;charset=utf-8,Web Console test for bug 618311 (private browsing)"); - - browser.addEventListener("load", function onLoad() { - browser.removeEventListener("load", onLoad, true); - - registerCleanupFunction(function() { - pb.privateBrowsingEnabled = false; - pb = null; - }); - - ok(!pb.privateBrowsingEnabled, "private browsing is not enabled"); - - togglePBAndThen(function() { - ok(pb.privateBrowsingEnabled, "private browsing is enabled"); - - openConsole(gBrowser.selectedTab, function(hud) { - content.location = TEST_URI; - waitForSuccess({ - name: "network message displayed", - validatorFn: function() - { - return hud.outputNode.querySelector(".webconsole-msg-network"); - }, - successFn: performTest, - failureFn: finishTest, - }); - }); - }); - }, true); -} - -function performTest() { - let hudId = HUDService.getHudIdByWindow(content); - let HUD = HUDService.hudReferences[hudId]; - - HUD.jsterm.execute("document"); - - let networkMessage = HUD.outputNode.querySelector(".webconsole-msg-network"); - ok(networkMessage, "found network message"); - - let networkLink = networkMessage.querySelector(".webconsole-msg-link"); - ok(networkLink, "found network message link"); - - let popupset = document.getElementById("mainPopupSet"); - ok(popupset, "found #mainPopupSet"); - - let popupsShown = 0; - let hiddenPopups = 0; - - let onpopupshown = function() { - popupsShown++; - if (popupsShown == 2) { - document.removeEventListener("popupshown", onpopupshown, false); - - executeSoon(function() { - // Make sure the two panels are open. - let popups = popupset.querySelectorAll("panel[hudId=" + hudId + "]"); - is(popups.length, 2, "found two popups"); - - document.addEventListener("popuphidden", onpopuphidden, false); - - registerCleanupFunction(function() { - is(hiddenPopups, 2, "correct number of popups hidden"); - if (hiddenPopups != 2) { - document.removeEventListener("popuphidden", onpopuphidden, false); - } - }); - - // Now toggle private browsing off. We expect the panels to close. - pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled; - }); - } - }; - - let onpopuphidden = function(aEvent) { - // Skip popups that are not opened by the Web Console. - if (!aEvent.target.hasAttribute("hudId")) { - return; - } - - hiddenPopups++; - if (hiddenPopups == 2) { - document.removeEventListener("popuphidden", onpopuphidden, false); - - executeSoon(function() { - let popups = popupset.querySelectorAll("panel[hudId=" + hudId + "]"); - is(popups.length, 0, "no popups found"); - - ok(!pb.privateBrowsingEnabled, "private browsing is not enabled"); - - gBrowser.removeCurrentTab(); - executeSoon(finishTest); - }); - } - }; - - document.addEventListener("popupshown", onpopupshown, false); - - registerCleanupFunction(function() { - is(popupsShown, 2, "correct number of popups shown"); - if (popupsShown != 2) { - document.removeEventListener("popupshown", onpopupshown, false); - } - }); - - // Show the network and object inspector panels. - waitForSuccess({ - name: "jsterm output message", - validatorFn: function() - { - return HUD.outputNode.querySelector(".webconsole-msg-output"); - }, - successFn: function() - { - let jstermMessage = HUD.outputNode.querySelector(".webconsole-msg-output"); - EventUtils.sendMouseEvent({ type: "mousedown" }, jstermMessage, HUD.iframeWindow); - EventUtils.sendMouseEvent({ type: "mouseup" }, jstermMessage, HUD.iframeWindow); - EventUtils.sendMouseEvent({ type: "click" }, jstermMessage, HUD.iframeWindow); - EventUtils.sendMouseEvent({ type: "mousedown" }, networkLink, HUD.iframeWindow); - EventUtils.sendMouseEvent({ type: "mouseup" }, networkLink, HUD.iframeWindow); - EventUtils.sendMouseEvent({ type: "click" }, networkLink, HUD.iframeWindow); - }, - failureFn: finishTest, - }); -} - -function togglePBAndThen(callback) { - function pbObserver(aSubject, aTopic, aData) { - if (aTopic != "private-browsing-transition-complete") { - return; - } - - Services.obs.removeObserver(pbObserver, "private-browsing-transition-complete"); - afterAllTabsLoaded(callback); - } - - Services.obs.addObserver(pbObserver, "private-browsing-transition-complete", false); - pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled; -} diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 58c224d5fbe1..60b67a2b7b0f 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -343,13 +343,8 @@ @BINPATH@/components/DownloadsUI.js @BINPATH@/components/BrowserPlaces.manifest @BINPATH@/components/BrowserPageThumbs.manifest -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING @BINPATH@/components/nsPrivateBrowsingServiceObsolete.manifest @BINPATH@/components/nsPrivateBrowsingServiceObsolete.js -#else -@BINPATH@/components/nsPrivateBrowsingService.manifest -@BINPATH@/components/nsPrivateBrowsingService.js -#endif @BINPATH@/components/SiteSpecificUserAgent.js @BINPATH@/components/SiteSpecificUserAgent.manifest @BINPATH@/components/toolkitsearch.manifest diff --git a/browser/locales/en-US/chrome/browser/aboutPrivateBrowsing.dtd b/browser/locales/en-US/chrome/browser/aboutPrivateBrowsing.dtd index 0b3d3a95fae4..ef885d0bb08f 100644 --- a/browser/locales/en-US/chrome/browser/aboutPrivateBrowsing.dtd +++ b/browser/locales/en-US/chrome/browser/aboutPrivateBrowsing.dtd @@ -5,27 +5,14 @@ - - - - - - - - - - - - - diff --git a/browser/locales/en-US/chrome/browser/browser.dtd b/browser/locales/en-US/chrome/browser/browser.dtd index 3cd9783906c3..e3f8fdf8bb18 100644 --- a/browser/locales/en-US/chrome/browser/browser.dtd +++ b/browser/locales/en-US/chrome/browser/browser.dtd @@ -282,11 +282,6 @@ These should match what Safari and other Apple applications use on OS X Lion. -- - - - - - diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index 638c91b6684d..0d377686d6f0 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -282,18 +282,6 @@ safebrowsing.reportedAttackSite=Reported Attack Site! safebrowsing.notAnAttackButton.label=This isn't an attack site… safebrowsing.notAnAttackButton.accessKey=A -# Private Browsing Confirmation dialog -# LOCALIZATION NOTE (privateBrowsingMessage): %S will be replaced -# by the name of the application. -# LOCALIZATION NOTE (privateBrowsingYesTitle, privateBrowsingNoTitle, privateBrowsingNeverAsk): -# Access keys are specified by prefixing the desired letter with an ampersand. -privateBrowsingDialogTitle=Start Private Browsing -privateBrowsingMessageHeader=Would you like to start Private Browsing? -privateBrowsingMessage=%S will save your current tabs for when you are done with your Private Browsing session. -privateBrowsingYesTitle=&Start Private Browsing -privateBrowsingNoTitle=&Cancel -privateBrowsingNeverAsk=&Do not show this message again - # Ctrl-Tab # LOCALIZATION NOTE (ctrlTab.showAll.label): #1 represents the number # of tabs in the current browser window. It will always be 2 at least. diff --git a/browser/locales/en-US/chrome/browser/taskbar.properties b/browser/locales/en-US/chrome/browser/taskbar.properties index 6d50e963f1d2..987d5ccf8448 100644 --- a/browser/locales/en-US/chrome/browser/taskbar.properties +++ b/browser/locales/en-US/chrome/browser/taskbar.properties @@ -6,10 +6,6 @@ taskbar.tasks.newTab.label=Open new tab taskbar.tasks.newTab.description=Open a new browser tab. taskbar.tasks.newWindow.label=Open new window taskbar.tasks.newWindow.description=Open a new browser window. -taskbar.tasks.enterPrivacyMode.label=Enter private browsing -taskbar.tasks.enterPrivacyMode.description=Start private browsing. The current session will be saved. -taskbar.tasks.exitPrivacyMode.label=Quit private browsing -taskbar.tasks.exitPrivacyMode.description=Quit private browsing and restore the previous session. taskbar.tasks.newPrivateWindow.label=New private window taskbar.tasks.newPrivateWindow.description=Open a new window in private browsing mode. taskbar.frequent.label=Frequent diff --git a/browser/modules/RecentWindow.jsm b/browser/modules/RecentWindow.jsm index 23db7858a023..6bddd93e1511 100644 --- a/browser/modules/RecentWindow.jsm +++ b/browser/modules/RecentWindow.jsm @@ -26,13 +26,8 @@ this.RecentWindow = { * in both groups, don't specify the private property. */ getMostRecentBrowserWindow: function RW_getMostRecentBrowserWindow(aOptions) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING let checkPrivacy = typeof aOptions == "object" && "private" in aOptions; -#else - // In global PB builds, always ignore the requested privacy status - let checkPrivacy = false; -#endif function isSuitableBrowserWindow(win) { return (!win.closed && diff --git a/browser/modules/Social.jsm b/browser/modules/Social.jsm index dc4a56821452..cb9e823a7f8f 100644 --- a/browser/modules/Social.jsm +++ b/browser/modules/Social.jsm @@ -84,9 +84,6 @@ this.Social = { } if (!this._addedObservers) { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.addObserver(this, "private-browsing", false); -#endif Services.obs.addObserver(this, "social:pref-changed", false); this._addedObservers = true; } @@ -133,22 +130,6 @@ this.Social = { }, observe: function(aSubject, aTopic, aData) { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - if (aTopic == "private-browsing") { - if (aData == "enter") { - this._enabledBeforePrivateBrowsing = this.enabled; - this.enabled = false; - } else if (aData == "exit") { - // if the user has explicitly re-enabled social in PB mode, then upon - // leaving we want to tear the world down then reenable to prevent - // information leaks during this transition. - // The next 2 lines rely on the fact that setting this.enabled to - // its current value doesn't actually do anything... - this.enabled = false; - this.enabled = this._enabledBeforePrivateBrowsing; - } - } else -#endif if (aTopic == "social:pref-changed") { // Make sure our provider's enabled state matches the overall state of the // social components. diff --git a/browser/modules/WindowsJumpLists.jsm b/browser/modules/WindowsJumpLists.jsm index a1a6d82e04d0..e7f7855198b5 100644 --- a/browser/modules/WindowsJumpLists.jsm +++ b/browser/modules/WindowsJumpLists.jsm @@ -74,12 +74,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "_winShellService", "@mozilla.org/browser/shell-service;1", "nsIWindowsShellService"); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -XPCOMUtils.defineLazyServiceGetter(this, "_privateBrowsingSvc", - "@mozilla.org/privatebrowsing;1", - "nsIPrivateBrowsingService"); -#endif - XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); @@ -129,7 +123,6 @@ var tasksCfg = [ // shutdown. Thus true for consistency. }, -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // Open new private window { get title() _getString("taskbar.tasks.newPrivateWindow.label"), @@ -140,33 +133,6 @@ var tasksCfg = [ close: true, // No point, but we don't always update the list on // shutdown. Thus true for consistency. }, -#else - // Toggle the Private Browsing mode - { - get title() { - if (_privateBrowsingSvc.privateBrowsingEnabled) - return _getString("taskbar.tasks.exitPrivacyMode.label"); - else - return _getString("taskbar.tasks.enterPrivacyMode.label"); - }, - get description() { - if (_privateBrowsingSvc.privateBrowsingEnabled) - return _getString("taskbar.tasks.exitPrivacyMode.description"); - else - return _getString("taskbar.tasks.enterPrivacyMode.description"); - }, - args: "-private-toggle", - iconIndex: 4, // Private browsing mode icon - get open() { - // Don't show when inside permanent private browsing mode - return !PrivateBrowsingUtils.permanentPrivateBrowsing; - }, - get close() { - // Don't show when inside permanent private browsing mode - return !PrivateBrowsingUtils.permanentPrivateBrowsing; - }, - }, -#endif ]; ///////////////////////////////////////////////////////////////////////////// @@ -526,9 +492,6 @@ this.WinTaskbarJumpList = }, _initObs: function WTBJL__initObs() { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.addObserver(this, "private-browsing", false); -#endif // If the browser is closed while in private browsing mode, the "exit" // notification is fired on quit-application-granted. // History cleanup can happen at profile-change-teardown. @@ -538,9 +501,6 @@ this.WinTaskbarJumpList = }, _freeObs: function WTBJL__freeObs() { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.removeObserver(this, "private-browsing"); -#endif Services.obs.removeObserver(this, "profile-before-change"); Services.obs.removeObserver(this, "browser:purge-session-history"); _prefs.removeObserver("", this); @@ -606,11 +566,6 @@ this.WinTaskbarJumpList = case "browser:purge-session-history": this.update(); break; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - case "private-browsing": - this.update(); - break; -#endif case "idle": if (this._timer) { this._timer.cancel(); diff --git a/browser/themes/gnomestripe/browser.css b/browser/themes/gnomestripe/browser.css index 004d726c5c0a..44a7f9bcbf31 100644 --- a/browser/themes/gnomestripe/browser.css +++ b/browser/themes/gnomestripe/browser.css @@ -2659,12 +2659,10 @@ chatbox[minimized="true"] { min-width: 0; } -%ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING #main-window[privatebrowsingmode=temporary] #TabsToolbar::before { display: -moz-box; content: ""; background: url("chrome://browser/skin/privatebrowsing-mask.png") center no-repeat; width: 40px; } -%endif diff --git a/browser/themes/pinstripe/browser.css b/browser/themes/pinstripe/browser.css index f64e10ac7a30..2978bd8e74d3 100644 --- a/browser/themes/pinstripe/browser.css +++ b/browser/themes/pinstripe/browser.css @@ -4173,7 +4173,6 @@ panel[type="arrow"][popupid="click-to-play-plugins"] > .panel-arrowcontainer > . min-width: 0; } -%ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING #main-window[privatebrowsingmode=temporary] { background-image: url("chrome://browser/skin/privatebrowsing-mask.png"); background-position: top right; @@ -4201,5 +4200,4 @@ panel[type="arrow"][popupid="click-to-play-plugins"] > .panel-arrowcontainer > . #main-window[privatebrowsingmode=temporary]:-moz-window-inactive { background-color: -moz-mac-chrome-inactive; } -%endif diff --git a/browser/themes/winstripe/browser.css b/browser/themes/winstripe/browser.css index 6a0ae9c781e4..6e31f0ae62f9 100644 --- a/browser/themes/winstripe/browser.css +++ b/browser/themes/winstripe/browser.css @@ -3355,7 +3355,6 @@ chatbox[minimized="true"] { min-width: 0; } -%ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING #main-window[privatebrowsingmode=temporary] #toolbar-menubar { background-image: url("chrome://browser/skin/privatebrowsing-dark.png"); background-position: top right; @@ -3371,5 +3370,4 @@ chatbox[minimized="true"] { width: 20px; height: 16px; } -%endif diff --git a/config/writemozinfo.py b/config/writemozinfo.py index 3efabd67d5e5..0612a446a3aa 100755 --- a/config/writemozinfo.py +++ b/config/writemozinfo.py @@ -69,9 +69,6 @@ def build_dict(env=os.environ): # crashreporter d["crashreporter"] = 'MOZ_CRASHREPORTER' in env and env['MOZ_CRASHREPORTER'] == '1' - - # per-window private browsing - d["perwindowprivatebrowsing"] = 'MOZ_PER_WINDOW_PRIVATE_BROWSING' in env and env['MOZ_PER_WINDOW_PRIVATE_BROWSING'] == '1' return d #TODO: replace this with the json module when Python >= 2.6 is a requirement. diff --git a/configure.in b/configure.in index 98c946b5fe72..22c68ecedf85 100644 --- a/configure.in +++ b/configure.in @@ -8510,11 +8510,6 @@ AC_SUBST(MOZ_OS2_TOOLS) AC_SUBST(MOZ_POST_DSO_LIB_COMMAND) AC_SUBST(MOZ_POST_PROGRAM_COMMAND) AC_SUBST(MOZ_LINKER_EXTRACT) -AC_SUBST(MOZ_PER_WINDOW_PRIVATE_BROWSING) - -if test -n "$MOZ_PER_WINDOW_PRIVATE_BROWSING" ; then - AC_DEFINE(MOZ_PER_WINDOW_PRIVATE_BROWSING) -fi dnl ======================================================== dnl = Mac bundle name prefix @@ -9063,7 +9058,6 @@ MOZ_WIDGET_TOOLKIT=${MOZ_WIDGET_TOOLKIT} \ UNIVERSAL_BINARY=${UNIVERSAL_BINARY} \ MOZ_CRASHREPORTER=${MOZ_CRASHREPORTER} \ MOZ_APP_NAME=${MOZ_APP_NAME} \ -MOZ_PER_WINDOW_PRIVATE_BROWSING=${MOZ_PER_WINDOW_PRIVATE_BROWSING} \ $PYTHON ${_topsrcdir}/config/writemozinfo.py ./mozinfo.json.tmp if cmp -s ./mozinfo.json.tmp ./mozinfo.json; then rm ./mozinfo.json.tmp diff --git a/content/base/src/nsCCUncollectableMarker.cpp b/content/base/src/nsCCUncollectableMarker.cpp index 3041f991ab6f..af79c6265c3f 100644 --- a/content/base/src/nsCCUncollectableMarker.cpp +++ b/content/base/src/nsCCUncollectableMarker.cpp @@ -367,7 +367,6 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic, nsCOMPtr shellTreeNode = do_QueryInterface(shell); MarkDocShell(shellTreeNode, cleanupJS, prepareForCC); } -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING bool hasHiddenPrivateWindow = false; appShell->GetHasHiddenPrivateWindow(&hasHiddenPrivateWindow); if (hasHiddenPrivateWindow) { @@ -379,7 +378,6 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic, MarkDocShell(shellTreeNode, cleanupJS, prepareForCC); } } -#endif } #ifdef MOZ_XUL diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 4f487eecef6b..18cdcdfedbf2 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -194,12 +194,8 @@ #include "mozilla/Telemetry.h" #include "nsISecurityUITelemetry.h" -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING #include "nsIAppShellService.h" #include "nsAppShellCID.h" -#else -#include "nsIPrivateBrowsingService.h" -#endif static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); @@ -2028,13 +2024,11 @@ nsDocShell::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing) NS_IMETHODIMP nsDocShell::SetUsePrivateBrowsing(bool aUsePrivateBrowsing) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING nsContentUtils::ReportToConsoleNonLocalized( NS_LITERAL_STRING("Only internal code is allowed to set the usePrivateBrowsing attribute"), nsIScriptError::warningFlag, "Internal API Used", mContentViewer ? mContentViewer->GetDocument() : nullptr); -#endif return SetPrivateBrowsing(aUsePrivateBrowsing); } @@ -2850,18 +2844,6 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent) NS_SUCCEEDED(parentAsLoadContext->GetUsePrivateBrowsing(&value))) { SetPrivateBrowsing(value); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - // Belt and suspenders - we want to catch any instances where the flag - // we're propagating doesn't match the global state. - nsCOMPtr pbs = - do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID); - if (pbs) { - bool inPrivateBrowsing = false; - pbs->GetPrivateBrowsingEnabled(&inPrivateBrowsing); - NS_ASSERTION(inPrivateBrowsing == mInPrivateBrowsing, - "Privacy status of parent docshell doesn't match global state!"); - } -#endif } nsCOMPtr parentURIListener(do_GetInterface(parent)); diff --git a/docshell/base/nsDownloadHistory.cpp b/docshell/base/nsDownloadHistory.cpp index bf2c0d64e889..63d9c6eeb190 100644 --- a/docshell/base/nsDownloadHistory.cpp +++ b/docshell/base/nsDownloadHistory.cpp @@ -13,9 +13,6 @@ #include "nsIComponentRegistrar.h" #include "nsDocShellCID.h" #include "nsNetCID.h" -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -#include "nsIPrivateBrowsingService.h" -#endif //////////////////////////////////////////////////////////////////////////////// //// nsDownloadHistory @@ -33,20 +30,6 @@ nsDownloadHistory::AddDownload(nsIURI *aSource, { NS_ENSURE_ARG_POINTER(aSource); -#if !(defined(MOZ_PER_WINDOW_PRIVATE_BROWSING)) && defined(DEBUG) - // This code makes sure that in global private browsing mode, the flag - // passed to us matches the global PB mode. This can be removed when - // per-window private browsing has been turned on. - nsCOMPtr pbService = - do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID); - if (pbService) { - bool inPrivateBrowsing = false; - if (NS_SUCCEEDED(pbService->GetPrivateBrowsingEnabled(&inPrivateBrowsing))) { - MOZ_ASSERT(!inPrivateBrowsing, "Shouldn't be adding any download history in PB mode"); - } - } -#endif - nsCOMPtr history = do_GetService("@mozilla.org/browser/global-history;2"); if (!history) diff --git a/docshell/test/chrome/Makefile.in b/docshell/test/chrome/Makefile.in index e0bf8708cf39..56af5314ea7c 100644 --- a/docshell/test/chrome/Makefile.in +++ b/docshell/test/chrome/Makefile.in @@ -94,16 +94,11 @@ MOCHITEST_CHROME_FILES = \ test_mozFrameType.xul \ mozFrameType_window.xul \ test_bug789773.xul \ + test_private_hidden_window.html \ docshell_helpers.js \ generic.html \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_CHROME_FILES += \ - test_private_hidden_window.html \ - $(NULL) -endif - ifneq ($(MOZ_WIDGET_TOOLKIT),gtk2) MOCHITEST_CHROME_FILES += \ test_bug454235.xul \ diff --git a/dom/indexedDB/test/Makefile.in b/dom/indexedDB/test/Makefile.in index 86161b061f59..7d49b55609ea 100644 --- a/dom/indexedDB/test/Makefile.in +++ b/dom/indexedDB/test/Makefile.in @@ -130,6 +130,7 @@ MOCHITEST_BROWSER_FILES = \ browser_permissionsPrompt.html \ browser_permissionsPromptAllow.js \ browser_permissionsPromptDeny.js \ + browser_perwindow_privateBrowsing.js \ browser_quotaPrompt.html \ browser_quotaPromptAllow.js \ browser_quotaPromptDeny.js \ @@ -140,16 +141,6 @@ MOCHITEST_BROWSER_FILES = \ head.js \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ - browser_perwindow_privateBrowsing.js \ - $(NULL) -else -MOCHITEST_BROWSER_FILES += \ - browser_privateBrowsing.js \ - $(NULL) -endif - endif include $(topsrcdir)/config/rules.mk diff --git a/dom/indexedDB/test/browser_privateBrowsing.js b/dom/indexedDB/test/browser_privateBrowsing.js deleted file mode 100644 index 0e102188c327..000000000000 --- a/dom/indexedDB/test/browser_privateBrowsing.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -const testPageURL = "http://mochi.test:8888/browser/" + - "dom/indexedDB/test/browser_permissionsPrompt.html"; -const notificationID = "indexedDB-permissions-prompt"; - -function test() -{ - waitForExplicitFinish(); - executeSoon(test1); -} - -function test1() -{ - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function () { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - setFinishedCallback(function(result, exception) { - ok(result instanceof Components.interfaces.nsIIDBDatabase, - "First database creation was successful"); - ok(!exception, "No exception"); - gBrowser.removeCurrentTab(); - - executeSoon(test2); - }); - }, true); - content.location = testPageURL; -} - -function test2() -{ - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - pb.privateBrowsingEnabled = true; - - executeSoon(test3); -} - -function test3() -{ - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function () { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - - setFinishedCallback(function(result, exception) { - ok(!result, "No database"); - is(exception, "InvalidStateError", "Correct exception"); - gBrowser.removeCurrentTab(); - - executeSoon(test4); - }); - }, true); - content.location = testPageURL; -} - -function test4() -{ - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - pb.privateBrowsingEnabled = false; - - executeSoon(finish); -} diff --git a/dom/plugins/test/mochitest/Makefile.in b/dom/plugins/test/mochitest/Makefile.in index ba0e64ace159..1d4fb73a0ec5 100644 --- a/dom/plugins/test/mochitest/Makefile.in +++ b/dom/plugins/test/mochitest/Makefile.in @@ -102,18 +102,9 @@ MOCHITEST_CHROME_FILES = \ test_wmode.xul \ test_bug479979.xul \ test_refresh_navigator_plugins.html \ - $(NULL) - -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_CHROME_FILES += \ - test_privatemode.xul \ - $(NULL) -else -MOCHITEST_CHROME_FILES += \ privatemode_perwindowpb.xul \ test_privatemode_perwindowpb.xul \ $(NULL) -endif ifneq ($(MOZ_WIDGET_TOOLKIT),cocoa) MOCHITEST_FILES += \ diff --git a/dom/plugins/test/mochitest/test_privatemode.xul b/dom/plugins/test/mochitest/test_privatemode.xul deleted file mode 100644 index 7f8106f78c3f..000000000000 --- a/dom/plugins/test/mochitest/test_privatemode.xul +++ /dev/null @@ -1,98 +0,0 @@ - - - - - NPAPI Private Mode Tests - - diff --git a/dom/tests/browser/Makefile.in b/dom/tests/browser/Makefile.in index 1247879a01da..df2e0a338a45 100644 --- a/dom/tests/browser/Makefile.in +++ b/dom/tests/browser/Makefile.in @@ -17,24 +17,15 @@ MOCHITEST_BROWSER_FILES := \ browser_ConsoleAPITests.js \ test-console-api.html \ browser_ConsoleStorageAPITests.js \ + browser_ConsoleStoragePBTest_perwindowpb.js \ browser_autofocus_preference.js \ browser_bug396843.js \ browser_xhr_sandbox.js \ browser_geolocation_privatebrowsing_page.html \ + browser_geolocation_privatebrowsing_perwindowpb.js \ network_geolocation.sjs \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ - browser_geolocation_privatebrowsing_perwindowpb.js \ - $(NULL) -else -MOCHITEST_BROWSER_FILES += \ - browser_ConsoleStoragePBTest.js \ - browser_geolocation_privatebrowsing.js \ - $(NULL) -endif - ifeq (Linux,$(OS_ARCH)) MOCHITEST_BROWSER_FILES += \ browser_webapps_permissions.js \ @@ -45,16 +36,6 @@ MOCHITEST_BROWSER_FILES += \ $(NULL) endif -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ - browser_ConsoleStoragePBTest_perwindowpb.js \ - $(NULL) -else -MOCHITEST_BROWSER_FILES += \ - browser_ConsoleStoragePBTest.js \ - $(NULL) -endif - # TODO: Re-enable permissions tests on Mac and Windows, bug 795334 # TODO: disabled test browser_webapps_perms_reinstall.js, re-enable when bug 794920 is fixed diff --git a/dom/tests/browser/browser_ConsoleStoragePBTest.js b/dom/tests/browser/browser_ConsoleStoragePBTest.js deleted file mode 100644 index 4da2b8940dc6..000000000000 --- a/dom/tests/browser/browser_ConsoleStoragePBTest.js +++ /dev/null @@ -1,93 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - try { - var pb = Cc["@mozilla.org/privatebrowsing;1"].getService(Ci.nsIPrivateBrowsingService); - } catch (ex) { - ok(true, "nothing to do here, PB service doesn't exist"); - return; - } - - waitForExplicitFinish(); - - var CSS = {}; - Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm", CSS); - - let innerID, beforeEvents, storageShouldOccur; - - var ConsoleObserver = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), - - observe: function CO_observe(aSubject, aTopic, aData) - { - if (aTopic != "console-api-log-event") { - return; - } - - let afterEvents = CSS.ConsoleAPIStorage.getEvents(innerID); - - is(beforeEvents.length == afterEvents.length - 1, - storageShouldOccur, - "storage should" + (storageShouldOccur ? "" : " not") + " occur"); - - executeSoon(function() { - Services.obs.removeObserver(ConsoleObserver, "console-api-log-event"); - pb.privateBrowsingEnabled = storageShouldOccur; - }); - } - }; - - function checkStorageOccurs() { - Services.obs.addObserver(ConsoleObserver, "console-api-log-event", false); - - let win = XPCNativeWrapper.unwrap(browser.contentWindow); - innerID = getInnerWindowId(win); - - beforeEvents = CSS.ConsoleAPIStorage.getEvents(innerID); - win.console.log("foo bar baz (private: " + !storageShouldOccur + ")"); - } - - function pbObserver(aSubject, aTopic, aData) { - if (aData == "enter") { - storageShouldOccur = false; - checkStorageOccurs(); - } else if (aData == "exit") { - executeSoon(finish); - } - } - - const TEST_URI = "http://example.com/browser/dom/tests/browser/test-console-api.html"; - var tab = gBrowser.selectedTab = gBrowser.addTab(TEST_URI); - var browser = gBrowser.selectedBrowser; - - Services.obs.addObserver(pbObserver, "private-browsing", false); - - const PB_KEEP_SESSION_PREF = "browser.privatebrowsing.keep_current_session"; - Services.prefs.setBoolPref(PB_KEEP_SESSION_PREF, true); - - registerCleanupFunction(function () { - gBrowser.removeTab(tab); - - Services.obs.removeObserver(pbObserver, "private-browsing"); - - if (Services.prefs.prefHasUserValue(PB_KEEP_SESSION_PREF)) - Services.prefs.clearUserPref(PB_KEEP_SESSION_PREF); - }); - - browser.addEventListener("DOMContentLoaded", function onLoad(event) { - if (browser.currentURI.spec != TEST_URI) - return; - - browser.removeEventListener("DOMContentLoaded", onLoad, false); - - storageShouldOccur = true; - checkStorageOccurs(); - }, false); -} - -function getInnerWindowId(aWindow) { - return aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils) - .currentInnerWindowID; -} diff --git a/dom/tests/browser/browser_geolocation_privatebrowsing.js b/dom/tests/browser/browser_geolocation_privatebrowsing.js deleted file mode 100644 index b3642454fb0a..000000000000 --- a/dom/tests/browser/browser_geolocation_privatebrowsing.js +++ /dev/null @@ -1,50 +0,0 @@ -function test() { - var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); - let baseProvider = "http://mochi.test:8888/browser/dom/tests/browser/network_geolocation.sjs"; - prefs.setCharPref("geo.wifi.uri", baseProvider + "?desired_access_token=fff"); - - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - - prefs.setBoolPref("geo.prompt.testing", true); - prefs.setBoolPref("geo.prompt.testing.allow", true); - - prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - const testPageURL = "http://mochi.test:8888/browser/" + - "dom/tests/browser/browser_geolocation_privatebrowsing_page.html"; - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("georesult", function load(ev) { - gBrowser.selectedBrowser.removeEventListener("georesult", load, false); - is(ev.detail, 200, "unexpected access token"); - gBrowser.removeCurrentTab(); - - prefs.setCharPref("geo.wifi.uri", baseProvider + "?desired_access_token=ggg"); - - pb.privateBrowsingEnabled = true; - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("georesult", function load2(ev) { - gBrowser.selectedBrowser.removeEventListener("georesult", load2, false); - is(ev.detail, 200, "unexpected access token"); - gBrowser.removeCurrentTab(); - - prefs.setCharPref("geo.wifi.uri", baseProvider + "?expected_access_token=fff"); - pb.privateBrowsingEnabled = false; - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("georesult", function load3(ev) { - gBrowser.selectedBrowser.removeEventListener("georesult", load3, false); - is(ev.detail, 200, "unexpected access token"); - gBrowser.removeCurrentTab(); - prefs.setBoolPref("geo.prompt.testing", false); - prefs.setBoolPref("geo.prompt.testing.allow", false); - prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - }, false, true); - content.location = testPageURL; - }, false, true); - content.location = testPageURL; - }, false, true); - content.location = testPageURL; -} diff --git a/dom/tests/mochitest/localstorage/Makefile.in b/dom/tests/mochitest/localstorage/Makefile.in index f7748529bcef..95ac1ef0940c 100644 --- a/dom/tests/mochitest/localstorage/Makefile.in +++ b/dom/tests/mochitest/localstorage/Makefile.in @@ -27,7 +27,6 @@ MOCHITEST_FILES = \ interOriginFrame.js \ interOriginTest.js \ interOriginTest2.js \ - pbSwitch.js \ test_appIsolation.html \ test_brokenUTF-16.html \ test_bug624047.html \ @@ -55,24 +54,14 @@ MOCHITEST_FILES = \ test_storageConstructor.html \ $(NULL) -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_FILES += \ - test_localStorageBasePrivateBrowsing.html \ - test_localStorageQuotaPrivateBrowsing.html \ - $(NULL) -else -MOCHITEST_CHROME_FILES += \ - test_localStorageBasePrivateBrowsing_perwindowpb.html \ - page_blank.html \ - test_localStorageQuotaPrivateBrowsing_perwindowpb.html \ - $(NULL) -endif - MOCHITEST_CHROME_FILES = \ + test_localStorageBasePrivateBrowsing_perwindowpb.html \ test_localStorageFromChrome.xhtml \ + test_localStorageQuotaPrivateBrowsing_perwindowpb.html \ test_app_uninstall.html \ test_clear_browser_data.html \ frame_clear_browser_data.html \ + page_blank.html \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/dom/tests/mochitest/localstorage/pbSwitch.js b/dom/tests/mochitest/localstorage/pbSwitch.js deleted file mode 100644 index 434bf8e5dca3..000000000000 --- a/dom/tests/mochitest/localstorage/pbSwitch.js +++ /dev/null @@ -1,40 +0,0 @@ -var _PBSvc = null; - -function get_PBSvc() -{ - if (_PBSvc) - return _PBSvc; - - try { - _PBSvc = SpecialPowers.Components.classes["@mozilla.org/privatebrowsing;1"]. - getService(SpecialPowers.Ci.nsIPrivateBrowsingService); - return _PBSvc; - } - catch (ex) { - } - - return null; -} - -function enterPrivateBrowsing() -{ - if (get_PBSvc()) { - var prefBranch = SpecialPowers.Components.classes["@mozilla.org/preferences-service;1"]. - getService(SpecialPowers.Ci.nsIPrefBranch); - prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - get_PBSvc().privateBrowsingEnabled = true; - } -} - -function leavePrivateBrowsing() -{ - if (get_PBSvc()) { - get_PBSvc().privateBrowsingEnabled = false; - - var prefBranch = SpecialPowers.Components.classes["@mozilla.org/preferences-service;1"]. - getService(SpecialPowers.Ci.nsIPrefBranch); - if (prefBranch.prefHasUserValue("browser.privatebrowsing.keep_current_session")) - prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session"); - } -} diff --git a/dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing.html b/dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing.html deleted file mode 100644 index 42e7bc5cafd2..000000000000 --- a/dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing.html +++ /dev/null @@ -1,233 +0,0 @@ - - -localStorage basic test, while in sesison only mode - - - - - - - - - - - - - diff --git a/dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing.html b/dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing.html deleted file mode 100644 index 12df16acb97e..000000000000 --- a/dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing.html +++ /dev/null @@ -1,137 +0,0 @@ - - -localStorage and DOM quota test - - - - - - - - - - - - - - diff --git a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index 455a16862eae..164c68506695 100644 --- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -61,10 +61,6 @@ #include "nsSandboxFlags.h" #include "mozilla/Preferences.h" -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -#include "nsIPrivateBrowsingService.h" -#endif - #ifdef USEWEAKREFS #include "nsIWeakReference.h" #endif @@ -912,16 +908,6 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent, (!!(chromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW) && !(chromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW)); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - nsCOMPtr pbs = - do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID); - if (pbs) { - bool inPrivateBrowsing = false; - pbs->GetPrivateBrowsingEnabled(&inPrivateBrowsing); - isPrivateBrowsingWindow |= inPrivateBrowsing; - } -#endif - // Otherwise, propagate the privacy status of the parent window, if // available, to the child. if (!isPrivateBrowsingWindow && diff --git a/extensions/cookie/test/unit/head_cookies.js b/extensions/cookie/test/unit/head_cookies.js index 44473c5240ef..9b1b8e593b44 100644 --- a/extensions/cookie/test/unit/head_cookies.js +++ b/extensions/cookie/test/unit/head_cookies.js @@ -25,10 +25,6 @@ XPCOMUtils.defineLazyServiceGetter(Services, "permissions", "@mozilla.org/permissionmanager;1", "nsIPermissionManager"); -XPCOMUtils.defineLazyServiceGetter(Services, "pb", - "@mozilla.org/privatebrowsing;1", - "nsIPrivateBrowsingService"); - function do_check_throws(f, result, stack) { if (!stack) diff --git a/extensions/cookie/test/unit/test_bug468700.js b/extensions/cookie/test/unit/test_bug468700.js deleted file mode 100644 index 345e184ff2ab..000000000000 --- a/extensions/cookie/test/unit/test_bug468700.js +++ /dev/null @@ -1,57 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function make_channel(url) { - var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); - var chan = ios.newChannel(url, null, null).QueryInterface(Ci.nsIHttpChannel); - return chan; -} - -function make_uri(url) { - var ios = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService); - return ios.newURI(url, null, null); -} - -function run_test() { - do_load_manifest("cookieprompt.manifest"); - - var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); - var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2); - var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); - var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); - - var spec = "http://foo.bar/baz"; - var uri = ios.newURI(spec, null, null); - - // accept all cookies - prefs.setIntPref("network.cookie.lifetimePolicy", 0); - // add a test cookie - cs.setCookieString(uri, null, "foo=bar", null); - do_check_eq(cs.countCookiesFromHost("foo.bar"), 1); - // ask all cookies (will result in rejection because the prompt is not available) - prefs.setIntPref("network.cookie.lifetimePolicy", 1); - // add a test cookie - cs.setCookieString(uri, null, "bar=baz", null); - do_check_eq(cs.countCookiesFromHost("foo.bar"), 1); - cs.removeAll(); - - - // Simulate private browsing with a private channel for context - var chan = make_channel(uri.spec); - chan.QueryInterface(Ci.nsIPrivateBrowsingChannel); - chan.setPrivate(true); - - // accept all cookies - prefs.setIntPref("network.cookie.lifetimePolicy", 0); - - // add a test cookie - cs.setCookieString(uri, null, "foobar=bar", chan); - do_check_eq(cs.getCookieString(uri, chan), "foobar=bar"); - // ask all cookies (will result in rejection because the prompt is not available) - prefs.setIntPref("network.cookie.lifetimePolicy", 1); - // add a test cookie - cs.setCookieString(uri, null, "foobaz=bar", chan); - do_check_eq(cs.getCookieString(uri, chan), "foobar=bar; foobaz=bar"); -} - diff --git a/extensions/cookie/test/unit/xpcshell.ini b/extensions/cookie/test/unit/xpcshell.ini index be3d6a893fe7..baefdbef7fa6 100644 --- a/extensions/cookie/test/unit/xpcshell.ini +++ b/extensions/cookie/test/unit/xpcshell.ini @@ -2,8 +2,6 @@ head = head_cookies.js tail = -[test_bug468700.js] -skip-if = perwindowprivatebrowsing [test_bug526789.js] [test_bug650522.js] [test_bug667087.js] diff --git a/layout/forms/test/Makefile.in b/layout/forms/test/Makefile.in index b2310f44cb8e..e16b6012ca27 100644 --- a/layout/forms/test/Makefile.in +++ b/layout/forms/test/Makefile.in @@ -47,20 +47,11 @@ MOCHITEST_FILES = test_bug231389.html \ $(NULL) MOCHITEST_CHROME_FILES = \ + bug536567_iframe.html \ + test_bug536567_perwindowpb.html \ bug536567_subframe.html \ test_bug665540.html \ bug665540_window.xul \ $(NULL) -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_CHROME_FILES += \ - test_bug536567.html \ - $(NULL) -else -MOCHITEST_CHROME_FILES += \ - bug536567_iframe.html \ - test_bug536567_perwindowpb.html \ - $(NULL) -endif - include $(topsrcdir)/config/rules.mk diff --git a/layout/forms/test/test_bug536567.html b/layout/forms/test/test_bug536567.html deleted file mode 100644 index eb268aa70444..000000000000 --- a/layout/forms/test/test_bug536567.html +++ /dev/null @@ -1,170 +0,0 @@ - - - - - Test for Bug 536567 - - - - - -Mozilla Bug 536567 -

- -
-
-
- - diff --git a/mobile/android/confvars.sh b/mobile/android/confvars.sh index 4764c983ffd2..c9a55637a9ca 100755 --- a/mobile/android/confvars.sh +++ b/mobile/android/confvars.sh @@ -45,5 +45,3 @@ MOZ_APP_ID={aa3c5121-dab2-40e2-81ca-7ea25febc110} MOZ_ANDROID_OMTC=1 MOZ_EXTENSION_MANAGER=1 MOZ_APP_STATIC_INI=1 - -MOZ_PER_WINDOW_PRIVATE_BROWSING=1 diff --git a/netwerk/base/public/Makefile.in b/netwerk/base/public/Makefile.in index 9a73424120da..2584b91469a2 100644 --- a/netwerk/base/public/Makefile.in +++ b/netwerk/base/public/Makefile.in @@ -62,6 +62,7 @@ XPIDLSRCS = \ nsIPermission.idl \ nsIPermissionManager.idl \ nsIPrivateBrowsingChannel.idl \ + nsIPrivateBrowsingServiceObsolete.idl \ nsIProgressEventSink.idl \ nsIPrompt.idl \ nsIProtocolProxyService.idl \ @@ -125,12 +126,6 @@ ifdef MOZ_TOOLKIT_SEARCH XPIDLSRCS += nsIBrowserSearchService.idl endif -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -XPIDLSRCS += nsIPrivateBrowsingServiceObsolete.idl -else -XPIDLSRCS += nsIPrivateBrowsingService.idl -endif - EXPORTS = \ netCore.h \ nsNetUtil.h \ diff --git a/netwerk/base/public/nsIPrivateBrowsingService.idl b/netwerk/base/public/nsIPrivateBrowsingService.idl deleted file mode 100644 index 2d4e08c5ae94..000000000000 --- a/netwerk/base/public/nsIPrivateBrowsingService.idl +++ /dev/null @@ -1,53 +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/. */ - -#include "nsISupports.idl" - -[scriptable, uuid(b5a148a4-b422-478d-b475-194a126bbab1)] -interface nsIPrivateBrowsingService : nsISupports -{ - // When read, determines whether the private browsing mode is currently - // active. Setting to true enters the private browsing mode, and setting - // to false leaves the private browsing mode. - // Setting this value while handling one of the notifications generated - // by the private browsing service throws NS_ERROR_FAILURE. - attribute boolean privateBrowsingEnabled; - - // Determine whether the private browsing mode has been started - // automatically at application startup. - // This value will never be true if privateBrowsingEnabled is false. - readonly attribute boolean autoStarted; - - // Determine whether the last private browsing transition was performed through - // the command line (using either the -private or -private-toggle switches). - readonly attribute boolean lastChangedByCommandLine; -}; - -%{C++ -/** - * Private Browsing service notifications: - * - * - NS_PRIVATE_BROWSING_REQUEST_TOPIC: - * The data parameter determines which kind of request this represents: - * --- NS_PRIVATE_BROWSING_ENTER: - * We send this notification before switching to the private browsing mode. - * The subject parameter is set to a nsISupportsPRBool, which observers can - * set to true to prevent the switch to the private browsing mode. - * --- NS_PRIVATE_BROWSING_LEAVE: - * We send this notification before leaving the private browsing mode. - * The subject parameter is set to a nsISupportsPRBool, which observers can - * set to true to prevent leaving the private browsing mode. - * - * - NS_PRIVATE_BROWSING_SWITCH_TOPIC: - * The data parameter determines which kind of switch this represents: - * --- NS_PRIVATE_BROWSING_ENTER: - * We send this notification while switching to the private browsing mode. - * --- NS_PRIVATE_BROWSING_LEAVE: - * We send this notification while leaving the private browsing mode. - */ -#define NS_PRIVATE_BROWSING_SWITCH_TOPIC "private-browsing" -#define NS_PRIVATE_BROWSING_REQUEST_TOPIC "private-browsing-cancel-vote" -#define NS_PRIVATE_BROWSING_ENTER "enter" -#define NS_PRIVATE_BROWSING_LEAVE "exit" -%} diff --git a/netwerk/build/nsNetCID.h b/netwerk/build/nsNetCID.h index 230982a70d7a..417292ee4ea3 100644 --- a/netwerk/build/nsNetCID.h +++ b/netwerk/build/nsNetCID.h @@ -473,19 +473,6 @@ {0x9a, 0x05, 0xb6, 0xd9, 0x2f, 0x8f, 0x22, 0x9a} \ } -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -// component implementing nsIPrivateBrowsingService -#define NS_PRIVATE_BROWSING_SERVICE_CONTRACTID \ - "@mozilla.org/privatebrowsing-wrapper;1" -#define NS_PRIVATE_BROWSING_SERVICE_CID \ -{ /* c31f4883-839b-45f6-82ad-a6a9bc5ad599 */ \ - 0xc31f4883, \ - 0x839b, \ - 0x45f6, \ - {0x82, 0xad, 0xa6, 0xa9, 0xbc, 0x5a, 0xd5, 0x99} \ -} -#endif - /** * Contract ID for a service implementing nsIURIClassifier that identifies * phishing and malware sites. diff --git a/security/manager/ssl/tests/mochitest/browser/Makefile.in b/security/manager/ssl/tests/mochitest/browser/Makefile.in index 13e8683e192a..91d1b50815a6 100644 --- a/security/manager/ssl/tests/mochitest/browser/Makefile.in +++ b/security/manager/ssl/tests/mochitest/browser/Makefile.in @@ -13,12 +13,7 @@ include $(DEPTH)/config/autoconf.mk MOCHITEST_BROWSER_FILES = \ head.js \ - $(NULL) - -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ browser_bug627234_perwindowpb.js \ $(NULL) -endif include $(topsrcdir)/config/rules.mk diff --git a/security/manager/ssl/tests/mochitest/stricttransportsecurity/Makefile.in b/security/manager/ssl/tests/mochitest/stricttransportsecurity/Makefile.in index 6d2a8e6e337b..e431550c2bc7 100644 --- a/security/manager/ssl/tests/mochitest/stricttransportsecurity/Makefile.in +++ b/security/manager/ssl/tests/mochitest/stricttransportsecurity/Makefile.in @@ -21,15 +21,9 @@ MOCHITEST_FILES = \ test_stricttransportsecurity.html \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING MOCHITEST_CHROME_FILES += \ test_sts_privatebrowsing_perwindowpb.html \ page_blank.html \ $(NULL) -else -MOCHITEST_FILES += \ - test_sts_privatebrowsing.html \ - $(NULL) -endif include $(topsrcdir)/config/rules.mk diff --git a/security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing.html b/security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing.html deleted file mode 100644 index 90067cbb4735..000000000000 --- a/security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing.html +++ /dev/null @@ -1,233 +0,0 @@ - - - - - - opens additional content that should be converted to https - - - - - - - - This test will load some iframes and do some tests. - - - diff --git a/security/manager/ssl/tests/unit/test_bug627234.js b/security/manager/ssl/tests/unit/test_bug627234.js deleted file mode 100644 index 0558db6391fb..000000000000 --- a/security/manager/ssl/tests/unit/test_bug627234.js +++ /dev/null @@ -1,64 +0,0 @@ -var Cc = Components.classes; -var Ci = Components.interfaces; - -Components.utils.import("resource://gre/modules/Services.jsm"); - -var gSTSService = Cc["@mozilla.org/stsservice;1"] - .getService(Ci.nsIStrictTransportSecurityService); - -var gNextTest = null; - -function cleanup() { - leavePB(); - // (we have to remove any state added to the sts service so as to not muck - // with other tests). - var uri = Services.io.newURI("http://localhost", null, null); - gSTSService.removeStsState(uri, privacyFlags()); -} - -function run_test() { - do_test_pending(); - do_register_cleanup(cleanup); - - gNextTest = test_part1; - enterPB(); -} - -var gInPrivate = false; -function enterPB() { - gInPrivate = true; - do_execute_soon(gNextTest); -} - -function leavePB() { - gInPrivate = false; - Services.obs.notifyObservers(null, "last-pb-context-exited", null); - do_execute_soon(gNextTest); -} - -function privacyFlags() { - return gInPrivate ? Ci.nsISocketProvider.NO_PERMANENT_STORAGE : 0; -} - -function test_part1() { - var uri = Services.io.newURI("https://localhost/img.png", null, null); - gSTSService.processStsHeader(uri, "max-age=1000", privacyFlags()); - do_check_true(gSTSService.isStsHost("localhost", privacyFlags())); - gNextTest = test_part2; - leavePB(); -} - -function test_part2() { - var uri = Services.io.newURI("https://localhost/img.png", null, null); - gSTSService.processStsHeader(uri, "max-age=1000", privacyFlags()); - do_check_true(gSTSService.isStsHost("localhost", privacyFlags())); - gNextTest = test_part3; - enterPB(); -} - -function test_part3() { - var uri = Services.io.newURI("https://localhost/img.png", null, null); - gSTSService.processStsHeader(uri, "max-age=1000", privacyFlags()); - do_check_true(gSTSService.isStsHost("localhost", privacyFlags())); - do_test_finished(); -} diff --git a/security/manager/ssl/tests/unit/test_sts_preloadlist.js b/security/manager/ssl/tests/unit/test_sts_preloadlist.js deleted file mode 100644 index 8fec91622c37..000000000000 --- a/security/manager/ssl/tests/unit/test_sts_preloadlist.js +++ /dev/null @@ -1,216 +0,0 @@ -var Cc = Components.classes; -var Ci = Components.interfaces; - -Components.utils.import("resource://gre/modules/Services.jsm"); - -var _pbsvc; - -// lazy getter, added for bug 785860 to avoid testing private browsing when the -// private browsing service doesn't exist -function getPBSvc() { - if (_pbsvc) - return _pbsvc; - - try { - _pbsvc = Cc["@mozilla.org/privatebrowsing;1"] - .getService(Ci.nsIPrivateBrowsingService); - return _pbsvc; - } catch (e) {} - - return null; -} - -var gSTSService = Cc["@mozilla.org/stsservice;1"] - .getService(Ci.nsIStrictTransportSecurityService); - -function Observer() {} -Observer.prototype = { - observe: function(subject, topic, data) { - run_next_test(); - } -}; - -var gObserver = new Observer(); - -// This is a list of every host we call processStsHeader with -// (we have to remove any state added to the sts service so as to not muck -// with other tests). -var hosts = ["http://keyerror.com", "http://subdomain.intercom.io", - "http://subdomain.pixi.me", "http://crypto.cat", - "http://logentries.com"]; - -function cleanup() { - Services.obs.removeObserver(gObserver, "private-browsing-transition-complete"); - if (getPBSvc()) - getPBSvc().privateBrowsingEnabled = false; - - for (var host of hosts) { - var uri = Services.io.newURI(host, null, null); - gSTSService.removeStsState(uri, 0); - } -} - -function run_test() { - do_register_cleanup(cleanup); - Services.obs.addObserver(gObserver, "private-browsing-transition-complete", false); - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - add_test(test_part1); - if (getPBSvc()) { - add_test(test_private_browsing1); - add_test(test_private_browsing2); - } - - run_next_test(); -} - -function test_part1() { - // check that a host not in the list is not identified as an sts host - do_check_false(gSTSService.isStsHost("nonexistent.mozilla.com", 0)); - - // check that an ancestor domain is not identified as an sts host - do_check_false(gSTSService.isStsHost("com", 0)); - - // Note: the following were taken from the STS preload list - // as of Sept. 2012. If the list changes, this test will need to be modified. - // check that the pref to toggle using the preload list works - Services.prefs.setBoolPref("network.stricttransportsecurity.preloadlist", false); - do_check_false(gSTSService.isStsHost("factor.cc", 0)); - Services.prefs.setBoolPref("network.stricttransportsecurity.preloadlist", true); - do_check_true(gSTSService.isStsHost("factor.cc", 0)); - - // check that an entry at the beginning of the list is an sts host - do_check_true(gSTSService.isStsHost("arivo.com.br", 0)); - - // check that a subdomain is an sts host (includeSubdomains is set) - do_check_true(gSTSService.isStsHost("subdomain.arivo.com.br", 0)); - - // check that another subdomain is an sts host (includeSubdomains is set) - do_check_true(gSTSService.isStsHost("a.b.c.subdomain.arivo.com.br", 0)); - - // check that an entry in the middle of the list is an sts host - do_check_true(gSTSService.isStsHost("neg9.org", 0)); - - // check that a subdomain is not an sts host (includeSubdomains is not set) - do_check_false(gSTSService.isStsHost("subdomain.neg9.org", 0)); - - // check that an entry at the end of the list is an sts host - do_check_true(gSTSService.isStsHost("www.noisebridge.net", 0)); - - // check that a subdomain is not an sts host (includeSubdomains is not set) - do_check_false(gSTSService.isStsHost("a.subdomain.www.noisebridge.net", 0)); - - // check that a host with a dot on the end won't break anything - do_check_false(gSTSService.isStsHost("notsts.nonexistent.mozilla.com.", 0)); - - // check that processing a header with max-age: 0 will remove a preloaded - // site from the list - var uri = Services.io.newURI("http://keyerror.com", null, null); - gSTSService.processStsHeader(uri, "max-age=0", 0); - do_check_false(gSTSService.isStsHost("keyerror.com", 0)); - do_check_false(gSTSService.isStsHost("subdomain.keyerror.com", 0)); - // check that processing another header (with max-age non-zero) will - // re-enable a site's sts status - gSTSService.processStsHeader(uri, "max-age=1000", 0); - do_check_true(gSTSService.isStsHost("keyerror.com", 0)); - // but this time include subdomains was not set, so test for that - do_check_false(gSTSService.isStsHost("subdomain.keyerror.com", 0)); - - // check that processing a header with max-age: 0 from a subdomain of a site - // will not remove that (ancestor) site from the list - var uri = Services.io.newURI("http://subdomain.intercom.io", null, null); - gSTSService.processStsHeader(uri, "max-age=0", 0); - do_check_true(gSTSService.isStsHost("intercom.io", 0)); - do_check_false(gSTSService.isStsHost("subdomain.intercom.io", 0)); - - var uri = Services.io.newURI("http://subdomain.pixi.me", null, null); - gSTSService.processStsHeader(uri, "max-age=0", 0); - // we received a header with "max-age=0", so we have "no information" - // regarding the sts state of subdomain.pixi.me specifically, but - // it is actually still an STS host, because of the preloaded pixi.me - // including subdomains. - // Here's a drawing: - // |-- pixi.me (in preload list, includes subdomains) IS sts host - // |-- subdomain.pixi.me IS sts host - // | `-- another.subdomain.pixi.me IS sts host - // `-- sibling.pixi.me IS sts host - do_check_true(gSTSService.isStsHost("subdomain.pixi.me", 0)); - do_check_true(gSTSService.isStsHost("sibling.pixi.me", 0)); - do_check_true(gSTSService.isStsHost("another.subdomain.pixi.me", 0)); - - gSTSService.processStsHeader(uri, "max-age=1000", 0); - // Here's what we have now: - // |-- pixi.me (in preload list, includes subdomains) IS sts host - // |-- subdomain.pixi.me (include subdomains is false) IS sts host - // | `-- another.subdomain.pixi.me IS NOT sts host - // `-- sibling.pixi.me IS sts host - do_check_true(gSTSService.isStsHost("subdomain.pixi.me", 0)); - do_check_true(gSTSService.isStsHost("sibling.pixi.me", 0)); - do_check_false(gSTSService.isStsHost("another.subdomain.pixi.me", 0)); - - // Test private browsing correctly interacts with removing preloaded sites. - // If we don't have the private browsing service, don't run those tests - // (which means we have to manually call run_next_test() instead of relying - // on our observer to call it). - if (getPBSvc()) { - getPBSvc().privateBrowsingEnabled = true; - } else { - run_next_test(); - } -} - -const IS_PRIVATE = Ci.nsISocketProvider.NO_PERMANENT_STORAGE; - -function test_private_browsing1() { - // sanity - crypto.cat is preloaded, includeSubdomains set - do_check_true(gSTSService.isStsHost("crypto.cat", IS_PRIVATE)); - do_check_true(gSTSService.isStsHost("a.b.c.subdomain.crypto.cat", IS_PRIVATE)); - - var uri = Services.io.newURI("http://crypto.cat", null, null); - gSTSService.processStsHeader(uri, "max-age=0", IS_PRIVATE); - do_check_false(gSTSService.isStsHost("crypto.cat", IS_PRIVATE)); - do_check_false(gSTSService.isStsHost("a.b.subdomain.crypto.cat", IS_PRIVATE)); - - // check adding it back in - gSTSService.processStsHeader(uri, "max-age=1000", IS_PRIVATE); - do_check_true(gSTSService.isStsHost("crypto.cat", IS_PRIVATE)); - // but no includeSubdomains this time - do_check_false(gSTSService.isStsHost("b.subdomain.crypto.cat", IS_PRIVATE)); - - // do the hokey-pokey... - gSTSService.processStsHeader(uri, "max-age=0", IS_PRIVATE); - do_check_false(gSTSService.isStsHost("crypto.cat", IS_PRIVATE)); - do_check_false(gSTSService.isStsHost("subdomain.crypto.cat", IS_PRIVATE)); - - // TODO unfortunately we don't have a good way to know when an entry - // has expired in the permission manager, so we can't yet extend this test - // to that case. - // Test that an expired private browsing entry results in correctly - // identifying a host that is on the preload list as no longer sts. - // (This happens when we're in private browsing mode, we get a header from - // a site on the preload list, and that header later expires. We need to - // then treat that host as no longer an sts host.) - // (sanity check first - this should be in the preload list) - do_check_true(gSTSService.isStsHost("logentries.com", IS_PRIVATE)); - var uri = Services.io.newURI("http://logentries.com", null, null); - // according to the rfc, max-age can't be negative, but this is a great - // way to test an expired entry - gSTSService.processStsHeader(uri, "max-age=-1000", IS_PRIVATE); - do_check_false(gSTSService.isStsHost("logentries.com", IS_PRIVATE)); - - // if this test gets this far, it means there's a private browsing service - getPBSvc().privateBrowsingEnabled = false; -} - -function test_private_browsing2() { - // if this test gets this far, it means there's a private browsing service - do_check_true(gSTSService.isStsHost("crypto.cat", 0)); - // the crypto.cat entry has includeSubdomains set - do_check_true(gSTSService.isStsHost("subdomain.crypto.cat", 0)); - - // Now that we're out of private browsing mode, we need to make sure - // we've "forgotten" that we "forgot" this site's sts status. - do_check_true(gSTSService.isStsHost("logentries.com", 0)); - - run_next_test(); -} diff --git a/security/manager/ssl/tests/unit/xpcshell.ini b/security/manager/ssl/tests/unit/xpcshell.ini index 0629e85475a8..45990cf501c4 100644 --- a/security/manager/ssl/tests/unit/xpcshell.ini +++ b/security/manager/ssl/tests/unit/xpcshell.ini @@ -13,10 +13,5 @@ skip-if = os == "android" [test_hmac.js] # Bug 676972: test hangs consistently on Android skip-if = os == "android" -[test_bug627234.js] -skip-if = perwindowprivatebrowsing -[test_sts_preloadlist.js] -skip-if = perwindowprivatebrowsing [test_sts_preloadlist_perwindowpb.js] -skip-if = !perwindowprivatebrowsing [test_sts_preloadlist_selfdestruct.js] diff --git a/services/sync/modules/engines/tabs.js b/services/sync/modules/engines/tabs.js index 69ed71d269ec..ad1331e5cc5e 100644 --- a/services/sync/modules/engines/tabs.js +++ b/services/sync/modules/engines/tabs.js @@ -288,9 +288,6 @@ TabTracker.prototype = { switch (aTopic) { case "weave:engine:start-tracking": if (!this._enabled) { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Svc.Obs.add("private-browsing", this); -#endif Svc.Obs.add("domwindowopened", this); let wins = Services.wm.getEnumerator("navigator:browser"); while (wins.hasMoreElements()) @@ -300,9 +297,6 @@ TabTracker.prototype = { break; case "weave:engine:stop-tracking": if (this._enabled) { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Svc.Obs.remove("private-browsing", this); -#endif Svc.Obs.remove("domwindowopened", this); let wins = Services.wm.getEnumerator("navigator:browser"); while (wins.hasMoreElements()) @@ -319,11 +313,6 @@ TabTracker.prototype = { self._registerListenersForWindow(aSubject); }, false); break; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - case "private-browsing": - if (aData == "enter" && !PrivateBrowsingUtils.permanentPrivateBrowsing) - this.modified = false; -#endif } }, diff --git a/toolkit/components/console/content/consoleBindings.xml b/toolkit/components/console/content/consoleBindings.xml index aba57f305fd9..f0c997572988 100644 --- a/toolkit/components/console/content/consoleBindings.xml +++ b/toolkit/components/console/content/consoleBindings.xml @@ -167,11 +167,9 @@ if (!this.showChromeErrors && scriptError.sourceName.substr(0, 9) == "chrome://") return; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // filter private windows if (scriptError.isFromPrivateWindow) return; -#endif this.appendError(scriptError); } catch (ex) { diff --git a/toolkit/components/downloads/nsDownloadManager.cpp b/toolkit/components/downloads/nsDownloadManager.cpp index 8a01d5dda601..7c251a024cb5 100644 --- a/toolkit/components/downloads/nsDownloadManager.cpp +++ b/toolkit/components/downloads/nsDownloadManager.cpp @@ -20,9 +20,6 @@ #include "nsIWindowMediator.h" #include "nsILocalFileWin.h" #include "nsILoadContext.h" -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -#include "nsIPrivateBrowsingService.h" -#endif #include "nsAppDirectoryServiceDefs.h" #include "nsArrayEnumerator.h" @@ -80,12 +77,6 @@ static const int64_t gUpdateInterval = 400 * PR_USEC_PER_MSEC; #define NS_SYSTEMINFO_CONTRACTID "@mozilla.org/system-info;1" -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -const bool gUsePerWindowPrivateBrowsing = true; -#else -const bool gUsePerWindowPrivateBrowsing = false; -#endif - //////////////////////////////////////////////////////////////////////////////// //// nsDownloadManager @@ -1002,10 +993,6 @@ nsDownloadManager::Init() (void)mObserverService->AddObserver(this, "profile-before-change", true); (void)mObserverService->AddObserver(this, NS_IOSERVICE_GOING_OFFLINE_TOPIC, true); (void)mObserverService->AddObserver(this, NS_IOSERVICE_OFFLINE_STATUS_TOPIC, true); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - (void)mObserverService->AddObserver(this, NS_PRIVATE_BROWSING_REQUEST_TOPIC, true); - (void)mObserverService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, true); -#endif (void)mObserverService->AddObserver(this, "last-pb-context-exited", true); (void)mObserverService->AddObserver(this, "last-pb-context-exiting", true); @@ -1114,18 +1101,14 @@ nsDownloadManager::GetDownloadFromDB(const nsACString& aGUID, nsDownload **retVa nsresult nsDownloadManager::GetDownloadFromDB(uint32_t aID, nsDownload **retVal) { - if (gUsePerWindowPrivateBrowsing) - NS_WARNING("Using integer IDs without compat mode enabled"); + NS_WARNING("Using integer IDs without compat mode enabled"); MOZ_ASSERT(!FindDownload(aID), "If it is a current download, you should not call this method!"); - nsCOMPtr dbConn = - IsInGlobalPrivateBrowsing() ? mPrivateDBConn : mDBConn; - // First, let's query the database and see if it even exists nsCOMPtr stmt; - nsresult rv = dbConn->CreateStatement(NS_LITERAL_CSTRING( + nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING( "SELECT id, state, startTime, source, target, tempPath, name, referrer, " "entityID, currBytes, maxBytes, mimeType, preferredAction, " "preferredApplication, autoResume, guid " @@ -1136,7 +1119,7 @@ nsDownloadManager::GetDownloadFromDB(uint32_t aID, nsDownload **retVal) rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), aID); NS_ENSURE_SUCCESS(rv, rv); - return GetDownloadFromDB(dbConn, stmt, retVal); + return GetDownloadFromDB(mDBConn, stmt, retVal); } nsresult @@ -1305,8 +1288,7 @@ nsDownloadManager::GetActivePrivateDownloadCount(int32_t* aResult) NS_IMETHODIMP nsDownloadManager::GetActiveDownloadCount(int32_t *aResult) { - *aResult = IsInGlobalPrivateBrowsing() ? - mCurrentPrivateDownloads.Count() : mCurrentDownloads.Count(); + *aResult = mCurrentDownloads.Count(); return NS_OK; } @@ -1314,9 +1296,7 @@ nsDownloadManager::GetActiveDownloadCount(int32_t *aResult) NS_IMETHODIMP nsDownloadManager::GetActiveDownloads(nsISimpleEnumerator **aResult) { - return NS_NewArrayEnumerator(aResult, - IsInGlobalPrivateBrowsing() ? - mCurrentPrivateDownloads : mCurrentDownloads); + return NS_NewArrayEnumerator(aResult, mCurrentDownloads); } NS_IMETHODIMP @@ -1549,20 +1529,6 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType, nsresult rv; -#if !(defined(MOZ_PER_WINDOW_PRIVATE_BROWSING)) && defined(DEBUG) - // This code makes sure that in global private browsing mode, the flag - // passed to us matches the global PB mode. This can be removed when - // per-window private browsing has been turned on. - nsCOMPtr pbService = - do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID); - if (pbService) { - bool inPrivateBrowsing = false; - if (NS_SUCCEEDED(pbService->GetPrivateBrowsingEnabled(&inPrivateBrowsing))) { - MOZ_ASSERT(inPrivateBrowsing == aIsPrivate); - } - } -#endif - // target must be on the local filesystem nsCOMPtr targetFileURL = do_QueryInterface(aTarget, &rv); NS_ENSURE_SUCCESS(rv, rv); @@ -1689,9 +1655,7 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType, NS_IMETHODIMP nsDownloadManager::GetDownload(uint32_t aID, nsIDownload **aDownloadItem) { - if (gUsePerWindowPrivateBrowsing) { - NS_WARNING("Using integer IDs without compat mode enabled"); - } + NS_WARNING("Using integer IDs without compat mode enabled"); nsDownload *itm = FindDownload(aID); @@ -1749,29 +1713,12 @@ nsDownloadManager::GetDownloadByGUID(const nsACString& aGUID, return NS_OK; } -bool -nsDownloadManager::IsInGlobalPrivateBrowsing() -{ - bool inPrivateBrowsing = false; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - nsCOMPtr pbs = - do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID); - if (pbs) { - pbs->GetPrivateBrowsingEnabled(&inPrivateBrowsing); - } -#endif - return inPrivateBrowsing; -} - nsDownload * nsDownloadManager::FindDownload(uint32_t aID) { - nsCOMArray& currentDownloads = - IsInGlobalPrivateBrowsing() ? - mCurrentPrivateDownloads : mCurrentDownloads; // we shouldn't ever have many downloads, so we can loop over them - for (int32_t i = currentDownloads.Count() - 1; i >= 0; --i) { - nsDownload *dl = currentDownloads[i]; + for (int32_t i = mCurrentDownloads.Count() - 1; i >= 0; --i) { + nsDownload *dl = mCurrentDownloads[i]; if (dl->mID == aID) return dl; } @@ -1801,9 +1748,7 @@ nsDownloadManager::FindDownload(const nsACString& aGUID) NS_IMETHODIMP nsDownloadManager::CancelDownload(uint32_t aID) { - if (gUsePerWindowPrivateBrowsing) { - NS_WARNING("Using integer IDs without compat mode enabled"); - } + NS_WARNING("Using integer IDs without compat mode enabled"); // We AddRef here so we don't lose access to member variables when we remove nsRefPtr dl = FindDownload(aID); @@ -1829,9 +1774,7 @@ nsDownloadManager::RetryDownload(const nsACString& aGUID) NS_IMETHODIMP nsDownloadManager::RetryDownload(uint32_t aID) { - if (gUsePerWindowPrivateBrowsing) { - NS_WARNING("Using integer IDs without compat mode enabled"); - } + NS_WARNING("Using integer IDs without compat mode enabled"); nsRefPtr dl; nsresult rv = GetDownloadFromDB(aID, getter_AddRefs(dl)); @@ -1933,9 +1876,7 @@ nsDownloadManager::RemoveDownload(const nsACString& aGUID) NS_IMETHODIMP nsDownloadManager::RemoveDownload(uint32_t aID) { - if (gUsePerWindowPrivateBrowsing) { - NS_WARNING("Using integer IDs without compat mode enabled"); - } + NS_WARNING("Using integer IDs without compat mode enabled"); nsRefPtr dl = FindDownload(aID); MOZ_ASSERT(!dl, "Can't call RemoveDownload on a download in progress!"); @@ -1945,10 +1886,8 @@ nsDownloadManager::RemoveDownload(uint32_t aID) nsresult rv = GetDownloadFromDB(aID, getter_AddRefs(dl)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr dbConn = - IsInGlobalPrivateBrowsing() ? mPrivateDBConn : mDBConn; nsCOMPtr stmt; - rv = dbConn->CreateStatement(NS_LITERAL_CSTRING( + rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING( "DELETE FROM moz_downloads " "WHERE id = :id"), getter_AddRefs(stmt)); NS_ENSURE_SUCCESS(rv, rv); @@ -1970,10 +1909,8 @@ nsDownloadManager::NotifyDownloadRemoval(nsDownload* aRemoved) nsCOMPtr guid; nsresult rv; - // Only send an integer ID notification if the download is public, - // or we're in global PB compatiblity mode, or we're removing multiple downloads. - bool sendDeprecatedNotification = !gUsePerWindowPrivateBrowsing || - !(aRemoved && aRemoved->mPrivate); + // Only send an integer ID notification if the download is public. + bool sendDeprecatedNotification = !(aRemoved && aRemoved->mPrivate); if (sendDeprecatedNotification && aRemoved) { id = do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID, &rv); @@ -2158,9 +2095,7 @@ nsDownloadManager::GetCanCleanUpPrivate(bool *aResult) NS_IMETHODIMP nsDownloadManager::PauseDownload(uint32_t aID) { - if (gUsePerWindowPrivateBrowsing) { - NS_WARNING("Using integer IDs without compat mode enabled"); - } + NS_WARNING("Using integer IDs without compat mode enabled"); nsDownload *dl = FindDownload(aID); if (!dl) @@ -2172,9 +2107,7 @@ nsDownloadManager::PauseDownload(uint32_t aID) NS_IMETHODIMP nsDownloadManager::ResumeDownload(uint32_t aID) { - if (gUsePerWindowPrivateBrowsing) { - NS_WARNING("Using integer IDs without compat mode enabled"); - } + NS_WARNING("Using integer IDs without compat mode enabled"); nsDownload *dl = FindDownload(aID); if (!dl) @@ -2186,7 +2119,7 @@ nsDownloadManager::ResumeDownload(uint32_t aID) NS_IMETHODIMP nsDownloadManager::GetDBConnection(mozIStorageConnection **aDBConn) { - NS_ADDREF(*aDBConn = IsInGlobalPrivateBrowsing() ? mPrivateDBConn : mDBConn); + NS_ADDREF(*aDBConn = mDBConn); return NS_OK; } @@ -2229,11 +2162,9 @@ nsDownloadManager::NotifyListenersOnDownloadStateChange(int16_t aOldState, mPrivacyAwareListeners[i]->OnDownloadStateChange(aOldState, aDownload); } - // In global PB compatibility mode, it's fine for all listeners to receive - // notifications about all downloads. Otherwise, only privacy-aware listeners - // should receive notifications about private downloads, while non-privacy-aware - // listeners receive no sign they exist. - if (aDownload->mPrivate && gUsePerWindowPrivateBrowsing) { + // Only privacy-aware listeners should receive notifications about private + // downloads, while non-privacy-aware listeners receive no sign they exist. + if (aDownload->mPrivate) { return; } @@ -2257,11 +2188,9 @@ nsDownloadManager::NotifyListenersOnProgressChange(nsIWebProgress *aProgress, aMaxTotalProgress, aDownload); } - // In global PB compatibility mode, it's fine for all listeners to receive - // notifications about all downloads. Otherwise, only privacy-aware listeners - // should receive notifications about private downloads, while non-privacy-aware - // listeners receive no sign they exist. - if (aDownload->mPrivate && gUsePerWindowPrivateBrowsing) { + // Only privacy-aware listeners should receive notifications about private + // downloads, while non-privacy-aware listeners receive no sign they exist. + if (aDownload->mPrivate) { return; } @@ -2284,11 +2213,9 @@ nsDownloadManager::NotifyListenersOnStateChange(nsIWebProgress *aProgress, aDownload); } - // In global PB compatibility mode, it's fine for all listeners to receive - // notifications about all downloads. Otherwise, only privacy-aware listeners - // should receive notifications about private downloads, while non-privacy-aware - // listeners receive no sign they exist. - if (aDownload->mPrivate && gUsePerWindowPrivateBrowsing) { + // Only privacy-aware listeners should receive notifications about private + // downloads, while non-privacy-aware listeners receive no sign they exist. + if (aDownload->mPrivate) { return; } @@ -2392,31 +2319,24 @@ nsDownloadManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) { - // If we're in global private browsing mode, the total number of active - // downloads we want to warn about is the number of active private downloads. - // Otherwise, we need to count the active public downloads that could be lost + // We need to count the active public downloads that could be lost // by quitting, and add any active private ones as well, since per-window // private browsing may be active. - nsCOMArray& currDownloads = - IsInGlobalPrivateBrowsing() ? mCurrentPrivateDownloads : mCurrentDownloads; - int32_t currDownloadCount = currDownloads.Count(); + int32_t currDownloadCount = mCurrentDownloads.Count(); // If we don't need to cancel all the downloads on quit, only count the ones - // that aren't resumable (this includes private downloads if we're in - // global private browsing mode). - if (GetQuitBehavior() != QUIT_AND_CANCEL && !IsInGlobalPrivateBrowsing()) { + // that aren't resumable. + if (GetQuitBehavior() != QUIT_AND_CANCEL) { for (int32_t i = currDownloadCount - 1; i >= 0; --i) { - if (currDownloads[i]->IsResumable()) { + if (mCurrentDownloads[i]->IsResumable()) { currDownloadCount--; } } - if (gUsePerWindowPrivateBrowsing) { - // We have a count of the public, non-resumable downloads. Now we need - // to add the total number of private downloads, since they are in danger - // of being lost. - currDownloadCount += mCurrentPrivateDownloads.Count(); - } + // We have a count of the public, non-resumable downloads. Now we need + // to add the total number of private downloads, since they are in danger + // of being lost. + currDownloadCount += mCurrentPrivateDownloads.Count(); } nsresult rv; @@ -2518,77 +2438,16 @@ nsDownloadManager::Observe(nsISupports *aSubject, nsCOMPtr cancelDownloads = do_QueryInterface(aSubject, &rv); NS_ENSURE_SUCCESS(rv, rv); -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING ConfirmCancelDownloads(mCurrentPrivateDownloads.Count(), cancelDownloads, NS_LITERAL_STRING("leavePrivateBrowsingCancelDownloadsAlertTitle").get(), NS_LITERAL_STRING("leavePrivateBrowsingWindowsCancelDownloadsAlertMsgMultiple").get(), NS_LITERAL_STRING("leavePrivateBrowsingWindowsCancelDownloadsAlertMsg").get(), NS_LITERAL_STRING("dontLeavePrivateBrowsingButton").get()); -#else - ConfirmCancelDownloads(mCurrentPrivateDownloads.Count(), cancelDownloads, - NS_LITERAL_STRING("leavePrivateBrowsingCancelDownloadsAlertTitle").get(), - NS_LITERAL_STRING("leavePrivateBrowsingCancelDownloadsAlertMsgMultiple").get(), - NS_LITERAL_STRING("leavePrivateBrowsingCancelDownloadsAlertMsg").get(), - NS_LITERAL_STRING("dontLeavePrivateBrowsingButton").get()); -#endif } -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - else if (strcmp(aTopic, NS_PRIVATE_BROWSING_REQUEST_TOPIC) == 0) { - if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_ENTER).Equals(aData) && - currDownloadCount) { - nsCOMPtr cancelDownloads = - do_QueryInterface(aSubject, &rv); - NS_ENSURE_SUCCESS(rv, rv); - ConfirmCancelDownloads(currDownloadCount, cancelDownloads, - NS_LITERAL_STRING("enterPrivateBrowsingCancelDownloadsAlertTitle").get(), - NS_LITERAL_STRING("enterPrivateBrowsingCancelDownloadsAlertMsgMultiple").get(), - NS_LITERAL_STRING("enterPrivateBrowsingCancelDownloadsAlertMsg").get(), - NS_LITERAL_STRING("dontEnterPrivateBrowsingButton").get()); - } - } - else if (strcmp(aTopic, NS_PRIVATE_BROWSING_SWITCH_TOPIC) == 0) { - if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_ENTER).Equals(aData)) - OnEnterPrivateBrowsingMode(); - else if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_LEAVE).Equals(aData)) - OnLeavePrivateBrowsingMode(); - } -#endif return NS_OK; } -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -void -nsDownloadManager::OnEnterPrivateBrowsingMode() -{ - // Pause all downloads, and mark them to auto-resume. - (void)PauseAllDownloads(true); - (void)RemoveAllDownloads(); - - // Notify that the database type changed before resuming current downloads - (void)mObserverService->NotifyObservers( - static_cast(this), - "download-manager-database-type-changed", - nullptr); -} - -void -nsDownloadManager::OnLeavePrivateBrowsingMode() -{ - nsresult rv = RestoreDatabaseState(); - NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to restore database state"); - - // Notify that the database type changed before resuming current downloads - (void)mObserverService->NotifyObservers( - static_cast(this), - "download-manager-database-type-changed", - nullptr); - - rv = RestoreActiveDownloads(); - NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to restore all active downloads"); -} -#endif - void nsDownloadManager::ConfirmCancelDownloads(int32_t aCount, nsISupportsPRBool *aCancelDownloads, @@ -2889,33 +2748,33 @@ nsDownload::SetState(DownloadState aState) case nsIDownloadManager::DOWNLOAD_DOWNLOADING: // Only send the dl-start event to downloads that are actually starting. if (oldState == nsIDownloadManager::DOWNLOAD_QUEUED) { - if (!gUsePerWindowPrivateBrowsing || !mPrivate) + if (!mPrivate) mDownloadManager->SendEvent(this, "dl-start"); } break; case nsIDownloadManager::DOWNLOAD_FAILED: - if (!gUsePerWindowPrivateBrowsing || !mPrivate) + if (!mPrivate) mDownloadManager->SendEvent(this, "dl-failed"); break; case nsIDownloadManager::DOWNLOAD_SCANNING: - if (!gUsePerWindowPrivateBrowsing || !mPrivate) + if (!mPrivate) mDownloadManager->SendEvent(this, "dl-scanning"); break; case nsIDownloadManager::DOWNLOAD_FINISHED: - if (!gUsePerWindowPrivateBrowsing || !mPrivate) + if (!mPrivate) mDownloadManager->SendEvent(this, "dl-done"); break; case nsIDownloadManager::DOWNLOAD_BLOCKED_PARENTAL: case nsIDownloadManager::DOWNLOAD_BLOCKED_POLICY: - if (!gUsePerWindowPrivateBrowsing || !mPrivate) + if (!mPrivate) mDownloadManager->SendEvent(this, "dl-blocked"); break; case nsIDownloadManager::DOWNLOAD_DIRTY: - if (!gUsePerWindowPrivateBrowsing || !mPrivate) + if (!mPrivate) mDownloadManager->SendEvent(this, "dl-dirty"); break; case nsIDownloadManager::DOWNLOAD_CANCELED: - if (!gUsePerWindowPrivateBrowsing || !mPrivate) + if (!mPrivate) mDownloadManager->SendEvent(this, "dl-cancel"); break; default: @@ -3259,7 +3118,7 @@ nsDownload::GetSpeed(double *aSpeed) NS_IMETHODIMP nsDownload::GetId(uint32_t *aId) { - if (mPrivate && gUsePerWindowPrivateBrowsing) { + if (mPrivate) { return NS_ERROR_NOT_AVAILABLE; } *aId = mID; diff --git a/toolkit/components/downloads/nsDownloadManager.h b/toolkit/components/downloads/nsDownloadManager.h index e77f7b622e46..6d7f737e5934 100644 --- a/toolkit/components/downloads/nsDownloadManager.h +++ b/toolkit/components/downloads/nsDownloadManager.h @@ -242,8 +242,6 @@ private: nsresult ResumeAllDownloads(nsCOMArray& aDownloads, bool aResumeAll); nsresult RemoveDownloadsForURI(mozIStorageStatement* aStatement, nsIURI *aURI); - bool IsInGlobalPrivateBrowsing(); - nsCOMArray mListeners; nsCOMArray mPrivacyAwareListeners; nsCOMPtr mBundle; diff --git a/toolkit/components/downloads/test/unit/test_private_resume_global.js b/toolkit/components/downloads/test/unit/test_private_resume_global.js deleted file mode 100644 index 1dc18733131c..000000000000 --- a/toolkit/components/downloads/test/unit/test_private_resume_global.js +++ /dev/null @@ -1,129 +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.__defineGetter__("pb", function () { - delete this.pb; - try { - return this.pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - } catch (e) {} - return this.pb = null; -}); - -// Public request gets times=0 cookie, completes -// Private request gets times=1 cookie, canceled -// Private resumed request sends times=1 cookie, completes - -function run_test() { - // Don't run the test where the PB service is not available - if (!pb) { - return; - } - - do_test_pending(); - let httpserv = new HttpServer(); - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - let times = 0; - httpserv.registerPathHandler("/head_download_manager.js", function (meta, response) { - response.setHeader("Content-Type", "text/plain", false); - response.setStatusLine("1.1", !meta.hasHeader('range') ? 200 : 206); - - // Set a cookie if none is sent with the request. Public and private requests - // should therefore receive different cookies, so we can tell if the resumed - // request is actually treated as private or not. - if (!meta.hasHeader('Cookie')) { - do_check_true(times == 0 || times == 1); - response.setHeader('Set-Cookie', 'times=' + times++); - } else { - do_check_eq(times, 2); - do_check_eq(meta.getHeader('Cookie'), 'times=1'); - } - let full = ""; - let body = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; //60 - for (var i = 0; i < 1000; i++) { - full += body; - } - response.write(full); - }); - httpserv.start(4444); - - let state = 0; - - let listener = { - onDownloadStateChange: function(aState, aDownload) { - switch (aDownload.state) { - case downloadUtils.downloadManager.DOWNLOAD_DOWNLOADING: - // We only care about the private download - if (state != 1) - break; - - state++; - do_check_true(aDownload.resumable); - - downloadUtils.downloadManager.pauseDownload(aDownload.id); - do_check_eq(aDownload.state, downloadUtils.downloadManager.DOWNLOAD_PAUSED); - - do_execute_soon(function() { - downloadUtils.downloadManager.resumeDownload(aDownload.id); - }); - break; - - case downloadUtils.downloadManager.DOWNLOAD_FINISHED: - if (state == 0) { - do_execute_soon(function() { - // Perform an identical request but in private mode. - // It should receive a different cookie than the - // public request. - - state++; - - pb.privateBrowsingEnabled = true; - - addDownload({ - isPrivate: pb.privateBrowsingEnabled, - sourceURI: downloadCSource, - downloadName: downloadCName + "!!!", - runBeforeStart: function (aDownload) { - // Check that dl is retrievable - do_check_eq(downloadUtils.downloadManager.activeDownloadCount, 1); - } - }); - }); - } else if (state == 2) { - // We're done here. - do_execute_soon(function() { - pb.privateBrowsingEnabled = false; - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - httpserv.stop(do_test_finished); - }); - } - break; - - default: - break; - } - }, - onStateChange: function(a, b, c, d, e) { }, - onProgressChange: function(a, b, c, d, e, f, g) { }, - onSecurityChange: function(a, b, c, d) { } - }; - - downloadUtils.downloadManager.addListener(listener); - - const downloadCSource = "http://localhost:4444/head_download_manager.js"; - const downloadCName = "download-C"; - - // First a public download that completes without interruption. - let dl = addDownload({ - isPrivate: pb.privateBrowsingEnabled, - sourceURI: downloadCSource, - downloadName: downloadCName, - runBeforeStart: function (aDownload) { - // Check that dl is retrievable - do_check_eq(downloadUtils.downloadManager.activeDownloadCount, 1); - } - }); -} \ No newline at end of file diff --git a/toolkit/components/downloads/test/unit/test_privatebrowsing_cancel_global.js b/toolkit/components/downloads/test/unit/test_privatebrowsing_cancel_global.js deleted file mode 100644 index b6a3c49ee337..000000000000 --- a/toolkit/components/downloads/test/unit/test_privatebrowsing_cancel_global.js +++ /dev/null @@ -1,266 +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/. */ - -/** - Make sure that the download manager service is given a chance to cancel the - private browisng mode transition. -**/ - -const Cm = Components.manager; - -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); - -let fakePromptServiceFactory = { - createInstance: function(aOuter, aIid) { - if (aOuter != null) - throw Cr.NS_ERROR_NO_AGGREGATION; - return promptService.QueryInterface(aIid); - } -}; - -let promptService = { - _buttonChoice: 0, - _called: false, - wasCalled: function() { - let called = this._called; - this._called = false; - return called; - }, - sayCancel: function() { - this._buttonChoice = 1; - this._called = false; - }, - sayProceed: function() { - this._buttonChoice = 0; - this._called = false; - }, - QueryInterface: function(aIID) { - if (aIID.equals(Ci.nsIPromptService) || - aIID.equals(Ci.nsISupports)) { - return this; - } - throw Cr.NS_ERROR_NO_INTERFACE; - }, - confirmEx: function(parent, title, text, buttonFlags, - button0Title, button1Title, button2Title, - checkMsg, checkState) { - this._called = true; - return this._buttonChoice; - } -}; - -Cm.QueryInterface(Ci.nsIComponentRegistrar) - .registerFactory(Components.ID(kPromptServiceUUID), "Prompt Service", - kPromptServiceContractID, fakePromptServiceFactory); - -this.__defineGetter__("pb", function () { - delete this.pb; - try { - return this.pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - } catch (e) {} - return this.pb = null; -}); - -this.__defineGetter__("dm", function() { - delete this.dm; - return this.dm = Cc["@mozilla.org/download-manager;1"]. - getService(Ci.nsIDownloadManager); -}); - -function run_test() { - if (!pb) // Private Browsing might not be available - return; - - function finishTest() { - // Cancel Download-E - dm.cancelDownload(dlE.id); - dm.removeDownload(dlE.id); - dm.cleanUp(); - do_check_eq(dm.activeDownloadCount, 0); - - prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session"); - dm.removeListener(listener); - httpserv.stop(do_test_finished); - - // 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); - } - - let prefBranch = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); - prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - do_test_pending(); - let httpserv = new HttpServer(); - httpserv.registerDirectory("/file/", do_get_cwd()); - httpserv.registerPathHandler("/noresume", function (meta, response) { - response.setHeader("Content-Type", "text/html", false); - response.setHeader("Accept-Ranges", "none", false); - response.write("foo"); - }); - httpserv.start(4444); - - let tmpDir = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties). - get("TmpD", Ci.nsIFile); - - // make sure we're starting with an empty DB - do_check_eq(dm.activeDownloadCount, 0); - - let listener = { - onDownloadStateChange: function(aState, aDownload) - { - switch (aDownload.state) { - case dm.DOWNLOAD_QUEUED: - case dm.DOWNLOAD_DOWNLOADING: - if (aDownload.targetFile.equals(dlD.targetFile)) { - // Sanity check: Download-D must not be resumable - do_check_false(dlD.resumable); - - // Cancel the transition - promptService.sayCancel(); - - // Enter private browsing mode immediately - pb.privateBrowsingEnabled = true; - do_check_true(promptService.wasCalled()); - do_check_false(pb.privateBrowsingEnabled); // transition was canceled - - // Check that Download-D status has not changed - do_check_neq(dlD.state, dm.DOWNLOAD_PAUSED); - - // proceed with the transition - promptService.sayProceed(); - - // Try to enter the private browsing mode again - pb.privateBrowsingEnabled = true; - do_check_true(promptService.wasCalled()); - do_check_true(pb.privateBrowsingEnabled); - - // Check that Download-D is canceled and not accessible - do_check_eq(dlD.state, dm.DOWNLOAD_CANCELED); - - // Exit private browsing mode - pb.privateBrowsingEnabled = false; - do_check_false(pb.privateBrowsingEnabled); - - // Create Download-E - dlE = addDownload({ - isPrivate: pb.privateBrowsingEnabled, - targetFile: fileE, - sourceURI: downloadESource, - downloadName: downloadEName - }); - - // Wait for Download-E to start - } else if (aDownload.targetFile.equals(dlE.targetFile)) { - // Sanity check: Download-E must be resumable - do_check_true(dlE.resumable); - - // Enter the private browsing mode - pb.privateBrowsingEnabled = true; - do_check_false(promptService.wasCalled()); - do_check_true(pb.privateBrowsingEnabled); - - // Create Download-F - dlF = addDownload({ - isPrivate: pb.privateBrowsingEnabled, - targetFile: fileF, - sourceURI: downloadFSource, - downloadName: downloadFName - }); - - // Wait for Download-F to start - } else if (aDownload.targetFile.equals(dlF.targetFile)) { - // Sanity check: Download-F must be resumable - do_check_true(dlF.resumable); - - // Cancel the transition - promptService.sayCancel(); - - // Exit private browsing mode immediately - pb.privateBrowsingEnabled = false; - do_check_true(promptService.wasCalled()); - do_check_true(pb.privateBrowsingEnabled); // transition was canceled - - // Check that Download-F status has not changed - do_check_neq(dlF.state, dm.DOWNLOAD_PAUSED); - - // proceed with the transition - promptService.sayProceed(); - - // Try to exit the private browsing mode again - pb.privateBrowsingEnabled = false; - do_check_true(promptService.wasCalled()); - do_check_false(pb.privateBrowsingEnabled); - - // Simulate leaving PB mode - Services.obs.notifyObservers(null, "last-pb-context-exited", null); - - // Check that Download-F is canceled and not accessible - do_check_eq(dlF.state, dm.DOWNLOAD_PAUSED); - - finishTest(); - } - break; - } - }, - onStateChange: function(a, b, c, d, e) { }, - onProgressChange: function(a, b, c, d, e, f, g) { }, - onSecurityChange: function(a, b, c, d) { } - }; - - dm.addListener(listener); - - // properties of Download-D - const downloadDSource = "http://localhost:4444/noresume"; - const downloadDDest = "download-file-D"; - const downloadDName = "download-D"; - - // properties of Download-E - const downloadESource = "http://localhost:4444/file/head_download_manager.js"; - const downloadEDest = "download-file-E"; - const downloadEName = "download-E"; - - // properties of Download-F - const downloadFSource = "http://localhost:4444/file/test_privatebrowsing_cancel.js"; - const downloadFDest = "download-file-F"; - const downloadFName = "download-F"; - - // Create all target files - let fileD = tmpDir.clone(); - fileD.append(downloadDDest); - fileD.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); - let fileE = tmpDir.clone(); - fileE.append(downloadEDest); - fileE.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); - let fileF = tmpDir.clone(); - fileF.append(downloadFDest); - fileF.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); - - // Create Download-D - let dlD = addDownload({ - isPrivate: pb.privateBrowsingEnabled, - targetFile: fileD, - sourceURI: downloadDSource, - downloadName: downloadDName - }); - downloadD = dlD.id; - - let dlE, dlF; - - // wait for Download-D to start -} diff --git a/toolkit/components/downloads/test/unit/test_privatebrowsing_global.js b/toolkit/components/downloads/test/unit/test_privatebrowsing_global.js deleted file mode 100644 index f8de6ff51784..000000000000 --- a/toolkit/components/downloads/test/unit/test_privatebrowsing_global.js +++ /dev/null @@ -1,315 +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 download manager's interaction with the private browsing service. - - An overview of what this test does follows: - - * Create a download (Download-A) with specific details. - * Check that Download-A is retrievable. - * Enter private browsing mode. - * Check that Download-A is not accessible. - * Create another download (Download-B) with specific and different details. - * Check that Download-B is retrievable. - * Exit private browsing mode. - * Check that Download-A is retrievable. - * Check that Download-B is not accessible. - * Create a new download (Download-C) with specific details. - Start it and enter private browsing mode immediately after. - * Check that Download-C has been paused. - * Exit the private browsing mode. - * Verify that Download-C resumes and finishes correctly now. -**/ - -this.__defineGetter__("pb", function () { - delete this.pb; - try { - return this.pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - } catch (e) {} - return this.pb = null; -}); - -this.__defineGetter__("dm", function() { - delete this.dm; - return this.dm = Cc["@mozilla.org/download-manager;1"]. - getService(Ci.nsIDownloadManager); -}); - -/** - * Try to see if an active download is available using the |activeDownloads| - * property. - */ -function is_active_download_available(aID, aSrc, aDst, aName) { - let enumerator = dm.activeDownloads; - while (enumerator.hasMoreElements()) { - let download = enumerator.getNext(); - if (download.id == aID && - download.source.spec == aSrc && - download.targetFile.path == aDst.path && - download.displayName == aName && - download.isPrivate == pb.privateBrowsingEnabled) - return true; - } - return false; -} - -/** - * Try to see if a download is available using the |getDownload| method. The - * download can both be active or inactive. - */ -function is_download_available(aID, aSrc, aDst, aName) { - let download; - try { - download = dm.getDownload(aID); - } catch (ex) { - return false; - } - return (download.id == aID && - download.source.spec == aSrc && - download.targetFile.path == aDst.path && - download.displayName == aName); -} - -function run_test() { - if (!pb) // Private Browsing might not be available - return; - - let prefBranch = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); - prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - do_test_pending(); - let httpserv = new HttpServer(); - httpserv.registerDirectory("/", do_get_cwd()); - - let tmpDir = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties). - get("TmpD", Ci.nsIFile); - const nsIWBP = Ci.nsIWebBrowserPersist; - - // make sure we're starting with an empty DB - do_check_eq(dm.activeDownloadCount, 0); - - let listener = { - phase: 1, - handledC: false, - onDownloadStateChange: function(aState, aDownload) - { - switch (aDownload.state) { - case dm.DOWNLOAD_FAILED: - case dm.DOWNLOAD_CANCELED: - case dm.DOWNLOAD_DIRTY: - case dm.DOWNLOAD_BLOCKED_POLICY: - // Fail! - if (aDownload.targetFile.exists()) - aDownload.targetFile.remove(false); - dm.removeListener(this); - do_throw("Download failed (name: " + aDownload.displayName + ", state: " + aDownload.state + ")"); - do_test_finished(); - break; - - // We need to wait until Download-C has started, because otherwise it - // won't be resumable, so the private browsing mode won't correctly pause it. - case dm.DOWNLOAD_DOWNLOADING: - if (aDownload.id == downloadC && !this.handledC && this.phase == 2) { - // Sanity check: Download-C must be resumable - do_check_true(dlC.resumable); - - // Enter private browsing mode immediately - pb.privateBrowsingEnabled = true; - do_check_true(pb.privateBrowsingEnabled); - - // Check that Download-C is paused and not accessible - do_check_eq(dlC.state, dm.DOWNLOAD_PAUSED); - do_check_eq(dm.activeDownloadCount, 0); - do_check_false(is_download_available(downloadC, downloadCSource, - fileC, downloadCName)); - - // Exit private browsing mode - pb.privateBrowsingEnabled = false; - do_check_false(pb.privateBrowsingEnabled); - - // Check that Download-A is accessible - do_check_true(is_download_available(downloadA, downloadASource, - fileA, downloadAName)); - - // Check that Download-B is not accessible - do_check_false(is_download_available(downloadB, downloadBSource, - fileB, downloadBName)); - - // Check that Download-C is accessible - do_check_true(is_download_available(downloadC, downloadCSource, - fileC, downloadCName)); - - // only perform these checks the first time that Download-C is started - this.handledC = true; - } - break; - - case dm.DOWNLOAD_FINISHED: - do_check_true(aDownload.targetFile.exists()); - aDownload.targetFile.remove(false); - this.onDownloadFinished(); - break; - } - }, - onStateChange: function(a, b, c, d, e) { }, - onProgressChange: function(a, b, c, d, e, f, g) { }, - onSecurityChange: function(a, b, c, d) { }, - onDownloadFinished: function () { - switch (this.phase) { - case 1: { - do_check_eq(dm.activeDownloadCount, 0); - - // Enter private browsing mode - pb.privateBrowsingEnabled = true; - do_check_true(pb.privateBrowsingEnabled); - - // Check that Download-A is not accessible - do_check_false(is_download_available(downloadA, downloadASource, - fileA, downloadAName)); - - // Create Download-B - let dlB = addDownload({ - isPrivate: pb.privateBrowsingEnabled, - targetFile: fileB, - sourceURI: downloadBSource, - downloadName: downloadBName, - runBeforeStart: function (aDownload) { - // Check that Download-B is retrievable - do_check_eq(dm.activeDownloadCount, 1); - do_check_true(is_active_download_available(aDownload.id, - downloadBSource, fileB, downloadBName)); - do_check_true(is_download_available(aDownload.id, - downloadBSource, fileB, downloadBName)); - } - }); - downloadB = dlB.id; - - // wait for Download-B to finish - ++this.phase; - } - break; - - case 2: { - do_check_eq(dm.activeDownloadCount, 0); - - // Exit private browsing mode - pb.privateBrowsingEnabled = false; - do_check_false(pb.privateBrowsingEnabled); - - // Check that Download-A is accessible - do_check_true(is_download_available(downloadA, downloadASource, - fileA, downloadAName)); - - // Check that Download-B is not accessible - do_check_false(is_download_available(downloadB, downloadBSource, - fileB, downloadBName)); - - // Create Download-C - httpserv.start(4444); - dlC = addDownload({ - isPrivate: pb.privateBrowsingEnabled, - targetFile: fileC, - sourceURI: downloadCSource, - downloadName: downloadCName, - runBeforeStart: function (aDownload) { - // Check that Download-C is retrievable - do_check_eq(dm.activeDownloadCount, 1); - do_check_true(is_active_download_available(aDownload.id, - downloadCSource, fileC, downloadCName)); - do_check_true(is_download_available(aDownload.id, - downloadCSource, fileC, downloadCName)); - } - }); - downloadC = dlC.id; - - // wait for Download-C to finish - ++this.phase; - } - break; - - case 3: { - do_check_eq(dm.activeDownloadCount, 0); - - // Check that Download-A is accessible - do_check_true(is_download_available(downloadA, downloadASource, - fileA, downloadAName)); - - // Check that Download-B is not accessible - do_check_false(is_download_available(downloadB, downloadBSource, - fileB, downloadBName)); - - // Check that Download-C is accessible - do_check_true(is_download_available(downloadC, downloadCSource, - fileC, downloadCName)); - - // cleanup - prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session"); - dm.removeListener(this); - httpserv.stop(do_test_finished); - } - break; - - default: - do_throw("Unexpected phase: " + this.phase); - break; - } - } - }; - - dm.addListener(listener); - dm.addListener(getDownloadListener()); - - // properties of Download-A - let downloadA = -1; - const downloadASource = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9gKHhQaLFEVkXsAAAAIdEVYdENvbW1lbnQA9syWvwAABXZJREFUaN7VmnuIVUUcxz/3uma5ZJJmrZGVuZWupGSZsVNwTRYJYk8vRzd6o0kglgpm9q/ZEhlBUEssUpTtqMixl6LlURtDwyzCWmLxkZZL6qZRi/nc/tjf2Ybjufd6797HOrDM7NzfmfP9zfzm9zxwkbdEIRYxyhsCTAYmAWOBkcAwYBBwFugEDgN7gd3AdmCTtn5HWRkwynsamA7U5bnEBqBFW395SRkwylsIzAWqnOnvgTVAG3AIOA4cAwYAlwFDgZuAUcB4YApQIc+2A29p6zcWlQGjvEeBJUC1TO0BmoAPtfXbc1yrH/AwMB+YKNNtwGJt/VUFZ8Ao713gOfn3O2CBtv7mAt2hUcAi4BmZatLWn10QBozyRgArgFoRixe09d8vhkYxypsKfAwMBrYBDdr6B/JmwChvNLBWRCYA6rX1/y6mWjTKqwQ+BVIiUvXa+q3p6JNZdj4E3wJMKTZ4AG39TuA+oFnevVaw5MaAiE01sEJbf4a2/rlSGSdt/S5gJrAqxJATA3Jha4GdwFPlsLDChBZbUSuYst8BUZUr5cKOyVU9FuFODAZagWuAaVEVG3cCS6SfWW7wchLHgcci2OIZEAtbDWzR1l/dVxw2bf1N4X0QjD2tIkI7V/oF7qQyqa40a58Rd6EVWA+8Z3VwNI4wwxqIs/e7OHnNVgdbY2gWAQ8JxsbzTkAcsyog0NbfeYGbUwFcBdwLvAq0KpNK5bHJlcDNwBPAFmVS7yiTSkZOYQ+wGqgSrOeJ0HTpmzO9yeogEf6JozZOrCfisK1VJjUihzWSwNXiRhwTktnA8zGPNkewdjMg/nwdcBr45EK3zerglNXBj1YHDSKjAJdHRTDLGl1WB4etDpYDs5yfZsWQfwUcAeoEc88JTA4JemFtX3fG+cYH651xdcxlPgd84WIOGZgk/Te9UBa7nfF1ea7hXvR/09BsdzGHDIyV/ucya8ypzvjrNDS7XMyhGh0p/S+9ePlYZ3zwQh9SJpUAhgD3A8tk+i/g5TSP7HcxhwwMk/5ILxiY74w3ZgGdziYclQiv0epgXxqaDhG1YS4DlY5hIofd6w/cAiwUxwvgH+CNPDdhKHAnMAHYl8YqnzXKOxFirsj1DVksagcw3epgfzY7EFmzUkRwLjADWKVM6k2rg3lplhgQNWSd0g/KkZ8zAtoCrwCjrQ6+zHVTrA46rQ52iD35SKZfVCZVH+OdDgT6hZjDEzgs4G9Md3Tpdq8IbZnjfc6RqNBtwx3MPSewV/pRfcD5dFX5HTG/17iYkxEjNIG+1S6NmRvvYk5GrFtdHwBd44x/i/l9sos5ZGCT9DcY5Y0pMwOuPVkXucBXSqzegzkpurVDgmeAhlIjViY1UJnUXcqkWkSNIq710qgZEA20Icxsu3agRURojlHeEm39E0UE3JWF5FfgEauDQ87uJ5yIseW8gEZS3O2iTp8s8SGcpDujvU4CmRqrg2hU+IBY/XY3HZ+ICepfk8VGauuf7AuqyCivQtRrNfCSm4aPxp2Nko8cLoz0lTZPwLdFawhxeaHFYYbCKK+2D+z+bU4+aHHW1KJkvppEvNYY5VWVOSv3mSibprjCRyLDw1Z07i5gkrb+6RKDvwTYDNwNbNPWV3F0mbLTDXIfbges5O1LBf4K4FsB35bJNiUzpPMOAPWywETgJ6O860sA/lpxE8bxf4EjbZUm1xLTn8CD2vpbiwA8IdpmKdCfQpSYIi9wi3yfA89q6/9RIPC3Ah9IOAmFLPJFXuSWWbskenpbW39HnsZpGvC4k04pXpk1xmK7he6DdKckNwI/AAejJSkJBWvorn/dI35XaQvdMYxk+tTgEHBKsgeDRa6jrTyfGsQwUraPPS769h+G3Ox+KOb9iAAAAABJRU5ErkJggg=="; - const downloadADest = "download-file-A"; - const downloadAName = "download-A"; - - // properties of Download-B - let downloadB = -1; - const downloadBSource = "data:application/octet-stream;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9gKHhQaLFEVkXsAAAAIdEVYdENvbW1lbnQA9syWvwAABXZJREFUaN7VmnuIVUUcxz/3uma5ZJJmrZGVuZWupGSZsVNwTRYJYk8vRzd6o0kglgpm9q/ZEhlBUEssUpTtqMixl6LlURtDwyzCWmLxkZZL6qZRi/nc/tjf2Ybjufd6797HOrDM7NzfmfP9zfzm9zxwkbdEIRYxyhsCTAYmAWOBkcAwYBBwFugEDgN7gd3AdmCTtn5HWRkwynsamA7U5bnEBqBFW395SRkwylsIzAWqnOnvgTVAG3AIOA4cAwYAlwFDgZuAUcB4YApQIc+2A29p6zcWlQGjvEeBJUC1TO0BmoAPtfXbc1yrH/AwMB+YKNNtwGJt/VUFZ8Ao713gOfn3O2CBtv7mAt2hUcAi4BmZatLWn10QBozyRgArgFoRixe09d8vhkYxypsKfAwMBrYBDdr6B/JmwChvNLBWRCYA6rX1/y6mWjTKqwQ+BVIiUvXa+q3p6JNZdj4E3wJMKTZ4AG39TuA+oFnevVaw5MaAiE01sEJbf4a2/rlSGSdt/S5gJrAqxJATA3Jha4GdwFPlsLDChBZbUSuYst8BUZUr5cKOyVU9FuFODAZagWuAaVEVG3cCS6SfWW7wchLHgcci2OIZEAtbDWzR1l/dVxw2bf1N4X0QjD2tIkI7V/oF7qQyqa40a58Rd6EVWA+8Z3VwNI4wwxqIs/e7OHnNVgdbY2gWAQ8JxsbzTkAcsyog0NbfeYGbUwFcBdwLvAq0KpNK5bHJlcDNwBPAFmVS7yiTSkZOYQ+wGqgSrOeJ0HTpmzO9yeogEf6JozZOrCfisK1VJjUihzWSwNXiRhwTktnA8zGPNkewdjMg/nwdcBr45EK3zerglNXBj1YHDSKjAJdHRTDLGl1WB4etDpYDs5yfZsWQfwUcAeoEc88JTA4JemFtX3fG+cYH651xdcxlPgd84WIOGZgk/Te9UBa7nfF1ea7hXvR/09BsdzGHDIyV/ucya8ypzvjrNDS7XMyhGh0p/S+9ePlYZ3zwQh9SJpUAhgD3A8tk+i/g5TSP7HcxhwwMk/5ILxiY74w3ZgGdziYclQiv0epgXxqaDhG1YS4DlY5hIofd6w/cAiwUxwvgH+CNPDdhKHAnMAHYl8YqnzXKOxFirsj1DVksagcw3epgfzY7EFmzUkRwLjADWKVM6k2rg3lplhgQNWSd0g/KkZ8zAtoCrwCjrQ6+zHVTrA46rQ52iD35SKZfVCZVH+OdDgT6hZjDEzgs4G9Md3Tpdq8IbZnjfc6RqNBtwx3MPSewV/pRfcD5dFX5HTG/17iYkxEjNIG+1S6NmRvvYk5GrFtdHwBd44x/i/l9sos5ZGCT9DcY5Y0pMwOuPVkXucBXSqzegzkpurVDgmeAhlIjViY1UJnUXcqkWkSNIq710qgZEA20Icxsu3agRURojlHeEm39E0UE3JWF5FfgEauDQ87uJ5yIseW8gEZS3O2iTp8s8SGcpDujvU4CmRqrg2hU+IBY/XY3HZ+ICepfk8VGauuf7AuqyCivQtRrNfCSm4aPxp2Nko8cLoz0lTZPwLdFawhxeaHFYYbCKK+2D+z+bU4+aHHW1KJkvppEvNYY5VWVOSv3mSibprjCRyLDw1Z07i5gkrb+6RKDvwTYDNwNbNPWV3F0mbLTDXIfbges5O1LBf4K4FsB35bJNiUzpPMOAPWywETgJ6O860sA/lpxE8bxf4EjbZUm1xLTn8CD2vpbiwA8IdpmKdCfQpSYIi9wi3yfA89q6/9RIPC3Ah9IOAmFLPJFXuSWWbskenpbW39HnsZpGvC4k04pXpk1xmK7he6DdKckNwI/AAejJSkJBWvorn/dI35XaQvdMYxk+tTgEHBKsgeDRa6jrTyfGsQwUraPPS769h+G3Ox+KOb9iAAAAABJRU5ErkJggg=="; - const downloadBDest = "download-file-B"; - const downloadBName = "download-B"; - - // properties of Download-C - let downloadC = -1; - const downloadCSource = "http://localhost:4444/head_download_manager.js"; - const downloadCDest = "download-file-C"; - const downloadCName = "download-C"; - - // Create all target files - let fileA = tmpDir.clone(); - fileA.append(downloadADest); - fileA.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); - let fileB = tmpDir.clone(); - fileB.append(downloadBDest); - fileB.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); - let fileC = tmpDir.clone(); - fileC.append(downloadCDest); - fileC.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); - - // use js closures to access dlC - let dlC; - - // Create Download-A - let dlA = addDownload({ - isPrivate: pb.privateBrowsingEnabled, - targetFile: fileA, - sourceURI: downloadASource, - downloadName: downloadAName, - runBeforeStart: function (aDownload) { - // Check that Download-A is retrievable - do_check_eq(dm.activeDownloadCount, 1); - do_check_true(is_active_download_available(aDownload.id, downloadASource, fileA, downloadAName)); - do_check_true(is_download_available(aDownload.id, downloadASource, fileA, downloadAName)); - } - }); - downloadA = dlA.id; - - // wait for Download-A to finish -} diff --git a/toolkit/components/downloads/test/unit/xpcshell.ini b/toolkit/components/downloads/test/unit/xpcshell.ini index 7d78f9c43675..39272abd196c 100644 --- a/toolkit/components/downloads/test/unit/xpcshell.ini +++ b/toolkit/components/downloads/test/unit/xpcshell.ini @@ -22,17 +22,8 @@ skip-if = os == "android" [test_offline_support.js] [test_old_download_files_removed.js] [test_private_resume.js] -skip-if = !perwindowprivatebrowsing -[test_private_resume_global.js] -skip-if = perwindowprivatebrowsing [test_privatebrowsing.js] -skip-if = !perwindowprivatebrowsing -[test_privatebrowsing_global.js] -skip-if = perwindowprivatebrowsing [test_privatebrowsing_cancel.js] -skip-if = !perwindowprivatebrowsing -[test_privatebrowsing_cancel_global.js] -skip-if = perwindowprivatebrowsing [test_removeDownloadsByTimeframe.js] [test_resume.js] [test_sleep_wake.js] diff --git a/toolkit/components/passwordmgr/test/Makefile.in b/toolkit/components/passwordmgr/test/Makefile.in index 8d9398f395e1..ee4c9953323e 100644 --- a/toolkit/components/passwordmgr/test/Makefile.in +++ b/toolkit/components/passwordmgr/test/Makefile.in @@ -53,6 +53,9 @@ MOCHITEST_FILES = \ test_maxforms_3.html \ test_notifications.html \ test_notifications_popup.html \ + privbrowsing_perwindowpb_iframe.html \ + test_privbrowsing_perwindowpb.html \ + $(filter disabled-for-intermittent-failures--bug-835904, test_prompt.html) \ test_prompt_async.html \ test_xhr.html \ test_xml_load.html \ @@ -82,24 +85,6 @@ MOCHITEST_FILES = \ subtst_prompt_async.html \ $(NULL) -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_FILES += \ - test_privbrowsing.html \ - $(NULL) - -ifneq ($(OS_TARGET),Linux) -MOCHITEST_FILES += \ - test_prompt.html \ - $(NULL) -endif - -else -MOCHITEST_FILES += \ - privbrowsing_perwindowpb_iframe.html \ - test_privbrowsing_perwindowpb.html \ - $(NULL) -endif - # This test doesn't pass because we can't ensure a cross-platform # event that occurs between DOMContentLoaded and Pageload # test_bug_221634.html diff --git a/toolkit/components/passwordmgr/test/test_privbrowsing.html b/toolkit/components/passwordmgr/test/test_privbrowsing.html deleted file mode 100644 index ee07604c5883..000000000000 --- a/toolkit/components/passwordmgr/test/test_privbrowsing.html +++ /dev/null @@ -1,275 +0,0 @@ - - - - - Test for Bug 248970 - - - - - -Mozilla Bug 248970 -

- -
-
-
- - - diff --git a/toolkit/components/passwordmgr/test/test_prompt.html b/toolkit/components/passwordmgr/test/test_prompt.html index bbc1b7ba2f71..dc995421906f 100644 --- a/toolkit/components/passwordmgr/test/test_prompt.html +++ b/toolkit/components/passwordmgr/test/test_prompt.html @@ -620,11 +620,6 @@ var proxyAuthinfo = { var prefs = Cc["@mozilla.org/preferences-service;1"]. getService(Ci.nsIPrefBranch); -var pb; -try { - pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); -} catch (e) {} const Cc_promptFac= Cc["@mozilla.org/passwordmanager/authpromptfactory;1"]; ok(Cc_promptFac != null, "Access Cc[@mozilla.org/passwordmanager/authpromptfactory;1]"); @@ -1120,25 +1115,6 @@ proxyAuthinfo.password = ""; proxyAuthinfo.realm = "Proxy Realm"; proxyAuthinfo.flags = Ci.nsIAuthInformation.AUTH_PROXY; -if (pb) { - prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - pb.privateBrowsingEnabled = true; - - time1 = pwmgr.findLogins({}, mozproxy, null, "Proxy Realm")[0].QueryInterface(Ci.nsILoginMetaInfo).timeLastUsed; - startCallbackTimer(); - isOk = prompter2.promptAuth(proxyChannel, level, proxyAuthinfo); - time2 = pwmgr.findLogins({}, mozproxy, null, "Proxy Realm")[0].QueryInterface(Ci.nsILoginMetaInfo).timeLastUsed; - - ok(isOk, "Checking dialog return value (accept)"); - ok(didDialog, "handleDialog was invoked"); - is(time1, time2, "Checking that timeLastUsed was not updated"); - is(proxyAuthinfo.username, "proxuser", "Checking returned username"); - is(proxyAuthinfo.password, "proxpass", "Checking returned password"); - - pb.privateBrowsingEnabled = false; - prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); -} - prefs.clearUserPref("signon.autologin.proxy"); diff --git a/toolkit/components/places/AsyncFaviconHelpers.cpp b/toolkit/components/places/AsyncFaviconHelpers.cpp index 6cb7ee0d3846..22ba3ce7f127 100644 --- a/toolkit/components/places/AsyncFaviconHelpers.cpp +++ b/toolkit/components/places/AsyncFaviconHelpers.cpp @@ -19,9 +19,6 @@ #include "nsStreamUtils.h" #include "nsIPrivateBrowsingChannel.h" #include -#if !(defined(MOZ_PER_WINDOW_PRIVATE_BROWSING)) && defined(DEBUG) -#include "nsIPrivateBrowsingService.h" -#endif using namespace mozilla::places; using namespace mozilla::storage; @@ -455,30 +452,6 @@ AsyncFetchAndSetIconForPage::AsyncFetchAndSetIconForPage( , mPage(aPage) , mFaviconLoadPrivate(aFaviconLoadType == nsIFaviconService::FAVICON_LOAD_PRIVATE) { -#if !(defined(MOZ_PER_WINDOW_PRIVATE_BROWSING)) && defined(DEBUG) - // This code makes sure that in global private browsing mode, the flag - // passed to us matches the global PB mode. This can be removed when - // per-window private browsing has been turned on. - nsCOMPtr pbService = - do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID); - if (pbService) { - bool inPrivateBrowsing = false; - if (NS_SUCCEEDED(pbService->GetPrivateBrowsingEnabled(&inPrivateBrowsing))) { - // In one specific case that we know of, it is possible for these flags - // to not match (bug 801151). We mostly care about the cases where the - // global private browsing mode is on, but the favicon load is not marked - // as private, as those cases will cause privacy leaks. But because - // fixing bug 801151 properly is going to mean tons of really dirty and - // fragile work which might cause other types of problems, we fatally - // assert the condition which would be a privacy leak, and non-fatally - // assert the other side of the condition which would designate a bug, - // but not a privacy sensitive one. - MOZ_ASSERT_IF(inPrivateBrowsing && !mFaviconLoadPrivate, false); - NS_ASSERTION(inPrivateBrowsing == mFaviconLoadPrivate, - "The favicon load flag and the global PB flag do not match"); - } - } -#endif } AsyncFetchAndSetIconForPage::~AsyncFetchAndSetIconForPage() diff --git a/toolkit/components/places/Helpers.cpp b/toolkit/components/places/Helpers.cpp index dfdaf70f5922..4ebb661eb639 100644 --- a/toolkit/components/places/Helpers.cpp +++ b/toolkit/components/places/Helpers.cpp @@ -14,10 +14,6 @@ #include "nsIRandomGenerator.h" #endif -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -#include "nsIPrivateBrowsingService.h" -#endif - // The length of guids that are used by history and bookmarks. #define GUID_LENGTH 12 @@ -416,22 +412,5 @@ AsyncStatementTelemetryTimer::HandleCompletion(uint16_t aReason) return NS_OK; } -void -EnsureNotGlobalPrivateBrowsing() -{ -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - // This code makes sure that certain code is not invoked when global private - // browsing is enabled. - nsCOMPtr pbService = - do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID); - if (pbService) { - bool inPrivateBrowsing = false; - if (NS_SUCCEEDED(pbService->GetPrivateBrowsingEnabled(&inPrivateBrowsing))) { - MOZ_ASSERT(!inPrivateBrowsing); - } - } -#endif -} - } // namespace places } // namespace mozilla diff --git a/toolkit/components/places/Helpers.h b/toolkit/components/places/Helpers.h index 3840fb40dd67..618700141496 100644 --- a/toolkit/components/places/Helpers.h +++ b/toolkit/components/places/Helpers.h @@ -264,11 +264,6 @@ private: const TimeStamp mStart; }; -/** - * Used to abort if global private browsing is in use. - */ -void EnsureNotGlobalPrivateBrowsing(); - } // namespace places } // namespace mozilla diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index 9d8286528e49..2fe2a58c68c4 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -2457,8 +2457,6 @@ History::AddDownload(nsIURI* aSource, nsIURI* aReferrer, MOZ_ASSERT(NS_IsMainThread()); NS_ENSURE_ARG(aSource); - ENSURE_NOT_PRIVATE_BROWSING; - if (mShuttingDown) { return NS_OK; } diff --git a/toolkit/components/places/nsAnnotationService.cpp b/toolkit/components/places/nsAnnotationService.cpp index edd4cc229c3e..57005d84d3a6 100644 --- a/toolkit/components/places/nsAnnotationService.cpp +++ b/toolkit/components/places/nsAnnotationService.cpp @@ -344,8 +344,6 @@ nsAnnotationService::SetPageAnnotationString(nsIURI* aURI, { NS_ENSURE_ARG(aURI); - ENSURE_NOT_PRIVATE_BROWSING; - nsresult rv = SetAnnotationStringInternal(aURI, 0, aName, aValue, aFlags, aExpiration); NS_ENSURE_SUCCESS(rv, rv); @@ -418,8 +416,6 @@ nsAnnotationService::SetPageAnnotationInt32(nsIURI* aURI, { NS_ENSURE_ARG(aURI); - ENSURE_NOT_PRIVATE_BROWSING; - nsresult rv = SetAnnotationInt32Internal(aURI, 0, aName, aValue, aFlags, aExpiration); NS_ENSURE_SUCCESS(rv, rv); @@ -492,8 +488,6 @@ nsAnnotationService::SetPageAnnotationInt64(nsIURI* aURI, { NS_ENSURE_ARG(aURI); - ENSURE_NOT_PRIVATE_BROWSING; - nsresult rv = SetAnnotationInt64Internal(aURI, 0, aName, aValue, aFlags, aExpiration); NS_ENSURE_SUCCESS(rv, rv); @@ -566,8 +560,6 @@ nsAnnotationService::SetPageAnnotationDouble(nsIURI* aURI, { NS_ENSURE_ARG(aURI); - ENSURE_NOT_PRIVATE_BROWSING; - nsresult rv = SetAnnotationDoubleInternal(aURI, 0, aName, aValue, aFlags, aExpiration); NS_ENSURE_SUCCESS(rv, rv); @@ -647,8 +639,6 @@ nsAnnotationService::SetPageAnnotationBinary(nsIURI* aURI, { NS_ENSURE_ARG(aURI); - ENSURE_NOT_PRIVATE_BROWSING; - nsresult rv = SetAnnotationBinaryInternal(aURI, 0, aName, aData, aDataLen, aMimeType, aFlags, aExpiration); NS_ENSURE_SUCCESS(rv, rv); @@ -1658,8 +1648,6 @@ nsAnnotationService::CopyPageAnnotations(nsIURI* aSourceURI, NS_ENSURE_ARG(aSourceURI); NS_ENSURE_ARG(aDestURI); - ENSURE_NOT_PRIVATE_BROWSING; - mozStorageTransaction transaction(mDB->MainConn(), false); nsCOMPtr sourceStmt = mDB->GetStatement( diff --git a/toolkit/components/places/nsFaviconService.cpp b/toolkit/components/places/nsFaviconService.cpp index d396106cd62c..c2833d415b9a 100644 --- a/toolkit/components/places/nsFaviconService.cpp +++ b/toolkit/components/places/nsFaviconService.cpp @@ -191,8 +191,6 @@ nsFaviconService::SetFaviconUrlForPage(nsIURI* aPageURI, nsIURI* aFaviconURI) NS_ENSURE_ARG(aPageURI); NS_ENSURE_ARG(aFaviconURI); - ENSURE_NOT_PRIVATE_BROWSING; - // If we are about to expire all favicons, don't bother setting a new one. if (mFaviconsExpirationRunning) { return NS_OK; diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp index f8268328e217..751c9282e3c1 100644 --- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -3447,8 +3447,6 @@ nsNavHistory::SetPageTitle(nsIURI* aURI, NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread"); NS_ENSURE_ARG(aURI); - ENSURE_NOT_PRIVATE_BROWSING; - // if aTitle is empty we want to clear the previous title. // We don't want to set it to an empty string, but to a NULL value, // so we use SetIsVoid and SetPageTitleInternal will take care of that @@ -3677,8 +3675,6 @@ nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic, if (isPrivate) return NS_OK; - ENSURE_NOT_PRIVATE_BROWSING; - nsCOMPtr popup; input->GetPopup(getter_AddRefs(popup)); if (!popup) @@ -5090,8 +5086,6 @@ nsresult nsNavHistory::AutoCompleteFeedback(int32_t aIndex, nsIAutoCompleteController *aController) { - ENSURE_NOT_PRIVATE_BROWSING; - nsCOMPtr stmt = mDB->GetAsyncStatement( "INSERT OR REPLACE INTO moz_inputhistory " // use_count will asymptotically approach the max of 10. diff --git a/toolkit/components/places/nsPlacesMacros.h b/toolkit/components/places/nsPlacesMacros.h index 2daa02d27b07..80fb1580333c 100644 --- a/toolkit/components/places/nsPlacesMacros.h +++ b/toolkit/components/places/nsPlacesMacros.h @@ -37,9 +37,3 @@ } \ return _sInstance; \ } - -#if !defined(MOZ_PER_WINDOW_PRIVATE_BROWSING) || !defined(DEBUG) -# define ENSURE_NOT_PRIVATE_BROWSING /* nothing */ -#else -# define ENSURE_NOT_PRIVATE_BROWSING EnsureNotGlobalPrivateBrowsing() -#endif diff --git a/toolkit/components/places/tests/Makefile.in b/toolkit/components/places/tests/Makefile.in index 8fa0c1e53d82..b6926b1e1436 100644 --- a/toolkit/components/places/tests/Makefile.in +++ b/toolkit/components/places/tests/Makefile.in @@ -35,15 +35,9 @@ MOCHITEST_FILES = \ mochitest/test_bug_411966.html \ $(NULL) -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_FILES += \ - mochitest/test_bug_461710.html \ - $(NULL) -else MOCHITEST_CHROME_FILES = \ mochitest/test_bug_461710_perwindowpb.html \ $(NULL) -endif DIRS = \ chrome \ diff --git a/toolkit/components/places/tests/browser/Makefile.in b/toolkit/components/places/tests/browser/Makefile.in index e9e86384552b..e3b344b39707 100644 --- a/toolkit/components/places/tests/browser/Makefile.in +++ b/toolkit/components/places/tests/browser/Makefile.in @@ -13,14 +13,19 @@ include $(DEPTH)/config/autoconf.mk MOCHITEST_BROWSER_FILES = \ head.js \ + browser_bug248970.js \ browser_bug399606.js \ browser_bug646422.js \ browser_bug680727.js \ browser_colorAnalyzer.js \ + browser_favicon_privatebrowsing_perwindowpb.js \ + browser_favicon_setAndFetchFaviconForPage.js \ + browser_favicon_setAndFetchFaviconForPage_failures.js \ browser_notfound.js \ browser_redirect.js \ browser_visituri.js \ browser_visituri_nohistory.js \ + browser_visituri_privatebrowsing_perwindowpb.js \ browser_settitle.js \ colorAnalyzer/category-discover.png \ colorAnalyzer/dictionaryGeneric-16.png \ @@ -28,21 +33,6 @@ MOCHITEST_BROWSER_FILES = \ colorAnalyzer/localeGeneric.png \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ - browser_bug248970.js \ - browser_favicon_setAndFetchFaviconForPage.js \ - browser_favicon_setAndFetchFaviconForPage_failures.js \ - browser_visituri_privatebrowsing_perwindowpb.js \ - browser_favicon_privatebrowsing_perwindowpb.js \ - $(NULL) -else -MOCHITEST_BROWSER_FILES += \ - browser_favicon_privatebrowsing.js \ - browser_visituri_privatebrowsing.js \ - $(NULL) -endif - # These are files that need to be loaded via the HTTP proxy server # Access them through http://example.com/ MOCHITEST_FILES = \ diff --git a/toolkit/components/places/tests/browser/browser_favicon_privatebrowsing.js b/toolkit/components/places/tests/browser/browser_favicon_privatebrowsing.js deleted file mode 100644 index d4154b8c10a0..000000000000 --- a/toolkit/components/places/tests/browser/browser_favicon_privatebrowsing.js +++ /dev/null @@ -1,49 +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/. */ - -/** - * One-time DOMContentLoaded callback. - */ -function waitForLoad(callback) -{ - gTab.linkedBrowser.addEventListener("load", function() - { - gTab.linkedBrowser.removeEventListener("load", arguments.callee, true); - callback(); - }, true); -} - -let gTab; -function test() -{ - if (!("@mozilla.org/privatebrowsing;1" in Cc)) { - todo(false, "PB service is not available, bail out"); - return; - } - - gTab = gBrowser.selectedTab = gBrowser.addTab(); - - waitForExplicitFinish(); - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - pb.privateBrowsingEnabled = true; - - const pageURI ="http://example.org/tests/toolkit/components/places/tests/browser/favicon.html"; - content.location.href = pageURI; - waitForLoad(function() - { - PlacesUtils.favicons.getFaviconURLForPage( - NetUtil.newURI(pageURI), - function(uri, dataLen, data, mimeType) { - is(uri, null, "no result should be found"); - gBrowser.removeCurrentTab(); - pb.privateBrowsingEnabled = false; - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - }); - }); -} - diff --git a/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing.js b/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing.js deleted file mode 100644 index 40ef72d699b5..000000000000 --- a/toolkit/components/places/tests/browser/browser_visituri_privatebrowsing.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -const INITIAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/begin.html"; -const FINAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/final.html"; - -let gTab; - -/** - * One-time observer callback. - */ -function waitForObserve(name, callback) -{ - let observer = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), - observe: function(subject, topic, data) - { - Services.obs.removeObserver(observer, name); - callback(subject, topic, data); - } - }; - - Services.obs.addObserver(observer, name, false); -} - -/** - * One-time DOMContentLoaded callback. - */ -function waitForLoad(callback) -{ - gTab.linkedBrowser.addEventListener("load", function() - { - gTab.linkedBrowser.removeEventListener("load", arguments.callee, true); - callback(); - }, true); -} - -function test() -{ - if (!("@mozilla.org/privatebrowsing;1" in Cc)) { - todo(false, "PB service is not available, bail out"); - return; - } - - gTab = gBrowser.selectedTab = gBrowser.addTab(); - - waitForExplicitFinish(); - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - pb.privateBrowsingEnabled = true; - - waitForObserve("uri-visit-saved", function(subject, topic, data) - { - let uri = subject.QueryInterface(Ci.nsIURI); - is(uri.spec, FINAL_URL, "received expected visit"); - if (uri.spec != FINAL_URL) - return; - gBrowser.removeCurrentTab(); - promiseClearHistory().then(finish); - }); - - content.location.href = INITIAL_URL; - waitForLoad(function() - { - pb.privateBrowsingEnabled = false; - try { - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - } catch(ex) {} - executeSoon(function() - { - content.location.href = FINAL_URL; - }); - }); -} diff --git a/toolkit/components/places/tests/favicons/test_setAndFetchFaviconForPage.js b/toolkit/components/places/tests/favicons/test_setAndFetchFaviconForPage.js deleted file mode 100644 index 191d9b569189..000000000000 --- a/toolkit/components/places/tests/favicons/test_setAndFetchFaviconForPage.js +++ /dev/null @@ -1,112 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * This file tests the normal operation of setAndFetchFaviconForPage. - */ - -//////////////////////////////////////////////////////////////////////////////// -/// Globals - -const FAVICON_URI = NetUtil.newURI(do_get_file("favicon-normal32.png")); -const FAVICON_DATA = readFileData(do_get_file("favicon-normal32.png")); -const FAVICON_MIMETYPE = "image/png"; - -//////////////////////////////////////////////////////////////////////////////// -/// Tests - -function run_test() -{ - // Check that the favicon loaded correctly before starting the actual tests. - do_check_eq(FAVICON_DATA.length, 344); - run_next_test(); -} - -add_test(function test_normal() -{ - let pageURI = NetUtil.newURI("http://example.com/normal"); - waitForFaviconChanged(pageURI, FAVICON_URI, - function test_normal_callback() { - checkFaviconDataForPage(pageURI, FAVICON_MIMETYPE, FAVICON_DATA, - run_next_test); - }); - - addVisits({ uri: pageURI, transition: TRANSITION_TYPED}, function () { - PlacesUtils.favicons.setAndFetchFaviconForPage(pageURI, FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); - }); -}); - -add_test(function test_aboutURI_bookmarked() -{ - let pageURI = NetUtil.newURI("about:testAboutURI_bookmarked"); - waitForFaviconChanged(pageURI, FAVICON_URI, - function test_aboutURI_bookmarked_callback() { - checkFaviconDataForPage(pageURI, FAVICON_MIMETYPE, FAVICON_DATA, - run_next_test); - }); - - PlacesUtils.bookmarks.insertBookmark( - PlacesUtils.unfiledBookmarksFolderId, pageURI, - PlacesUtils.bookmarks.DEFAULT_INDEX, pageURI.spec); - PlacesUtils.favicons.setAndFetchFaviconForPage(pageURI, FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); -}); - -add_test(function test_privateBrowsing_bookmarked() -{ - if (!("@mozilla.org/privatebrowsing;1" in Cc)) { - do_log_info("Private Browsing service is not available, bail out."); - run_next_test(); - return; - } - - let pageURI = NetUtil.newURI("http://example.com/privateBrowsing_bookmarked"); - waitForFaviconChanged(pageURI, FAVICON_URI, - function test_privateBrowsing_bookmarked_callback() { - checkFaviconDataForPage(pageURI, FAVICON_MIMETYPE, FAVICON_DATA, - run_next_test); - }); - - // Enable private browsing while changing the favicon. - let pb = Cc["@mozilla.org/privatebrowsing;1"] - .getService(Ci.nsIPrivateBrowsingService); - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", - true); - pb.privateBrowsingEnabled = true; - - PlacesUtils.bookmarks.insertBookmark( - PlacesUtils.unfiledBookmarksFolderId, pageURI, - PlacesUtils.bookmarks.DEFAULT_INDEX, pageURI.spec); - PlacesUtils.favicons.setAndFetchFaviconForPage(pageURI, FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_PRIVATE); - - // The setAndFetchFaviconForPage function calls CanAddURI synchronously, - // thus we can exit Private Browsing Mode immediately. - pb.privateBrowsingEnabled = false; - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); -}); - -add_test(function test_disabledHistory_bookmarked() -{ - let pageURI = NetUtil.newURI("http://example.com/disabledHistory_bookmarked"); - waitForFaviconChanged(pageURI, FAVICON_URI, - function test_disabledHistory_bookmarked_callback() { - checkFaviconDataForPage(pageURI, FAVICON_MIMETYPE, FAVICON_DATA, - run_next_test); - }); - - // Disable history while changing the favicon. - Services.prefs.setBoolPref("places.history.enabled", false); - - PlacesUtils.bookmarks.insertBookmark( - PlacesUtils.unfiledBookmarksFolderId, pageURI, - PlacesUtils.bookmarks.DEFAULT_INDEX, pageURI.spec); - PlacesUtils.favicons.setAndFetchFaviconForPage(pageURI, FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); - - // The setAndFetchFaviconForPage function calls CanAddURI synchronously, thus - // we can set the preference back to true immediately. We don't clear the - // preference because not all products enable Places by default. - Services.prefs.setBoolPref("places.history.enabled", true); -}); diff --git a/toolkit/components/places/tests/favicons/test_setAndFetchFaviconForPage_failures.js b/toolkit/components/places/tests/favicons/test_setAndFetchFaviconForPage_failures.js deleted file mode 100644 index 254611170adf..000000000000 --- a/toolkit/components/places/tests/favicons/test_setAndFetchFaviconForPage_failures.js +++ /dev/null @@ -1,173 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * This file tests setAndFetchFaviconForPage when it is called with invalid - * arguments, and when no favicon is stored for the given arguments. - */ - -//////////////////////////////////////////////////////////////////////////////// -/// Globals - -const FAVICON_URI = NetUtil.newURI(do_get_file("favicon-normal16.png")); -const LAST_PAGE_URI = NetUtil.newURI("http://example.com/verification"); -const LAST_FAVICON_URI = NetUtil.newURI(do_get_file("favicon-normal32.png")); - -//////////////////////////////////////////////////////////////////////////////// -/// Tests - -function run_test() -{ - // We run all the tests that follow, but only the last one should raise the - // onPageChanged notification, executing the waitForFaviconChanged callback. - waitForFaviconChanged(LAST_PAGE_URI, LAST_FAVICON_URI, - function final_callback() { - // Check that only one record corresponding to the last favicon is present. - let resultCount = 0; - let stmt = DBConn().createAsyncStatement("SELECT url FROM moz_favicons"); - stmt.executeAsync({ - handleResult: function final_handleResult(aResultSet) { - for (let row; (row = aResultSet.getNextRow()); ) { - do_check_eq(LAST_FAVICON_URI.spec, row.getResultByIndex(0)); - resultCount++; - } - }, - handleError: function final_handleError(aError) { - do_throw("Unexpected error (" + aError.result + "): " + aError.message); - }, - handleCompletion: function final_handleCompletion(aReason) { - do_check_eq(Ci.mozIStorageStatementCallback.REASON_FINISHED, aReason); - do_check_eq(1, resultCount); - run_next_test(); - } - }); - stmt.finalize(); - }); - - run_next_test(); -} - -add_test(function test_null_pageURI() -{ - try { - PlacesUtils.favicons.setAndFetchFaviconForPage( - null, - FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); - do_throw("Exception expected because aPageURI is null."); - } catch (ex) { - // We expected an exception. - } - - run_next_test(); -}); - -add_test(function test_null_faviconURI() -{ - try { - PlacesUtils.favicons.setAndFetchFaviconForPage( - NetUtil.newURI("http://example.com/null_faviconURI"), - null, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); - do_throw("Exception expected because aFaviconURI is null."); - } catch (ex) { - // We expected an exception. - } - - run_next_test(); -}); - -add_test(function test_aboutURI() -{ - PlacesUtils.favicons.setAndFetchFaviconForPage( - NetUtil.newURI("about:testAboutURI"), - FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); - - run_next_test(); -}); - -add_test(function test_privateBrowsing_nonBookmarkedURI() -{ - if (!("@mozilla.org/privatebrowsing;1" in Cc)) { - do_log_info("Private Browsing service is not available, bail out."); - run_next_test(); - return; - } - - let pageURI = NetUtil.newURI("http://example.com/privateBrowsing"); - addVisits({ uri: pageURI, transitionType: TRANSITION_TYPED }, function () { - let pb = Cc["@mozilla.org/privatebrowsing;1"] - .getService(Ci.nsIPrivateBrowsingService); - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", - true); - pb.privateBrowsingEnabled = true; - - PlacesUtils.favicons.setAndFetchFaviconForPage( - pageURI, - FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_PRIVATE); - - // The setAndFetchFaviconForPage function calls CanAddURI synchronously, - // thus we can exit Private Browsing Mode immediately. - pb.privateBrowsingEnabled = false; - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - run_next_test(); - }); -}); - -add_test(function test_disabledHistory() -{ - let pageURI = NetUtil.newURI("http://example.com/disabledHistory"); - addVisits({ uri: pageURI, transition: TRANSITION_TYPED }, function () { - Services.prefs.setBoolPref("places.history.enabled", false); - - PlacesUtils.favicons.setAndFetchFaviconForPage( - pageURI, - FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); - - // The setAndFetchFaviconForPage function calls CanAddURI synchronously, thus - // we can set the preference back to true immediately . We don't clear the - // preference because not all products enable Places by default. - Services.prefs.setBoolPref("places.history.enabled", true); - run_next_test(); - }); -}); - -add_test(function test_errorIcon() -{ - let pageURI = NetUtil.newURI("http://example.com/errorIcon"); - let places = [{ uri: pageURI, transition: TRANSITION_TYPED }]; - addVisits({ uri: pageURI, transition: TRANSITION_TYPED }, function () { - PlacesUtils.favicons.setAndFetchFaviconForPage( - pageURI, - FAVICON_ERRORPAGE_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); - - run_next_test(); - }); -}); - -add_test(function test_nonexistingPage() -{ - PlacesUtils.favicons.setAndFetchFaviconForPage( - NetUtil.newURI("http://example.com/nonexistingPage"), - FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); - - run_next_test(); -}); - -add_test(function test_finalVerification() -{ - // This is the only test that should cause the waitForFaviconChanged callback - // we set up earlier to be invoked. In turn, the callback will invoke - // run_next_test() causing the tests to finish. - addVisits({ uri: LAST_PAGE_URI, transition: TRANSITION_TYPED }, function () { - PlacesUtils.favicons.setAndFetchFaviconForPage( - LAST_PAGE_URI, - LAST_FAVICON_URI, true, - PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); - }); -}); diff --git a/toolkit/components/places/tests/favicons/xpcshell.ini b/toolkit/components/places/tests/favicons/xpcshell.ini index d6b18f4f3758..975fcbc2d563 100644 --- a/toolkit/components/places/tests/favicons/xpcshell.ini +++ b/toolkit/components/places/tests/favicons/xpcshell.ini @@ -15,9 +15,3 @@ fail-if = os == "android" [test_query_result_favicon_changed_on_child.js] [test_replaceFaviconData.js] [test_replaceFaviconDataFromDataURL.js] -[test_setAndFetchFaviconForPage.js] -skip-if = perwindowprivatebrowsing -[test_setAndFetchFaviconForPage_failures.js] -# Bug 676989: test fails consistently on Android -fail-if = os == "android" -skip-if = perwindowprivatebrowsing diff --git a/toolkit/components/places/tests/mochitest/test_bug_461710.html b/toolkit/components/places/tests/mochitest/test_bug_461710.html deleted file mode 100644 index 80829e9c6f7d..000000000000 --- a/toolkit/components/places/tests/mochitest/test_bug_461710.html +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Test for Bug 461710 - - - - -Mozilla Bug 461710 -

- -
-
-
- - diff --git a/toolkit/components/places/tests/unit/test_248970.js b/toolkit/components/places/tests/unit/test_248970.js deleted file mode 100644 index 2d0adf571941..000000000000 --- a/toolkit/components/places/tests/unit/test_248970.js +++ /dev/null @@ -1,234 +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 unit test performs checks on the history testing area as outlined -// https://wiki.mozilla.org/Firefox3.1/PrivateBrowsing/TestPlan#History -// http://developer.mozilla.org/en/Using_the_Places_history_service - -/** - * Function prohibits an attempt to pop up a confirmation - * dialog box when entering Private Browsing mode. - * - * @return a reference to the Private Browsing service - */ -let _PBSvc = null; -function get_PBSvc() { - if (_PBSvc) - return _PBSvc; - - try { - _PBSvc = Components.classes["@mozilla.org/privatebrowsing;1"]. - getService(Components.interfaces.nsIPrivateBrowsingService); - return _PBSvc; - } catch (e) {} - return null; -} - -let visited_URIs = ["http://www.test-link.com/", - "http://www.test-typed.com/", - "http://www.test-bookmark.com/", - "http://www.test-redirect-permanent.com/", - "http://www.test-redirect-temporary.com/", - "http://www.test-embed.com/", - "http://www.test-framed.com/", - "http://www.test-download.com/"]; - -let nonvisited_URIs = ["http://www.google.ca/typed/", - "http://www.google.com/bookmark/", - "http://www.google.co.il/link/", - "http://www.google.fr/download/", - "http://www.google.es/embed/", - "http://www.google.it/framed-link/", - "http://www.google.com.tr/redirect-permanent/", - "http://www.google.de/redirect-temporary/"]; - -/** - * Function fills history, one for each transition type. - */ -function task_fill_history_visitedURI() { - yield promiseAddVisits([ - { uri: uri(visited_URIs[0]), transition: TRANSITION_LINK }, - { uri: uri(visited_URIs[1]), transition: TRANSITION_TYPED }, - { uri: uri(visited_URIs[2]), transition: TRANSITION_BOOKMARK }, - { uri: uri(visited_URIs[3]), transition: TRANSITION_REDIRECT_PERMANENT }, - { uri: uri(visited_URIs[4]), transition: TRANSITION_REDIRECT_TEMPORARY }, - { uri: uri(visited_URIs[5]), transition: TRANSITION_EMBED }, - { uri: uri(visited_URIs[6]), transition: TRANSITION_FRAMED_LINK }, - { uri: uri(visited_URIs[7]), transition: TRANSITION_DOWNLOAD }, - ]); -} - -// Initial batch of history items (7) + Bookmark_A (1) -// This number should not change after tests enter private browsing -// it will be set to 10 with the addition of Bookmark-B during private -// browsing mode. -let num_places_entries = 8; - -/** - * Function performs a really simple query on our places entries, - * and makes sure that the number of entries equal num_places_entries. - */ -function check_placesItem_Count(){ - // get bookmarks count - let options = PlacesUtils.history.getNewQueryOptions(); - options.includeHidden = true; - options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS; - let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(), - options).root; - root.containerOpen = true; - let cc = root.childCount; - root.containerOpen = false; - - // get history item count - options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY; - let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(), - options).root; - root.containerOpen = true; - cc += root.childCount; - root.containerOpen = false; - - // check the total count - do_check_eq(cc,num_places_entries); -} - -/** - * Function creates a bookmark - * @param aURI - * The URI for the bookmark - * @param aTitle - * The title for the bookmark - * @param aKeyword - * The keyword for the bookmark - * @returns the bookmark - */ - -let myBookmarks = new Array(2); // Bookmark-A and Bookmark-B - -function create_bookmark(aURI, aTitle, aKeyword) { - let bookmarkID = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarksMenuFolderId, - aURI, - PlacesUtils.bookmarks.DEFAULT_INDEX, - aTitle); - PlacesUtils.bookmarks.setKeywordForBookmark(bookmarkID, aKeyword); - return bookmarkID; -} - -/** - * Function attempts to check if Bookmark-A has been visited - * during private browsing mode, function should return false - * - * @returns false if the accessCount has not changed - * true if the accessCount has changed - */ -function is_bookmark_A_altered(){ - - let options = PlacesUtils.history.getNewQueryOptions(); - options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS; - options.maxResults = 1; // should only expect Bookmark-A - options.resultType = options.RESULT_TYPE_VISIT; - - let query = PlacesUtils.history.getNewQuery(); - query.setFolders([PlacesUtils.bookmarks.bookmarksMenuFolder],1); - - let root = PlacesUtils.history.executeQuery(query, options).root; - root.containerOpen = true; - do_check_eq(root.childCount,options.maxResults); - let node = root.getChild(0); - root.containerOpen = false; - - return (node.accessCount!=0); -} - -function run_test() -{ - run_next_test(); -} - -add_task(function test_execute() -{ - // Private Browsing might not be available. - let pb = get_PBSvc(); - if (!pb) { - return; - } - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - - let bookmark_A_URI = NetUtil.newURI("http://google.com/"); - let bookmark_B_URI = NetUtil.newURI("http://bugzilla.mozilla.org/"); - - // History database should be empty - do_check_false(PlacesUtils.history.hasHistoryEntries); - - // Create a handful of history items with various visit types - yield task_fill_history_visitedURI(); - - // History database should have entries - do_check_true(PlacesUtils.history.hasHistoryEntries); - - // Create Bookmark-A - myBookmarks[0] = create_bookmark(bookmark_A_URI,"title 1", "google"); - - // History items should be retrievable by query - visited_URIs.forEach(function (visited_uri) { - do_check_true(PlacesUtils.bhistory.isVisited(uri(visited_uri))); - if (/embed/.test(visited_uri)) { - do_check_false(!!page_in_database(visited_uri)); - } - else { - do_check_true(!!page_in_database(visited_uri)); - } - }); - - check_placesItem_Count(); - - // Bookmark-A should be bookmarked, data should be retrievable - do_check_true(PlacesUtils.bookmarks.isBookmarked(bookmark_A_URI)); - do_check_eq("google", PlacesUtils.bookmarks.getKeywordForURI(bookmark_A_URI)); - - // Enter Private Browsing Mode - pb.privateBrowsingEnabled = true; - - // Check if Bookmark-A has been visited, should be false - do_check_false(is_bookmark_A_altered()); - - // We still have 7 history entries and 1 history entry, Bookmark-A. - check_placesItem_Count(); - - // Check if Bookmark-A is still accessible - do_check_true(PlacesUtils.bookmarks.isBookmarked(bookmark_A_URI)); - do_check_eq("google",PlacesUtils.bookmarks.getKeywordForURI(bookmark_A_URI)); - - // Create Bookmark-B - myBookmarks[1] = create_bookmark(bookmark_B_URI,"title 2", "bugzilla"); - - // A check on the history count should be same as before, 7 history entries with - // now 2 bookmark items (A) and bookmark (B), so we increase num_places_entries. - num_places_entries++; // Bookmark-B successfully added but not the history entries. - check_placesItem_Count(); - - // Exit Private Browsing Mode - pb.privateBrowsingEnabled = false; - - // Check if Bookmark-B is still accessible - do_check_true(PlacesUtils.bookmarks.isBookmarked(bookmark_B_URI)); - do_check_eq("bugzilla",PlacesUtils.bookmarks.getKeywordForURI(bookmark_B_URI)); - - // Check if Bookmark-A is still accessible - do_check_true(PlacesUtils.bookmarks.isBookmarked(bookmark_A_URI)); - do_check_eq("google",PlacesUtils.bookmarks.getKeywordForURI(bookmark_A_URI)); - - // Check that the original set of history items are still accessible via isVisited - visited_URIs.forEach(function (visited_uri) { - do_check_true(PlacesUtils.bhistory.isVisited(uri(visited_uri))); - if (/embed/.test(visited_uri)) { - do_check_false(!!page_in_database(visited_uri)); - } - else { - do_check_true(!!page_in_database(visited_uri)); - } - }); - - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); -}); diff --git a/toolkit/components/places/tests/unit/xpcshell.ini b/toolkit/components/places/tests/unit/xpcshell.ini index 17d8120301c0..b647a17ed101 100644 --- a/toolkit/components/places/tests/unit/xpcshell.ini +++ b/toolkit/components/places/tests/unit/xpcshell.ini @@ -3,8 +3,6 @@ head = head_bookmarks.js tail = [test_000_frecency.js] -[test_248970.js] -skip-if = perwindowprivatebrowsing [test_317472.js] # Bug 676989: test hangs consistently on Android skip-if = os == "android" diff --git a/toolkit/components/satchel/test/Makefile.in b/toolkit/components/satchel/test/Makefile.in index a3f92fc48327..5d2c713907ba 100644 --- a/toolkit/components/satchel/test/Makefile.in +++ b/toolkit/components/satchel/test/Makefile.in @@ -33,11 +33,5 @@ MOCHITEST_FILES = \ subtst_privbrowsing.html \ $(NULL) -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_FILES += \ - test_privbrowsing.html \ - $(NULL) -endif - include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/satchel/test/browser/Makefile.in b/toolkit/components/satchel/test/browser/Makefile.in index 93b26d953b44..6c9329a44b77 100644 --- a/toolkit/components/satchel/test/browser/Makefile.in +++ b/toolkit/components/satchel/test/browser/Makefile.in @@ -13,13 +13,8 @@ include $(DEPTH)/config/autoconf.mk MOCHITEST_BROWSER_FILES = \ head.js \ ../subtst_privbrowsing.html \ - $(NULL) - -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_BROWSER_FILES += \ browser_privbrowsing_perwindowpb.js \ $(NULL) -endif include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/satchel/test/test_privbrowsing.html b/toolkit/components/satchel/test/test_privbrowsing.html deleted file mode 100644 index efae82e1637a..000000000000 --- a/toolkit/components/satchel/test/test_privbrowsing.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - Test for Bug 472396 - - - - - -Mozilla Bug 472396 -

- -
-
-
- - - diff --git a/toolkit/components/social/MozSocialAPI.jsm b/toolkit/components/social/MozSocialAPI.jsm index 7e192eff5fd4..a97fb26b0ecc 100644 --- a/toolkit/components/social/MozSocialAPI.jsm +++ b/toolkit/components/social/MozSocialAPI.jsm @@ -8,9 +8,6 @@ Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "SocialService", "resource://gre/modules/SocialService.jsm"); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); -#endif this.EXPORTED_SYMBOLS = ["MozSocialAPI", "openChatWindow"]; @@ -43,11 +40,7 @@ this.MozSocialAPI = { function injectController(doc, topic, data) { try { let window = doc.defaultView; - if (!window -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - || !PrivateBrowsingUtils.isWindowPrivate(window) -#endif - ) + if (!window) return; // Do not attempt to load the API into about: error pages @@ -236,11 +229,7 @@ function getChromeWindow(contentWin) { function isWindowGoodForChats(win) { return win.SocialChatBar - && win.SocialChatBar.isAvailable -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - && !PrivateBrowsingUtils.isWindowPrivate(win) -#endif - ; + && win.SocialChatBar.isAvailable; } function findChromeWindowForChats(preferredWindow) { diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp index 51febc7cb150..4656eaa9a8bc 100644 --- a/toolkit/components/startup/nsAppStartup.cpp +++ b/toolkit/components/startup/nsAppStartup.cpp @@ -337,7 +337,6 @@ nsAppStartup::Quit(uint32_t aMode) appShell->GetApplicationProvidedHiddenWindow(&usefulHiddenWindow); nsCOMPtr hiddenWindow; appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow)); -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // If the remaining windows are useful, we won't quit: nsCOMPtr hiddenPrivateWindow; if (hasHiddenPrivateWindow) { @@ -347,11 +346,6 @@ nsAppStartup::Quit(uint32_t aMode) } else if (!hiddenWindow || usefulHiddenWindow) { return NS_OK; } -#else - // If the one window is useful, we won't quit: - if (!hiddenWindow || usefulHiddenWindow) - return NS_OK; -#endif ferocity = eAttemptQuit; } diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 0067dbe46aee..5e817acb8bc2 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -2212,30 +2212,6 @@ "kind": "boolean", "description": "XMLHttpRequest response was of type multipart/x-mixed-replace." }, - "PRIVATE_BROWSING_TRANSITION_ENTER_PREPARATION_MS": { - "kind": "exponential", - "high": "3000", - "n_buckets": 10, - "description": "Time spent on private browsing enter transition, excluding session restore (ms)" - }, - "PRIVATE_BROWSING_TRANSITION_ENTER_TOTAL_MS": { - "kind": "exponential", - "high": "10000", - "n_buckets": 50, - "description": "Time spent on private browsing enter transition, including session restore (ms)" - }, - "PRIVATE_BROWSING_TRANSITION_EXIT_PREPARATION_MS": { - "kind": "exponential", - "high": "3000", - "n_buckets": 10, - "description": "Time spent on private browsing exit transition, excluding session restore (ms)" - }, - "PRIVATE_BROWSING_TRANSITION_EXIT_TOTAL_MS": { - "kind": "exponential", - "high": "10000", - "n_buckets": 50, - "description": "Time spent on private browsing exit transition, including session restore (ms)" - }, "DOM_TIMERS_FIRED_PER_NATIVE_TIMEOUT": { "kind": "exponential", "high": "3000", diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index 20f34ca76db4..a9ee915afc04 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -742,9 +742,6 @@ TelemetryPing.prototype = { Telemetry.canRecord = false; return; } -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.addObserver(this, "private-browsing", false); -#endif Services.obs.addObserver(this, "profile-before-change", false); Services.obs.addObserver(this, "sessionstore-windows-restored", false); Services.obs.addObserver(this, "quit-application-granted", false); @@ -969,9 +966,6 @@ TelemetryPing.prototype = { this._hasXulWindowVisibleObserver = false; } Services.obs.removeObserver(this, "profile-before-change"); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - Services.obs.removeObserver(this, "private-browsing"); -#endif Services.obs.removeObserver(this, "quit-application-granted"); }, @@ -1039,16 +1033,6 @@ TelemetryPing.prototype = { this.gatherMemory(); } break; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - case "private-browsing": - Telemetry.canRecord = aData == "exit"; - if (aData == "enter") { - this.detachObservers() - } else { - this.attachObservers() - } - break; -#endif case "xul-window-visible": Services.obs.removeObserver(this, "xul-window-visible"); this._hasXulWindowVisibleObserver = false; diff --git a/toolkit/content/PrivateBrowsingUtils.jsm b/toolkit/content/PrivateBrowsingUtils.jsm index edad45dc93f9..52528d6c98e1 100644 --- a/toolkit/content/PrivateBrowsingUtils.jsm +++ b/toolkit/content/PrivateBrowsingUtils.jsm @@ -27,18 +27,8 @@ this.PrivateBrowsingUtils = { }, get permanentPrivateBrowsing() { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING return gTemporaryAutoStartMode || Services.prefs.getBoolPref(kAutoStartPref, false); -#else - try { - return Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService). - autoStarted; - } catch (e) { - return false; // PB not supported - } -#endif }, // These should only be used from internal code diff --git a/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties b/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties index e6120a66889f..2bd5fc9efbe5 100644 --- a/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties +++ b/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties @@ -31,12 +31,7 @@ quitCancelDownloadsAlertMsgMacMultiple=If you quit now, %S downloads will be can offlineCancelDownloadsAlertTitle=Cancel All Downloads? offlineCancelDownloadsAlertMsg=If you go offline now, 1 download will be canceled. Are you sure you want to go offline? offlineCancelDownloadsAlertMsgMultiple=If you go offline now, %S downloads will be canceled. Are you sure you want to go offline? -enterPrivateBrowsingCancelDownloadsAlertTitle=Cancel All Downloads? -enterPrivateBrowsingCancelDownloadsAlertMsg=If you enter the Private Browsing mode now, 1 download will be canceled. Are you sure you want to enter the Private Browsing mode? -enterPrivateBrowsingCancelDownloadsAlertMsgMultiple=If you enter the Private Browsing mode now, %S downloads will be canceled. Are you sure you want to enter the Private Browsing mode? leavePrivateBrowsingCancelDownloadsAlertTitle=Cancel All Downloads? -leavePrivateBrowsingCancelDownloadsAlertMsg=If you leave the Private Browsing mode now, 1 download will be canceled. Are you sure you want to leave the Private Browsing mode? -leavePrivateBrowsingCancelDownloadsAlertMsgMultiple=If you leave the Private Browsing mode now, %S downloads will be canceled. Are you sure you want to leave the Private Browsing mode? leavePrivateBrowsingWindowsCancelDownloadsAlertMsg=If you close all Private Browsing windows now, 1 download will be canceled. Are you sure you want to leave the Private Browsing mode? leavePrivateBrowsingWindowsCancelDownloadsAlertMsgMultiple=If you close all Private Browsing windows now, %S downloads will be canceled. Are you sure you want to leave the Private Browsing mode? cancelDownloadsOKText=Cancel 1 Download diff --git a/toolkit/mozapps/downloads/content/downloads.js b/toolkit/mozapps/downloads/content/downloads.js index 2a3c46eaf298..24489072140f 100644 --- a/toolkit/mozapps/downloads/content/downloads.js +++ b/toolkit/mozapps/downloads/content/downloads.js @@ -436,10 +436,6 @@ function Startup() let obs = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); obs.addObserver(gDownloadObserver, "download-manager-remove-download", false); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - obs.addObserver(gDownloadObserver, "private-browsing", false); - obs.addObserver(gDownloadObserver, "private-browsing-change-granted", false); -#endif obs.addObserver(gDownloadObserver, "browser-lastwindow-close-granted", false); // Clear the search box and move focus to the list on escape from the box @@ -464,10 +460,6 @@ function Shutdown() let obs = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - obs.removeObserver(gDownloadObserver, "private-browsing"); - obs.removeObserver(gDownloadObserver, "private-browsing-change-granted"); -#endif obs.removeObserver(gDownloadObserver, "download-manager-remove-download"); obs.removeObserver(gDownloadObserver, "browser-lastwindow-close-granted"); @@ -492,35 +484,6 @@ let gDownloadObserver = { let dl = getDownload(id.data); removeFromView(dl); break; -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - case "private-browsing-change-granted": - // Finalize our statements cause the connection will be closed by the - // service during the private browsing transition. - gStmt.finalize(); - gStmt = null; - break; - case "private-browsing": - if (aData == "enter" || aData == "exit") { - // We need to reset the title here, because otherwise the title of - // the download manager would still reflect the progress of current - // active downloads, if any, after switching the private browsing - // mode, even though the downloads will no longer be accessible. - // If any download is auto-started after switching the private - // browsing mode, the title will be updated as needed by the progress - // listener. - document.title = document.documentElement.getAttribute("statictitle"); - - // We might get this notification before the download manager - // service, so the new database connection might not be ready - // yet. Defer this until all private-browsing notifications - // have been processed. - setTimeout(function() { - initStatement(); - buildDownloadList(true); - }, 0); - } - break; -#endif case "browser-lastwindow-close-granted": #ifndef XP_MACOSX if (gDownloadManager.activeDownloadCount == 0) { @@ -1354,12 +1317,6 @@ function getDownload(aID) /** * Initialize the statement which is used to retrieve the list of downloads. -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - * - * This function gets called both at startup, and when entering the private - * browsing mode (because the database connection is changed when entering - * the private browsing mode, and a new statement should be initialized. -#endif */ function initStatement() { diff --git a/toolkit/mozapps/downloads/content/downloads.xul b/toolkit/mozapps/downloads/content/downloads.xul index e4314a565f8b..c452a4300507 100644 --- a/toolkit/mozapps/downloads/content/downloads.xul +++ b/toolkit/mozapps/downloads/content/downloads.xul @@ -26,9 +26,6 @@ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="downloadManager" windowtype="Download:Manager" orient="vertical" title="&downloads.title;" -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - statictitle="&downloads.title;" -#endif width="&window.width2;" height="&window.height;" screenX="10" screenY="10" persist="width height screenX screenY sizemode" onload="Startup();" onunload="Shutdown();" diff --git a/toolkit/mozapps/downloads/tests/chrome/Makefile.in b/toolkit/mozapps/downloads/tests/chrome/Makefile.in index ebb232444a44..e0937e46dca4 100644 --- a/toolkit/mozapps/downloads/tests/chrome/Makefile.in +++ b/toolkit/mozapps/downloads/tests/chrome/Makefile.in @@ -55,10 +55,4 @@ MOCHITEST_CHROME_FILES += \ $(NULL) endif -ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_CHROME_FILES += \ - test_privatebrowsing_title.xul \ - $(NULL) -endif - include $(topsrcdir)/config/rules.mk diff --git a/toolkit/mozapps/downloads/tests/chrome/test_privatebrowsing_title.xul b/toolkit/mozapps/downloads/tests/chrome/test_privatebrowsing_title.xul deleted file mode 100644 index 89d29f77eb4a..000000000000 --- a/toolkit/mozapps/downloads/tests/chrome/test_privatebrowsing_title.xul +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - -

- -

-  
-
diff --git a/toolkit/mozapps/update/test/unit/test_bug497578.js b/toolkit/mozapps/update/test/unit/test_bug497578.js deleted file mode 100644 index 9758798e56c9..000000000000 --- a/toolkit/mozapps/update/test/unit/test_bug497578.js +++ /dev/null @@ -1,114 +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 497578 - begin download of a complete update after a failure applying a - * partial update. - */ - -const PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing;1"; - -function run_test() { - // Return early if Private Browsing is unavailable. - if (!(PRIVATEBROWSING_CONTRACT_ID in AUS_Cc)) - return; - - do_test_pending(); - do_register_cleanup(end_test); - - logTestInfo("testing Bug 497578 - begin download of a complete update " + - "after a failure to apply a partial update with " + - "browser.privatebrowsing.autostart set to true"); - - removeUpdateDirsAndFiles(); - - let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar); - registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), - "Fake Window Watcher", - "@mozilla.org/embedcomp/window-watcher;1", - WindowWatcherFactory); - - // Enable automatic app update so that after the failed partial is found the - // complete update will start to download automatically. - Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, true); - Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true); - - do_execute_soon(run_test_pt1); -} - -function end_test() { - let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar); - registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), - WindowWatcherFactory); - cleanUp(); -} - -function run_test_pt1() { - writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false); - let url = URL_HOST + URL_PATH + "/partial.mar"; - let patches = getLocalPatchString("partial", url, null, null, null, null, - STATE_FAILED) + - getLocalPatchString(null, null, null, null, null, null, - STATE_NONE); - let updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0", - null, null, null, null, url); - writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); - writeStatusFile(STATE_FAILED); - - standardInit(); - - logTestInfo("testing activeUpdate.state should equal STATE_DOWNLOADING " + - "prior to entering private browsing"); - do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING); - - let privBrowsing = AUS_Cc[PRIVATEBROWSING_CONTRACT_ID]. - getService(AUS_Ci.nsIPrivateBrowsingService). - QueryInterface(AUS_Ci.nsIObserver); - - privBrowsing.observe(null, "profile-after-change", ""); - logTestInfo("Testing: private mode should be entered automatically"); - do_check_true(privBrowsing.privateBrowsingEnabled); - - logTestInfo("Testing: private browsing is auto-started"); - Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); - do_check_true(PrivateBrowsingUtils.permanentPrivateBrowsing); - - // Give private browsing time to reset necko. - do_execute_soon(run_test_pt2); -} -function run_test_pt2() { - logTestInfo("Testing: update count should equal 1"); - do_check_eq(gUpdateManager.updateCount, 1); - logTestInfo("Testing: activeUpdate should not equal null"); - do_check_neq(gUpdateManager.activeUpdate, null); - logTestInfo("Testing: activeUpdate.state should not equal null"); - do_check_neq(gUpdateManager.activeUpdate.state, null); - logTestInfo("Testing: activeUpdate.state should equal STATE_DOWNLOADING"); - do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING); - - do_test_finished(); -} - -// Prevent the attempt to display the Update wizard for the failed update -var WindowWatcher = { - openWindow: function(parent, url, name, features, args) { - }, - - QueryInterface: function(iid) { - if (iid.equals(AUS_Ci.nsIWindowWatcher) || - iid.equals(AUS_Ci.nsISupports)) - return this; - - throw AUS_Cr.NS_ERROR_NO_INTERFACE; - } -} - -var WindowWatcherFactory = { - createInstance: function createInstance(outer, iid) { - if (outer != null) - throw AUS_Cr.NS_ERROR_NO_AGGREGATION; - return WindowWatcher.QueryInterface(iid); - } -}; diff --git a/toolkit/mozapps/update/test/unit/xpcshell.ini b/toolkit/mozapps/update/test/unit/xpcshell.ini index c4a9f2f83f5a..0591e2705572 100644 --- a/toolkit/mozapps/update/test/unit/xpcshell.ini +++ b/toolkit/mozapps/update/test/unit/xpcshell.ini @@ -28,8 +28,6 @@ skip-if = os == 'android' run-if = os == 'win' [include:xpcshell_updater_xp_unix.ini] run-if = os == 'linux' || os == 'mac' || os == 'sunos' -[test_bug497578.js] -skip-if = perwindowprivatebrowsing [test_bug595059.js] skip-if = toolkit == "gonk" reason = custom nsIUpdatePrompt diff --git a/widget/tests/Makefile.in b/widget/tests/Makefile.in index 672df9ae4732..85ab2dfe7bd3 100644 --- a/widget/tests/Makefile.in +++ b/widget/tests/Makefile.in @@ -36,6 +36,7 @@ MOCHITEST_CHROME_FILES = test_bug343416.xul \ window_bug429954.xul \ test_bug444800.xul \ $(filter disabled-for-intermittent-timeouts--bug-561929, test_bug478536.xul) \ + test_bug462106_perwindow.xul \ window_bug478536.xul \ test_bug517396.xul \ test_bug538242.xul \ @@ -58,12 +59,6 @@ MOCHITEST_CHROME_FILES = test_bug343416.xul \ test_bug760802.xul \ $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_CHROME_FILES += test_bug462106_perwindow.xul -else -MOCHITEST_CHROME_FILES += test_bug462106.xul -endif - # test_bug413277.html mac-only based on 604789, 605178 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) diff --git a/widget/tests/test_bug462106.xul b/widget/tests/test_bug462106.xul deleted file mode 100644 index 9b3f43af123a..000000000000 --- a/widget/tests/test_bug462106.xul +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 6946ffa4edce..4511534ee038 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -89,11 +89,9 @@ nsAppShellService::CreateHiddenWindow() void nsAppShellService::EnsurePrivateHiddenWindow() { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (!mHiddenPrivateWindow) { CreateHiddenWindowHelper(true); } -#endif } nsresult @@ -129,9 +127,7 @@ nsAppShellService::CreateHiddenWindowHelper(bool aIsPrivate) NS_ENSURE_SUCCESS(rv, rv); mHiddenWindow.swap(newWindow); - } -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - else { + } else { // Create the hidden private window chromeMask |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW; @@ -148,7 +144,6 @@ nsAppShellService::CreateHiddenWindowHelper(bool aIsPrivate) mHiddenPrivateWindow.swap(newWindow); } -#endif // RegisterTopLevelWindow(newWindow); -- Mac only @@ -164,13 +159,11 @@ nsAppShellService::DestroyHiddenWindow() mHiddenWindow = nullptr; } -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (mHiddenPrivateWindow) { mHiddenPrivateWindow->Destroy(); mHiddenPrivateWindow = nullptr; } -#endif return NS_OK; } @@ -406,12 +399,10 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent, // Enforce the Private Browsing autoStart pref first. bool isPrivateBrowsingWindow = Preferences::GetBool("browser.privatebrowsing.autostart"); -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (aChromeMask & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW) { // Caller requested a private window isPrivateBrowsingWindow = true; } -#endif if (!isPrivateBrowsingWindow) { // Ensure that we propagate any existing private browsing status // from the parent, even if it will not actually be used @@ -472,7 +463,6 @@ nsAppShellService::GetHiddenDOMWindow(nsIDOMWindow **aWindow) NS_IMETHODIMP nsAppShellService::GetHiddenPrivateWindow(nsIXULWindow **aWindow) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING NS_ENSURE_ARG_POINTER(aWindow); EnsurePrivateHiddenWindow(); @@ -480,15 +470,11 @@ nsAppShellService::GetHiddenPrivateWindow(nsIXULWindow **aWindow) *aWindow = mHiddenPrivateWindow; NS_IF_ADDREF(*aWindow); return *aWindow ? NS_OK : NS_ERROR_FAILURE; -#else - return NS_ERROR_NOT_IMPLEMENTED; -#endif } NS_IMETHODIMP nsAppShellService::GetHiddenPrivateDOMWindow(nsIDOMWindow **aWindow) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING EnsurePrivateHiddenWindow(); nsresult rv; @@ -504,22 +490,15 @@ nsAppShellService::GetHiddenPrivateDOMWindow(nsIDOMWindow **aWindow) *aWindow = hiddenPrivateDOMWindow; NS_IF_ADDREF(*aWindow); return NS_OK; -#else - return NS_ERROR_NOT_IMPLEMENTED; -#endif } NS_IMETHODIMP nsAppShellService::GetHasHiddenPrivateWindow(bool* aHasPrivateWindow) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING NS_ENSURE_ARG_POINTER(aHasPrivateWindow); *aHasPrivateWindow = !!mHiddenPrivateWindow; return NS_OK; -#else - return NS_ERROR_NOT_IMPLEMENTED; -#endif } NS_IMETHODIMP @@ -639,12 +618,10 @@ nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow) // CreateHiddenWindow() does not register the window, so we're done. return NS_OK; } -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (aWindow == mHiddenPrivateWindow) { // CreateHiddenWindow() does not register the window, so we're done. return NS_OK; } -#endif // tell the window mediator nsCOMPtr mediator @@ -682,11 +659,9 @@ nsAppShellService::Observe(nsISupports* aSubject, const char *aTopic, if (mHiddenWindow) { mHiddenWindow->Destroy(); } -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (mHiddenPrivateWindow) { mHiddenPrivateWindow->Destroy(); } -#endif } else { NS_ERROR("Unexpected observer topic!"); } diff --git a/xpfe/appshell/src/nsAppShellService.h b/xpfe/appshell/src/nsAppShellService.h index e040678948ad..6523ed9343c7 100644 --- a/xpfe/appshell/src/nsAppShellService.h +++ b/xpfe/appshell/src/nsAppShellService.h @@ -44,9 +44,7 @@ protected: uint32_t CalculateWindowZLevel(nsIXULWindow *aParent, uint32_t aChromeMask); nsRefPtr mHiddenWindow; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING nsRefPtr mHiddenPrivateWindow; -#endif bool mXPCOMWillShutDown; bool mXPCOMShuttingDown; uint16_t mModalWindowCount; diff --git a/xpfe/appshell/src/test/Makefile.in b/xpfe/appshell/src/test/Makefile.in index f2638be9ae35..d05d2d87a265 100644 --- a/xpfe/appshell/src/test/Makefile.in +++ b/xpfe/appshell/src/test/Makefile.in @@ -10,10 +10,8 @@ relativesrcdir := @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING MOCHITEST_CHROME_FILES := \ test_hiddenPrivateWindow.xul \ $(NULL) -endif include $(topsrcdir)/config/rules.mk