|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 let win, cw, groupItem; |
|
6 |
|
7 function checkNumberOfGroupItems(num) { |
|
8 is(cw.GroupItems.groupItems.length, num, "there are " + num + " groupItems"); |
|
9 } |
|
10 |
|
11 function next() { |
|
12 if (tests.length) |
|
13 tests.shift()(); |
|
14 else |
|
15 finish(); |
|
16 } |
|
17 |
|
18 // Empty groups should not be closed when toggling Panorama on and off. |
|
19 function test1() { |
|
20 hideTabView(function () { |
|
21 showTabView(function () { |
|
22 checkNumberOfGroupItems(2); |
|
23 next(); |
|
24 }, win); |
|
25 }, win); |
|
26 } |
|
27 |
|
28 // Groups should not be closed when their last tab is closed outside of Panorama. |
|
29 function test2() { |
|
30 whenTabViewIsHidden(function () { |
|
31 whenTabViewIsShown(function () { |
|
32 checkNumberOfGroupItems(2); |
|
33 next(); |
|
34 }, win); |
|
35 |
|
36 win.gBrowser.removeTab(win.gBrowser.selectedTab); |
|
37 }, win); |
|
38 |
|
39 groupItem.newTab(); |
|
40 } |
|
41 |
|
42 // Groups should be closed when their last tab is closed. |
|
43 function test3() { |
|
44 whenTabViewIsHidden(function () { |
|
45 showTabView(function () { |
|
46 let tab = win.gBrowser.tabs[1]; |
|
47 tab._tabViewTabItem.close(); |
|
48 checkNumberOfGroupItems(1); |
|
49 next(); |
|
50 }, win); |
|
51 }, win); |
|
52 |
|
53 win.gBrowser.addTab(); |
|
54 } |
|
55 |
|
56 // Groups should be closed when their last tab is dragged out. |
|
57 function test4() { |
|
58 groupItem = createGroupItemWithBlankTabs(win, 200, 200, 20, 1); |
|
59 checkNumberOfGroupItems(2); |
|
60 |
|
61 let tab = win.gBrowser.tabs[1]; |
|
62 let target = tab._tabViewTabItem.container; |
|
63 |
|
64 waitForFocus(function () { |
|
65 EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); |
|
66 EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw); |
|
67 EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw); |
|
68 |
|
69 checkNumberOfGroupItems(2); |
|
70 closeGroupItem(cw.GroupItems.groupItems[1], next); |
|
71 }, win); |
|
72 } |
|
73 |
|
74 let tests = [test1, test2, test3, test4]; |
|
75 |
|
76 waitForExplicitFinish(); |
|
77 |
|
78 newWindowWithTabView(function (aWin) { |
|
79 registerCleanupFunction(function () aWin.close()); |
|
80 |
|
81 win = aWin; |
|
82 cw = win.TabView.getContentWindow(); |
|
83 groupItem = createEmptyGroupItem(cw, 200, 200, 20); |
|
84 |
|
85 checkNumberOfGroupItems(2); |
|
86 next(); |
|
87 }); |
|
88 } |