Date: Mon Dec 10 00:16:09 2012 -0500
☠☠ backed out by 0a05fb0f9add ☠ ☠
authorJosh Matthews <josh@joshmatthews.net>
Mon, 10 Dec 2012 06:39:00 -0500
changeset 116021 7878092679cfc5bb217894bbced986a529f63aa9
parent 116020 b9a891c0a6e73b6fb9094334de0defb017e840e0
child 116022 2cf3cca4171e7ad18ffb52b9ba71a6942e539146
push id24034
push useremorley@mozilla.com
push dateFri, 14 Dec 2012 15:28:57 +0000
treeherdermozilla-central@50d8f411d305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs819202
milestone20.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
Date: Mon Dec 10 00:16:09 2012 -0500 Bug 819202 - Simplify the semantics of OpenBrowserWindow: new windows are public unless explicitly passed a 'private' option or global private browsing is in effect. r=dao
browser/base/content/browser.js
browser/base/content/test/browser_private_browsing_window.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_ui.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_newwindow_stopcmd.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3489,27 +3489,26 @@ 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 = "";
-  var forcePrivate = false;
 #ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
-  forcePrivate = typeof options == "object" && "private" in options && options.private;
+  if (typeof options == "object" && options.private) {
 #else
-  forcePrivate = gPrivateBrowsingUI.privateBrowsingEnabled;
+  if (gPrivateBrowsingUI.privateBrowsingEnabled) {
 #endif
-
-  if (forcePrivate) {
     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
   // set, then extract the current charset menu setting from the current document and use it to
   // initialize the new browser window...
   var win;
   if (window && (wintype == "navigator:browser") && window.content && window.content.document)
   {
--- a/browser/base/content/test/browser_private_browsing_window.js
+++ b/browser/base/content/test/browser_private_browsing_window.js
@@ -1,11 +1,24 @@
 // Make sure that we can open private browsing windows
 
 function test() {
+  waitForExplicitFinish();
   var nonPrivateWin = OpenBrowserWindow();
   ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow() should open a normal window");
   nonPrivateWin.close();
+
   var privateWin = OpenBrowserWindow({private: true});
   ok(PrivateBrowsingUtils.isWindowPrivate(privateWin), "OpenBrowserWindow({private: true}) should open a private window");
-  privateWin.close();
+
+  nonPrivateWin = OpenBrowserWindow({private: false});
+  ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow({private: false}) should open a normal window");
+  nonPrivateWin.close();
+
+  whenDelayedStartupFinished(privateWin, function() {
+    nonPrivateWin = privateWin.OpenBrowserWindow({private: false});
+    ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "privateWin.OpenBrowserWindow({private: false}) should open a normal window");
+    nonPrivateWin.close();
+    privateWin.close();
+    finish();
+  });
 }
 
--- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_ui.js
+++ b/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_ui.js
@@ -35,17 +35,17 @@ function test() {
             aCallback();
             Services.obs.removeObserver(observer2, "domwindowclosed");
           }, "domwindowclosed", false);
           aSubject.close();
         });
         Services.obs.removeObserver(observer1, "domwindowopened");
       }, false);
     }, "domwindowopened", false);
-    OpenBrowserWindow();
+    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");
--- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_newwindow_stopcmd.js
+++ b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_newwindow_stopcmd.js
@@ -8,17 +8,17 @@
 function test() {
   // initialization
   let pb = Cc["@mozilla.org/privatebrowsing;1"].
            getService(Ci.nsIPrivateBrowsingService);
   waitForExplicitFinish();
 
   pb.privateBrowsingEnabled = true;
 
-  let win = OpenBrowserWindow();
+  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();