From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../browser_restore_session_in_undoCloseTab.js | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 browser/components/sessionstore/test/browser_restore_session_in_undoCloseTab.js (limited to 'browser/components/sessionstore/test/browser_restore_session_in_undoCloseTab.js') 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]); +}); -- cgit v1.2.3