browser/base/content/test/general/browser_private_browsing_window.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Make sure that we can open private browsing windows
michael@0 2
michael@0 3 function test() {
michael@0 4 waitForExplicitFinish();
michael@0 5 var nonPrivateWin = OpenBrowserWindow();
michael@0 6 ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow() should open a normal window");
michael@0 7 nonPrivateWin.close();
michael@0 8
michael@0 9 var privateWin = OpenBrowserWindow({private: true});
michael@0 10 ok(PrivateBrowsingUtils.isWindowPrivate(privateWin), "OpenBrowserWindow({private: true}) should open a private window");
michael@0 11
michael@0 12 nonPrivateWin = OpenBrowserWindow({private: false});
michael@0 13 ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow({private: false}) should open a normal window");
michael@0 14 nonPrivateWin.close();
michael@0 15
michael@0 16 whenDelayedStartupFinished(privateWin, function() {
michael@0 17 nonPrivateWin = privateWin.OpenBrowserWindow({private: false});
michael@0 18 ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "privateWin.OpenBrowserWindow({private: false}) should open a normal window");
michael@0 19
michael@0 20 nonPrivateWin.close();
michael@0 21
michael@0 22 [
michael@0 23 { normal: "menu_newNavigator", private: "menu_newPrivateWindow", accesskey: true },
michael@0 24 { normal: "appmenu_newNavigator", private: "appmenu_newPrivateWindow", accesskey: false },
michael@0 25 ].forEach(function(menu) {
michael@0 26 let newWindow = privateWin.document.getElementById(menu.normal);
michael@0 27 let newPrivateWindow = privateWin.document.getElementById(menu.private);
michael@0 28 if (newWindow && newPrivateWindow) {
michael@0 29 ok(!newPrivateWindow.hidden, "New Private Window menu item should be hidden");
michael@0 30 isnot(newWindow.label, newPrivateWindow.label, "New Window's label shouldn't be overwritten");
michael@0 31 if (menu.accesskey) {
michael@0 32 isnot(newWindow.accessKey, newPrivateWindow.accessKey, "New Window's accessKey shouldn't be overwritten");
michael@0 33 }
michael@0 34 isnot(newWindow.command, newPrivateWindow.command, "New Window's command shouldn't be overwritten");
michael@0 35 }
michael@0 36 });
michael@0 37
michael@0 38 privateWin.close();
michael@0 39
michael@0 40 Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true);
michael@0 41 privateWin = OpenBrowserWindow({private: true});
michael@0 42 whenDelayedStartupFinished(privateWin, function() {
michael@0 43 [
michael@0 44 { normal: "menu_newNavigator", private: "menu_newPrivateWindow", accessKey: true },
michael@0 45 { normal: "appmenu_newNavigator", private: "appmenu_newPrivateWindow", accessKey: false },
michael@0 46 ].forEach(function(menu) {
michael@0 47 let newWindow = privateWin.document.getElementById(menu.normal);
michael@0 48 let newPrivateWindow = privateWin.document.getElementById(menu.private);
michael@0 49 if (newWindow && newPrivateWindow) {
michael@0 50 ok(newPrivateWindow.hidden, "New Private Window menu item should be hidden");
michael@0 51 is(newWindow.label, newPrivateWindow.label, "New Window's label should be overwritten");
michael@0 52 if (menu.accesskey) {
michael@0 53 is(newWindow.accessKey, newPrivateWindow.accessKey, "New Window's accessKey should be overwritten");
michael@0 54 }
michael@0 55 is(newWindow.command, newPrivateWindow.command, "New Window's command should be overwritten");
michael@0 56 }
michael@0 57 });
michael@0 58
michael@0 59 privateWin.close();
michael@0 60 Services.prefs.clearUserPref("browser.privatebrowsing.autostart");
michael@0 61 finish();
michael@0 62 });
michael@0 63 });
michael@0 64 }
michael@0 65

mercurial