|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 "use strict"; |
|
4 |
|
5 function test() { |
|
6 if (!isTiltEnabled()) { |
|
7 info("Skipping initialization test because Tilt isn't enabled."); |
|
8 return; |
|
9 } |
|
10 if (!isWebGLSupported()) { |
|
11 info("Skipping initialization test because WebGL isn't supported."); |
|
12 return; |
|
13 } |
|
14 |
|
15 waitForExplicitFinish(); |
|
16 |
|
17 createTab(function() { |
|
18 let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow); |
|
19 |
|
20 is(id, Tilt.currentWindowId, |
|
21 "The unique window identifiers should match for the same window."); |
|
22 |
|
23 createTilt({ |
|
24 onTiltOpen: function(instance) |
|
25 { |
|
26 is(document.activeElement, instance.presenter.canvas, |
|
27 "The visualizer canvas should be focused on initialization."); |
|
28 |
|
29 ok(Tilt.visualizers[id] instanceof TiltVisualizer, |
|
30 "A new instance of the visualizer wasn't created properly."); |
|
31 ok(Tilt.visualizers[id].isInitialized(), |
|
32 "The new instance of the visualizer wasn't initialized properly."); |
|
33 }, |
|
34 onTiltClose: function() |
|
35 { |
|
36 is(document.activeElement, gBrowser.selectedBrowser, |
|
37 "The focus wasn't correctly given back to the selectedBrowser."); |
|
38 |
|
39 is(Tilt.visualizers[id], null, |
|
40 "The current instance of the visualizer wasn't destroyed properly."); |
|
41 }, |
|
42 onEnd: function() |
|
43 { |
|
44 cleanup(); |
|
45 } |
|
46 }, true, function suddenDeath() |
|
47 { |
|
48 info("Tilt could not be initialized properly."); |
|
49 cleanup(); |
|
50 }); |
|
51 }); |
|
52 } |
|
53 |
|
54 function cleanup() { |
|
55 gBrowser.removeCurrentTab(); |
|
56 finish(); |
|
57 } |