browser_tab_groups_restore_simple.js (1798B)
1 "use strict"; 2 3 const ORIG_STATE = SessionStore.getBrowserState(); 4 5 registerCleanupFunction(async () => { 6 await SessionStoreTestUtils.promiseBrowserState(ORIG_STATE); 7 }); 8 9 add_task(async function test_RestoreSingleGroup() { 10 let win = await promiseNewWindowLoaded(); 11 let aboutRobotsTab = BrowserTestUtils.addTab(win.gBrowser, "about:robots"); 12 let aboutAboutTab = BrowserTestUtils.addTab(win.gBrowser, "about:about"); 13 const { id: originalTabGroupId } = win.gBrowser.addTabGroup( 14 [aboutRobotsTab, aboutAboutTab], 15 { 16 color: "blue", 17 label: "about pages", 18 } 19 ); 20 21 await TabStateFlusher.flushWindow(win); 22 await BrowserTestUtils.closeWindow(win); 23 24 // Now restore the window 25 win = SessionStore.undoCloseWindow(0); 26 await BrowserTestUtils.waitForEvent(win, "SSWindowStateReady"); 27 await BrowserTestUtils.waitForEvent( 28 win.gBrowser.tabContainer, 29 "SSTabRestored" 30 ); 31 32 Assert.equal( 33 win.gBrowser.tabs.length, 34 3, 35 "there should be 2 tabs restored + 1 initial tab from the new window" 36 ); 37 Assert.equal( 38 win.gBrowser.tabGroups.length, 39 1, 40 "there should be 1 tab group restored" 41 ); 42 43 let tabGroup = win.gBrowser.tabGroups[0]; 44 Assert.equal( 45 tabGroup.tabs.length, 46 2, 47 "the 2 restored tabs should be in the restored tab group" 48 ); 49 Assert.equal( 50 tabGroup.label, 51 "about pages", 52 "tab group name should be restored" 53 ); 54 Assert.equal( 55 tabGroup.id, 56 originalTabGroupId, 57 "tab group ID should be restored" 58 ); 59 Assert.equal(tabGroup.color, "blue", "tab group color should be restored"); 60 Assert.ok( 61 !tabGroup.collapsed, 62 "tab group collapsed state should be restored" 63 ); 64 65 await win.gBrowser.removeTabGroup(tabGroup); 66 await BrowserTestUtils.closeWindow(win); 67 forgetClosedWindows(); 68 });