summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_userTyped_restored_after_discard.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_userTyped_restored_after_discard.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.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_userTyped_restored_after_discard.js')
-rw-r--r--browser/components/sessionstore/test/browser_userTyped_restored_after_discard.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_userTyped_restored_after_discard.js b/browser/components/sessionstore/test/browser_userTyped_restored_after_discard.js
new file mode 100644
index 0000000000..171197a743
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_userTyped_restored_after_discard.js
@@ -0,0 +1,47 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+add_task(async function testDiscardWithNotLoadedUserTypedValue() {
+ let tab1 = await BrowserTestUtils.openNewForegroundTab(
+ gBrowser,
+ "https://example.com"
+ );
+
+ // Make sure we flushed the state at least once (otherwise the fix
+ // for Bug 1422588 would make SessionStore.resetBrowserToLazyState
+ // to still store the user typed value into the tab state cache
+ // even when the user typed value was not yet being loading when
+ // the tab got discarded).
+ await TabStateFlusher.flush(tab1.linkedBrowser);
+
+ tab1.linkedBrowser.userTypedValue = "mockUserTypedValue";
+
+ let tab2 = await BrowserTestUtils.openNewForegroundTab(
+ gBrowser,
+ "about:robots"
+ );
+
+ let waitForTabDiscarded = BrowserTestUtils.waitForEvent(
+ tab1,
+ "TabBrowserDiscarded"
+ );
+ gBrowser.discardBrowser(tab1);
+ await waitForTabDiscarded;
+
+ const promiseTabLoaded = BrowserTestUtils.browserLoaded(
+ tab1.linkedBrowser,
+ false,
+ "https://example.com/"
+ );
+ await BrowserTestUtils.switchTab(gBrowser, tab1);
+ info("Wait for the restored tab to load https://example.com");
+ await promiseTabLoaded;
+ is(
+ tab1.linkedBrowser.currentURI.spec,
+ "https://example.com/",
+ "Restored discarded tab has loaded the expected url"
+ );
+
+ BrowserTestUtils.removeTab(tab2);
+ BrowserTestUtils.removeTab(tab1);
+});