summaryrefslogtreecommitdiff
path: root/toolkit/devtools/tilt/test/browser_tilt_picking_highlight02.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/devtools/tilt/test/browser_tilt_picking_highlight02.js')
-rw-r--r--toolkit/devtools/tilt/test/browser_tilt_picking_highlight02.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/toolkit/devtools/tilt/test/browser_tilt_picking_highlight02.js b/toolkit/devtools/tilt/test/browser_tilt_picking_highlight02.js
new file mode 100644
index 000000000..b6f20121e
--- /dev/null
+++ b/toolkit/devtools/tilt/test/browser_tilt_picking_highlight02.js
@@ -0,0 +1,72 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+let nodeHighlighted = false;
+let presenter;
+
+function test() {
+ if (!isTiltEnabled()) {
+ aborting();
+ info("Skipping highlight test because Tilt isn't enabled.");
+ return;
+ }
+ if (!isWebGLSupported()) {
+ aborting();
+ info("Skipping highlight test because WebGL isn't supported.");
+ return;
+ }
+
+ waitForExplicitFinish();
+
+ createTab(function() {
+ createTilt({
+ onTiltOpen: function(instance)
+ {
+ presenter = instance.presenter;
+ Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false);
+
+ presenter._onInitializationFinished = function() {
+ nodeHighlighted = true;
+ presenter.highlightNodeAt.apply(this, getPickablePoint(presenter));
+ };
+ }
+ }, false, function suddenDeath()
+ {
+ ok(false, "Tilt could not be initialized properly.");
+ cleanup();
+ });
+ });
+}
+
+function whenHighlighting() {
+ ok(presenter._currentSelection > 0,
+ "Highlighting a node didn't work properly.");
+ ok(!presenter._highlight.disabled,
+ "After highlighting a node, it should be highlighted. D'oh.");
+
+ executeSoon(function() {
+ Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
+ Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false);
+ presenter.highlightNode(null);
+ });
+}
+
+function whenUnhighlighting() {
+ ok(presenter._currentSelection < 0,
+ "Unhighlighting a should remove the current selection.");
+ ok(presenter._highlight.disabled,
+ "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh.");
+
+ executeSoon(function() {
+ Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
+ Services.obs.addObserver(cleanup, DESTROYED, false);
+ Tilt.destroy(Tilt.currentWindowId);
+ });
+}
+
+function cleanup() {
+ if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); }
+ gBrowser.removeCurrentTab();
+ finish();
+}