1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_private_browsing_window.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +// Make sure that we can open private browsing windows 1.5 + 1.6 +function test() { 1.7 + waitForExplicitFinish(); 1.8 + var nonPrivateWin = OpenBrowserWindow(); 1.9 + ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow() should open a normal window"); 1.10 + nonPrivateWin.close(); 1.11 + 1.12 + var privateWin = OpenBrowserWindow({private: true}); 1.13 + ok(PrivateBrowsingUtils.isWindowPrivate(privateWin), "OpenBrowserWindow({private: true}) should open a private window"); 1.14 + 1.15 + nonPrivateWin = OpenBrowserWindow({private: false}); 1.16 + ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow({private: false}) should open a normal window"); 1.17 + nonPrivateWin.close(); 1.18 + 1.19 + whenDelayedStartupFinished(privateWin, function() { 1.20 + nonPrivateWin = privateWin.OpenBrowserWindow({private: false}); 1.21 + ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "privateWin.OpenBrowserWindow({private: false}) should open a normal window"); 1.22 + 1.23 + nonPrivateWin.close(); 1.24 + 1.25 + [ 1.26 + { normal: "menu_newNavigator", private: "menu_newPrivateWindow", accesskey: true }, 1.27 + { normal: "appmenu_newNavigator", private: "appmenu_newPrivateWindow", accesskey: false }, 1.28 + ].forEach(function(menu) { 1.29 + let newWindow = privateWin.document.getElementById(menu.normal); 1.30 + let newPrivateWindow = privateWin.document.getElementById(menu.private); 1.31 + if (newWindow && newPrivateWindow) { 1.32 + ok(!newPrivateWindow.hidden, "New Private Window menu item should be hidden"); 1.33 + isnot(newWindow.label, newPrivateWindow.label, "New Window's label shouldn't be overwritten"); 1.34 + if (menu.accesskey) { 1.35 + isnot(newWindow.accessKey, newPrivateWindow.accessKey, "New Window's accessKey shouldn't be overwritten"); 1.36 + } 1.37 + isnot(newWindow.command, newPrivateWindow.command, "New Window's command shouldn't be overwritten"); 1.38 + } 1.39 + }); 1.40 + 1.41 + privateWin.close(); 1.42 + 1.43 + Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true); 1.44 + privateWin = OpenBrowserWindow({private: true}); 1.45 + whenDelayedStartupFinished(privateWin, function() { 1.46 + [ 1.47 + { normal: "menu_newNavigator", private: "menu_newPrivateWindow", accessKey: true }, 1.48 + { normal: "appmenu_newNavigator", private: "appmenu_newPrivateWindow", accessKey: false }, 1.49 + ].forEach(function(menu) { 1.50 + let newWindow = privateWin.document.getElementById(menu.normal); 1.51 + let newPrivateWindow = privateWin.document.getElementById(menu.private); 1.52 + if (newWindow && newPrivateWindow) { 1.53 + ok(newPrivateWindow.hidden, "New Private Window menu item should be hidden"); 1.54 + is(newWindow.label, newPrivateWindow.label, "New Window's label should be overwritten"); 1.55 + if (menu.accesskey) { 1.56 + is(newWindow.accessKey, newPrivateWindow.accessKey, "New Window's accessKey should be overwritten"); 1.57 + } 1.58 + is(newWindow.command, newPrivateWindow.command, "New Window's command should be overwritten"); 1.59 + } 1.60 + }); 1.61 + 1.62 + privateWin.close(); 1.63 + Services.prefs.clearUserPref("browser.privatebrowsing.autostart"); 1.64 + finish(); 1.65 + }); 1.66 + }); 1.67 +} 1.68 +