|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 let cw; |
|
6 |
|
7 let createGroupItem = function () { |
|
8 let bounds = new cw.Rect(20, 20, 200, 200); |
|
9 let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true}); |
|
10 |
|
11 cw.UI.setActive(groupItem); |
|
12 gBrowser.loadOneTab('about:blank', {inBackground: true}); |
|
13 |
|
14 return groupItem; |
|
15 } |
|
16 |
|
17 let finishTest = function () { |
|
18 ok(!TabView.isVisible(), 'cleanup: tabview is hidden'); |
|
19 is(gBrowser.tabs.length, 1, 'cleanup: there is one tab, only'); |
|
20 is(cw.GroupItems.groupItems.length, 1, 'cleanup: there is one group, only'); |
|
21 |
|
22 finish(); |
|
23 } |
|
24 |
|
25 let testAddChildFromAnotherGroup = function () { |
|
26 let sourceGroup = cw.GroupItems.groupItems[0]; |
|
27 let targetGroup = createGroupItem(); |
|
28 |
|
29 afterAllTabsLoaded(function () { |
|
30 // check setup |
|
31 is(sourceGroup.getChildren().length, 1, 'setup: source group has one child'); |
|
32 is(targetGroup.getChildren().length, 1, 'setup: target group has one child'); |
|
33 |
|
34 let tabItem = sourceGroup.getChild(0); |
|
35 targetGroup.add(tabItem); |
|
36 |
|
37 // check state after adding tabItem to targetGroup |
|
38 is(tabItem.parent, targetGroup, 'tabItem changed groups'); |
|
39 is(cw.GroupItems.groupItems.length, 1, 'source group was closed automatically'); |
|
40 is(targetGroup.getChildren().length, 2, 'target group has now two children'); |
|
41 |
|
42 // cleanup and finish |
|
43 targetGroup.getChild(0).close(); |
|
44 hideTabView(finishTest); |
|
45 }); |
|
46 } |
|
47 |
|
48 waitForExplicitFinish(); |
|
49 |
|
50 showTabView(function () { |
|
51 cw = TabView.getContentWindow(); |
|
52 testAddChildFromAnotherGroup(); |
|
53 }); |
|
54 } |