Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3 "use strict";
5 let tab0, tab1, tab2;
6 let testStep = -1;
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 }
18 waitForExplicitFinish();
20 gBrowser.tabContainer.addEventListener("TabSelect", tabSelect, false);
21 createTab1();
22 }
24 function createTab1() {
25 tab0 = gBrowser.selectedTab;
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 }
41 function createTab2() {
42 tab2 = createTab(function() {
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 }
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 ];
86 function cleanup() {
87 gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect, false);
89 if (tab1) {
90 gBrowser.removeTab(tab1);
91 tab1 = null;
92 }
93 if (tab2) {
94 gBrowser.removeTab(tab2);
95 tab2 = null;
96 }
98 finish();
99 }
101 function tabSelect() {
102 if (testStep !== -1) {
103 executeSoon(testSteps[testStep]);
104 testStep++;
105 }
106 }