diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /browser/base/content/test/general/browser_private_browsing_window.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/general/browser_private_browsing_window.js')
-rw-r--r-- | browser/base/content/test/general/browser_private_browsing_window.js | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_private_browsing_window.js b/browser/base/content/test/general/browser_private_browsing_window.js new file mode 100644 index 0000000000..34a4c8bbf0 --- /dev/null +++ b/browser/base/content/test/general/browser_private_browsing_window.js @@ -0,0 +1,133 @@ +// 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" + ); + + 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(); + + [ + { + normal: "menu_newNavigator", + private: "menu_newPrivateWindow", + accesskey: true, + }, + { + normal: "appmenu_newNavigator", + private: "appmenu_newPrivateWindow", + accesskey: false, + }, + ].forEach(function (menu) { + let newWindow = privateWin.document.getElementById(menu.normal); + let newPrivateWindow = privateWin.document.getElementById(menu.private); + if (newWindow && newPrivateWindow) { + ok( + !newPrivateWindow.hidden, + "New Private Window menu item should be hidden" + ); + isnot( + newWindow.label, + newPrivateWindow.label, + "New Window's label shouldn't be overwritten" + ); + if (menu.accesskey) { + isnot( + newWindow.accessKey, + newPrivateWindow.accessKey, + "New Window's accessKey shouldn't be overwritten" + ); + } + isnot( + newWindow.command, + newPrivateWindow.command, + "New Window's command shouldn't be overwritten" + ); + } + }); + + is( + privateWin.gBrowser.tabs[0].label, + "New Private Tab", + "New tabs in the private browsing windows should have 'New Private Tab' as the title." + ); + + privateWin.close(); + + Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true); + privateWin = OpenBrowserWindow({ private: true }); + whenDelayedStartupFinished(privateWin, function () { + [ + { + normal: "menu_newNavigator", + private: "menu_newPrivateWindow", + accessKey: true, + }, + { + normal: "appmenu_newNavigator", + private: "appmenu_newPrivateWindow", + accessKey: false, + }, + ].forEach(function (menu) { + let newWindow = privateWin.document.getElementById(menu.normal); + let newPrivateWindow = privateWin.document.getElementById(menu.private); + if (newWindow && newPrivateWindow) { + ok( + newPrivateWindow.hidden, + "New Private Window menu item should be hidden" + ); + is( + newWindow.label, + newPrivateWindow.label, + "New Window's label should be overwritten" + ); + if (menu.accesskey) { + is( + newWindow.accessKey, + newPrivateWindow.accessKey, + "New Window's accessKey should be overwritten" + ); + } + is( + newWindow.command, + newPrivateWindow.command, + "New Window's command should be overwritten" + ); + } + }); + + is( + privateWin.gBrowser.tabs[0].label, + "New Tab", + "Normal tab title is used also in the permanent private browsing mode." + ); + privateWin.close(); + Services.prefs.clearUserPref("browser.privatebrowsing.autostart"); + finish(); + }); + }); +} |