1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/tilt/test/browser_tilt_05_destruction.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 +"use strict"; 1.7 + 1.8 +let tiltOpened = false; 1.9 + 1.10 +function test() { 1.11 + if (!isTiltEnabled()) { 1.12 + info("Skipping destruction test because Tilt isn't enabled."); 1.13 + return; 1.14 + } 1.15 + if (!isWebGLSupported()) { 1.16 + info("Skipping destruction test because WebGL isn't supported."); 1.17 + return; 1.18 + } 1.19 + 1.20 + waitForExplicitFinish(); 1.21 + 1.22 + createTab(function() { 1.23 + createTilt({ 1.24 + onTiltOpen: function() 1.25 + { 1.26 + tiltOpened = true; 1.27 + 1.28 + Services.obs.addObserver(finalize, DESTROYED, false); 1.29 + Tilt.destroy(Tilt.currentWindowId); 1.30 + } 1.31 + }, false, function suddenDeath() 1.32 + { 1.33 + info("Tilt could not be initialized properly."); 1.34 + cleanup(); 1.35 + }); 1.36 + }); 1.37 +} 1.38 + 1.39 +function finalize() { 1.40 + let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow); 1.41 + 1.42 + is(Tilt.visualizers[id], null, 1.43 + "The current instance of the visualizer wasn't destroyed properly."); 1.44 + 1.45 + cleanup(); 1.46 +} 1.47 + 1.48 +function cleanup() { 1.49 + if (tiltOpened) { Services.obs.removeObserver(finalize, DESTROYED); } 1.50 + gBrowser.removeCurrentTab(); 1.51 + finish(); 1.52 +}