1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_701377.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,41 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +let state = {windows:[{tabs:[ 1.8 + {entries:[{url:"http://example.com#1"}]}, 1.9 + {entries:[{url:"http://example.com#2"}], hidden: true} 1.10 +]}]}; 1.11 + 1.12 +function test() { 1.13 + waitForExplicitFinish(); 1.14 + 1.15 + newWindowWithState(state, function (aWindow) { 1.16 + let tab = aWindow.gBrowser.tabs[1]; 1.17 + ok(tab.hidden, "the second tab is hidden"); 1.18 + 1.19 + let tabShown = false; 1.20 + let tabShowCallback = function () tabShown = true; 1.21 + tab.addEventListener("TabShow", tabShowCallback, false); 1.22 + 1.23 + let tabState = ss.getTabState(tab); 1.24 + ss.setTabState(tab, tabState); 1.25 + 1.26 + tab.removeEventListener("TabShow", tabShowCallback, false); 1.27 + ok(tab.hidden && !tabShown, "tab remains hidden"); 1.28 + 1.29 + finish(); 1.30 + }); 1.31 +} 1.32 + 1.33 +// ---------- 1.34 +function newWindowWithState(aState, aCallback) { 1.35 + let opts = "chrome,all,dialog=no,height=800,width=800"; 1.36 + let win = window.openDialog(getBrowserURL(), "_blank", opts); 1.37 + 1.38 + registerCleanupFunction(function () win.close()); 1.39 + 1.40 + whenWindowLoaded(win, function onWindowLoaded(aWin) { 1.41 + ss.setWindowState(aWin, JSON.stringify(aState), true); 1.42 + executeSoon(function () aCallback(aWin)); 1.43 + }); 1.44 +}