Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3 "use strict";
5 let nodeHighlighted = false;
6 let presenter;
8 function test() {
9 if (!isTiltEnabled()) {
10 info("Skipping highlight test because Tilt isn't enabled.");
11 return;
12 }
13 if (!isWebGLSupported()) {
14 info("Skipping highlight test because WebGL isn't supported.");
15 return;
16 }
18 waitForExplicitFinish();
20 createTab(function() {
21 createTilt({
22 onTiltOpen: function(instance)
23 {
24 presenter = instance.presenter;
25 Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false);
27 presenter._onInitializationFinished = function() {
28 let contentDocument = presenter.contentWindow.document;
29 let div = contentDocument.getElementById("first-law");
31 nodeHighlighted = true;
32 presenter.highlightNode(div, "moveIntoView");
33 };
34 }
35 }, false, function suddenDeath()
36 {
37 info("Tilt could not be initialized properly.");
38 cleanup();
39 });
40 });
41 }
43 function whenHighlighting() {
44 ok(presenter._currentSelection > 0,
45 "Highlighting a node didn't work properly.");
46 ok(!presenter._highlight.disabled,
47 "After highlighting a node, it should be highlighted. D'oh.");
48 ok(!presenter.controller.arcball._resetInProgress,
49 "Highlighting a node that's already visible shouldn't trigger a reset.");
51 executeSoon(function() {
52 Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
53 Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false);
54 presenter.highlightNode(null);
55 });
56 }
58 function whenUnhighlighting() {
59 ok(presenter._currentSelection < 0,
60 "Unhighlighting a should remove the current selection.");
61 ok(presenter._highlight.disabled,
62 "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh.");
64 executeSoon(function() {
65 Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
66 Services.obs.addObserver(cleanup, DESTROYED, false);
67 Tilt.destroy(Tilt.currentWindowId);
68 });
69 }
71 function cleanup() {
72 if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); }
73 gBrowser.removeCurrentTab();
74 finish();
75 }