browser_pending_tabs.js (1196B)
1 "use strict"; 2 3 const TAB_STATE = { 4 entries: [ 5 { url: "about:mozilla", triggeringPrincipal_base64 }, 6 { url: "about:robots", triggeringPrincipal_base64 }, 7 ], 8 index: 1, 9 }; 10 11 add_task(async function () { 12 // Create a background tab. 13 let tab = BrowserTestUtils.addTab(gBrowser, "about:blank"); 14 let browser = tab.linkedBrowser; 15 await BrowserTestUtils.browserLoaded(browser, { wantLoad: "about:blank" }); 16 17 // The tab shouldn't be restored right away. 18 Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true); 19 20 // Prepare the tab state. 21 let promise = promiseTabRestoring(tab); 22 ss.setTabState(tab, JSON.stringify(TAB_STATE)); 23 ok(tab.hasAttribute("pending"), "tab is pending"); 24 await promise; 25 26 // Flush to ensure the parent has all data. 27 await TabStateFlusher.flush(browser); 28 29 // Check that the shistory index is the one we restored. 30 let tabState = TabState.collect(tab, ss.getInternalObjectState(tab)); 31 is(tabState.index, TAB_STATE.index, "correct shistory index"); 32 33 // Check we don't collect userTypedValue when we shouldn't. 34 ok(!tabState.userTypedValue, "tab didn't have a userTypedValue"); 35 36 // Cleanup. 37 gBrowser.removeTab(tab); 38 });