browser_588426.js (1519B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 function test() { 5 let state = { 6 windows: [ 7 { 8 tabs: [ 9 { 10 entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }], 11 hidden: true, 12 }, 13 { 14 entries: [{ url: "about:rights", triggeringPrincipal_base64 }], 15 hidden: true, 16 }, 17 ], 18 }, 19 ], 20 }; 21 22 waitForExplicitFinish(); 23 24 newWindowWithState(state, function (win) { 25 registerCleanupFunction(() => BrowserTestUtils.closeWindow(win)); 26 27 is(win.gBrowser.tabs.length, 2, "two tabs were restored"); 28 is(win.gBrowser.visibleTabs.length, 1, "one tab is visible"); 29 30 let tab = win.gBrowser.visibleTabs[0]; 31 is( 32 tab.linkedBrowser.currentURI.spec, 33 "about:mozilla", 34 "visible tab is about:mozilla" 35 ); 36 37 finish(); 38 }); 39 } 40 41 function newWindowWithState(state, callback) { 42 let opts = "chrome,all,dialog=no,height=800,width=800"; 43 let win = window.openDialog(AppConstants.BROWSER_CHROME_URL, "_blank", opts); 44 45 win.addEventListener( 46 "load", 47 function () { 48 executeSoon(function () { 49 win.addEventListener( 50 "SSWindowStateReady", 51 function () { 52 promiseTabRestored(win.gBrowser.tabs[0]).then(() => callback(win)); 53 }, 54 { once: true } 55 ); 56 57 ss.setWindowState(win, JSON.stringify(state), true); 58 }); 59 }, 60 { once: true } 61 ); 62 }