browser/devtools/tilt/test/browser_tilt_picking_highlight02.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     3 "use strict";
     5 let nodeHighlighted = false;
     6 let presenter;
     8 function test() {
     9   if (!isTiltEnabled()) {
    10     info("Skipping highlight test because Tilt isn't enabled.");
    11     return;
    12   }
    13   if (!isWebGLSupported()) {
    14     info("Skipping highlight test because WebGL isn't supported.");
    15     return;
    16   }
    18   waitForExplicitFinish();
    20   createTab(function() {
    21     createTilt({
    22       onTiltOpen: function(instance)
    23       {
    24         presenter = instance.presenter;
    25         Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false);
    27         presenter._onInitializationFinished = function() {
    28           nodeHighlighted = true;
    29           presenter.highlightNodeAt.apply(this, getPickablePoint(presenter));
    30         };
    31       }
    32     }, false, function suddenDeath()
    33     {
    34       info("Tilt could not be initialized properly.");
    35       cleanup();
    36     });
    37   });
    38 }
    40 function whenHighlighting() {
    41   ok(presenter._currentSelection > 0,
    42     "Highlighting a node didn't work properly.");
    43   ok(!presenter._highlight.disabled,
    44     "After highlighting a node, it should be highlighted. D'oh.");
    46   executeSoon(function() {
    47     Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
    48     Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false);
    49     presenter.highlightNode(null);
    50   });
    51 }
    53 function whenUnhighlighting() {
    54   ok(presenter._currentSelection < 0,
    55     "Unhighlighting a should remove the current selection.");
    56   ok(presenter._highlight.disabled,
    57     "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh.");
    59   executeSoon(function() {
    60     Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
    61     Services.obs.addObserver(cleanup, DESTROYED, false);
    62     Tilt.destroy(Tilt.currentWindowId);
    63   });
    64 }
    66 function cleanup() {
    67   if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); }
    68   gBrowser.removeCurrentTab();
    69   finish();
    70 }

mercurial