|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let state1 = { |
|
5 windows: [{ |
|
6 tabs: [{ |
|
7 entries: [{ url: "about:blank#1" }], |
|
8 hidden: true, |
|
9 extData: {"tabview-tab": '{"url":"about:blank#1","groupID":1,"bounds":{"left":120,"top":20,"width":20,"height":20}}'} |
|
10 },{ |
|
11 entries: [{ url: "about:blank#2" }], |
|
12 hidden: false, |
|
13 extData: {"tabview-tab": '{"url":"about:blank#2","groupID":2,"bounds":{"left":20,"top":20,"width":20,"height":20}}'}, |
|
14 }], |
|
15 selected: 2, |
|
16 extData: { |
|
17 "tabview-groups": '{"nextID":3,"activeGroupId":2, "totalNumber":2}', |
|
18 "tabview-group": |
|
19 '{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},"id":1},' + |
|
20 '"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},"id":2}}' |
|
21 } |
|
22 }] |
|
23 }; |
|
24 |
|
25 let state2 = { |
|
26 windows: [{ |
|
27 tabs: [{entries: [{ url: "about:blank#1" }], hidden: true}, |
|
28 {entries: [{ url: "about:blank#2" }], hidden: false}], |
|
29 selected: 2 |
|
30 }] |
|
31 }; |
|
32 |
|
33 let ss = Cc["@mozilla.org/browser/sessionstore;1"] |
|
34 .getService(Ci.nsISessionStore); |
|
35 |
|
36 function test() { |
|
37 waitForExplicitFinish(); |
|
38 |
|
39 newWindowWithState(state1, function (win) { |
|
40 registerCleanupFunction(function () win.close()); |
|
41 |
|
42 showTabView(function () { |
|
43 let cw = win.TabView.getContentWindow(); |
|
44 let [group1, group2] = cw.GroupItems.groupItems; |
|
45 let [tab1, tab2] = win.gBrowser.tabs; |
|
46 |
|
47 checkUrl(group1.getChild(0), "about:blank#1", "tab1 is in first group"); |
|
48 checkUrl(group2.getChild(0), "about:blank#2", "tab2 is in second group"); |
|
49 |
|
50 whenWindowStateReady(win, function () { |
|
51 let groups = cw.GroupItems.groupItems; |
|
52 is(groups.length, 1, "one groupItem"); |
|
53 is(groups[0].getChildren().length, 2, "single groupItem has two children"); |
|
54 |
|
55 finish(); |
|
56 }); |
|
57 |
|
58 ss.setWindowState(win, JSON.stringify(state2), true); |
|
59 }, win); |
|
60 }); |
|
61 } |
|
62 |
|
63 function checkUrl(aTabItem, aUrl, aMsg) { |
|
64 is(aTabItem.tab.linkedBrowser.currentURI.spec, aUrl, aMsg); |
|
65 } |