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

     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 }

mercurial