|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let activeTab; |
|
5 let testTab; |
|
6 let testGroup; |
|
7 let contentWindow; |
|
8 |
|
9 function test() { |
|
10 waitForExplicitFinish(); |
|
11 |
|
12 // create new tab |
|
13 testTab = gBrowser.addTab("about:blank"); |
|
14 |
|
15 window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); |
|
16 TabView.toggle(); |
|
17 } |
|
18 |
|
19 function onTabViewWindowLoaded() { |
|
20 window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); |
|
21 ok(TabView.isVisible(), "Tab View is visible"); |
|
22 |
|
23 contentWindow = document.getElementById("tab-view").contentWindow; |
|
24 |
|
25 // create group |
|
26 let testGroupRect = new contentWindow.Rect(20, 20, 300, 300); |
|
27 testGroup = new contentWindow.GroupItem([], { bounds: testGroupRect }); |
|
28 ok(testGroup.isEmpty(), "This group is empty"); |
|
29 |
|
30 ok(testTab._tabViewTabItem, "tab item exists"); |
|
31 |
|
32 // place tab in group |
|
33 let testTabItem = testTab._tabViewTabItem; |
|
34 |
|
35 if (testTabItem.parent) |
|
36 testTabItem.parent.remove(testTabItem); |
|
37 testGroup.add(testTabItem); |
|
38 |
|
39 ok(testTab._tabViewTabItem, "tab item exists after adding to group"); |
|
40 |
|
41 // record last update time of tab canvas |
|
42 let initialUpdateTime = testTabItem._lastTabUpdateTime; |
|
43 |
|
44 // simulate resize |
|
45 let resizer = contentWindow.iQ('.iq-resizable-handle', testGroup.container)[0]; |
|
46 let offsetX = 100; |
|
47 let offsetY = 100; |
|
48 let delay = 500; |
|
49 |
|
50 let funcChain = new Array(); |
|
51 funcChain.push(function() { |
|
52 EventUtils.synthesizeMouse( |
|
53 resizer, 1, 1, { type: "mousedown" }, contentWindow); |
|
54 setTimeout(funcChain.shift(), delay); |
|
55 }); |
|
56 // drag |
|
57 for (let i = 4; i >= 0; i--) { |
|
58 funcChain.push(function() { |
|
59 EventUtils.synthesizeMouse( |
|
60 resizer, Math.round(offsetX/4), Math.round(offsetY/4), |
|
61 { type: "mousemove" }, contentWindow); |
|
62 setTimeout(funcChain.shift(), delay); |
|
63 }); |
|
64 } |
|
65 funcChain.push(function() { |
|
66 EventUtils.synthesizeMouse(resizer, 0, 0, { type: "mouseup" }, |
|
67 contentWindow); |
|
68 setTimeout(funcChain.shift(), delay); |
|
69 }); |
|
70 funcChain.push(function() { |
|
71 // verify that update time has changed after last update |
|
72 let lastTime = testTabItem._lastTabUpdateTime; |
|
73 let hbTiming = contentWindow.TabItems._heartbeatTiming; |
|
74 ok((lastTime - initialUpdateTime) > hbTiming, "Tab has been updated:"+lastTime+"-"+initialUpdateTime+">"+hbTiming); |
|
75 |
|
76 // clean up |
|
77 testGroup.remove(testTab._tabViewTabItem); |
|
78 testTab._tabViewTabItem.close(); |
|
79 testGroup.close(); |
|
80 |
|
81 let currentTabs = contentWindow.TabItems.getItems(); |
|
82 ok(currentTabs[0], "A tab item exists to make active"); |
|
83 contentWindow.UI.setActive(currentTabs[0]); |
|
84 |
|
85 window.addEventListener("tabviewhidden", finishTest, false); |
|
86 TabView.toggle(); |
|
87 }); |
|
88 setTimeout(funcChain.shift(), delay); |
|
89 } |
|
90 |
|
91 function finishTest() { |
|
92 window.removeEventListener("tabviewhidden", finishTest, false); |
|
93 ok(!TabView.isVisible(), "Tab View is not visible"); |
|
94 |
|
95 finish(); |
|
96 } |