michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const DUMMY_PAGE_URL = "http://mochi.test:8888/browser/browser/components/tabview/test/dummy_page.html"; michael@0: const DUMMY_PAGE_URL_2 = "http://mochi.test:8888/"; michael@0: michael@0: let state = { michael@0: windows: [{ michael@0: tabs: [{ michael@0: entries: [{ url: DUMMY_PAGE_URL }], michael@0: hidden: true, michael@0: attributes: {}, michael@0: extData: { michael@0: "tabview-tab": michael@0: '{"bounds":{"left":21,"top":29,"width":204,"height":153},' + michael@0: '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":1,' + michael@0: '"imageData":null,"title":null}' michael@0: } michael@0: },{ michael@0: entries: [{ url: DUMMY_PAGE_URL_2 }], michael@0: hidden: false, michael@0: attributes: {}, michael@0: extData: { michael@0: "tabview-tab": michael@0: '{"bounds":{"left":315,"top":29,"width":111,"height":84},' + michael@0: '"userSize":null,"url":"' + DUMMY_PAGE_URL_2 + '","groupID":2,' + michael@0: '"imageData":null,"title":null}' michael@0: }, michael@0: }], michael@0: selected:2, michael@0: _closedTabs: [], michael@0: extData: { michael@0: "tabview-groups": '{"nextID":3,"activeGroupId":2}', michael@0: "tabview-group": michael@0: '{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},' + michael@0: '"userSize":null,"title":"","id":1},' + michael@0: '"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},' + michael@0: '"userSize":null,"title":"","id":2}}', michael@0: "tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":788,"height":548}}' michael@0: }, sizemode:"normal" michael@0: }] michael@0: }; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: registerCleanupFunction(function () { michael@0: Services.prefs.clearUserPref("browser.sessionstore.restore_hidden_tabs"); michael@0: }); michael@0: michael@0: Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", false); michael@0: michael@0: testTabSwitchAfterRestore(function () { michael@0: Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", true); michael@0: testTabSwitchAfterRestore(finish); michael@0: }); michael@0: } michael@0: michael@0: function testTabSwitchAfterRestore(callback) { michael@0: newWindowWithState(state, function (win) { michael@0: registerCleanupFunction(function () win.close()); michael@0: michael@0: let [firstTab, secondTab] = win.gBrowser.tabs; michael@0: is(firstTab.linkedBrowser.currentURI.spec, DUMMY_PAGE_URL, michael@0: "The url of first tab url is dummy_page.html"); michael@0: michael@0: // check the hidden state of both tabs. michael@0: ok(firstTab.hidden, "The first tab is hidden"); michael@0: ok(!secondTab.hidden, "The second tab is not hidden"); michael@0: is(secondTab, win.gBrowser.selectedTab, "The second tab is selected"); michael@0: michael@0: // when the second tab is hidden, Panorama should be initialized and michael@0: // the first tab should be visible. michael@0: let container = win.gBrowser.tabContainer; michael@0: container.addEventListener("TabHide", function onTabHide() { michael@0: container.removeEventListener("TabHide", onTabHide, false); michael@0: michael@0: ok(win.TabView.getContentWindow(), "Panorama is loaded"); michael@0: ok(!firstTab.hidden, "The first tab is not hidden"); michael@0: is(firstTab, win.gBrowser.selectedTab, "The first tab is selected"); michael@0: ok(secondTab.hidden, "The second tab is hidden"); michael@0: michael@0: callback(); michael@0: }, false); michael@0: michael@0: // switch to another tab michael@0: win.switchToTabHavingURI(DUMMY_PAGE_URL); michael@0: }); michael@0: }