|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let win; |
|
5 let contentWindow; |
|
6 let originalTab; |
|
7 |
|
8 function test() { |
|
9 waitForExplicitFinish(); |
|
10 |
|
11 newWindowWithTabView( |
|
12 function() { |
|
13 ok(win.TabView.isVisible(), "Tab View is visible"); |
|
14 |
|
15 contentWindow = win.document.getElementById("tab-view").contentWindow; |
|
16 is(contentWindow.GroupItems.groupItems.length, 1, "There is one group"); |
|
17 is(contentWindow.GroupItems.groupItems[0].getChildren().length, 1, |
|
18 "The group has only one tab item"); |
|
19 |
|
20 // show the undo close group button |
|
21 let group = contentWindow.GroupItems.groupItems[0]; |
|
22 hideGroupItem(group, function () restore(group.id)); |
|
23 }, |
|
24 function(newWin) { |
|
25 win = newWin; |
|
26 originalTab = win.gBrowser.visibleTabs[0]; |
|
27 win.gBrowser.addTab(); |
|
28 win.gBrowser.pinTab(originalTab); |
|
29 } |
|
30 ); |
|
31 } |
|
32 |
|
33 function restore(groupId) { |
|
34 // window state ready |
|
35 let handleSSWindowStateReady = function() { |
|
36 win.removeEventListener("SSWindowStateReady", handleSSWindowStateReady, false); |
|
37 |
|
38 executeSoon(function() { |
|
39 is(contentWindow.GroupItems.groupItems.length, 1, "There is one group"); |
|
40 |
|
41 let group = contentWindow.GroupItems.groupItems[0]; |
|
42 ok(!group.hidden, "The group is visible"); |
|
43 is(group.getChildren().length, 2, "This group has two tab items"); |
|
44 |
|
45 // check the position of the group item and the tab items. |
|
46 let tabItemOne = group.getChildren()[0]; |
|
47 let tabItemTwo = group.getChildren()[1]; |
|
48 |
|
49 let groupBounds = group.getBounds(); |
|
50 let tabItemOneBounds = tabItemOne.getBounds(); |
|
51 let tabItemTwoBounds = tabItemTwo.getBounds(); |
|
52 |
|
53 ok(groupBounds.left < tabItemOneBounds.left && |
|
54 (groupBounds.right) > (tabItemOneBounds.right) && |
|
55 groupBounds.top < tabItemOneBounds.top && |
|
56 (groupBounds.bottom) > (tabItemOneBounds.bottom), |
|
57 "Tab item one is within the group"); |
|
58 |
|
59 ok(groupBounds.left < tabItemOneBounds.left && |
|
60 (groupBounds.right) > (tabItemTwoBounds.right) && |
|
61 groupBounds.top < tabItemOneBounds.top && |
|
62 (groupBounds.bottom) > (tabItemTwoBounds.bottom), |
|
63 "Tab item two is within the group"); |
|
64 |
|
65 win.close(); |
|
66 finish(); |
|
67 }); |
|
68 } |
|
69 win.addEventListener("SSWindowStateReady", handleSSWindowStateReady, false); |
|
70 |
|
71 // simulate restoring previous session (one group and two tab items) |
|
72 const DUMMY_PAGE_URL = "http://example.com/"; |
|
73 let newState = { |
|
74 windows: [{ |
|
75 tabs: [{ |
|
76 entries: [{ url: DUMMY_PAGE_URL }], |
|
77 index: 2, |
|
78 hidden: false, |
|
79 attributes: {}, |
|
80 extData: { |
|
81 "tabview-tab": |
|
82 '{"bounds":{"left":208,"top":54,"width":205,"height":169},' + |
|
83 '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":' + |
|
84 groupId + ',"imageData":null,"title":null}' |
|
85 }}, { |
|
86 entries: [{ url: DUMMY_PAGE_URL }], |
|
87 index: 1, |
|
88 hidden: false, |
|
89 attributes: {}, |
|
90 extData: { |
|
91 "tabview-tab": |
|
92 '{"bounds":{"left":429,"top":54,"width":205,"height":169},' + |
|
93 '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":' + |
|
94 groupId + ',"imageData":null,"title":null}' |
|
95 } |
|
96 }], |
|
97 extData: { |
|
98 "tabview-groups": '{"nextID":' + (groupId + 1) + ',"activeGroupId":' + groupId + '}', |
|
99 "tabview-group": |
|
100 '{"' + groupId + '":{"bounds":{"left":202,"top":30,"width":455,"height":249},' + |
|
101 '"userSize":null,"locked":{},"title":"","id":' + groupId +'}}', |
|
102 "tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":788,"height":548}}' |
|
103 }, sizemode:"normal" |
|
104 }] |
|
105 }; |
|
106 let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); |
|
107 ss.setWindowState(win, JSON.stringify(newState), true); |
|
108 } |
|
109 |