summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_394759_perwindowpb.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/components/sessionstore/test/browser_394759_perwindowpb.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/sessionstore/test/browser_394759_perwindowpb.js')
-rw-r--r--browser/components/sessionstore/test/browser_394759_perwindowpb.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_394759_perwindowpb.js b/browser/components/sessionstore/test/browser_394759_perwindowpb.js
new file mode 100644
index 0000000000..ef4125e231
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_394759_perwindowpb.js
@@ -0,0 +1,59 @@
+/* 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/. */
+
+"use strict";
+
+const TESTS = [
+ { url: "about:config", key: "bug 394759 Non-PB", value: "uniq" + r() },
+ { url: "about:mozilla", key: "bug 394759 PB", value: "uniq" + r() },
+];
+
+function promiseTestOpenCloseWindow(aIsPrivate, aTest) {
+ return (async function() {
+ let win = await BrowserTestUtils.openNewBrowserWindow({
+ private: aIsPrivate,
+ });
+ BrowserTestUtils.loadURI(win.gBrowser.selectedBrowser, aTest.url);
+ await promiseBrowserLoaded(win.gBrowser.selectedBrowser, true, aTest.url);
+ // Mark the window with some unique data to be restored later on.
+ ss.setCustomWindowValue(win, aTest.key, aTest.value);
+ await TabStateFlusher.flushWindow(win);
+ // Close.
+ await BrowserTestUtils.closeWindow(win);
+ })();
+}
+
+function promiseTestOnWindow(aIsPrivate, aValue) {
+ return (async function() {
+ let win = await BrowserTestUtils.openNewBrowserWindow({
+ private: aIsPrivate,
+ });
+ await TabStateFlusher.flushWindow(win);
+ let data = ss.getClosedWindowData()[0];
+ is(
+ ss.getClosedWindowCount(),
+ 1,
+ "Check that the closed window count hasn't changed"
+ );
+ ok(
+ JSON.stringify(data).indexOf(aValue) > -1,
+ "Check the closed window data was stored correctly"
+ );
+ registerCleanupFunction(() => BrowserTestUtils.closeWindow(win));
+ })();
+}
+
+add_setup(async function() {
+ forgetClosedWindows();
+ while (ss.getClosedTabCount(window) > 0) {
+ ss.forgetClosedTab(window, 0);
+ }
+});
+
+add_task(async function main() {
+ await promiseTestOpenCloseWindow(false, TESTS[0]);
+ await promiseTestOpenCloseWindow(true, TESTS[1]);
+ await promiseTestOnWindow(false, TESTS[0].value);
+ await promiseTestOnWindow(true, TESTS[0].value);
+});