browser/components/tabview/test/browser_tabview_bug635696.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:3dcb0e186967
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 groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1);
9
10 let groupItemId = groupItem.id;
11 registerCleanupFunction(function() {
12 let groupItem = cw.GroupItems.groupItem(groupItemId);
13 if (groupItem)
14 groupItem.close();
15 });
16
17 return groupItem;
18 }
19
20 let testSingleGroupItem = function () {
21 let groupItem = cw.GroupItems.groupItems[0];
22 is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is active");
23
24 let tabItem = groupItem.getChild(0);
25 is(cw.UI.getActiveTab(), tabItem, "tabItem is active");
26
27 hideGroupItem(groupItem, function () {
28 unhideGroupItem(groupItem, function () {
29 is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is still active");
30 is(cw.UI.getActiveTab(), tabItem, "tabItem is still active");
31 next();
32 });
33 });
34 }
35
36 let testTwoGroupItems = function () {
37 let groupItem = cw.GroupItems.groupItems[0];
38 let tabItem = groupItem.getChild(0);
39
40 let groupItem2 = createGroupItem();
41 let tabItem2 = groupItem2.getChild(0);
42
43 hideGroupItem(groupItem, function () {
44 is(cw.UI.getActiveTab(), tabItem2, "tabItem2 is active");
45 unhideGroupItem(groupItem, function () {
46 cw.UI.setActive(tabItem);
47 closeGroupItem(groupItem2, next);
48 });
49 });
50 }
51
52 let tests = [testSingleGroupItem, testTwoGroupItems];
53
54 let next = function () {
55 let test = tests.shift();
56 if (test)
57 test();
58 else
59 hideTabView(finishTest);
60 }
61
62 let finishTest = function () {
63 is(cw.GroupItems.groupItems.length, 1, "there is one groupItem");
64 is(gBrowser.tabs.length, 1, "there is one tab");
65 ok(!TabView.isVisible(), "tabview is hidden");
66
67 finish();
68 }
69
70 waitForExplicitFinish();
71
72 showTabView(function () {
73 registerCleanupFunction(function () TabView.hide());
74 cw = TabView.getContentWindow();
75 next();
76 });
77 }

mercurial