browser/devtools/tilt/test/browser_tilt_picking_highlight01.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_picking_highlight01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     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 nodeHighlighted = false;
     1.9 +let presenter;
    1.10 +
    1.11 +function test() {
    1.12 +  if (!isTiltEnabled()) {
    1.13 +    info("Skipping highlight test because Tilt isn't enabled.");
    1.14 +    return;
    1.15 +  }
    1.16 +  if (!isWebGLSupported()) {
    1.17 +    info("Skipping highlight test because WebGL isn't supported.");
    1.18 +    return;
    1.19 +  }
    1.20 +
    1.21 +  waitForExplicitFinish();
    1.22 +
    1.23 +  createTab(function() {
    1.24 +    createTilt({
    1.25 +      onTiltOpen: function(instance)
    1.26 +      {
    1.27 +        presenter = instance.presenter;
    1.28 +        Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false);
    1.29 +
    1.30 +        presenter._onInitializationFinished = function() {
    1.31 +          let contentDocument = presenter.contentWindow.document;
    1.32 +          let div = contentDocument.getElementById("first-law");
    1.33 +
    1.34 +          nodeHighlighted = true;
    1.35 +          presenter.highlightNode(div, "moveIntoView");
    1.36 +        };
    1.37 +      }
    1.38 +    }, false, function suddenDeath()
    1.39 +    {
    1.40 +      info("Tilt could not be initialized properly.");
    1.41 +      cleanup();
    1.42 +    });
    1.43 +  });
    1.44 +}
    1.45 +
    1.46 +function whenHighlighting() {
    1.47 +  ok(presenter._currentSelection > 0,
    1.48 +    "Highlighting a node didn't work properly.");
    1.49 +  ok(!presenter._highlight.disabled,
    1.50 +    "After highlighting a node, it should be highlighted. D'oh.");
    1.51 +  ok(!presenter.controller.arcball._resetInProgress,
    1.52 +    "Highlighting a node that's already visible shouldn't trigger a reset.");
    1.53 +
    1.54 +  executeSoon(function() {
    1.55 +    Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
    1.56 +    Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false);
    1.57 +    presenter.highlightNode(null);
    1.58 +  });
    1.59 +}
    1.60 +
    1.61 +function whenUnhighlighting() {
    1.62 +  ok(presenter._currentSelection < 0,
    1.63 +    "Unhighlighting a should remove the current selection.");
    1.64 +  ok(presenter._highlight.disabled,
    1.65 +    "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh.");
    1.66 +
    1.67 +  executeSoon(function() {
    1.68 +    Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
    1.69 +    Services.obs.addObserver(cleanup, DESTROYED, false);
    1.70 +    Tilt.destroy(Tilt.currentWindowId);
    1.71 +  });
    1.72 +}
    1.73 +
    1.74 +function cleanup() {
    1.75 +  if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); }
    1.76 +  gBrowser.removeCurrentTab();
    1.77 +  finish();
    1.78 +}

mercurial