browser/components/tabview/test/browser_tabview_bug640765.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:be4dc493606b
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 let contentWindow;
5 let groupItem;
6
7 function test() {
8 waitForExplicitFinish();
9
10 let newTabOne = gBrowser.addTab();
11 let newTabTwo = gBrowser.addTab();
12 let newTabThree = gBrowser.addTab();
13
14 registerCleanupFunction(function() {
15 TabView.hide();
16 while (gBrowser.tabs.length > 1)
17 gBrowser.removeTab(gBrowser.tabs[0]);
18 });
19
20 showTabView(function() {
21 contentWindow = document.getElementById("tab-view").contentWindow;
22 is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
23
24 groupItem = contentWindow.GroupItems.groupItems[0];
25
26 whenAppTabIconAdded(groupItem, function () {
27 whenAppTabIconAdded(groupItem, function () {
28 whenAppTabIconAdded(groupItem, function () {
29
30 is(xulTabForAppTabIcon(0), newTabOne,
31 "New tab one matches the first app tab icon in tabview");
32 is(xulTabForAppTabIcon(1), newTabTwo,
33 "New tab two matches the second app tab icon in tabview");
34 is(xulTabForAppTabIcon(2), newTabThree,
35 "New tab three matches the third app tab icon in tabview");
36
37 // move the last tab to the first position
38 gBrowser.moveTabTo(newTabThree, 0);
39 is(xulTabForAppTabIcon(0), newTabThree,
40 "New tab three matches the first app tab icon in tabview");
41 is(xulTabForAppTabIcon(1), newTabOne,
42 "New tab one matches the second app tab icon in tabview");
43 is(xulTabForAppTabIcon(2), newTabTwo,
44 "New tab two matches the third app tab icon in tabview");
45
46 // move the first tab to the second position
47 gBrowser.moveTabTo(newTabThree, 1);
48 is(xulTabForAppTabIcon(0), newTabOne,
49 "New tab one matches the first app tab icon in tabview");
50 is(xulTabForAppTabIcon(1), newTabThree,
51 "New tab three matches the second app tab icon in tabview");
52 is(xulTabForAppTabIcon(2), newTabTwo,
53 "New tab two matches the third app tab icon in tabview");
54
55 hideTabView(function() {
56 gBrowser.removeTab(newTabOne);
57 gBrowser.removeTab(newTabTwo);
58 gBrowser.removeTab(newTabThree);
59 finish();
60 });
61 });
62 gBrowser.pinTab(newTabThree);
63 });
64 gBrowser.pinTab(newTabTwo);
65 });
66 gBrowser.pinTab(newTabOne);
67 });
68 }
69
70 function xulTabForAppTabIcon(index) {
71 return contentWindow.iQ(
72 contentWindow.iQ(".appTabIcon",
73 groupItem.$appTabTray)[index]).data("xulTab");
74 }
75

mercurial