From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/browser/browser_privatebrowsing_crh.js | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js (limited to 'browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js') diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js new file mode 100644 index 0000000000..b436e6e190 --- /dev/null +++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js @@ -0,0 +1,48 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// This test makes sure that the Clear Recent History menu item and command +// is disabled inside the private browsing mode. + +add_task(async function test() { + function checkDisableOption(aPrivateMode, aWindow) { + let crhCommand = aWindow.document.getElementById("Tools:Sanitize"); + ok(crhCommand, "The clear recent history command should exist"); + + is( + PrivateBrowsingUtils.isWindowPrivate(aWindow), + aPrivateMode, + "PrivateBrowsingUtils should report the correct per-window private browsing status" + ); + is( + crhCommand.hasAttribute("disabled"), + aPrivateMode, + "Clear Recent History command should be disabled according to the private browsing mode" + ); + } + + let testURI = "http://mochi.test:8888/"; + + let privateWin = await BrowserTestUtils.openNewBrowserWindow({ + private: true, + }); + let privateBrowser = privateWin.gBrowser.selectedBrowser; + BrowserTestUtils.loadURIString(privateBrowser, testURI); + await BrowserTestUtils.browserLoaded(privateBrowser); + + info("Test on private window"); + checkDisableOption(true, privateWin); + + let win = await BrowserTestUtils.openNewBrowserWindow(); + let browser = win.gBrowser.selectedBrowser; + BrowserTestUtils.loadURIString(browser, testURI); + await BrowserTestUtils.browserLoaded(browser); + + info("Test on public window"); + checkDisableOption(false, win); + + // Cleanup + await BrowserTestUtils.closeWindow(privateWin); + await BrowserTestUtils.closeWindow(win); +}); -- cgit v1.2.3