browser/devtools/tilt/test/browser_tilt_picking_miv.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_miv.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     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("far-far-away");
    1.33 +
    1.34 +          nodeHighlighted = true;
    1.35 +          presenter.highlightNode(div);
    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 not already visible shouldn't trigger a reset " +
    1.53 +    "without this being explicitly requested!");
    1.54 +
    1.55 +  EventUtils.sendKey("F");
    1.56 +  executeSoon(whenBringingIntoView);
    1.57 +}
    1.58 +
    1.59 +function whenBringingIntoView() {
    1.60 +  ok(presenter._currentSelection > 0,
    1.61 +    "The node should still be selected.");
    1.62 +  ok(!presenter._highlight.disabled,
    1.63 +    "The node should still be highlighted");
    1.64 +  ok(presenter.controller.arcball._resetInProgress,
    1.65 +    "Highlighting a node that's not already visible should trigger a reset " +
    1.66 +    "when this is being explicitly requested!");
    1.67 +
    1.68 +  executeSoon(function() {
    1.69 +    Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
    1.70 +    Services.obs.addObserver(cleanup, DESTROYED, false);
    1.71 +    Tilt.destroy(Tilt.currentWindowId);
    1.72 +  });
    1.73 +}
    1.74 +
    1.75 +function cleanup() {
    1.76 +  if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); }
    1.77 +  gBrowser.removeCurrentTab();
    1.78 +  finish();
    1.79 +}

mercurial