browser/devtools/tilt/test/browser_tilt_03_tab_switch.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial