browser_history_restore_session.js (1584B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 add_task(async function testRestoreSession() { 8 info("Check history panel's restore previous session button"); 9 10 let win = await BrowserTestUtils.openNewBrowserWindow(); 11 CustomizableUI.addWidgetToArea( 12 "history-panelmenu", 13 CustomizableUI.AREA_FIXED_OVERFLOW_PANEL 14 ); 15 registerCleanupFunction(() => CustomizableUI.reset()); 16 17 // We need to make sure the history is cleared before starting the test 18 await Sanitizer.sanitize(["history"]); 19 20 await openHistoryPanel(win.document); 21 22 let restorePrevSessionBtn = win.document.getElementById( 23 "appMenu-restoreSession" 24 ); 25 26 Assert.ok( 27 restorePrevSessionBtn.hidden, 28 "Restore previous session button is not visible" 29 ); 30 await hideHistoryPanel(win.document); 31 32 BrowserTestUtils.addTab(win.gBrowser, "about:mozilla"); 33 await BrowserTestUtils.closeWindow(win); 34 35 win = await BrowserTestUtils.openNewBrowserWindow(); 36 37 let lastSession = ChromeUtils.importESModule( 38 "resource:///modules/sessionstore/SessionStore.sys.mjs" 39 )._LastSession; 40 lastSession.setState(true); 41 42 await openHistoryPanel(win.document); 43 44 restorePrevSessionBtn = win.document.getElementById("appMenu-restoreSession"); 45 Assert.ok( 46 !restorePrevSessionBtn.hidden, 47 "Restore previous session button is visible" 48 ); 49 50 await hideHistoryPanel(win.document); 51 await BrowserTestUtils.closeWindow(win); 52 });