|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 waitForExplicitFinish(); |
|
6 newWindowWithTabView(onTabViewWindowLoaded); |
|
7 } |
|
8 |
|
9 function onTabViewWindowLoaded(win) { |
|
10 ok(win.TabView.isVisible(), "Tab View is visible"); |
|
11 |
|
12 let contentWindow = win.document.getElementById("tab-view").contentWindow; |
|
13 let [originalTab] = win.gBrowser.visibleTabs; |
|
14 let originalGroup = contentWindow.GroupItems.getActiveGroupItem(); |
|
15 |
|
16 // open a group with a tab, and close either the group or the tab. |
|
17 function openAndClose(groupOrTab, callback) { |
|
18 // let's create a group with a tab. |
|
19 let group = new contentWindow.GroupItem([], { |
|
20 immediately: true, |
|
21 bounds: {left: 20, top: 20, width: 400, height: 400} |
|
22 }); |
|
23 contentWindow.UI.setActive(group); |
|
24 win.gBrowser.loadOneTab('about:blank', {inBackground: true}); |
|
25 |
|
26 is(group.getChildren().length, 1, "The group has one child now."); |
|
27 let tab = group.getChild(0); |
|
28 |
|
29 function check() { |
|
30 if (groupOrTab == 'group') { |
|
31 group.removeSubscriber("groupHidden", check); |
|
32 group.closeHidden(); |
|
33 } else |
|
34 tab.removeSubscriber("tabRemoved", check); |
|
35 |
|
36 is(contentWindow.GroupItems.getActiveGroupItem(), originalGroup, |
|
37 "The original group is active."); |
|
38 is(contentWindow.UI.getActiveTab(), originalTab._tabViewTabItem, |
|
39 "The original tab is active"); |
|
40 |
|
41 callback(); |
|
42 } |
|
43 |
|
44 if (groupOrTab == 'group') { |
|
45 group.addSubscriber("groupHidden", check); |
|
46 group.closeAll(); |
|
47 } else { |
|
48 tab.addSubscriber("tabRemoved", check); |
|
49 tab.close(); |
|
50 } |
|
51 } |
|
52 |
|
53 // PHASE 1: create a group with a tab and close the group. |
|
54 openAndClose("group", function postPhase1() { |
|
55 // PHASE 2: create a group with a tab and close the tab. |
|
56 openAndClose("tab", function postPhase2() { |
|
57 win.close(); |
|
58 finish(); |
|
59 }); |
|
60 }); |
|
61 } |