diff options
Diffstat (limited to 'browser/devtools/tilt/test/browser_tilt_05_destruction.js')
-rw-r--r-- | browser/devtools/tilt/test/browser_tilt_05_destruction.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/browser/devtools/tilt/test/browser_tilt_05_destruction.js b/browser/devtools/tilt/test/browser_tilt_05_destruction.js new file mode 100644 index 000000000..a083fa1bc --- /dev/null +++ b/browser/devtools/tilt/test/browser_tilt_05_destruction.js @@ -0,0 +1,49 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +let tiltOpened = false; + +function test() { + if (!isTiltEnabled()) { + info("Skipping destruction test because Tilt isn't enabled."); + return; + } + if (!isWebGLSupported()) { + info("Skipping destruction test because WebGL isn't supported."); + return; + } + + waitForExplicitFinish(); + + createTab(function() { + createTilt({ + onTiltOpen: function() + { + tiltOpened = true; + + Services.obs.addObserver(finalize, DESTROYED, false); + Tilt.destroy(Tilt.currentWindowId); + } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); + }); + }); +} + +function finalize() { + let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow); + + is(Tilt.visualizers[id], null, + "The current instance of the visualizer wasn't destroyed properly."); + + cleanup(); +} + +function cleanup() { + if (tiltOpened) { Services.obs.removeObserver(finalize, DESTROYED); } + gBrowser.removeCurrentTab(); + finish(); +} |