browser/devtools/tilt/test/browser_tilt_05_destruction.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

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 tiltOpened = false;
     7 function test() {
     8   if (!isTiltEnabled()) {
     9     info("Skipping destruction test because Tilt isn't enabled.");
    10     return;
    11   }
    12   if (!isWebGLSupported()) {
    13     info("Skipping destruction test because WebGL isn't supported.");
    14     return;
    15   }
    17   waitForExplicitFinish();
    19   createTab(function() {
    20     createTilt({
    21       onTiltOpen: function()
    22       {
    23         tiltOpened = true;
    25         Services.obs.addObserver(finalize, DESTROYED, false);
    26         Tilt.destroy(Tilt.currentWindowId);
    27       }
    28     }, false, function suddenDeath()
    29     {
    30       info("Tilt could not be initialized properly.");
    31       cleanup();
    32     });
    33   });
    34 }
    36 function finalize() {
    37   let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow);
    39   is(Tilt.visualizers[id], null,
    40     "The current instance of the visualizer wasn't destroyed properly.");
    42   cleanup();
    43 }
    45 function cleanup() {
    46   if (tiltOpened) { Services.obs.removeObserver(finalize, DESTROYED); }
    47   gBrowser.removeCurrentTab();
    48   finish();
    49 }

mercurial