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_615394-SSWindowState_events_undoCloseTab.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_615394-SSWindowState_events_undoCloseTab.js')
-rw-r--r-- | browser/components/sessionstore/test/browser_615394-SSWindowState_events_undoCloseTab.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_615394-SSWindowState_events_undoCloseTab.js b/browser/components/sessionstore/test/browser_615394-SSWindowState_events_undoCloseTab.js new file mode 100644 index 0000000000..345bba516c --- /dev/null +++ b/browser/components/sessionstore/test/browser_615394-SSWindowState_events_undoCloseTab.js @@ -0,0 +1,65 @@ +"use strict"; + +const testState = { + windows: [ + { + tabs: [ + { entries: [{ url: "about:blank", triggeringPrincipal_base64 }] }, + { entries: [{ url: "about:rights", triggeringPrincipal_base64 }] }, + ], + }, + ], +}; + +// Test for Bug 615394 - Session Restore should notify when it is beginning and +// ending a restore. +add_task(async function test_undoCloseTab() { + await promiseBrowserState(testState); + + let tab = gBrowser.tabs[1]; + let busyEventCount = 0; + let readyEventCount = 0; + // This will be set inside the `onSSWindowStateReady` method. + let lastTab; + + ss.setCustomTabValue(tab, "foo", "bar"); + + function onSSWindowStateBusy(aEvent) { + busyEventCount++; + } + + function onSSWindowStateReady(aEvent) { + Assert.equal(gBrowser.tabs.length, 2, "Should only have 2 tabs"); + lastTab = gBrowser.tabs[1]; + readyEventCount++; + Assert.equal(ss.getCustomTabValue(lastTab, "foo"), "bar"); + ss.setCustomTabValue(lastTab, "baz", "qux"); + } + + window.addEventListener("SSWindowStateBusy", onSSWindowStateBusy); + window.addEventListener("SSWindowStateReady", onSSWindowStateReady); + + let restoredPromise = BrowserTestUtils.waitForEvent( + gBrowser.tabContainer, + "SSTabRestored" + ); + + await promiseRemoveTabAndSessionState(tab); + let reopenedTab = ss.undoCloseTab(window, 0); + + await Promise.all([ + restoredPromise, + BrowserTestUtils.browserLoaded(reopenedTab.linkedBrowser), + ]); + + Assert.equal(reopenedTab, lastTab, "Tabs should be the same one."); + Assert.equal(busyEventCount, 1); + Assert.equal(readyEventCount, 1); + Assert.equal(ss.getCustomTabValue(reopenedTab, "baz"), "qux"); + Assert.equal(reopenedTab.linkedBrowser.currentURI.spec, "about:rights"); + + window.removeEventListener("SSWindowStateBusy", onSSWindowStateBusy); + window.removeEventListener("SSWindowStateReady", onSSWindowStateReady); + + BrowserTestUtils.removeTab(reopenedTab); +}); |