|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 waitForExplicitFinish(); |
|
6 |
|
7 window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); |
|
8 TabView.toggle(); |
|
9 } |
|
10 |
|
11 let moves = 0; |
|
12 let contentWindow = null; |
|
13 let newTabs = []; |
|
14 let originalTab = null; |
|
15 |
|
16 function onTabMove(e) { |
|
17 let tab = e.target; |
|
18 moves++; |
|
19 } |
|
20 |
|
21 function onTabViewWindowLoaded() { |
|
22 window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); |
|
23 |
|
24 contentWindow = document.getElementById("tab-view").contentWindow; |
|
25 |
|
26 originalTab = gBrowser.selectedTab; |
|
27 newTabs = [gBrowser.addTab("about:rights"), gBrowser.addTab("about:mozilla"), gBrowser.addTab("about:license")]; |
|
28 |
|
29 is(originalTab._tPos, 0, "Original tab is in position 0"); |
|
30 is(newTabs[0]._tPos, 1, "Rights is in position 1"); |
|
31 is(newTabs[1]._tPos, 2, "Mozilla is in position 2"); |
|
32 is(newTabs[2]._tPos, 3, "License is in position 3"); |
|
33 |
|
34 gBrowser.tabContainer.addEventListener("TabMove", onTabMove, false); |
|
35 |
|
36 let groupItem = contentWindow.GroupItems.getActiveGroupItem(); |
|
37 |
|
38 // move 3 > 0 (and therefore 0 > 1, 1 > 2, 2 > 3) |
|
39 groupItem._children.splice(0, 0, groupItem._children.splice(3, 1)[0]); |
|
40 groupItem.arrange(); |
|
41 |
|
42 window.addEventListener("tabviewhidden", onTabViewWindowHidden, false); |
|
43 TabView.toggle(); |
|
44 } |
|
45 |
|
46 function onTabViewWindowHidden() { |
|
47 window.removeEventListener("tabviewhidden", onTabViewWindowHidden, false); |
|
48 gBrowser.tabContainer.removeEventListener("TabMove", onTabMove, false); |
|
49 |
|
50 is(moves, 1, "Only one move should be necessary for this basic move."); |
|
51 |
|
52 is(newTabs[2]._tPos, 0, "License is in position 0"); |
|
53 is(originalTab._tPos, 1, "Original tab is in position 1"); |
|
54 is(newTabs[0]._tPos, 2, "Rights is in position 2"); |
|
55 is(newTabs[1]._tPos, 3, "Mozilla is in position 3"); |
|
56 |
|
57 gBrowser.removeTab(newTabs[0]); |
|
58 gBrowser.removeTab(newTabs[1]); |
|
59 gBrowser.removeTab(newTabs[2]); |
|
60 finish(); |
|
61 } |