|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 "use strict"; |
|
4 |
|
5 let tab0, tab1, tab2; |
|
6 let testStep = -1; |
|
7 |
|
8 function test() { |
|
9 if (!isTiltEnabled()) { |
|
10 info("Skipping tab switch test because Tilt isn't enabled."); |
|
11 return; |
|
12 } |
|
13 if (!isWebGLSupported()) { |
|
14 info("Skipping tab switch test because WebGL isn't supported."); |
|
15 return; |
|
16 } |
|
17 |
|
18 waitForExplicitFinish(); |
|
19 |
|
20 gBrowser.tabContainer.addEventListener("TabSelect", tabSelect, false); |
|
21 createTab1(); |
|
22 } |
|
23 |
|
24 function createTab1() { |
|
25 tab0 = gBrowser.selectedTab; |
|
26 |
|
27 tab1 = createTab(function() { |
|
28 createTilt({ |
|
29 onTiltOpen: function() |
|
30 { |
|
31 createTab2(); |
|
32 } |
|
33 }, false, function suddenDeath() |
|
34 { |
|
35 info("Tilt could not be initialized properly."); |
|
36 cleanup(); |
|
37 }); |
|
38 }); |
|
39 } |
|
40 |
|
41 function createTab2() { |
|
42 tab2 = createTab(function() { |
|
43 |
|
44 createTilt({ |
|
45 onTiltOpen: function() |
|
46 { |
|
47 testStep = 0; |
|
48 tabSelect(); |
|
49 } |
|
50 }, false, function suddenDeath() |
|
51 { |
|
52 info("Tilt could not be initialized properly."); |
|
53 cleanup(); |
|
54 }); |
|
55 }); |
|
56 } |
|
57 |
|
58 let testSteps = [ |
|
59 function step0() { |
|
60 gBrowser.selectedTab = tab1; |
|
61 }, |
|
62 function step1() { |
|
63 gBrowser.selectedTab = tab0; |
|
64 }, |
|
65 function step2() { |
|
66 gBrowser.selectedTab = tab1; |
|
67 }, |
|
68 function step3() { |
|
69 gBrowser.selectedTab = tab2; |
|
70 }, |
|
71 function step4() { |
|
72 Tilt.destroy(Tilt.currentWindowId); |
|
73 gBrowser.removeCurrentTab(); |
|
74 tab2 = null; |
|
75 }, |
|
76 function step5() { |
|
77 Tilt.destroy(Tilt.currentWindowId); |
|
78 gBrowser.removeCurrentTab(); |
|
79 tab1 = null; |
|
80 }, |
|
81 function step6_cleanup() { |
|
82 cleanup(); |
|
83 } |
|
84 ]; |
|
85 |
|
86 function cleanup() { |
|
87 gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect, false); |
|
88 |
|
89 if (tab1) { |
|
90 gBrowser.removeTab(tab1); |
|
91 tab1 = null; |
|
92 } |
|
93 if (tab2) { |
|
94 gBrowser.removeTab(tab2); |
|
95 tab2 = null; |
|
96 } |
|
97 |
|
98 finish(); |
|
99 } |
|
100 |
|
101 function tabSelect() { |
|
102 if (testStep !== -1) { |
|
103 executeSoon(testSteps[testStep]); |
|
104 testStep++; |
|
105 } |
|
106 } |