browser/components/tabview/test/browser_tabview_bug590606.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:03ab0ae41edf
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 let originalTab;
5 let newTabOne;
6 let groupItemTwoId;
7
8 function test() {
9 waitForExplicitFinish();
10
11 originalTab = gBrowser.visibleTabs[0];
12 // add a tab to the existing group.
13 newTabOne = gBrowser.addTab();
14
15 registerCleanupFunction(function() {
16 while (gBrowser.tabs[1])
17 gBrowser.removeTab(gBrowser.tabs[1]);
18 hideTabView();
19 });
20
21 showTabView(function() {
22 let contentWindow = TabView.getContentWindow();
23
24 registerCleanupFunction(function() {
25 let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
26 if (groupItem)
27 closeGroupItem(groupItem);
28 });
29
30 is(contentWindow.GroupItems.groupItems.length, 1,
31 "There is one group item on startup");
32 let groupItemOne = contentWindow.GroupItems.groupItems[0];
33 is(groupItemOne.getChildren().length, 2,
34 "There should be two tab items in that group.");
35 is(gBrowser.selectedTab, groupItemOne.getChild(0).tab,
36 "The currently selected tab should be the first tab in the groupItemOne");
37
38 // create another group with a tab.
39 let groupItemTwo = createGroupItemWithBlankTabs(window, 300, 300, 200, 1);
40 groupItemTwoId = groupItemTwoId;
41 hideTabView(function() {
42 // start the test
43 testGroupSwitch(contentWindow, groupItemOne, groupItemTwo);
44 });
45 });
46 }
47
48 function testGroupSwitch(contentWindow, groupItemOne, groupItemTwo) {
49 is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab,
50 "The currently selected tab should be the only tab in the groupItemTwo");
51
52 // switch to groupItemOne
53 let tabItem = contentWindow.GroupItems.getNextGroupItemTab(false);
54 if (tabItem)
55 gBrowser.selectedTab = tabItem.tab;
56 is(gBrowser.selectedTab, groupItemOne.getChild(0).tab,
57 "The currently selected tab should be the first tab in the groupItemOne");
58
59 // switch to the second tab in groupItemOne
60 gBrowser.selectedTab = groupItemOne.getChild(1).tab;
61
62 // switch to groupItemTwo
63 tabItem = contentWindow.GroupItems.getNextGroupItemTab(false);
64 if (tabItem)
65 gBrowser.selectedTab = tabItem.tab;
66 is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab,
67 "The currently selected tab should be the only tab in the groupItemTwo");
68
69 // switch to groupItemOne
70 tabItem = contentWindow.GroupItems.getNextGroupItemTab(false);
71 if (tabItem)
72 gBrowser.selectedTab = tabItem.tab;
73 is(gBrowser.selectedTab, groupItemOne.getChild(1).tab,
74 "The currently selected tab should be the second tab in the groupItemOne");
75
76 // cleanup.
77 gBrowser.removeTab(groupItemTwo.getChild(0).tab);
78 gBrowser.removeTab(newTabOne);
79
80 finish();
81 }

mercurial