|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 "use strict"; |
|
4 |
|
5 let nodeHighlighted = false; |
|
6 let presenter; |
|
7 |
|
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 } |
|
17 |
|
18 waitForExplicitFinish(); |
|
19 |
|
20 createTab(function() { |
|
21 createTilt({ |
|
22 onTiltOpen: function(instance) |
|
23 { |
|
24 presenter = instance.presenter; |
|
25 Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false); |
|
26 |
|
27 presenter._onInitializationFinished = function() { |
|
28 nodeHighlighted = true; |
|
29 presenter.highlightNodeAt.apply(this, getPickablePoint(presenter)); |
|
30 }; |
|
31 } |
|
32 }, false, function suddenDeath() |
|
33 { |
|
34 info("Tilt could not be initialized properly."); |
|
35 cleanup(); |
|
36 }); |
|
37 }); |
|
38 } |
|
39 |
|
40 function whenHighlighting() { |
|
41 ok(presenter._currentSelection > 0, |
|
42 "Highlighting a node didn't work properly."); |
|
43 ok(!presenter._highlight.disabled, |
|
44 "After highlighting a node, it should be highlighted. D'oh."); |
|
45 |
|
46 executeSoon(function() { |
|
47 Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING); |
|
48 Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false); |
|
49 presenter.highlightNode(null); |
|
50 }); |
|
51 } |
|
52 |
|
53 function whenUnhighlighting() { |
|
54 ok(presenter._currentSelection < 0, |
|
55 "Unhighlighting a should remove the current selection."); |
|
56 ok(presenter._highlight.disabled, |
|
57 "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh."); |
|
58 |
|
59 executeSoon(function() { |
|
60 Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING); |
|
61 Services.obs.addObserver(cleanup, DESTROYED, false); |
|
62 Tilt.destroy(Tilt.currentWindowId); |
|
63 }); |
|
64 } |
|
65 |
|
66 function cleanup() { |
|
67 if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); } |
|
68 gBrowser.removeCurrentTab(); |
|
69 finish(); |
|
70 } |