browser/devtools/tilt/test/browser_tilt_picking.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 pickDone = false;
     7 function test() {
     8   if (!isTiltEnabled()) {
     9     info("Skipping picking test because Tilt isn't enabled.");
    10     return;
    11   }
    12   if (!isWebGLSupported()) {
    13     info("Skipping picking test because WebGL isn't supported.");
    14     return;
    15   }
    17   waitForExplicitFinish();
    19   createTab(function() {
    20     createTilt({
    21       onTiltOpen: function(instance)
    22       {
    23         let presenter = instance.presenter;
    24         let canvas = presenter.canvas;
    26         presenter._onSetupMesh = function() {
    27           let p = getPickablePoint(presenter);
    29           presenter.pickNode(p[0], p[1], {
    30             onpick: function(data)
    31             {
    32               ok(data.index > 0,
    33                 "Simply picking a node didn't work properly.");
    35               pickDone = true;
    36               Services.obs.addObserver(cleanup, DESTROYED, false);
    37               Tilt.destroy(Tilt.currentWindowId);
    38             }
    39           });
    40         };
    41       }
    42     }, false, function suddenDeath()
    43     {
    44       info("Tilt could not be initialized properly.");
    45       cleanup();
    46     });
    47   });
    48 }
    50 function cleanup() {
    51   if (pickDone) { Services.obs.removeObserver(cleanup, DESTROYED); }
    52   gBrowser.removeCurrentTab();
    53   finish();
    54 }

mercurial