summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_restore_session_in_undoCloseTab.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_restore_session_in_undoCloseTab.js
parentInitial commit. (diff)
downloadfirefox-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_session_in_undoCloseTab.js')
-rw-r--r--browser/components/sessionstore/test/browser_restore_session_in_undoCloseTab.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_restore_session_in_undoCloseTab.js b/browser/components/sessionstore/test/browser_restore_session_in_undoCloseTab.js
new file mode 100644
index 0000000000..a64f432eeb
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_restore_session_in_undoCloseTab.js
@@ -0,0 +1,56 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const { _LastSession } = ChromeUtils.importESModule(
+ "resource:///modules/sessionstore/SessionStore.sys.mjs"
+);
+
+/**
+ * Tests that if the user invokes undoCloseTab in a window for which there are no
+ * tabs to undo closing, that we attempt to restore the previous session if one
+ * exists.
+ */
+add_task(async function test_restore_session_in_undoCloseTab() {
+ forgetClosedTabs(window);
+ registerCleanupFunction(() => {
+ forgetClosedTabs(window);
+ });
+
+ const state = {
+ windows: [
+ {
+ tabs: [
+ {
+ entries: [
+ {
+ url: "https://example.org/",
+ triggeringPrincipal_base64,
+ },
+ ],
+ },
+ {
+ entries: [
+ {
+ url: "https://example.com/",
+ triggeringPrincipal_base64,
+ },
+ ],
+ },
+ ],
+ selected: 2,
+ },
+ ],
+ };
+
+ _LastSession.setState(state);
+
+ let sessionRestored = promiseSessionStoreLoads(2 /* total restored tabs */);
+ let result = undoCloseTab();
+ await sessionRestored;
+ Assert.equal(result, null);
+ Assert.equal(gBrowser.tabs.length, 2);
+
+ gBrowser.removeAllTabsBut(gBrowser.tabs[0]);
+});