diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/sessionstore/test/browser_restore_tabless_window.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/sessionstore/test/browser_restore_tabless_window.js')
-rw-r--r-- | browser/components/sessionstore/test/browser_restore_tabless_window.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_restore_tabless_window.js b/browser/components/sessionstore/test/browser_restore_tabless_window.js new file mode 100644 index 0000000000..cffb2159f5 --- /dev/null +++ b/browser/components/sessionstore/test/browser_restore_tabless_window.js @@ -0,0 +1,56 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * It's possible for us to restore windows without tabs, + * when on Windows/Linux the user closes the last tab as + * a means of closing the last window. That last tab + * would appear as a closed tab in session state for the + * window, with no open tabs (so the state would be resumed + * as showing the homepage). See bug 490136 for context. + * This test checks that in this case, the resulting window + * is functional and indeed has the required previously + * closed tabs available. + */ +add_task(async function test_restoring_tabless_window() { + let newWin = await BrowserTestUtils.openNewBrowserWindow(); + let newState = { + windows: [ + { + tabs: [], + _closedTabs: [ + { + state: { entries: [{ url: "about:" }] }, + title: "About:", + }, + ], + }, + ], + }; + + await setWindowState(newWin, newState, true); + let tab = await BrowserTestUtils.openNewForegroundTab( + newWin.gBrowser, + "https://example.com" + ); + await TabStateFlusher.flush(tab.linkedBrowser); + let receivedState = SessionStore.getWindowState(newWin); + let { tabs, selected } = receivedState.windows[0]; + is(tabs.length, 2, "Should have two tabs"); + is(selected, 2, "Should have selected the new tab"); + ok( + tabs[1]?.entries.some(e => e.url == "https://example.com/"), + "Should have found the new URL" + ); + + let closedTabData = SessionStore.getClosedTabDataForWindow(newWin); + is(closedTabData.length, 1, "Should have found 1 closed tab"); + is( + closedTabData[0]?.state.entries[0].url, + "about:", + "Should have found the right URL for the closed tab" + ); + await BrowserTestUtils.closeWindow(newWin); +}); |