diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js')
-rw-r--r-- | toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js b/toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js new file mode 100644 index 0000000000..3abc6ebe54 --- /dev/null +++ b/toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js @@ -0,0 +1,49 @@ +/* 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/. */ + +var { FormHistory } = ChromeUtils.importESModule( + "resource://gre/modules/FormHistory.sys.mjs" +); + +/** Test for Bug 472396 */ +add_task(async function test() { + // initialization + let windowsToClose = []; + let testURI = + "http://example.com/tests/toolkit/components/satchel/test/subtst_privbrowsing.html"; + + async function doTest(aShouldValueExist, aWindow) { + let browser = aWindow.gBrowser.selectedBrowser; + BrowserTestUtils.startLoadingURIString(browser, testURI); + await BrowserTestUtils.browserLoaded(browser); + + // Wait for the page to reload itself. + await BrowserTestUtils.browserLoaded(browser); + + let count = await FormHistory.count({ fieldname: "field", value: "value" }); + + if (aShouldValueExist) { + Assert.equal(count, 1, "In non-PB mode, we add a single entry"); + } else { + Assert.equal(count, 0, "In PB mode, we don't add any entries"); + } + } + + function testOnWindow(aOptions, aCallback) { + return BrowserTestUtils.openNewBrowserWindow(aOptions).then(win => { + windowsToClose.push(win); + return win; + }); + } + + await testOnWindow({ private: true }).then(aWin => doTest(false, aWin)); + + // Test when not on private mode after visiting a site on private + // mode. The form history should not exist. + await testOnWindow({}).then(aWin => doTest(true, aWin)); + + await Promise.all( + windowsToClose.map(win => BrowserTestUtils.closeWindow(win)) + ); +}); |