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 /browser/base/content/test/general/browser_tab_detach_restore.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 '')
-rw-r--r-- | browser/base/content/test/general/browser_tab_detach_restore.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_tab_detach_restore.js b/browser/base/content/test/general/browser_tab_detach_restore.js new file mode 100644 index 0000000000..405e4509b4 --- /dev/null +++ b/browser/base/content/test/general/browser_tab_detach_restore.js @@ -0,0 +1,54 @@ +"use strict"; + +const { TabStateFlusher } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/TabStateFlusher.sys.mjs" +); + +add_task(async function () { + let uri = + // eslint-disable-next-line @microsoft/sdl/no-insecure-url + "http://example.com/browser/browser/base/content/test/general/dummy_page.html"; + + // Clear out the closed windows set to start + while (SessionStore.getClosedWindowCount() > 0) { + SessionStore.forgetClosedWindow(0); + } + + let tab = BrowserTestUtils.addTab(gBrowser); + BrowserTestUtils.startLoadingURIString(tab.linkedBrowser, uri); + await BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, uri); + await TabStateFlusher.flush(tab.linkedBrowser); + + let key = tab.linkedBrowser.permanentKey; + let win = gBrowser.replaceTabWithWindow(tab); + await new Promise(resolve => whenDelayedStartupFinished(win, resolve)); + + is( + win.gBrowser.selectedBrowser.permanentKey, + key, + "Should have properly copied the permanentKey" + ); + await BrowserTestUtils.closeWindow(win); + + is( + SessionStore.getClosedWindowCount(), + 1, + "Should have restore data for the closed window" + ); + + win = SessionStore.undoCloseWindow(0); + await BrowserTestUtils.waitForEvent(win, "load"); + await BrowserTestUtils.waitForEvent( + win.gBrowser.tabContainer, + "SSTabRestored" + ); + + is(win.gBrowser.tabs.length, 1, "Should have restored one tab"); + is( + win.gBrowser.selectedBrowser.currentURI.spec, + uri, + "Should have restored the right page" + ); + + await promiseWindowClosed(win); +}); |