1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug589324.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +const DUMMY_PAGE_URL = "http://mochi.test:8888/browser/browser/components/tabview/test/dummy_page.html"; 1.8 +const DUMMY_PAGE_URL_2 = "http://mochi.test:8888/"; 1.9 + 1.10 +let state = { 1.11 + windows: [{ 1.12 + tabs: [{ 1.13 + entries: [{ url: DUMMY_PAGE_URL }], 1.14 + hidden: true, 1.15 + attributes: {}, 1.16 + extData: { 1.17 + "tabview-tab": 1.18 + '{"bounds":{"left":21,"top":29,"width":204,"height":153},' + 1.19 + '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":1,' + 1.20 + '"imageData":null,"title":null}' 1.21 + } 1.22 + },{ 1.23 + entries: [{ url: DUMMY_PAGE_URL_2 }], 1.24 + hidden: false, 1.25 + attributes: {}, 1.26 + extData: { 1.27 + "tabview-tab": 1.28 + '{"bounds":{"left":315,"top":29,"width":111,"height":84},' + 1.29 + '"userSize":null,"url":"' + DUMMY_PAGE_URL_2 + '","groupID":2,' + 1.30 + '"imageData":null,"title":null}' 1.31 + }, 1.32 + }], 1.33 + selected:2, 1.34 + _closedTabs: [], 1.35 + extData: { 1.36 + "tabview-groups": '{"nextID":3,"activeGroupId":2}', 1.37 + "tabview-group": 1.38 + '{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},' + 1.39 + '"userSize":null,"title":"","id":1},' + 1.40 + '"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},' + 1.41 + '"userSize":null,"title":"","id":2}}', 1.42 + "tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":788,"height":548}}' 1.43 + }, sizemode:"normal" 1.44 + }] 1.45 +}; 1.46 + 1.47 +function test() { 1.48 + waitForExplicitFinish(); 1.49 + 1.50 + registerCleanupFunction(function () { 1.51 + Services.prefs.clearUserPref("browser.sessionstore.restore_hidden_tabs"); 1.52 + }); 1.53 + 1.54 + Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", false); 1.55 + 1.56 + testTabSwitchAfterRestore(function () { 1.57 + Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", true); 1.58 + testTabSwitchAfterRestore(finish); 1.59 + }); 1.60 +} 1.61 + 1.62 +function testTabSwitchAfterRestore(callback) { 1.63 + newWindowWithState(state, function (win) { 1.64 + registerCleanupFunction(function () win.close()); 1.65 + 1.66 + let [firstTab, secondTab] = win.gBrowser.tabs; 1.67 + is(firstTab.linkedBrowser.currentURI.spec, DUMMY_PAGE_URL, 1.68 + "The url of first tab url is dummy_page.html"); 1.69 + 1.70 + // check the hidden state of both tabs. 1.71 + ok(firstTab.hidden, "The first tab is hidden"); 1.72 + ok(!secondTab.hidden, "The second tab is not hidden"); 1.73 + is(secondTab, win.gBrowser.selectedTab, "The second tab is selected"); 1.74 + 1.75 + // when the second tab is hidden, Panorama should be initialized and 1.76 + // the first tab should be visible. 1.77 + let container = win.gBrowser.tabContainer; 1.78 + container.addEventListener("TabHide", function onTabHide() { 1.79 + container.removeEventListener("TabHide", onTabHide, false); 1.80 + 1.81 + ok(win.TabView.getContentWindow(), "Panorama is loaded"); 1.82 + ok(!firstTab.hidden, "The first tab is not hidden"); 1.83 + is(firstTab, win.gBrowser.selectedTab, "The first tab is selected"); 1.84 + ok(secondTab.hidden, "The second tab is hidden"); 1.85 + 1.86 + callback(); 1.87 + }, false); 1.88 + 1.89 + // switch to another tab 1.90 + win.switchToTabHavingURI(DUMMY_PAGE_URL); 1.91 + }); 1.92 +}