|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let contentWindow; |
|
5 let groupItemTwoId; |
|
6 |
|
7 function test() { |
|
8 waitForExplicitFinish(); |
|
9 |
|
10 registerCleanupFunction(function() { |
|
11 while (gBrowser.tabs[1]) |
|
12 gBrowser.removeTab(gBrowser.tabs[1]); |
|
13 hideTabView(); |
|
14 }); |
|
15 gBrowser.loadOneTab("about:blank", { inBackground: true }); |
|
16 showTabView(setup); |
|
17 } |
|
18 |
|
19 function setup() { |
|
20 registerCleanupFunction(function() { |
|
21 let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId); |
|
22 if (groupItem) |
|
23 closeGroupItem(groupItem); |
|
24 }); |
|
25 |
|
26 let contentWindow = TabView.getContentWindow(); |
|
27 is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); |
|
28 |
|
29 let groupItemOne = contentWindow.GroupItems.groupItems[0]; |
|
30 is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items"); |
|
31 |
|
32 let groupItemTwo = createGroupItemWithBlankTabs(window, 250, 250, 40, 1); |
|
33 groupItemTwoId = groupItemTwo.id; |
|
34 testGroups(groupItemOne, groupItemTwo, contentWindow); |
|
35 } |
|
36 |
|
37 function testGroups(groupItemOne, groupItemTwo, contentWindow) { |
|
38 // check active tab and group |
|
39 is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo, |
|
40 "The group two is the active group"); |
|
41 is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(0), |
|
42 "The first tab item in group two is active"); |
|
43 |
|
44 let tabItem = groupItemOne.getChild(1); |
|
45 tabItem.addSubscriber("tabRemoved", function onTabRemoved() { |
|
46 tabItem.removeSubscriber("tabRemoved", onTabRemoved); |
|
47 |
|
48 is(groupItemOne.getChildren().length, 1, |
|
49 "The num of childen in group one is 1"); |
|
50 |
|
51 // check active group and active tab |
|
52 is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne, |
|
53 "The group one is the active group"); |
|
54 is(contentWindow.UI.getActiveTab(), groupItemOne.getChild(0), |
|
55 "The first tab item in group one is active"); |
|
56 |
|
57 whenTabViewIsHidden(function() { |
|
58 is(groupItemOne.getChildren().length, 2, |
|
59 "The num of childen in group one is 2"); |
|
60 |
|
61 // clean up and finish |
|
62 closeGroupItem(groupItemTwo, function() { |
|
63 gBrowser.removeTab(groupItemOne.getChild(1).tab); |
|
64 is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); |
|
65 is(groupItemOne.getChildren().length, 1, |
|
66 "The num of childen in group one is 1"); |
|
67 is(gBrowser.tabs.length, 1, "Has only one tab"); |
|
68 |
|
69 finish(); |
|
70 }); |
|
71 }); |
|
72 EventUtils.synthesizeKey("t", { accelKey: true }); |
|
73 }); |
|
74 // close a tab item in group one |
|
75 EventUtils.synthesizeMouseAtCenter(tabItem.$close[0], {}, contentWindow); |
|
76 } |