summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_705597.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/sessionstore/test/browser_705597.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/sessionstore/test/browser_705597.js')
-rw-r--r--browser/components/sessionstore/test/browser_705597.js85
1 files changed, 85 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_705597.js b/browser/components/sessionstore/test/browser_705597.js
new file mode 100644
index 0000000000..d497e46a97
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_705597.js
@@ -0,0 +1,85 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
+
+var tabState = {
+ entries: [
+ {
+ url: "about:robots",
+ triggeringPrincipal_base64,
+ children: [{ url: "about:mozilla", triggeringPrincipal_base64 }],
+ },
+ ],
+};
+
+function test() {
+ waitForExplicitFinish();
+ requestLongerTimeout(2);
+
+ Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
+ registerCleanupFunction(function () {
+ Services.prefs.clearUserPref("browser.sessionstore.interval");
+ });
+
+ let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
+
+ let browser = tab.linkedBrowser;
+
+ promiseTabState(tab, tabState).then(() => {
+ let entry;
+ if (!Services.appinfo.sessionHistoryInParent) {
+ let sessionHistory = browser.sessionHistory;
+ entry = sessionHistory.legacySHistory.getEntryAtIndex(0);
+ } else {
+ let sessionHistory = browser.browsingContext.sessionHistory;
+ entry = sessionHistory.getEntryAtIndex(0);
+ }
+
+ whenChildCount(entry, 1, function () {
+ whenChildCount(entry, 2, function () {
+ promiseBrowserLoaded(browser)
+ .then(() => {
+ return TabStateFlusher.flush(browser);
+ })
+ .then(() => {
+ let { entries } = JSON.parse(ss.getTabState(tab));
+ is(entries.length, 1, "tab has one history entry");
+ ok(!entries[0].children, "history entry has no subframes");
+
+ // Make sure that we reset the state.
+ let blankState = {
+ windows: [
+ {
+ tabs: [
+ {
+ entries: [
+ { url: "about:blank", triggeringPrincipal_base64 },
+ ],
+ },
+ ],
+ },
+ ],
+ };
+ waitForBrowserState(blankState, finish);
+ });
+
+ // Force reload the browser to deprecate the subframes.
+ browser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
+ });
+
+ // Create a dynamic subframe.
+ let doc = browser.contentDocument;
+ let iframe = doc.createElement("iframe");
+ doc.body.appendChild(iframe);
+ iframe.setAttribute("src", "about:mozilla");
+ });
+ });
+}
+
+function whenChildCount(aEntry, aChildCount, aCallback) {
+ if (aEntry.childCount == aChildCount) {
+ aCallback();
+ } else {
+ setTimeout(() => whenChildCount(aEntry, aChildCount, aCallback), 100);
+ }
+}