browser_705597.js (1984B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 /* eslint-disable mozilla/no-arbitrary-setTimeout */ 4 5 const tabState = { 6 entries: [ 7 { 8 url: "about:robots", 9 triggeringPrincipal_base64, 10 children: [{ url: "about:mozilla", triggeringPrincipal_base64 }], 11 }, 12 ], 13 }; 14 15 const blankState = { 16 windows: [ 17 { 18 tabs: [ 19 { 20 entries: [{ url: "about:blank", triggeringPrincipal_base64 }], 21 }, 22 ], 23 }, 24 ], 25 }; 26 27 add_task(async function test() { 28 Services.prefs.setIntPref("browser.sessionstore.interval", 4000); 29 registerCleanupFunction(function () { 30 Services.prefs.clearUserPref("browser.sessionstore.interval"); 31 }); 32 33 let tab = BrowserTestUtils.addTab(gBrowser, "about:blank"); 34 let browser = tab.linkedBrowser; 35 await BrowserTestUtils.browserLoaded(browser, false, "about:blank"); 36 37 await promiseTabState(tab, tabState); 38 let sessionHistory = browser.browsingContext.sessionHistory; 39 let entry = sessionHistory.getEntryAtIndex(0); 40 41 await whenChildCount(entry, 1); 42 43 // Create a dynamic subframe. 44 let doc = browser.contentDocument; 45 let iframe = doc.createElement("iframe"); 46 iframe.setAttribute("src", "about:mozilla"); 47 doc.body.appendChild(iframe); 48 49 await whenChildCount(entry, 2); 50 51 // Force reload the browser to discard the subframes. 52 browser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE); 53 54 await BrowserTestUtils.browserLoaded(browser, false, "about:robots"); 55 await TabStateFlusher.flush(browser); 56 57 let { entries } = JSON.parse(ss.getTabState(tab)); 58 is(entries.length, 1, "tab has one history entry"); 59 ok(!entries[0].children, "history entry has no subframes"); 60 61 // Make sure that we reset the state. 62 waitForBrowserState(blankState, finish); 63 }); 64 65 function whenChildCount(aEntry, aChildCount) { 66 return TestUtils.waitForCondition( 67 () => aEntry.childCount == aChildCount, 68 "wait for child count" 69 ); 70 }