diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 906499652a8..51a67b07352 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -936,7 +936,6 @@ var gBrowserInit = { LanguageDetectionListener.init(); BrowserOnClick.init(); DevEdition.init(); - AboutPrivateBrowsingListener.init(); let mm = window.getGroupMessageManager("browsers"); mm.loadFrameScript("chrome://browser/content/content.js", true); @@ -7776,13 +7775,3 @@ let PanicButtonNotifier = { popup.hidePopup(); }, }; - -let AboutPrivateBrowsingListener = { - init: function () { - window.messageManager.addMessageListener( - "AboutPrivateBrowsing:OpenPrivateWindow", - msg => { - OpenBrowserWindow({private: true}); - }); - } -}; diff --git a/browser/base/content/content.js b/browser/base/content/content.js index 46f25788a2c..a82c4a1767b 100644 --- a/browser/base/content/content.js +++ b/browser/base/content/content.js @@ -479,29 +479,6 @@ let AboutHomeListener = { }; AboutHomeListener.init(this); -let AboutPrivateBrowsingListener = { - init: function(chromeGlobal) { - chromeGlobal.addEventListener('AboutPrivateBrowsingOpenWindow', this, - false, true); - }, - - get isAboutPrivateBrowsing() { - return content.document.documentURI.toLowerCase() == "about:privatebrowsing"; - }, - - handleEvent: function(aEvent) { - if (!this.isAboutPrivateBrowsing) { - return; - } - switch (aEvent.type) { - case "AboutPrivateBrowsingOpenWindow": - sendAsyncMessage("AboutPrivateBrowsing:OpenPrivateWindow"); - break; - } - }, -}; -AboutPrivateBrowsingListener.init(this); - let AboutReaderListener = { _articlePromise: null, diff --git a/browser/base/content/test/general/browser_bug963945.js b/browser/base/content/test/general/browser_bug963945.js index 4531964b0c3..5a68d3f3565 100644 --- a/browser/base/content/test/general/browser_bug963945.js +++ b/browser/base/content/test/general/browser_bug963945.js @@ -7,17 +7,24 @@ * opened one time when in private browsing. */ -add_task(function* test() { - let win = yield BrowserTestUtils.openNewBrowserWindow({private: true}); +function test() { + waitForExplicitFinish(); + + var win = OpenBrowserWindow({private: true}); - let tab = win.gBrowser.selectedTab = win.gBrowser.addTab("about:addons"); - yield BrowserTestUtils.browserLoaded(tab.linkedBrowser); - yield promiseWaitForFocus(win); + whenDelayedStartupFinished(win, function() { + win.gBrowser.loadURI("about:addons"); - EventUtils.synthesizeKey("a", { ctrlKey: true, shiftKey: true }, win); + waitForFocus(function() { + EventUtils.synthesizeKey("a", { ctrlKey: true, shiftKey: true }, win); + + is(win.gBrowser.tabs.length, 1, "about:addons tab was re-focused."); + is(win.gBrowser.currentURI.spec, "about:addons", "Addons tab was opened."); + + win.close(); + finish(); + }); + }); +} - is(win.gBrowser.tabs.length, 2, "about:addons tab was re-focused."); - is(win.gBrowser.currentURI.spec, "about:addons", "Addons tab was opened."); - yield BrowserTestUtils.closeWindow(win); -}); diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp index de41b231c38..2da8a66f1dc 100644 --- a/browser/components/about/AboutRedirector.cpp +++ b/browser/components/about/AboutRedirector.cpp @@ -61,7 +61,6 @@ static RedirEntry kRedirMap[] = { nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::HIDE_FROM_ABOUTABOUT }, { "privatebrowsing", "chrome://browser/content/aboutPrivateBrowsing.xhtml", - nsIAboutModule::URI_MUST_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT }, { "rights", #ifdef MOZ_OFFICIAL_BRANDING diff --git a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js index b2f6b3dc7d8..eecb9e9556d 100644 --- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js +++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js @@ -17,6 +17,13 @@ if (!PrivateBrowsingUtils.isContentWindowPrivate(window)) { setFavIcon("chrome://browser/skin/Privacy-16.png"); } +var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShellTreeItem) + .rootTreeItem + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindow); + function setFavIcon(url) { var icon = document.createElement("link"); icon.setAttribute("rel", "icon"); @@ -47,7 +54,5 @@ document.addEventListener("DOMContentLoaded", function () { }, false); function openPrivateWindow() { - // Ask chrome to open a private window - document.dispatchEvent( - new CustomEvent("AboutPrivateBrowsingOpenWindow", {bubbles:true})); + mainWindow.OpenBrowserWindow({private: true}); } diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js index 5402398b765..962c860928e 100644 --- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js +++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js @@ -48,6 +48,8 @@ function test() { function testDownloadDir(aWin, gDownloadLastDir, aFile, aDisplayDir, aLastDir, aGlobalLastDir, aCallback) { + let context = aWin.gBrowser.selectedBrowser.contentWindow; + // Check lastDir preference. is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, aDisplayDir.path, "LastDir should be the expected display dir"); @@ -76,7 +78,7 @@ function test() { aCallback(); }; - launcherDialog.promptForSaveToFileAsync(launcher, aWin, null, null, null); + launcherDialog.promptForSaveToFileAsync(launcher, context, null, null, null); } testOnWindow(false, function(win, downloadDir) {