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