|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 const DUMMY_PAGE_URL = "http://mochi.test:8888/browser/browser/components/tabview/test/dummy_page.html"; |
|
5 const DUMMY_PAGE_URL_2 = "http://mochi.test:8888/"; |
|
6 |
|
7 let state = { |
|
8 windows: [{ |
|
9 tabs: [{ |
|
10 entries: [{ url: DUMMY_PAGE_URL }], |
|
11 hidden: true, |
|
12 attributes: {}, |
|
13 extData: { |
|
14 "tabview-tab": |
|
15 '{"bounds":{"left":21,"top":29,"width":204,"height":153},' + |
|
16 '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":1,' + |
|
17 '"imageData":null,"title":null}' |
|
18 } |
|
19 },{ |
|
20 entries: [{ url: DUMMY_PAGE_URL_2 }], |
|
21 hidden: false, |
|
22 attributes: {}, |
|
23 extData: { |
|
24 "tabview-tab": |
|
25 '{"bounds":{"left":315,"top":29,"width":111,"height":84},' + |
|
26 '"userSize":null,"url":"' + DUMMY_PAGE_URL_2 + '","groupID":2,' + |
|
27 '"imageData":null,"title":null}' |
|
28 }, |
|
29 }], |
|
30 selected:2, |
|
31 _closedTabs: [], |
|
32 extData: { |
|
33 "tabview-groups": '{"nextID":3,"activeGroupId":2}', |
|
34 "tabview-group": |
|
35 '{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},' + |
|
36 '"userSize":null,"title":"","id":1},' + |
|
37 '"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},' + |
|
38 '"userSize":null,"title":"","id":2}}', |
|
39 "tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":788,"height":548}}' |
|
40 }, sizemode:"normal" |
|
41 }] |
|
42 }; |
|
43 |
|
44 function test() { |
|
45 waitForExplicitFinish(); |
|
46 |
|
47 registerCleanupFunction(function () { |
|
48 Services.prefs.clearUserPref("browser.sessionstore.restore_hidden_tabs"); |
|
49 }); |
|
50 |
|
51 Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", false); |
|
52 |
|
53 testTabSwitchAfterRestore(function () { |
|
54 Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", true); |
|
55 testTabSwitchAfterRestore(finish); |
|
56 }); |
|
57 } |
|
58 |
|
59 function testTabSwitchAfterRestore(callback) { |
|
60 newWindowWithState(state, function (win) { |
|
61 registerCleanupFunction(function () win.close()); |
|
62 |
|
63 let [firstTab, secondTab] = win.gBrowser.tabs; |
|
64 is(firstTab.linkedBrowser.currentURI.spec, DUMMY_PAGE_URL, |
|
65 "The url of first tab url is dummy_page.html"); |
|
66 |
|
67 // check the hidden state of both tabs. |
|
68 ok(firstTab.hidden, "The first tab is hidden"); |
|
69 ok(!secondTab.hidden, "The second tab is not hidden"); |
|
70 is(secondTab, win.gBrowser.selectedTab, "The second tab is selected"); |
|
71 |
|
72 // when the second tab is hidden, Panorama should be initialized and |
|
73 // the first tab should be visible. |
|
74 let container = win.gBrowser.tabContainer; |
|
75 container.addEventListener("TabHide", function onTabHide() { |
|
76 container.removeEventListener("TabHide", onTabHide, false); |
|
77 |
|
78 ok(win.TabView.getContentWindow(), "Panorama is loaded"); |
|
79 ok(!firstTab.hidden, "The first tab is not hidden"); |
|
80 is(firstTab, win.gBrowser.selectedTab, "The first tab is selected"); |
|
81 ok(secondTab.hidden, "The second tab is hidden"); |
|
82 |
|
83 callback(); |
|
84 }, false); |
|
85 |
|
86 // switch to another tab |
|
87 win.switchToTabHavingURI(DUMMY_PAGE_URL); |
|
88 }); |
|
89 } |