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
This commit is contained in:
Josh Matthews 2012-12-10 06:39:00 -05:00
parent ac6c245f04
commit 42f22fa563
4 changed files with 20 additions and 8 deletions

View File

@ -3494,17 +3494,16 @@ function OpenBrowserWindow(options)
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

View File

@ -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();
});
}

View File

@ -40,7 +40,7 @@ function test() {
Services.obs.removeObserver(observer1, "domwindowopened");
}, false);
}, "domwindowopened", false);
OpenBrowserWindow();
OpenBrowserWindow({private: PrivateBrowsingUtils.isWindowPrivate(window)});
}
// test the gPrivateBrowsingUI object

View File

@ -13,7 +13,7 @@ function test() {
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() {