|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 waitForExplicitFinish(); |
|
6 |
|
7 window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); |
|
8 TabView.toggle(); |
|
9 } |
|
10 |
|
11 function onTabViewWindowLoaded() { |
|
12 window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); |
|
13 |
|
14 ok(TabView.isVisible(), "Tab View is visible"); |
|
15 |
|
16 let [originalTab] = gBrowser.visibleTabs; |
|
17 let contentWindow = document.getElementById("tab-view").contentWindow; |
|
18 |
|
19 // create group which we'll close |
|
20 let box1 = new contentWindow.Rect(310, 10, 300, 300); |
|
21 let group1 = new contentWindow.GroupItem([], { bounds: box1 }); |
|
22 ok(group1.isEmpty(), "This group is empty"); |
|
23 contentWindow.UI.setActive(group1); |
|
24 let tab1 = gBrowser.loadOneTab("about:blank#1", {inBackground: true}); |
|
25 let tab1Item = tab1._tabViewTabItem; |
|
26 ok(group1.getChildren().some(function(child) child == tab1Item), "The tab was made in our new group"); |
|
27 is(group1.getChildren().length, 1, "Only one tab in the first group"); |
|
28 |
|
29 group1.addSubscriber("close", function onClose() { |
|
30 group1.removeSubscriber("close", onClose); |
|
31 |
|
32 let onTabViewHidden = function() { |
|
33 window.removeEventListener("tabviewhidden", onTabViewHidden, false); |
|
34 // assert that we're no longer in tab view |
|
35 ok(!TabView.isVisible(), "Tab View is hidden"); |
|
36 finish(); |
|
37 }; |
|
38 window.addEventListener("tabviewhidden", onTabViewHidden, false); |
|
39 |
|
40 // delay to give time for hidden group DOM element to be removed so |
|
41 // the appropriate group would get selected when the key |
|
42 // combination is pressed |
|
43 executeSoon(function() { |
|
44 EventUtils.synthesizeKey("e", {accelKey : true, shiftKey: true}, contentWindow); |
|
45 }); |
|
46 }); |
|
47 |
|
48 hideGroupItem(group1, function () { |
|
49 // close undo group |
|
50 let closeButton = group1.$undoContainer.find(".close"); |
|
51 EventUtils.sendMouseEvent( |
|
52 { type: "click" }, closeButton[0], contentWindow); |
|
53 }); |
|
54 } |
|
55 |