browser_restore_pageProxyState.js (2125B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 const BACKUP_STATE = SessionStore.getBrowserState(); 5 registerCleanupFunction(() => promiseBrowserState(BACKUP_STATE)); 6 7 // The pageproxystate of the restored tab controls whether the identity 8 // information in the URL bar will display correctly. See bug 1766951 for more 9 // context. 10 async function test_pageProxyState(url1, url2) { 11 info(`urls: "${url1}", "${url2}"`); 12 13 await SpecialPowers.pushPrefEnv({ 14 set: [ 15 ["browser.sessionstore.restore_on_demand", true], 16 ["browser.sessionstore.restore_tabs_lazily", true], 17 ], 18 }); 19 20 await promiseBrowserState({ 21 windows: [ 22 { 23 tabs: [ 24 { 25 entries: [ 26 { 27 url: url1, 28 triggeringPrincipal_base64, 29 }, 30 ], 31 }, 32 { 33 entries: [ 34 { 35 url: url2, 36 triggeringPrincipal_base64, 37 }, 38 ], 39 }, 40 ], 41 selected: 1, 42 }, 43 ], 44 }); 45 46 // The first tab isn't lazy and should be initialized. 47 ok(gBrowser.tabs[0].linkedPanel, "first tab is not lazy"); 48 is(gBrowser.selectedTab, gBrowser.tabs[0], "first tab is selected"); 49 is(gBrowser.userTypedValue, null, "no user typed value"); 50 is( 51 gURLBar.getAttribute("pageproxystate"), 52 "valid", 53 "has valid page proxy state" 54 ); 55 56 // The second tab is lazy until selected. 57 ok(!gBrowser.tabs[1].linkedPanel, "second tab should be lazy"); 58 gBrowser.selectedTab = gBrowser.tabs[1]; 59 await promiseTabRestored(gBrowser.tabs[1]); 60 is(gBrowser.userTypedValue, null, "no user typed value"); 61 is( 62 gURLBar.getAttribute("pageproxystate"), 63 "valid", 64 "has valid page proxy state" 65 ); 66 } 67 68 add_task(async function test_system() { 69 await test_pageProxyState("about:support", "about:addons"); 70 }); 71 72 add_task(async function test_http() { 73 await test_pageProxyState( 74 "https://example.com/document-builder.sjs?html=tab1", 75 "https://example.com/document-builder.sjs?html=tab2" 76 ); 77 });