2012-01-25 00:04:15 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
|
2012-06-03 10:15:41 -07:00
|
|
|
let nodeHighlighted = false;
|
2012-01-19 07:48:22 -08:00
|
|
|
let presenter;
|
|
|
|
|
2012-01-25 00:04:15 -08:00
|
|
|
function test() {
|
|
|
|
if (!isTiltEnabled()) {
|
|
|
|
info("Skipping highlight test because Tilt isn't enabled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isWebGLSupported()) {
|
|
|
|
info("Skipping highlight test because WebGL isn't supported.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
createTab(function() {
|
|
|
|
createTilt({
|
|
|
|
onTiltOpen: function(instance)
|
|
|
|
{
|
2012-01-19 07:48:22 -08:00
|
|
|
presenter = instance.presenter;
|
|
|
|
Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false);
|
2012-01-25 00:04:15 -08:00
|
|
|
|
2012-03-28 00:54:21 -07:00
|
|
|
presenter._onInitializationFinished = function() {
|
2012-06-03 10:15:41 -07:00
|
|
|
nodeHighlighted = true;
|
2012-03-28 00:54:21 -07:00
|
|
|
presenter.highlightNodeFor(3); // 1 = html, 2 = body, 3 = first div
|
2012-01-25 00:04:15 -08:00
|
|
|
};
|
|
|
|
}
|
2012-06-03 10:15:41 -07:00
|
|
|
}, false, function suddenDeath()
|
|
|
|
{
|
|
|
|
info("Tilt could not be initialized properly.");
|
|
|
|
cleanup();
|
2012-01-25 00:04:15 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-01-19 07:48:22 -08:00
|
|
|
function whenHighlighting() {
|
|
|
|
ok(presenter._currentSelection > 0,
|
|
|
|
"Highlighting a node didn't work properly.");
|
2012-02-07 01:44:55 -08:00
|
|
|
ok(!presenter._highlight.disabled,
|
2012-01-19 07:48:22 -08:00
|
|
|
"After highlighting a node, it should be highlighted. D'oh.");
|
|
|
|
|
|
|
|
executeSoon(function() {
|
2012-03-13 10:20:53 -07:00
|
|
|
Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
|
2012-01-19 07:48:22 -08:00
|
|
|
Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false);
|
|
|
|
presenter.highlightNodeFor(-1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function whenUnhighlighting() {
|
|
|
|
ok(presenter._currentSelection < 0,
|
|
|
|
"Unhighlighting a should remove the current selection.");
|
2012-02-07 01:44:55 -08:00
|
|
|
ok(presenter._highlight.disabled,
|
2012-01-19 07:48:22 -08:00
|
|
|
"After unhighlighting a node, it shouldn't be highlighted anymore. D'oh.");
|
|
|
|
|
|
|
|
executeSoon(function() {
|
2012-03-13 10:20:53 -07:00
|
|
|
Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
|
2012-01-19 07:48:22 -08:00
|
|
|
Services.obs.addObserver(cleanup, DESTROYED, false);
|
2012-11-30 00:07:59 -08:00
|
|
|
Tilt.destroy(Tilt.currentWindowId);
|
2012-01-19 07:48:22 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-01-25 00:04:15 -08:00
|
|
|
function cleanup() {
|
2012-06-03 10:15:41 -07:00
|
|
|
if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); }
|
2012-01-25 00:04:15 -08:00
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
finish();
|
|
|
|
}
|