browser_367052.js (1611B)
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 () { 8 // make sure that the next closed tab will increase getClosedTabCountForWindow 9 let max_tabs_undo = Services.prefs.getIntPref( 10 "browser.sessionstore.max_tabs_undo" 11 ); 12 Services.prefs.setIntPref( 13 "browser.sessionstore.max_tabs_undo", 14 max_tabs_undo + 1 15 ); 16 registerCleanupFunction(() => 17 Services.prefs.clearUserPref("browser.sessionstore.max_tabs_undo") 18 ); 19 20 forgetClosedTabs(window); 21 22 // restore a blank tab 23 let tab = BrowserTestUtils.addTab(gBrowser, "about:mozilla"); 24 await promiseBrowserLoaded(tab.linkedBrowser); 25 26 let count = await promiseSHistoryCount(tab.linkedBrowser); 27 Assert.greaterOrEqual( 28 count, 29 1, 30 "the new tab does have at least one history entry" 31 ); 32 33 await promiseTabState(tab, { entries: [] }); 34 35 // We may have a different sessionHistory object if the tab 36 // switched from non-remote to remote. 37 count = await promiseSHistoryCount(tab.linkedBrowser); 38 is(count, 0, "the tab was restored without any history whatsoever"); 39 40 await promiseRemoveTabAndSessionState(tab); 41 is( 42 ss.getClosedTabCountForWindow(window), 43 0, 44 "The closed blank tab wasn't added to Recently Closed Tabs" 45 ); 46 }); 47 48 function promiseSHistoryCount(browser) { 49 return SpecialPowers.spawn(browser, [], async function () { 50 return docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory.count; 51 }); 52 }