|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 "use strict"; |
|
4 |
|
5 let tiltOpened = false; |
|
6 |
|
7 function test() { |
|
8 if (!isTiltEnabled()) { |
|
9 info("Skipping destruction test because Tilt isn't enabled."); |
|
10 return; |
|
11 } |
|
12 if (!isWebGLSupported()) { |
|
13 info("Skipping destruction test because WebGL isn't supported."); |
|
14 return; |
|
15 } |
|
16 |
|
17 waitForExplicitFinish(); |
|
18 |
|
19 createTab(function() { |
|
20 createTilt({ |
|
21 onTiltOpen: function() |
|
22 { |
|
23 tiltOpened = true; |
|
24 |
|
25 Services.obs.addObserver(finalize, DESTROYED, false); |
|
26 window.content.location = "about:mozilla"; |
|
27 } |
|
28 }, false, function suddenDeath() |
|
29 { |
|
30 info("Tilt could not be initialized properly."); |
|
31 cleanup(); |
|
32 }); |
|
33 }); |
|
34 } |
|
35 |
|
36 function finalize() { |
|
37 let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow); |
|
38 |
|
39 is(Tilt.visualizers[id], null, |
|
40 "The current instance of the visualizer wasn't destroyed properly."); |
|
41 |
|
42 cleanup(); |
|
43 } |
|
44 |
|
45 function cleanup() { |
|
46 if (tiltOpened) { Services.obs.removeObserver(finalize, DESTROYED); } |
|
47 gBrowser.removeCurrentTab(); |
|
48 finish(); |
|
49 } |