browser/devtools/tilt/test/browser_tilt_03_tab_switch.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/tilt/test/browser_tilt_03_tab_switch.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,106 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +"use strict";
     1.7 +
     1.8 +let tab0, tab1, tab2;
     1.9 +let testStep = -1;
    1.10 +
    1.11 +function test() {
    1.12 +  if (!isTiltEnabled()) {
    1.13 +    info("Skipping tab switch test because Tilt isn't enabled.");
    1.14 +    return;
    1.15 +  }
    1.16 +  if (!isWebGLSupported()) {
    1.17 +    info("Skipping tab switch test because WebGL isn't supported.");
    1.18 +    return;
    1.19 +  }
    1.20 +
    1.21 +  waitForExplicitFinish();
    1.22 +
    1.23 +  gBrowser.tabContainer.addEventListener("TabSelect", tabSelect, false);
    1.24 +  createTab1();
    1.25 +}
    1.26 +
    1.27 +function createTab1() {
    1.28 +  tab0 = gBrowser.selectedTab;
    1.29 +
    1.30 +  tab1 = createTab(function() {
    1.31 +    createTilt({
    1.32 +      onTiltOpen: function()
    1.33 +      {
    1.34 +        createTab2();
    1.35 +      }
    1.36 +    }, false, function suddenDeath()
    1.37 +    {
    1.38 +      info("Tilt could not be initialized properly.");
    1.39 +      cleanup();
    1.40 +    });
    1.41 +  });
    1.42 +}
    1.43 +
    1.44 +function createTab2() {
    1.45 +  tab2 = createTab(function() {
    1.46 +
    1.47 +    createTilt({
    1.48 +      onTiltOpen: function()
    1.49 +      {
    1.50 +        testStep = 0;
    1.51 +        tabSelect();
    1.52 +      }
    1.53 +    }, false, function suddenDeath()
    1.54 +    {
    1.55 +      info("Tilt could not be initialized properly.");
    1.56 +      cleanup();
    1.57 +    });
    1.58 +  });
    1.59 +}
    1.60 +
    1.61 +let testSteps = [
    1.62 +  function step0() {
    1.63 +    gBrowser.selectedTab = tab1;
    1.64 +  },
    1.65 +  function step1() {
    1.66 +    gBrowser.selectedTab = tab0;
    1.67 +  },
    1.68 +  function step2() {
    1.69 +    gBrowser.selectedTab = tab1;
    1.70 +  },
    1.71 +  function step3() {
    1.72 +    gBrowser.selectedTab = tab2;
    1.73 +  },
    1.74 +  function step4() {
    1.75 +    Tilt.destroy(Tilt.currentWindowId);
    1.76 +    gBrowser.removeCurrentTab();
    1.77 +    tab2 = null;
    1.78 +  },
    1.79 +  function step5() {
    1.80 +    Tilt.destroy(Tilt.currentWindowId);
    1.81 +    gBrowser.removeCurrentTab();
    1.82 +    tab1 = null;
    1.83 +  },
    1.84 +  function step6_cleanup() {
    1.85 +    cleanup();
    1.86 +  }
    1.87 +];
    1.88 +
    1.89 +function cleanup() {
    1.90 +  gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect, false);
    1.91 +
    1.92 +  if (tab1) {
    1.93 +    gBrowser.removeTab(tab1);
    1.94 +    tab1 = null;
    1.95 +  }
    1.96 +  if (tab2) {
    1.97 +    gBrowser.removeTab(tab2);
    1.98 +    tab2 = null;
    1.99 +  }
   1.100 +
   1.101 +  finish();
   1.102 +}
   1.103 +
   1.104 +function tabSelect() {
   1.105 +  if (testStep !== -1) {
   1.106 +    executeSoon(testSteps[testStep]);
   1.107 +    testStep++;
   1.108 +  }
   1.109 +}

mercurial