Bug 1079245 - Set about:privatebrowsing to load in child. r=mossop
☠☠ backed out by 7b259d8a61a8 ☠ ☠
authorSteven MacLeod <smacleod@mozilla.com>
Mon, 09 Feb 2015 15:42:39 -0500
changeset 234421 1b23439451a8ec0a5f9343c3699547d2efb628ec
parent 234420 b467fad71782b4dad59ef6e98b20dfccb0c4f78d
child 234422 11c3430c78f8e0297e1a1deaf9fa05d08598c763
push id28445
push userkwierso@gmail.com
push dateFri, 20 Mar 2015 02:10:04 +0000
treeherdermozilla-central@988afda9eac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1079245, 963945
milestone39.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
Bug 1079245 - Set about:privatebrowsing to load in child. r=mossop browser_privatebrowsing_downloadLastDir.js and browser_bug963945.js are also updated to work properly when about:privatebrowsing is loaded remotely.
browser/base/content/browser.js
browser/base/content/content.js
browser/base/content/test/general/browser_bug963945.js
browser/components/about/AboutRedirector.cpp
browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -931,16 +931,17 @@ var gBrowserInit = {
     // loading the frame script to ensure that we don't miss any
     // message sent between when the frame script is loaded and when
     // the listener is registered.
     DOMLinkHandler.init();
     gPageStyleMenu.init();
     LanguageDetectionListener.init();
     BrowserOnClick.init();
     DevEdition.init();
+    AboutPrivateBrowsingListener.init();
 
     let mm = window.getGroupMessageManager("browsers");
     mm.loadFrameScript("chrome://browser/content/content.js", true);
     mm.loadFrameScript("chrome://browser/content/content-UITour.js", true);
 
     window.messageManager.addMessageListener("Browser:LoadURI", RedirectLoad);
 
     // initialize observers and listeners
@@ -7770,8 +7771,18 @@ let PanicButtonNotifier = {
       Cu.reportError(ex);
     }
   },
   close: function() {
     let popup = document.getElementById("panic-button-success-notification");
     popup.hidePopup();
   },
 };
+
+let AboutPrivateBrowsingListener = {
+  init: function () {
+    window.messageManager.addMessageListener(
+      "AboutPrivateBrowsing:OpenPrivateWindow",
+      msg => {
+        OpenBrowserWindow({private: true});
+    });
+  }
+};
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -474,16 +474,39 @@ let AboutHomeListener = {
     let searchInput = content.document.getElementById("searchText");
     if (searchInput) {
       searchInput.focus();
     }
   },
 };
 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,
 
   init: function() {
     addEventListener("AboutReaderContentLoaded", this, false, true);
     addEventListener("DOMContentLoaded", this, false);
     addEventListener("pagehide", this, false);
--- a/browser/base/content/test/general/browser_bug963945.js
+++ b/browser/base/content/test/general/browser_bug963945.js
@@ -2,29 +2,22 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * This test ensures the about:addons tab is only
  * opened one time when in private browsing.
  */
 
-function test() {
-  waitForExplicitFinish();
-	
-  var win = OpenBrowserWindow({private: true});
+add_task(function* test() {
+  let win = yield BrowserTestUtils.openNewBrowserWindow({private: true});
 
-  whenDelayedStartupFinished(win, function() {
-    win.gBrowser.loadURI("about:addons");
-
-    waitForFocus(function() {
-      EventUtils.synthesizeKey("a", { ctrlKey: true, shiftKey: true }, win);
+  let tab = win.gBrowser.selectedTab = win.gBrowser.addTab("about:addons");
+  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
+  yield promiseWaitForFocus(win);
 
-      is(win.gBrowser.tabs.length, 1, "about:addons tab was re-focused.");
-      is(win.gBrowser.currentURI.spec, "about:addons", "Addons tab was opened.");
+  EventUtils.synthesizeKey("a", { ctrlKey: true, shiftKey: true }, win);
 
-      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);
+});
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -56,16 +56,17 @@ static RedirEntry kRedirMap[] = {
     nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
     nsIAboutModule::ALLOW_SCRIPT |
     nsIAboutModule::HIDE_FROM_ABOUTABOUT },
   { "feeds", "chrome://browser/content/feeds/subscribe.xhtml",
     nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
     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
     "chrome://global/content/aboutRights.xhtml",
 #else
     "chrome://global/content/aboutRights-unbranded.xhtml",
 #endif
     nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
--- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
+++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
@@ -12,23 +12,16 @@ var stringBundle = Cc["@mozilla.org/intl
 if (!PrivateBrowsingUtils.isContentWindowPrivate(window)) {
   document.title = stringBundle.GetStringFromName("title.normal");
   setFavIcon("chrome://global/skin/icons/question-16.png");
 } else {
   document.title = stringBundle.GetStringFromName("title");
   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");
   icon.setAttribute("type", "image/png");
   icon.setAttribute("href", url);
   var head = document.getElementsByTagName("head")[0];
   head.insertBefore(icon, head.firstChild);
 }
@@ -49,10 +42,12 @@ document.addEventListener("DOMContentLoa
   
   let startPrivateBrowsing = document.getElementById("startPrivateBrowsing");
   if (startPrivateBrowsing) {
     startPrivateBrowsing.addEventListener("command", openPrivateWindow);
   }
 }, false);
 
 function openPrivateWindow() {
-  mainWindow.OpenBrowserWindow({private: true});
+  // Ask chrome to open a private window
+  document.dispatchEvent(
+    new CustomEvent("AboutPrivateBrowsingOpenWindow", {bubbles:true}));
 }
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js
@@ -43,18 +43,16 @@ function test() {
       let gDownloadLastDir = new DownloadLastDir(win);
       aCallback(win, gDownloadLastDir);
       gDownloadLastDir.cleanupPrivateFile();
     });
   }
 
   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");
     // Check gDownloadLastDir value.
     is(gDownloadLastDir.file.path, aDisplayDir.path,
        "gDownloadLastDir should be the expected display dir");
 
     MockFilePicker.returnFiles = [aFile];
@@ -73,17 +71,17 @@ function test() {
       is(gDownloadLastDir.file.path, aGlobalLastDir.path,
          "gDownloadLastDir should be the expected global last dir");
 
       launcher.saveDestinationAvailable = null;
       aWin.close();
       aCallback();
     };
 
-    launcherDialog.promptForSaveToFileAsync(launcher, context, null, null, null);
+    launcherDialog.promptForSaveToFileAsync(launcher, aWin, null, null, null);
   }
 
   testOnWindow(false, function(win, downloadDir) {
     testDownloadDir(win, downloadDir, file1, tmpDir, dir1, dir1, function() {
       testOnWindow(true, function(win, downloadDir) {
         testDownloadDir(win, downloadDir, file2, dir1, dir1, dir2, function() {
           testOnWindow(false, function(win, downloadDir) {
             testDownloadDir(win, downloadDir, file3, dir1, dir3, dir3, finish);