author | Ehsan Akhgari <ehsan@mozilla.com> |
Tue, 29 Jan 2013 13:13:58 -0500 | |
changeset 120251 | 3a8a7a8502be210bd3748421c540512c6cb72765 |
parent 120250 | 2a0424e177c19a871d287a50688ac71efcac8458 (current diff) |
parent 120196 | 6aaf13ffc716c2245aeac913a5f97bd317021074 (diff) |
child 120252 | b211a11259a7e4b622f57ca599a041cfed99149c |
push id | 24243 |
push user | ryanvm@gmail.com |
push date | Wed, 30 Jan 2013 00:49:21 +0000 |
treeherder | mozilla-central@5c248ef0fe62 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
milestone | 21.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
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 --- 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 @@ -167,20 +167,16 @@ let TestPilotSetup = { // Set up observation for task state changes var self = this; this._obs.add("testpilot:task:changed", this.onTaskStatusChanged, self); this._obs.add( "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 // any one window. logger.trace("Setting interval for showing reminders..."); this._shortTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); this._shortTimer.initWithCallback( @@ -240,44 +236,29 @@ let TestPilotSetup = { self.taskList[i].onExperimentShutdown(); } this.taskList = []; this._loader.unload(); this._obs.remove("testpilot:task:changed", this.onTaskStatusChanged, self); 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(); logger.trace("Done unregistering everything."); }, _getFrontBrowserWindow: function TPS__getFrontWindow() { let wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); // TODO Is "most recent" the same as "front"? 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++) { this.taskList[i].onWindowClosed(window); } }, onWindowLoad: function TPS_onWindowLoad(window) {
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 --- 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 @@ -157,24 +157,16 @@ var TestPilotTask = { onAppStartup: function TestPilotTask_onAppStartup() { // Called by extension core when Firefox startup is complete. }, onAppShutdown: function TestPilotTask_onAppShutdown() { // 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) { }, onWindowClosed: function TestPilotTask_onWindowClosed(window) { }, onUrlLoad: function TestPilotTask_onUrlLoad(url) { }, @@ -529,40 +521,16 @@ TestPilotExperiment.prototype = { try { this._handlers.doExperimentCleanup(); } catch(e) { this._dataStore.logException("doExperimentCleanup: " + e); } } }, -#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) { let metadata = this._handlers.getStudyMetadata(); if (metadata.length) { // getStudyMetadata must return an array, otherwise it is invalid. return metadata; }
--- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -873,21 +873,16 @@ pref("toolkit.crashreporter.infoURL", pref("app.support.baseURL", "http://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/"); // Name of alternate about: page for certificate errors (when undefined, defaults to about:neterror) 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"); // Whether to use a panel that looks like an OS X sheet for customization #ifdef XP_MACOSX pref("toolbar.customization.usesheet", true); #else
--- a/browser/base/content/browser-appmenu.inc +++ b/browser/base/content/browser-appmenu.inc @@ -29,31 +29,21 @@ key="key_newNavigator"/> <menuseparator/> <menuitem id="appmenu_openFile" label="&openFileCmd.label;" command="Browser:OpenFile" key="openFileKb"/> </menupopup> </splitmenu> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING <menuitem id="appmenu_newPrivateWindow" class="menuitem-iconic menuitem-iconic-tooltip" label="&newPrivateWindow.label;" command="Tools:PrivateBrowsing" key="key_privatebrowsing"/> -#else - <menuitem id="appmenu_privateBrowsing" - class="menuitem-iconic menuitem-iconic-tooltip" - label="&privateBrowsingCmd.start.label;" - startlabel="&privateBrowsingCmd.start.label;" - stoplabel="&privateBrowsingCmd.stop.label;" - command="Tools:PrivateBrowsing" - key="key_privatebrowsing"/> -#endif <menuitem label="&goOfflineCmd.label;" id="appmenu_offlineModeRecovery" type="checkbox" observes="workOfflineMenuitemState" oncommand="BrowserOffline.toggleOfflineStatus();"/> <menuseparator class="appmenu-menuseparator"/> <hbox> <menuitem id="appmenu-edit-label"
--- a/browser/base/content/browser-context.inc +++ b/browser/base/content/browser-context.inc @@ -23,22 +23,20 @@ <menuitem id="context-openlinkintab" label="&openLinkCmdInTab.label;" accesskey="&openLinkCmdInTab.accesskey;" oncommand="gContextMenu.openLinkInTab();"/> <menuitem id="context-openlink" label="&openLinkCmd.label;" accesskey="&openLinkCmd.accesskey;" oncommand="gContextMenu.openLink();"/> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING <menuitem id="context-openlinkprivate" label="&openLinkInPrivateWindowCmd.label;" accesskey="&openLinkInPrivateWindowCmd.accesskey;" oncommand="gContextMenu.openLinkInPrivateWindow();"/> -#endif <menuseparator id="context-sep-open"/> <menuitem id="context-bookmarklink" label="&bookmarkThisLinkCmd.label;" accesskey="&bookmarkThisLinkCmd.accesskey;" oncommand="gContextMenu.bookmarkLink();"/> <menuitem id="context-savelink" label="&saveLinkCmd.label;" accesskey="&saveLinkCmd.accesskey;"
--- a/browser/base/content/browser-menubar.inc +++ b/browser/base/content/browser-menubar.inc @@ -17,23 +17,21 @@ command="cmd_newNavigatorTab" key="key_newNavigatorTab" accesskey="&tabCmd.accesskey;"/> <menuitem id="menu_newNavigator" label="&newNavigatorCmd.label;" accesskey="&newNavigatorCmd.accesskey;" key="key_newNavigator" command="cmd_newNavigator"/> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING <menuitem id="menu_newPrivateWindow" label="&newPrivateWindow.label;" accesskey="&newPrivateWindow.accesskey;" command="Tools:PrivateBrowsing" key="key_privatebrowsing"/> -#endif <menuitem id="menu_openLocation" class="show-only-for-keyboard" label="&openLocationCmd.label;" command="Browser:OpenLocation" key="focusURLBar" accesskey="&openLocationCmd.accesskey;"/> <menuitem id="menu_openFile" label="&openFileCmd.label;" @@ -595,27 +593,16 @@ <menuitem id="menu_pageInfo" accesskey="&pageInfoCmd.accesskey;" label="&pageInfoCmd.label;" #ifndef XP_WIN key="key_viewInfo" #endif command="View:PageInfo"/> <menuseparator id="sanitizeSeparator"/> -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - <menuitem id="privateBrowsingItem" - label="&privateBrowsingCmd.start.label;" - accesskey="&privateBrowsingCmd.start.accesskey;" - startlabel="&privateBrowsingCmd.start.label;" - startaccesskey="&privateBrowsingCmd.start.accesskey;" - stoplabel="&privateBrowsingCmd.stop.label;" - stopaccesskey="&privateBrowsingCmd.stop.accesskey;" - key="key_privatebrowsing" - command="Tools:PrivateBrowsing"/> -#endif <menuitem id="sanitizeItem" accesskey="&clearRecentHistory.accesskey;" label="&clearRecentHistory.label;" key="key_sanitize" command="Tools:Sanitize"/> #ifndef XP_UNIX <menuseparator id="prefSep"/> <menuitem id="menu_preferences"
--- a/browser/base/content/browser-sets.inc +++ b/browser/base/content/browser-sets.inc @@ -96,21 +96,17 @@ <command id="Tools:Scratchpad" oncommand="Scratchpad.openScratchpad();" disabled="true" hidden="true"/> <command id="Tools:ResponsiveUI" oncommand="ResponsiveUI.toggle();" disabled="true" hidden="true"/> <command id="Tools:Addons" oncommand="BrowserOpenAddonsMgr();"/> <command id="Tools:ErrorConsole" oncommand="toJavaScriptConsole()" disabled="true" hidden="true"/> <command id="Tools:DevToolsConnect" oncommand="gDevToolsBrowser.openConnectScreen(gBrowser)" disabled="true" hidden="true"/> <command id="Tools:Sanitize" oncommand="Cc['@mozilla.org/browser/browserglue;1'].getService(Ci.nsIBrowserGlue).sanitize(window);"/> <command id="Tools:PrivateBrowsing" -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING oncommand="OpenBrowserWindow({private: true});"/> -#else - oncommand="gPrivateBrowsingUI.toggleMode();"/> -#endif <command id="History:UndoCloseTab" oncommand="undoCloseTab();"/> <command id="History:UndoCloseWindow" oncommand="undoCloseWindow();"/> <command id="Browser:ToggleAddonBar" oncommand="toggleAddonBar();"/> <command id="Social:SharePage" oncommand="SocialShareButton.sharePage();" disabled="true"/> <command id="Social:UnsharePage" oncommand="SocialShareButton.unsharePage();"/> <command id="Social:ToggleSidebar" oncommand="Social.toggleSidebar();"/> <command id="Social:ToggleNotifications" oncommand="Social.toggleNotifications();"/> <command id="Social:FocusChat" oncommand="SocialChatBar.focus();" hidden="true" disabled="true"/>
--- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -13,21 +13,16 @@ let SocialUI = { // Called on delayed startup to initialize the UI init: function SocialUI_init() { Services.obs.addObserver(this, "social:pref-changed", false); Services.obs.addObserver(this, "social:ambient-notification-changed", false); Services.obs.addObserver(this, "social:profile-changed", false); 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); gBrowser.addEventListener("ActivateSocialFeature", this._activationEventHandler, true, true); // Called when we enter DOM full-screen mode. window.addEventListener("mozfullscreenchange", function () { @@ -41,19 +36,16 @@ let SocialUI = { // Called on window unload uninit: function SocialUI_uninit() { Services.obs.removeObserver(this, "social:pref-changed"); Services.obs.removeObserver(this, "social:ambient-notification-changed"); Services.obs.removeObserver(this, "social:profile-changed"); 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); }, // Called once, after window load, once Social.jsm's provider has been set. _providerReady: function SocialUI_providerReady() { this._updateActiveUI(); @@ -135,24 +127,16 @@ let SocialUI = { case "nsPref:changed": if (data == "social.sidebar.open") { SocialSidebar.update(); } else if (data == "social.toast-notifications.enabled") { 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); throw e; } }, nonBrowserWindowInit: function SocialUI_nonBrowserInit() { @@ -168,21 +152,18 @@ let SocialUI = { // XXX Bug 789585 will implement an API for provider-specified login pages. openUILinkIn(Social.provider.origin, "tab"); } }, _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; if (!Social.provider) return; let toggleCommand = document.getElementById("Social:Toggle"); // We only need to update the command itself - all our menu items use it. @@ -323,21 +304,17 @@ let SocialUI = { // multiple times... delete this._chromeless; this._chromeless = chromeless; return chromeless; }, 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); }, } let SocialChatBar = { get chatbar() {
--- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1325,21 +1325,18 @@ var gBrowserInit = { NP.trackBrowserWindow(window); #endif // initialize the session-restore service (in case it's not already running) let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); 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(); ctrlTab.readPref(); gPrefService.addObserver(ctrlTab.prefName, ctrlTab, false); gPrefService.addObserver(allTabs.prefName, allTabs, false); @@ -1546,20 +1543,16 @@ var gBrowserInit = { try { gBrowser.removeProgressListener(window.XULBrowserWindow); gBrowser.removeTabsProgressListener(window.TabsProgressListener); } catch (ex) { } PlacesStarButton.uninit(); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - gPrivateBrowsingUI.uninit(); -#endif - TabsOnTop.uninit(); TabsInTitlebar.uninit(); var enumerator = Services.wm.getEnumerator(null); enumerator.getNext(); if (!enumerator.hasMoreElements()) { document.persist("sidebar-box", "sidebarcommand"); @@ -1695,20 +1688,16 @@ var gBrowserInit = { // If nonBrowserWindowDelayedStartup hasn't run yet, we have no work to do - // just cancel the pending timeout and return; if (this._delayedStartupTimeoutId) { clearTimeout(this._delayedStartupTimeoutId); return; } BrowserOffline.uninit(); - -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - gPrivateBrowsingUI.uninit(); -#endif }, #endif _initializeSanitizer: function() { const kDidSanitizeDomain = "privacy.sanitize.didShutdownSanitize"; if (gPrefService.prefHasUserValue(kDidSanitizeDomain)) { gPrefService.clearUserPref(kDidSanitizeDomain); // We need to persist this preference change, since we want to @@ -2505,21 +2494,18 @@ function BrowserOnAboutPageLoad(document if (document.documentURI.toLowerCase() == "about:home") { // XXX bug 738646 - when Marketplace is launched, remove this statement and // the hidden attribute set on the apps button in aboutHome.xhtml if (getBoolPref("browser.aboutHome.apps", false)) document.getElementById("apps").removeAttribute("hidden"); 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. let docElt = document.documentElement; docElt.setAttribute("snippetsURL", AboutHomeUtils.snippetsURL); docElt.setAttribute("searchEngineName", AboutHomeUtils.defaultSearchEngine.name); docElt.setAttribute("searchEngineURL", @@ -3530,21 +3516,17 @@ function OpenBrowserWindow(options) var charsetArg = new String(); var handler = Components.classes["@mozilla.org/browser/clh;1"] .getService(Components.interfaces.nsIBrowserHandler); var defaultArgs = handler.defaultArgs; 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"; } else { extraFeatures = ",non-private"; } // if and only if the current window is a browser window and it has a document with a character @@ -6915,25 +6897,16 @@ function getTabModalPromptBox(aWindow) { return gBrowser.getTabModalPromptBox(foundBrowser); return null; }; /* DEPRECATED */ 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 if (!PrivateBrowsingUtils.isWindowPrivate(window)) { return; } // Disable the Clear Recent History... menu item when in PB mode @@ -6960,277 +6933,38 @@ let gPrivateBrowsingUI = { if (gURLBar) { // Disable switch to tab autocompletion for private windows gURLBar.setAttribute("autocompletesearchparam", ""); } } }; -#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. * If a matching tab is in this window, it will be switched to. Otherwise, other * windows will be searched. * * @param aURI * URI to search for * @param aOpenNew * True to open a new tab and switch to it, if no existing tab is found. * If no suitable window is found, a new one will be opened. * @return True if an existing tab was found, false otherwise */ 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++) { let browser = browsers[i]; if (browser.currentURI.equals(aURI)) { // Focus the matching window & tab aWindow.focus(); aWindow.gBrowser.tabContainer.selectedIndex = i;
--- a/browser/base/content/macBrowserOverlay.xul +++ b/browser/base/content/macBrowserOverlay.xul @@ -51,15 +51,13 @@ #include browser-menubar.inc <!-- Dock menu --> <popupset> <menupopup id="menu_mac_dockmenu"> <!-- The command cannot be cmd_newNavigator because we need to activate the application. --> <menuitem label="&newNavigatorCmd.label;" oncommand="OpenBrowserWindowFromDockMenu();" /> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING <menuitem label="&newPrivateWindow.label;" oncommand="OpenBrowserWindowFromDockMenu({private: true});" /> -#endif </menupopup> </popupset> </overlay>
--- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -132,23 +132,19 @@ nsContextMenu.prototype = { if (uri && uri.host) { this.linkURI = uri; this.linkURL = this.linkURI.spec; this.onPlainTextLink = true; } } 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); }, initNavigationItems: function CM_initNavigationItems() { var shouldShow = !(this.isContentSelected || this.onLink || this.onImage || this.onCanvas || this.onVideo || this.onAudio ||
--- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -619,23 +619,20 @@ !(this.mBrowser.docShell.loadType & Ci.nsIDocShell.LOAD_CMD_PUSHSTATE)) this.mBrowser.mIconURL = null; let autocomplete = this.mTabBrowser._placesAutocomplete; if (this.mBrowser.registeredOpenURI) { 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; } } if (!this.mBlank) { this._callProgressListeners("onLocationChange", [aWebProgress, aRequest, aLocation, @@ -1900,23 +1897,21 @@ </body> </method> <method name="swapBrowsersAndCloseOther"> <parameter name="aOurTab"/> <parameter name="aOtherTab"/> <body> <![CDATA[ -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // Do not allow transfering a private tab to a non-private window // and vice versa. if (PrivateBrowsingUtils.isWindowPrivate(window) != PrivateBrowsingUtils.isWindowPrivate(aOtherTab.ownerDocument.defaultView)) return; -#endif // That's gBrowser for the other window, not the tab's browser! var remoteBrowser = aOtherTab.ownerDocument.defaultView.gBrowser; // First, start teardown of the other browser. Make sure to not // fire the beforeunload event in the process. Close the other // window if this was its last tab. if (!remoteBrowser._beginRemoveTab(aOtherTab, true, true)) @@ -3458,23 +3453,21 @@ // tabs are always added as the first type if (types[0] == TAB_DROP_TYPE) { var sourceNode = dt.mozGetDataAt(TAB_DROP_TYPE, 0); if (sourceNode instanceof XULElement && sourceNode.localName == "tab" && sourceNode.ownerDocument.defaultView instanceof ChromeWindow && sourceNode.ownerDocument.documentElement.getAttribute("windowtype") == "navigator:browser" && sourceNode.ownerDocument.defaultView.gBrowser.tabContainer == sourceNode.parentNode) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING // Do not allow transfering a private tab to a non-private window // and vice versa. if (PrivateBrowsingUtils.isWindowPrivate(window) != PrivateBrowsingUtils.isWindowPrivate(sourceNode.ownerDocument.defaultView)) return dt.effectAllowed = "none"; -#endif #ifdef XP_MACOSX return dt.effectAllowed = event.altKey ? "copy" : "move"; #else return dt.effectAllowed = event.ctrlKey ? "copy" : "move"; #endif } }
--- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -45,23 +45,19 @@ MOCHITEST_FILES = \ $(NULL) # test_contextmenu.html is disabled on Linux due to bug 513558 ifneq (gtk2,$(MOZ_WIDGET_TOOLKIT)) MOCHITEST_FILES += \ audio.ogg \ test_contextmenu.html \ subtst_contextmenu.html \ - $(NULL) -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -MOCHITEST_FILES += \ privateBrowsingMode.js \ $(NULL) endif -endif # The following tests are disabled because they are unreliable: # browser_bug423833.js is bug 428712 # browser_sanitize-download-history.js is bug 432425 # # browser_sanitizeDialog_treeView.js is disabled until the tree view is added # back to the clear recent history dialog (sanitize.xul), if it ever is (bug # 480169) @@ -158,18 +154,21 @@ endif browser_bug655584.js \ browser_bug664672.js \ browser_bug710878.js \ browser_bug719271.js \ browser_bug724239.js \ browser_bug735471.js \ browser_bug743421.js \ browser_bug749738.js \ + browser_bug763468_perwindowpb.js \ + browser_bug767836_perwindowpb.js \ browser_bug783614.js \ browser_bug797677.js \ + browser_bug816527.js \ browser_bug832435.js \ browser_canonizeURL.js \ browser_customize.js \ browser_findbarClose.js \ browser_homeDrop.js \ browser_keywordBookmarklets.js \ browser_contextSearchTabPosition.js \ browser_ctrlTab.js \ @@ -185,26 +184,31 @@ endif browser_locationBarExternalLoad.js \ browser_page_style_menu.js \ browser_pinnedTabs.js \ browser_plainTextLinks.js \ browser_pluginnotification.js \ browser_plugins_added_dynamically.js \ browser_CTPScriptPlugin.js \ browser_pluginplaypreview.js \ + browser_private_browsing_window.js \ browser_relatedTabs.js \ browser_sanitize-passwordDisabledHosts.js \ browser_sanitize-sitepermissions.js \ browser_sanitize-timespans.js \ browser_clearplugindata.js \ browser_clearplugindata.html \ browser_clearplugindata_noage.html \ browser_popupUI.js \ browser_sanitizeDialog.js \ + browser_save_link-perwindowpb.js \ + browser_save_private_link_perwindowpb.js \ browser_save_video.js \ + browser_tabMatchesInAwesomebar_perwindowpb.js \ + browser_tab_drag_drop_perwindow.js \ bug564387.html \ bug564387_video1.ogv \ bug564387_video1.ogv^headers^ \ bug792517.html \ bug792517-2.html \ bug792517.sjs \ browser_scope.js \ browser_selectTabAtIndex.js \ @@ -313,33 +317,12 @@ endif # bug 766546, disable browser_bug561636.js on Windows ifneq ($(OS_ARCH),WINNT) _BROWSER_FILES += \ browser_bug561636.js \ $(NULL) endif -ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING -_BROWSER_FILES += \ - browser_bug763468_perwindowpb.js \ - browser_bug767836_perwindowpb.js \ - browser_bug816527.js \ - browser_private_browsing_window.js \ - browser_save_link-perwindowpb.js \ - browser_save_private_link_perwindowpb.js \ - browser_tabMatchesInAwesomebar_perwindowpb.js \ - browser_tab_drag_drop_perwindow.js \ - $(NULL) -else -_BROWSER_FILES += \ - browser_bug763468.js \ - browser_bug767836.js \ - browser_save_link.js \ - browser_save_private_link.js \ - browser_tabMatchesInAwesomebar.js \ - $(NULL) -endif - include $(topsrcdir)/config/rules.mk libs:: $(_BROWSER_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
deleted file mode 100644 --- a/browser/base/content/test/browser_bug763468.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 opening a new tab in private browsing mode opens about:privatebrowsing - -// initialization -const pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - -const PREF = "browser.newtab.url"; - -function test() { - let newTabUrl = Services.prefs.getCharPref(PREF) || "about:blank"; - - waitForExplicitFinish(); - // check whether the mode that we start off with is normal or not - ok(!pb.privateBrowsingEnabled, "private browsing is disabled"); - - // Open a new tab page in normal mode - openNewTab(function () { - // Check the new tab opened while in normal mode - is(gBrowser.selectedBrowser.currentURI.spec, newTabUrl, - "URL of NewTab should be browser.newtab.url in Normal mode"); - - // enter private browsing mode - togglePrivateBrowsing(function () { - ok(pb.privateBrowsingEnabled, "private browsing is enabled"); - - // Open a new tab page in private browsing mode - openNewTab(function () { - // Check the new tab opened while in private browsing mode - is(gBrowser.selectedBrowser.currentURI.spec, "about:privatebrowsing", - "URL of NewTab should be about:privatebrowsing in PB mode"); - - // exit private browsing mode - togglePrivateBrowsing(function () { - ok(!pb.privateBrowsingEnabled, "private browsing is disabled"); - - // Open a new tab page in normal mode to check if - // returning from pb mode restores everything as it should - openNewTab(function () { - // Check the new tab opened while in normal mode - is(gBrowser.selectedBrowser.currentURI.spec, newTabUrl, - "URL of NewTab should be browser.newtab.url in Normal mode"); - gBrowser.removeTab(gBrowser.selectedTab); - gBrowser.removeTab(gBrowser.selectedTab); - finish(); - }); - }); - }); - }); - }); -} - -function togglePrivateBrowsing(aCallback) { - let topic = "private-browsing-transition-complete"; - - Services.obs.addObserver(function observe() { - Services.obs.removeObserver(observe, topic); - executeSoon(aCallback); - }, topic, false); - - pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled; -} - -function openNewTab(aCallback) { - // Open a new tab - BrowserOpenTab(); - - let browser = gBrowser.selectedBrowser; - if (browser.contentDocument.readyState == "complete") { - executeSoon(aCallback); - return; - } - - browser.addEventListener("load", function onLoad() { - browser.removeEventListener("load", onLoad, true); - executeSoon(aCallback); - }, true); -}
deleted file mode 100644 --- a/browser/base/content/test/browser_bug767836.js +++ /dev/null @@ -1,98 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// initialization -const pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); -const PREF = "browser.newtab.url"; -const NEWTABURL = Services.prefs.getCharPref(PREF) || "about:blank"; -const TESTURL = "http://example.com/"; - -function test() { - - waitForExplicitFinish(); - // check whether the mode that we start off with is normal or not - ok(!pb.privateBrowsingEnabled, "private browsing is disabled"); - // check whether any custom new tab url has been configured - ok(!Services.prefs.prefHasUserValue(PREF), "No custom newtab url is set"); - - openNewTab(function () { - // Check the new tab opened while in normal mode - is(gBrowser.selectedBrowser.currentURI.spec, NEWTABURL, - "URL of NewTab should be browser.newtab.url in Normal mode"); - // Set the custom newtab url - Services.prefs.setCharPref(PREF, TESTURL); - ok(Services.prefs.prefHasUserValue(PREF), "Custom newtab url is set"); - - // Open a newtab after setting the custom newtab url - openNewTab(function () { - is(gBrowser.selectedBrowser.currentURI.spec, TESTURL, - "URL of NewTab should be the custom url"); - - // clear the custom url preference - Services.prefs.clearUserPref(PREF); - ok(!Services.prefs.prefHasUserValue(PREF), "No custom newtab url is set"); - - // enter private browsing mode - togglePrivateBrowsing(function () { - ok(pb.privateBrowsingEnabled, "private browsing is enabled"); - - // Open a new tab page in private browsing mode - openNewTab(function () { - // Check the new tab opened while in private browsing mode - is(gBrowser.selectedBrowser.currentURI.spec, "about:privatebrowsing", - "URL of NewTab should be about:privatebrowsing in PB mode"); - - Services.prefs.setCharPref(PREF, TESTURL); - ok(Services.prefs.prefHasUserValue(PREF), "Custom newtab url is set"); - - // Open a newtab after setting the custom newtab url - openNewTab(function () { - is(gBrowser.selectedBrowser.currentURI.spec, TESTURL, - "URL of NewTab should be the custom url"); - - Services.prefs.clearUserPref(PREF); - ok(!Services.prefs.prefHasUserValue(PREF), "No custom newtab url is set"); - - // exit private browsing mode - togglePrivateBrowsing(function () { - ok(!pb.privateBrowsingEnabled, "private browsing is disabled"); - - gBrowser.removeTab(gBrowser.selectedTab); - gBrowser.removeTab(gBrowser.selectedTab); - finish(); - }); - }); - }); - }); - }); - }); -} - -function togglePrivateBrowsing(aCallback) { - let topic = "private-browsing-transition-complete"; - - Services.obs.addObserver(function observe() { - Services.obs.removeObserver(observe, topic); - executeSoon(aCallback); - }, topic, false); - - pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled; -} - -function openNewTab(aCallback) { - // Open a new tab - BrowserOpenTab(); - - let browser = gBrowser.selectedBrowser; - if (browser.contentDocument.readyState == "complete") { - executeSoon(aCallback); - return; - } - - browser.addEventListener("load", function onLoad() { - browser.removeEventListener("load", onLoad, true); - executeSoon(aCallback); - }, true); -}
deleted file mode 100644 --- a/browser/base/content/test/browser_save_link.js +++ /dev/null @@ -1,128 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -var MockFilePicker = SpecialPowers.MockFilePicker; -MockFilePicker.init(window); - -let tempScope = {}; -Cu.import("resource://gre/modules/NetUtil.jsm", tempScope); -let NetUtil = tempScope.NetUtil; - -// Trigger a save of a link in public mode, then trigger an identical save -// in private mode and ensure that the second request is differentiated from -// the first by checking the cookies that are sent. - -function triggerSave(aCallback) { - var fileName; - gBrowser.selectedTab = gBrowser.addTab(); - let testBrowser = gBrowser.selectedBrowser; - testBrowser.loadURI("http://mochi.test:8888/browser/browser/base/content/test/bug792517-2.html"); - testBrowser.addEventListener("pageshow", function pageShown(event) { - if (event.target.location == "about:blank") - return; - testBrowser.removeEventListener("pageshow", pageShown, false); - - executeSoon(function () { - document.addEventListener("popupshown", contextMenuOpened, false); - - var link = testBrowser.contentDocument.getElementById("fff"); - EventUtils.synthesizeMouseAtCenter(link, - { type: "contextmenu", button: 2 }, - testBrowser.contentWindow); - }); - }, false); - - function contextMenuOpened(event) { - event.currentTarget.removeEventListener("popupshown", contextMenuOpened, false); - - // Create the folder the link will be saved into. - var destDir = createTemporarySaveDirectory(); - var destFile = destDir.clone(); - - MockFilePicker.displayDirectory = destDir; - MockFilePicker.showCallback = function(fp) { - fileName = fp.defaultString; - destFile.append (fileName); - MockFilePicker.returnFiles = [destFile]; - MockFilePicker.filterIndex = 1; // kSaveAsType_URL - }; - - mockTransferCallback = function(a) onTransferComplete(a, destFile, destDir); - - // Select "Save Link As" option from context menu - var saveLinkCommand = document.getElementById("context-savelink"); - saveLinkCommand.doCommand(); - - event.target.hidePopup(); - } - - function onTransferComplete(downloadSuccess, destFile, destDir) { - ok(downloadSuccess, "Link should have been downloaded successfully"); - gBrowser.removeCurrentTab(); - - // Give the request a chance to finish - executeSoon(function() aCallback(destFile, destDir)); - } -} - -function readFile(file, callback) { - let channel = NetUtil.newChannel(file); - channel.contentType = "application/javascript"; - - NetUtil.asyncFetch(channel, function(inputStream, status) { - ok(Components.isSuccessCode(status), - "file was read successfully"); - - let content = NetUtil.readInputStreamToString(inputStream, - inputStream.available()); - executeSoon(function() callback(content)); - }); -} - -function test() { - waitForExplicitFinish(); - - let pb = Cc["@mozilla.org/privatebrowsing;1"] - .getService(Ci.nsIPrivateBrowsingService); - - mockTransferRegisterer.register(); - - registerCleanupFunction(function () { - mockTransferRegisterer.unregister(); - MockFilePicker.cleanup(); - pb.privateBrowsingEnabled = false; - Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session"); - }); - - triggerSave(function(destFile, destDir) { - readFile(destFile, function(content) { - is(content, "cookie-not-present", "no cookie should be sent"); - destDir.remove(true); - - Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true); - pb.privateBrowsingEnabled = true; - triggerSave(function(destFile, destDir) { - readFile(destFile, function(content) { - is(content, "cookie-not-present", "no cookie should be sent"); - destDir.remove(true); - finish(); - }); - }); - }); - }); -} - -Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js", - this); - -function createTemporarySaveDirectory() { - var saveDir = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties) - .get("TmpD", Ci.nsIFile); - saveDir.append("testsavedir"); - if (!saveDir.exists()) - saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755); - return saveDir; -}
deleted file mode 100644 --- a/browser/base/content/test/browser_save_private_link.js +++ /dev/null @@ -1,116 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -var MockFilePicker = SpecialPowers.MockFilePicker; -MockFilePicker.init(window); - -function checkDiskCacheFor(filename) { - let visitor = { - visitDevice: function(deviceID, deviceInfo) { - if (deviceID == "disk") - info(deviceID + " device contains " + deviceInfo.entryCount + " entries"); - return deviceID == "disk"; - }, - - visitEntry: function(deviceID, entryInfo) { - info(entryInfo.key); - is(entryInfo.key.contains(filename), false, "web content present in disk cache"); - } - }; - cache.visitEntries(visitor); -} - -var cache = Cc["@mozilla.org/network/cache-service;1"] - .getService(Ci.nsICacheService); - -function test() { - waitForExplicitFinish(); - var fileName; - - gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true); - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - pb.privateBrowsingEnabled = true; - - gBrowser.loadURI("http://mochi.test:8888/browser/browser/base/content/test/bug792517.html"); - - registerCleanupFunction(function () { - pb.privateBrowsingEnabled = false; - gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session"); - gBrowser.addTab(); - gBrowser.removeCurrentTab(); - }); - - gBrowser.addEventListener("pageshow", function pageShown(event) { - if (event.target.location == "about:blank") - return; - gBrowser.removeEventListener("pageshow", pageShown); - - executeSoon(function () { - document.addEventListener("popupshown", contextMenuOpened); - - var img = gBrowser.contentDocument.getElementById("img"); - EventUtils.synthesizeMouseAtCenter(img, - { type: "contextmenu", button: 2 }, - gBrowser.contentWindow); - }); - }); - - function contextMenuOpened(event) { - cache.evictEntries(Ci.nsICache.STORE_ANYWHERE); - - event.currentTarget.removeEventListener("popupshown", contextMenuOpened); - - // Create the folder the image will be saved into. - var destDir = createTemporarySaveDirectory(); - var destFile = destDir.clone(); - - MockFilePicker.displayDirectory = destDir; - MockFilePicker.showCallback = function(fp) { - fileName = fp.defaultString; - destFile.append (fileName); - MockFilePicker.returnFiles = [destFile]; - MockFilePicker.filterIndex = 1; // kSaveAsType_URL - }; - - mockTransferCallback = onTransferComplete; - mockTransferRegisterer.register(); - - registerCleanupFunction(function () { - mockTransferRegisterer.unregister(); - MockFilePicker.cleanup(); - destDir.remove(true); - }); - - // Select "Save Image As" option from context menu - var saveVideoCommand = document.getElementById("context-saveimage"); - saveVideoCommand.doCommand(); - - event.target.hidePopup(); - } - - function onTransferComplete(downloadSuccess) { - ok(downloadSuccess, "Image file should have been downloaded successfully"); - - // Give the request a chance to finish and create a cache entry - executeSoon(function() { - checkDiskCacheFor(fileName); - finish(); - }); - } -} - -Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js", - this); - -function createTemporarySaveDirectory() { - var saveDir = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties) - .get("TmpD", Ci.nsIFile); - saveDir.append("testsavedir"); - if (!saveDir.exists()) - saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755); - return saveDir; -}
deleted file mode 100644 --- a/browser/base/content/test/browser_tabMatchesInAwesomebar.js +++ /dev/null @@ -1,323 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim:set ts=2 sw=2 sts=2 et: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const TEST_URL_BASES = [ - "http://example.org/browser/browser/base/content/test/dummy_page.html#tabmatch", - "http://example.org/browser/browser/base/content/test/moz.png#tabmatch" -]; - -var gPrivateBrowsing = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); -var gController = Cc["@mozilla.org/autocomplete/controller;1"]. - getService(Ci.nsIAutoCompleteController); - -var gTabWaitCount = 0; -var gTabCounter = 0; - -var gTestSteps = [ - function() { - info("Running step 1"); - for (let i = 0; i < 10; i++) { - let tab = gBrowser.addTab(); - loadTab(tab, TEST_URL_BASES[0] + (++gTabCounter)); - } - }, - function() { - info("Running step 2"); - gBrowser.selectTabAtIndex(1); - gBrowser.removeCurrentTab(); - gBrowser.selectTabAtIndex(1); - gBrowser.removeCurrentTab(); - for (let i = 1; i < gBrowser.tabs.length; i++) - loadTab(gBrowser.tabs[i], TEST_URL_BASES[1] + (++gTabCounter)); - }, - function() { - info("Running step 3"); - for (let i = 1; i < gBrowser.tabs.length; i++) - loadTab(gBrowser.tabs[i], TEST_URL_BASES[0] + gTabCounter); - }, - function() { - info("Running step 4"); - let ps = Services.prefs; - ps.setBoolPref("browser.privatebrowsing.keep_current_session", true); - ps.setBoolPref("browser.tabs.warnOnClose", false); - - // Make sure that all restored tabs are loaded without waiting for the user - // to bring them to the foreground. We ensure this by resetting the - // related preference (see the "firefox.js" defaults file for details). - ps.setBoolPref("browser.sessionstore.restore_on_demand", false); - - gPrivateBrowsing.privateBrowsingEnabled = true; - - executeSoon(function() { - ensure_opentabs_match_db(nextStep); - }); - }, - function() { - info("Running step 5"); - gPrivateBrowsing.privateBrowsingEnabled = false; - - executeSoon(function() { - let ps = Services.prefs; - ps.clearUserPref("browser.privatebrowsing.keep_current_session"); - ps.clearUserPref("browser.tabs.warnOnClose"); - - ensure_opentabs_match_db(nextStep); - }); - }, - function() { - info("Running step 6 - ensure we don't register subframes as open pages"); - let tab = gBrowser.addTab(); - tab.linkedBrowser.addEventListener("load", function () { - tab.linkedBrowser.removeEventListener("load", arguments.callee, true); - // Start the sub-document load. - executeSoon(function () { - tab.linkedBrowser.addEventListener("load", function (e) { - tab.linkedBrowser.removeEventListener("load", arguments.callee, true); - ensure_opentabs_match_db(nextStep); - }, true); - tab.linkedBrowser.contentDocument.querySelector("iframe").src = "http://test2.example.org/"; - }); - }, true); - tab.linkedBrowser.loadURI('data:text/html,<body><iframe src=""></iframe></body>'); - }, - 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")); -}
--- a/browser/base/content/test/newtab/Makefile.in +++ b/browser/base/content/test/newtab/Makefile.in @@ -25,23 +25,14 @@ include $(topsrcdir)/config/rules.mk browser_newtab_bug722273.js \ browser_newtab_bug723102.js \ browser_newtab_bug723121.js \ browser_newtab_bug725996.js \ browser_newtab_bug734043.js \ 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)
deleted file mode 100644 --- 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; -}
--- a/browser/base/content/test/social/Makefile.in +++ b/browser/base/content/test/social/Makefile.in @@ -7,16 +7,17 @@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ 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 \ browser_social_flyout.js \ browser_social_mozSocial_API.js \ browser_social_isVisible.js \ browser_social_chatwindow.js \ browser_social_multiprovider.js \ @@ -25,22 +26,12 @@ include $(DEPTH)/config/autoconf.mk social_share_image.png \ social_sidebar.html \ social_chat.html \ social_flyout.html \ social_window.html \ 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) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
deleted file mode 100644 --- 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; -}
--- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -5,44 +5,35 @@ // Services = object with smart getters for common XPCOM services Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); 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)) { if (PrivateBrowsingUtils.isWindowPrivate(window) && !PrivateBrowsingUtils.permanentPrivateBrowsing) return "about:privatebrowsing"; } return Services.prefs.getCharPref(PREF) || "about:blank"; } function update() { BROWSER_NEW_TAB_URL = getNewTabPageURL(); } 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(); }); var TAB_DROP_TYPE = "application/x-moz-tabbrowser-tab"; var gBidiUI = false; @@ -270,21 +261,19 @@ function openLinkIn(url, where, params) sa.AppendElement(wuri); sa.AppendElement(charset); sa.AppendElement(aReferrerURI); sa.AppendElement(aPostData); 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; } let loadInBackground = where == "current" ? false : aInBackground; if (loadInBackground == null) { loadInBackground = aFromChrome ?
--- a/browser/components/build/Makefile.in +++ b/browser/components/build/Makefile.in @@ -39,21 +39,16 @@ OS_LIBS += $(call EXPAND_LIBNAME,version endif SHARED_LIBRARY_LIBS = \ ../feeds/src/$(LIB_PREFIX)browser_feeds_s.$(LIB_SUFFIX) \ ../about/$(LIB_PREFIX)browserabout_s.$(LIB_SUFFIX) \ ../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 EXTRA_DSO_LDOPTS += \ $(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \ $(XPCOM_STATICRUNTIME_GLUE_LDOPTS) \ $(MOZ_COMPONENT_LIBS) \
--- a/browser/components/build/nsModule.cpp +++ b/browser/components/build/nsModule.cpp @@ -20,19 +20,16 @@ #include "nsIEHistoryEnumerator.h" #endif #include "rdf.h" #include "nsFeedSniffer.h" #include "AboutRedirector.h" #include "nsIAboutModule.h" -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING -#include "nsPrivateBrowsingServiceWrapper.h" -#endif #include "nsNetCID.h" using namespace mozilla::browser; ///////////////////////////////////////////////////////////////////////////// NS_GENERIC_FACTORY_CONSTRUCTOR(DirectoryProvider) #if defined(XP_WIN) @@ -44,54 +41,44 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGN #endif #if defined(XP_WIN) NS_GENERIC_FACTORY_CONSTRUCTOR(nsIEHistoryEnumerator) #endif 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); #elif defined(MOZ_WIDGET_GTK2) NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID); #endif NS_DEFINE_NAMED_CID(NS_FEEDSNIFFER_CID); NS_DEFINE_NAMED_CID(NS_BROWSER_ABOUT_REDIRECTOR_CID); #if defined(XP_WIN) 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 }, #if defined(XP_WIN) { &kNS_SHELLSERVICE_CID, false, NULL, nsWindowsShellServiceConstructor }, #elif defined(MOZ_WIDGET_GTK2) { &kNS_SHELLSERVICE_CID, false, NULL, nsGNOMEShellServiceConstructor }, #endif { &kNS_FEEDSNIFFER_CID, false, NULL, nsFeedSnifferConstructor }, { &kNS_BROWSER_ABOUT_REDIRECTOR_CID, false, NULL, AboutRedirector::Create }, #if defined(XP_WIN) { &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 } }; static const mozilla::Module::ContractIDEntry kBrowserContracts[] = { { NS_BROWSERDIRECTORYPROVIDER_CONTRACTID, &kNS_BROWSERDIRECTORYPROVIDER_CID }, #if defined(XP_WIN) { NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID }, #elif defined(MOZ_WIDGET_GTK2) @@ -120,19 +107,16 @@ static const mozilla::Module::ContractID #ifdef MOZ_SERVICES_HEALTHREPORT { NS_ABOUT_MODULE_CONTRACTID_PREFIX "healthreport", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, #endif #if defined(XP_WIN) { 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 } }; static const mozilla::Module::CategoryEntry kBrowserCategories[] = { { XPCOM_DIRECTORY_PROVIDER_CATEGORY, "browser-directory-provider", NS_BROWSERDIRECTORYPROVIDER_CONTRACTID }, { NS_CONTENT_SNIFFER_CATEGORY, "Feed Sniffer", NS_FEEDSNIFFER_CONTRACTID }, { NULL } };
--- a/browser/components/downloads/src/DownloadsCommon.jsm +++ b/browser/components/downloads/src/DownloadsCommon.jsm @@ -181,25 +181,21 @@ this.DownloadsCommon = { /** * Get access to one of the DownloadsData or PrivateDownloadsData objects, * depending on the privacy status of the window in question. * * @param aWindow * 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 }, /** * Initializes the data link for both the private and non-private downloads * data objects. * * @param aDownloadManagerService * Reference to the service implementing nsIDownloadManager. We need @@ -234,57 +230,46 @@ this.DownloadsCommon = { }, /** * Get access to one of the DownloadsIndicatorData or * PrivateDownloadsIndicatorData objects, depending on the privacy status of * 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 }, /** * Returns a reference to the DownloadsSummaryData singleton - creating one * in the process if one hasn't been instantiated yet. * * @param aWindow * The browser window which owns the download button. * @param aNumToExclude * The number of items on the top of the downloads list to exclude * from the summary. */ getSummary: function DC_getSummary(aWindow, aNumToExclude) { -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) { if (this._privateSummary) { return this._privateSummary; } return this._privateSummary = new DownloadsSummaryData(true, aNumToExclude); } else { if (this._summary) { return this._summary; } 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, /** * Given an iterable collection of DownloadDataItems, generates and returns * statistics about that collection. * @@ -554,22 +539,16 @@ function DownloadsDataCtor(aPrivate) { // This Object contains all the available DownloadsDataItem objects, indexed by // their globally unique identifier. The identifiers of downloads that have // been removed from the Download Manager data are still present, however the // associated objects are replaced with the value "null". This is required to // 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 = []; } DownloadsDataCtor.prototype = { /** * Starts receiving events for current downloads. @@ -580,33 +559,26 @@ DownloadsDataCtor.prototype = { * called, and we must ensure to register our listeners before the * getService call for the Download Manager returns. */ initializeDataLink: function DD_initializeDataLink(aDownloadManagerService) { // 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 }, /** * Stops receiving events for current downloads and cancels any pending read. */ terminateDataLink: function DD_terminateDataLink() { 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); }, ////////////////////////////////////////////////////////////////////////////// //// Registration of views /** @@ -912,51 +884,29 @@ DownloadsDataCtor.prototype = { function(aStatus, aResult) { if (aStatus == Components.results.NS_ERROR_NOT_AVAILABLE) { this._removeDataItem(dataItemBinding.downloadGuid); } }.bind(this)); } } 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 } }, ////////////////////////////////////////////////////////////////////////////// //// nsIDownloadProgressListener 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 // want to provide a visible indication that the download started. let isNew = aOldState == nsIDM.DOWNLOAD_NOTSTARTED || aOldState == nsIDM.DOWNLOAD_QUEUED; let dataItem = this._getOrAddDataItem(aDownload, isNew); @@ -1026,23 +976,21 @@ DownloadsDataCtor.prototype = { }, onProgressChange: function DD_onProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, 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) { return; } dataItem.currBytes = aDownload.amountTransferred; dataItem.maxBytes = aDownload.size;
--- a/browser/components/downloads/src/DownloadsStartup.js +++ b/browser/components/downloads/src/DownloadsStartup.js @@ -26,32 +26,23 @@ const Cr = Components.results; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "DownloadsCommon", "resource:///modules/DownloadsCommon.jsm"); 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", ]; /** * CID of our implementation of nsIDownloadManagerUI. */ @@ -140,46 +131,36 @@ DownloadsStartup.prototype = { if (!DownloadsCommon.useToolkitUI) { let removeFinishedDownloads = Services.prefs.getBoolPref( "browser.download.panel.removeFinishedDownloads"); aSubject.QueryInterface(Ci.nsISupportsPRInt32) .data = removeFinishedDownloads ? 0 : 2; } 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 // event is invoked only if the application is not shutting down yet. // If the Download Manager service is not initialized, we don't want to // initialize it just to clean up completed downloads, because they can // be present only in case there was a browser crash or restart. if (this._downloadsServiceInitialized && !DownloadsCommon.useToolkitUI) { Services.downloads.cleanUp(); } break; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING case "last-pb-context-exited": // Similar to the above notification, but for private downloads. if (this._downloadsServiceInitialized && !DownloadsCommon.useToolkitUI) { Services.downloads.cleanUpPrivate(); } break; -#endif case "quit-application": // When the application is shutting down, we must free all resources in // addition to cleaning up completed downloads. If the Download Manager // service is not initialized, we don't want to initialize it just to // clean up completed downloads, because they can be present only in // case there was a browser crash or restart. this._shuttingDown = true; @@ -271,21 +252,17 @@ DownloadsStartup.prototype = { return aValue; }, /** * Ensures that persistent download data is reloaded at the appropriate time. */ _ensureDataLoaded: function DS_ensureDataLoaded() { - if (!this._downloadsServiceInitialized -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - || gPrivateBrowsingService.privateBrowsingEnabled -#endif - ) { + if (!this._downloadsServiceInitialized) { return; } // If the previous session has been already restored, then we ensure that // all the downloads are loaded. Otherwise, we only ensure that the active // downloads from the previous session are loaded. DownloadsCommon.ensureAllPersistentDataLoaded(!this._recoverAllDownloads); }
--- a/browser/components/nsBrowserContentHandler.js +++ b/browser/components/nsBrowserContentHandler.js @@ -506,41 +506,32 @@ nsBrowserContentHandler.prototype = { } } if (cmdLine.handleFlag("preferences", false)) { openPreferences(); cmdLine.preventDefault = true; } 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) { doSearch(searchParam, cmdLine); cmdLine.preventDefault = true; } // 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(); } var fileParam = cmdLine.handleFlagWithParam("file", false); if (fileParam) { var file = cmdLine.resolveFile(fileParam); var ios = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService);
--- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -134,23 +134,18 @@ PlacesController.prototype = { // If selection includes history nodes there's no reason to allow cut. for (var i = 0; i < nodes.length; i++) { if (nodes[i].itemId == -1) return false; } // Otherwise fallback to cmd_delete check. case "cmd_delete": case "placesCmd_delete": + case "placesCmd_deleteDataHost": return this._hasRemovableSelection(false); - case "placesCmd_deleteDataHost": - return this._hasRemovableSelection(false) -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - && !PlacesUIUtils.privateBrowsing.privateBrowsingEnabled -#endif - ; case "placesCmd_moveBookmarks": return this._hasRemovableSelection(true); case "cmd_copy": case "placesCmd_copy": return this._view.hasSelection; case "cmd_paste": case "placesCmd_paste": return this._canInsert(true) && this._isClipboardDataPasteable(); @@ -599,24 +594,17 @@ PlacesController.prototype = { var visibleItemsBeforeSep = false; var anyVisible = false; for (var i = 0; i < aPopup.childNodes.length; ++i) { var item = aPopup.childNodes[i]; if (item.localName != "menuseparator") { // 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; anyVisible = true; // Show the separator above the menu-item if any if (separator) { separator.hidden = false;
--- a/browser/components/places/content/places.js +++ b/browser/components/places/content/places.js @@ -70,20 +70,16 @@ var PlacesOrganizer = { var historyMenuForward = document.getElementById("historyMenuForward"); historyMenuForward.removeAttribute("key"); #endif // remove the "Properties" context-menu item, we've our own details pane document.getElementById("placesContext") .removeChild(document.getElementById("placesContext_show:info")); -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - gPrivateBrowsingListener.init(); -#endif - ContentArea.focus(); }, QueryInterface: function PO_QueryInterface(aIID) { if (aIID.equals(Components.interfaces.nsIDOMEventListener) || aIID.equals(Components.interfaces.nsISupports)) return this; @@ -106,19 +102,16 @@ var PlacesOrganizer = { break; case "Search": PlacesSearchBox.findAll(); break; } }, destroy: function PO_destroy() { -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - gPrivateBrowsingListener.uninit(); -#endif }, _location: null, get location() { return this._location; }, set location(aLocation) { @@ -1193,55 +1186,16 @@ var ViewMenu = { aDirection = (aDirection || colLookupTable[columnId].dir).toUpperCase(); var sortConst = "SORT_BY_" + colLookupTable[columnId].key + "_" + aDirection; result.sortingAnnotation = colLookupTable[columnId].anno || ""; result.sortingMode = Ci.nsINavHistoryQueryOptions[sortConst]; } } -#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(), init: function CA_init() { this._deck = document.getElementById("placesViewsDeck"); this._toolbar = document.getElementById("placesToolbar"); ContentTree.init(); this._setupView();
--- a/browser/components/places/src/PlacesUIUtils.jsm +++ b/browser/components/places/src/PlacesUIUtils.jsm @@ -1004,22 +1004,16 @@ XPCOMUtils.defineLazyGetter(PlacesUIUtil return PlacesUIUtils.RDF.GetDataSource("rdf:local-store"); }); XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ellipsis", function() { return Services.prefs.getComplexValue("intl.ellipsis", 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"); XPCOMUtils.defineLazyGetter(this, "bundle", function() { const PLACES_STRING_BUNDLE_URI = "chrome://browser/locale/places/places.properties"; return Cc["@mozilla.org/intl/stringbundle;1"].
--- a/browser/components/preferences/in-content/jar.mn +++ b/browser/components/preferences/in-content/jar.mn @@ -5,18 +5,18 @@ browser.jar: * content/browser/preferences/in-content/preferences.js content/browser/preferences/in-content/landing.xul * content/browser/preferences/in-content/preferences.xul * content/browser/preferences/in-content/main.xul 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 * content/browser/preferences/in-content/applications.js content/browser/preferences/in-content/content.xul content/browser/preferences/in-content/content.js content/browser/preferences/in-content/sync.xul content/browser/preferences/in-content/sync.js
--- a/browser/components/preferences/in-content/privacy.js +++ b/browser/components/preferences/in-content/privacy.js @@ -271,17 +271,16 @@ var gPrivacyPane = { }, autoStartPrivateBrowsingObserver: { QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver]), 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; return; } const Cc = Components.classes, Ci = Components.interfaces; let pref = document.getElementById("browser.privatebrowsing.autostart"); @@ -313,33 +312,16 @@ var gPrivacyPane = { let mode = document.getElementById("historyMode"); if (mode.value != "custom") { mode.selectedIndex = pref.value ? 1 : 0; mode.doCommand(); } else { 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 } }, // HISTORY /** * Read the location bar enabled and suggestion prefs * @return Int value for suggestion menulist
--- a/browser/components/preferences/in-content/privacy.xul +++ b/browser/components/preferences/in-content/privacy.xul @@ -56,26 +56,18 @@ type="bool"/> <preference id="privacy.sanitize.timeSpan" name="privacy.sanitize.timeSpan" type="int"/> <!-- Private Browsing --> <preference id="browser.privatebrowsing.autostart" name="browser.privatebrowsing.autostart" onchange="gPrivacyPane.updatePrivacyMicroControls();" -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - instantApply="true" -#endif - type="bool"/> -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - <preference id="browser.privatebrowsing.keep_current_session" - name="browser.privatebrowsing.keep_current_session" instantApply="true" type="bool"/> -#endif </preferences> <hbox class="heading" data-category="panePrivacy" hidden="true"> <image class="preference-icon" type="privacy"/> <html:h1>&panePrivacy.title;</html:h1> </hbox>
--- a/browser/components/preferences/in-content/tests/Makefile.in +++ b/browser/components/preferences/in-content/tests/Makefile.in @@ -12,40 +12,22 @@ include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/config/rules.mk _BROWSER_FILES = \ head.js \ browser_advanced_update.js \ 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 \ + privacypane_tests_perwindow.js \ $(NULL) -endif ifdef MOZ_SERVICES_HEALTHREPORT _BROWSER_FILES += browser_healthreport.js endif libs:: $(_BROWSER_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
deleted file mode 100644 --- 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"); -}
--- a/browser/components/preferences/in-content/tests/browser_privacypane_1.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_1.js @@ -6,21 +6,17 @@ function test() { 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_pane_visibility, test_dependent_elements, test_dependent_cookie_elements, test_dependent_clearonclose_elements, test_dependent_prefs,
deleted file mode 100644 --- 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 - ]); -}
--- a/browser/components/preferences/in-content/tests/browser_privacypane_3.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_3.js @@ -5,21 +5,17 @@ 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_custom_retention("rememberHistory", "remember"), test_custom_retention("rememberHistory", "custom"), test_custom_retention("rememberForms", "remember"), test_custom_retention("rememberForms", "custom"), test_historymode_retention("remember", "remember"),
--- a/browser/components/preferences/in-content/tests/browser_privacypane_4.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_4.js @@ -5,21 +5,17 @@ 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_custom_retention("acceptCookies", "remember"), test_custom_retention("acceptCookies", "custom"), test_custom_retention("acceptThirdParty", "remember"), test_custom_retention("acceptThirdParty", "custom"), test_custom_retention("keepCookiesUntil", "remember", 1), test_custom_retention("keepCookiesUntil", "custom", 2),
--- a/browser/components/preferences/in-content/tests/browser_privacypane_5.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_5.js @@ -5,21 +5,17 @@ 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_locbar_suggestion_retention(-1, undefined), test_locbar_suggestion_retention(1, -1), test_locbar_suggestion_retention(2, 1), test_locbar_suggestion_retention(0, 2), test_locbar_suggestion_retention(0, 0),
deleted file mode 100644 --- 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 - ]); -}
deleted file mode 100644 --- 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 - ]); -}
--- a/browser/components/preferences/in-content/tests/browser_privacypane_8.js +++ b/browser/components/preferences/in-content/tests/browser_privacypane_8.js @@ -5,21 +5,17 @@ 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ // history mode should be initialized to remember test_historymode_retention("remember", undefined), // history mode should remain remember; toggle acceptCookies checkbox test_custom_retention("acceptCookies", "remember"),
deleted file mode 100644 --- 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(); -}
--- a/browser/components/preferences/jar.mn +++ b/browser/components/preferences/jar.mn @@ -27,18 +27,18 @@ browser.jar: content/browser/preferences/handlers.css * content/browser/preferences/languages.xul content/browser/preferences/languages.js * content/browser/preferences/main.xul content/browser/preferences/main.js * 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 content/browser/preferences/selectBookmark.xul content/browser/preferences/selectBookmark.js #ifdef MOZ_SERVICES_SYNC content/browser/preferences/sync.xul content/browser/preferences/sync.js
--- a/browser/components/preferences/privacy.js +++ b/browser/components/preferences/privacy.js @@ -274,17 +274,16 @@ var gPrivacyPane = { }, autoStartPrivateBrowsingObserver: { QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver]), 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; return; } const Cc = Components.classes, Ci = Components.interfaces; let pref = document.getElementById("browser.privatebrowsing.autostart"); @@ -316,33 +315,16 @@ var gPrivacyPane = { let mode = document.getElementById("historyMode"); if (mode.value != "custom") { mode.selectedIndex = pref.value ? 1 : 0; mode.doCommand(); } else { 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 } }, // HISTORY /** * Read the location bar enabled and suggestion prefs * @return Int value for suggestion menulist
--- a/browser/components/preferences/privacy.xul +++ b/browser/components/preferences/privacy.xul @@ -68,26 +68,18 @@ <preference id="privacy.sanitize.timeSpan" name="privacy.sanitize.timeSpan" type="int"/> <!-- Private Browsing --> <preference id="browser.privatebrowsing.autostart" name="browser.privatebrowsing.autostart" onchange="gPrivacyPane.updatePrivacyMicroControls();" -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - instantApply="true" -#endif - type="bool"/> -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING - <preference id="browser.privatebrowsing.keep_current_session" - name="browser.privatebrowsing.keep_current_session" instantApply="true" type="bool"/> -#endif </preferences> <stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences/preferences.properties"/> <script type="application/javascript" src="chrome://browser/content/preferences/privacy.js"/> <!-- Tracking -->
--- a/browser/components/preferences/tests/Makefile.in +++ b/browser/components/preferences/tests/Makefile.in @@ -13,40 +13,22 @@ include $(topsrcdir)/config/rules.mk _BROWSER_FILES = \ head.js \ browser_advanced_update.js \ browser_bug410900.js \ 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 \ + privacypane_tests_perwindow.js \ $(NULL) -endif ifdef MOZ_SERVICES_HEALTHREPORT _BROWSER_FILES += browser_healthreport.js endif libs:: $(_BROWSER_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
deleted file mode 100644 --- 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"); -}
--- a/browser/components/preferences/tests/browser_privacypane_1.js +++ b/browser/components/preferences/tests/browser_privacypane_1.js @@ -7,21 +7,17 @@ function test() { 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_pane_visibility, test_dependent_elements, test_dependent_cookie_elements, test_dependent_clearonclose_elements, test_dependent_prefs,
deleted file mode 100644 --- 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 - ]); -}
--- a/browser/components/preferences/tests/browser_privacypane_3.js +++ b/browser/components/preferences/tests/browser_privacypane_3.js @@ -6,21 +6,17 @@ 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_custom_retention("rememberHistory", "remember"), test_custom_retention("rememberHistory", "custom"), test_custom_retention("rememberForms", "remember"), test_custom_retention("rememberForms", "custom"), test_historymode_retention("remember", "remember"),
--- a/browser/components/preferences/tests/browser_privacypane_4.js +++ b/browser/components/preferences/tests/browser_privacypane_4.js @@ -6,21 +6,17 @@ 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_custom_retention("acceptCookies", "remember"), test_custom_retention("acceptCookies", "custom"), test_custom_retention("acceptThirdParty", "remember"), test_custom_retention("acceptThirdParty", "custom"), test_custom_retention("keepCookiesUntil", "remember", 1), test_custom_retention("keepCookiesUntil", "custom", 2),
--- a/browser/components/preferences/tests/browser_privacypane_5.js +++ b/browser/components/preferences/tests/browser_privacypane_5.js @@ -6,21 +6,17 @@ 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ test_locbar_suggestion_retention(-1, undefined), test_locbar_suggestion_retention(1, -1), test_locbar_suggestion_retention(2, 1), test_locbar_suggestion_retention(0, 2), test_locbar_suggestion_retention(0, 0),
deleted file mode 100644 --- 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 - ]); -}
deleted file mode 100644 --- 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 - ]); -}
--- a/browser/components/preferences/tests/browser_privacypane_8.js +++ b/browser/components/preferences/tests/browser_privacypane_8.js @@ -6,21 +6,17 @@ 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); - } + loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); run_test_subset([ // history mode should be initialized to remember test_historymode_retention("remember", undefined), // history mode should remain remember; toggle acceptCookies checkbox test_custom_retention("acceptCookies", "remember"),
deleted file mode 100644 --- 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(); -}
--- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml +++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml @@ -8,51 +8,37 @@ <!ENTITY % htmlDTD PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> %htmlDTD; <!ENTITY % netErrorDTD SYSTEM "chrome://global/locale/netError.dtd"> %netErrorDTD; <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd"> %globalDTD; <!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd"> %browserDTD; -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING #ifdef XP_MACOSX <!ENTITY basePBMenu.label "&fileMenu.label;"> #else <!ENTITY basePBMenu.label "<span class='appMenuButton'>&brandShortName;</span><span class='fileMenu'>&fileMenu.label;</span>"> #endif -#else -#ifdef XP_MACOSX - <!ENTITY basePBMenu.label "&toolsMenu.label;"> -#else - <!ENTITY basePBMenu.label "<span class='appMenuButton'>&brandShortName;</span><span class='toolsMenu'>&toolsMenu.label;</span>"> -#endif -#endif <!ENTITY % privatebrowsingpageDTD SYSTEM "chrome://browser/locale/aboutPrivateBrowsing.dtd"> %privatebrowsingpageDTD; ]> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all"/> <link rel="stylesheet" href="chrome://browser/skin/aboutPrivateBrowsing.css" type="text/css" media="all"/> <style type="text/css"><![CDATA[ body.normal .showPrivate, 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; } ]]></style> <script type="application/javascript;version=1.7"><![CDATA[ const Cc = Components.classes; const Ci = Components.interfaces; @@ -103,25 +89,19 @@ // Show the correct menu structure based on whether the App Menu button is // shown or not. var menuBar = mainWindow.document.getElementById("toolbar-menubar"); var appMenuButtonIsVisible = menuBar.getAttribute("autohide") == "true"; document.body.classList.add(appMenuButtonIsVisible ? "appMenuButtonVisible" : "appMenuButtonInvisible"); }, false); -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING function openPrivateWindow() { mainWindow.OpenBrowserWindow({private: true}); } -#else - function togglePrivateBrowsing() { - mainWindow.gPrivateBrowsingUI.toggleMode(); - } -#endif ]]></script> </head> <body dir="&locale.dir;" class="private"> <!-- PAGE CONTAINER (for styling purposes only) --> <div id="errorPageContainer"> @@ -132,58 +112,37 @@ <h1 id="errorTitleTextNormal" class="showNormal">&privatebrowsingpage.title.normal;</h1> </div> <!-- LONG CONTENT (the section most likely to require scrolling) --> <div id="errorLongContent"> <!-- Short Description --> <div id="errorShortDesc"> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING <p id="errorShortDescText" class="showPrivate">&privatebrowsingpage.perwindow.issueDesc;</p> <p id="errorShortDescTextNormal" class="showNormal">&privatebrowsingpage.perwindow.issueDesc.normal;</p> -#else - <p id="errorShortDescText" class="showPrivate">&privatebrowsingpage.issueDesc;</p> - <p id="errorShortDescTextNormal" class="showNormal">&privatebrowsingpage.issueDesc.normal;</p> -#endif </div> <!-- Long Description --> <div id="errorLongDesc"> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING <p id="errorLongDescText">&privatebrowsingpage.perwindow.description;</p> -#else - <p id="errorLongDescText">&privatebrowsingpage.description;</p> -#endif </div> <!-- Start Private Browsing --> <div id="startPrivateBrowsingDesc" class="showNormal"> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING <button xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="startPrivateBrowsing" label="&privatebrowsingpage.openPrivateWindow.label;" accesskey="&privatebrowsingpage.openPrivateWindow.accesskey;" oncommand="openPrivateWindow();"/> -#else - <button xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - id="startPrivateBrowsing" label="&privatebrowsingpage.startPrivateBrowsing.label;" - accesskey="&privatebrowsingpage.startPrivateBrowsing.accesskey;" - oncommand="togglePrivateBrowsing();"/> -#endif </div> <!-- Footer --> <div id="footerDesc"> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING <p id="footerText" class="showPrivate">&privatebrowsingpage.howToStop3;</p> <p id="footerTextNormal" class="showNormal">&privatebrowsingpage.howToStart3;</p> -#else - <p id="footerText" class="showPrivate">&privatebrowsingpage.howToStop2;</p> - <p id="footerTextNormal" class="showNormal">&privatebrowsingpage.howToStart2;</p> -#endif </div> <!-- More Info --> <div id="moreInfo" class="showPrivate"> <p id="moreInfoText"> &privatebrowsingpage.moreInfo; </p> <p id="moreInfoLinkContainer">
--- a/browser/components/privatebrowsing/src/Makefile.in +++ b/browser/components/privatebrowsing/src/Makefile.in @@ -10,34 +10,14 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk MODULE = privatebrowsing 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
deleted file mode 100644 --- 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]);
deleted file mode 100644 --- 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}
deleted file mode 100644 --- 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<nsIJSContextStack> 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<nsIObserver> observer(do_QueryInterface(mPBService)); - NS_ENSURE_TRUE(observer, NS_ERROR_FAILURE); - return observer->Observe(aSubject, aTopic, aData); -}
deleted file mode 100644 --- 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<nsIPrivateBrowsingService> mPBService; -};
--- a/browser/components/privatebrowsing/test/Makefile.in +++ b/browser/components/privatebrowsing/test/Makefile.in @@ -7,21 +7,12 @@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ 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) include $(topsrcdir)/config/rules.mk
--- a/browser/components/privatebrowsing/test/browser/Makefile.in +++ b/browser/components/privatebrowsing/test/browser/Makefile.in @@ -7,26 +7,11 @@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ 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
deleted file mode 100644 --- 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
deleted file mode 100644 --- 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(); - } -}
deleted file mode 100644 --- 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(); - } -}
deleted file mode 100644 --- 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); - }); - }); -}
deleted file mode 100644 --- 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"); -}
deleted file mode 100644 --- 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"); -}
deleted file mode 100644 --- 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"); -}
deleted file mode 100644 --- 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"); -}
deleted file mode 100644 --- 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; -}
deleted file mode 100644 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt_page.html +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> -<html> - <head> - <title>Geolocation invoker</title> - </head> - <body> - <script type="text/javascript"> - navigator.geolocation.getCurrentPosition(function (pos) { - // ignore - }); - </script> - </body> -</html>
deleted file mode 100644 --- 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'); -}
deleted file mode 100644 --- 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'); - }); -}
deleted file mode 100644 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page.html +++ /dev/null @@ -1,11 +0,0 @@ -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<script type="text/javascript"> - localStorage.clear(); - localStorage.setItem('zzztest', 'zzzvalue'); - document.title = localStorage.length; -</script> -</head> -<body> -</body> -</html>
deleted file mode 100644 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_before_after_page2.html +++ /dev/null @@ -1,10 +0,0 @@ -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<script type="text/javascript"> - document.title = localStorage.getItem('zzztest', 'zzzvalue') + '|' + localStorage.length; - localStorage.clear(); -</script> -</head> -<body> -</body> -</html>
deleted file mode 100644 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page1.html +++ /dev/null @@ -1,10 +0,0 @@ -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<script type="text/javascript"> - localStorage.clear(); - localStorage.setItem('test1', 'value1'); -</script> -</head> -<body> -</body> -</html>
deleted file mode 100644 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage_page2.html +++ /dev/null @@ -1,10 +0,0 @@ -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<script type="text/javascript"> - localStorage.setItem('test2', 'value2'); - document.title = localStorage.length; -</script> -</head> -<body> -</body> -</html>
deleted file mode 100644 --- 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); -}
deleted file mode 100644 --- 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); -}
deleted file mode 100644 --- 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(); - }); - }); - }); - }); - }); -}
deleted file mode 100644 --- 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); - }); -}
deleted file mode 100644 --- 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(); - }); - }); - }); -}
deleted file mode 100644 --- 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; -}
deleted file mode 100644 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler_page.html +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> -<html> - <head> - <title>Protocol registrar page</title> - </head> - <body> - <script type="text/javascript"> - navigator.registerProtocolHandler("testprotocol", - "https://example.com/foobar?uri=%s", - "Test Protocol"); - </script> - </body> -</html>
deleted file mode 100644 --- 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"); -}
deleted file mode 100644 --- 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 <command> 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 <command> 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); -}
deleted file mode 100644 --- 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(); -}
deleted file mode 100644 --- 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; -}
deleted file mode 100644 --- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle_page.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> -<html> - <head> - <title>Test title</title> - </head> - <body> - Test page for the window title test - </body> -</html>
deleted file mode 100644 --- 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:"; -}
deleted file mode 100644 --- 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); -}
deleted file mode 100644 index 4c3be508477eb19cd08ddf4d0f568a06a4ec7a45..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@<O00001
deleted file mode 100644 --- a/browser/components/privatebrowsing/test/browser/global/ctxmenu.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> -<html> - <head> - <title>Page containing an image</title> - </head> - <body> - <img src="ctxmenu-image.png"> - </body> -</html>
deleted file mode 100644 --- 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; -}
deleted file mode 100644 --- a/browser/components/privatebrowsing/test/browser/global/popup.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> -<html> - <head> - <title>Page creating a popup</title> - </head> - <body> - <script type="text/javascript"> - window.open("data:text/plain,test", "testwin"); - </script> - </body> -</html>
deleted file mode 100644 --- 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("<html><head><title>"); - response.write(title); - response.write("</title><body>test page</body></html>"); -}
deleted file mode 100644 --- 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
deleted file mode 100644 --- 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); -}
deleted file mode 100644 --- 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,<body%20onbeforeunload='return%20false;'>first</body>"; - const TEST_PAGE_2 = "data:text/html,<body%20onbeforeunload='return%20false;'>second</body>"; - 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); -}
deleted file mode 100644 --- 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:"); -}
deleted file mode 100644 --- 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; -}
deleted file mode 100644 --- 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(); -}
deleted file mode 100644 --- 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); - } -}
deleted file mode 100644 --- 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(); -}
deleted file mode 100644 --- 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); -}
deleted file mode 100644 --- 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(); -}
deleted file mode 100644 --- 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); -