fix: Fixed restoring tabs after restoring windows, b=bug #8699, c=workspaces, tests

This commit is contained in:
Mr. M
2025-06-07 20:35:08 +02:00
parent 10592ed243
commit ebd1910bb8
5 changed files with 119 additions and 45 deletions

View File

@@ -8,5 +8,7 @@ support-files = [
["browser_double_click_newtab.js"]
["browser_overflow_scrollbox.js"]
["browser_issue_8699.js"]
["browser_private_mode.js"]
["browser_private_mode_startup.js"]

View File

@@ -0,0 +1,47 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
add_task(async function test_Restore_Closed_Tabs() {
const currentTab = gBrowser.selectedTab;
const tabsToClose = [];
for (let i = 0; i < 3; i++) {
const tab = await BrowserTestUtils.openNewForegroundTab(
window.gBrowser,
`https://example.com/${i}`,
true,
{ skipAnimation: true }
);
tabsToClose.push(tab);
}
gBrowser.selectedTab = tabsToClose[0];
await TabStateFlusher.flushWindow(window);
Assert.equal(
gBrowser.tabs.length,
5, // 1 initial tab + 3 new tabs
'There should be four tabs after opening three new tabs'
);
gBrowser.removeTabs(tabsToClose);
await TabStateFlusher.flushWindow(window);
await new Promise((resolve) => {
Assert.equal(
gBrowser.selectedTab,
currentTab,
'Current tab should still be selected after closing tabs'
);
Assert.equal(gBrowser.tabs.length, 2, 'There should be one tab left after closing all tabs');
restoreLastClosedTabOrWindowOrSession();
ok(!currentTab.selected, 'Current tab should not be selected after restore');
Assert.equal(
gBrowser.tabs.length,
5, // 1 initial tab + 3 restored tabs
'There should be four tabs after restoring closed tabs'
);
gBrowser.selectedTab = currentTab;
resolve();
});
for (const tab of gBrowser.tabs.filter((t) => t !== currentTab)) {
await BrowserTestUtils.removeTab(tab);
}
});

View File

@@ -12,7 +12,7 @@ add_task(async function test_Private_Mode_Startup() {
setTimeout(() => {
Assert.equal(
privateWindow.gBrowser.tabs.length,
1,
2,
'Private window should start with one tab'
);
resolve();