1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/tilt/test/browser_tilt_04_initialization.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 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 +function test() { 1.9 + if (!isTiltEnabled()) { 1.10 + info("Skipping initialization test because Tilt isn't enabled."); 1.11 + return; 1.12 + } 1.13 + if (!isWebGLSupported()) { 1.14 + info("Skipping initialization test because WebGL isn't supported."); 1.15 + return; 1.16 + } 1.17 + 1.18 + waitForExplicitFinish(); 1.19 + 1.20 + createTab(function() { 1.21 + let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow); 1.22 + 1.23 + is(id, Tilt.currentWindowId, 1.24 + "The unique window identifiers should match for the same window."); 1.25 + 1.26 + createTilt({ 1.27 + onTiltOpen: function(instance) 1.28 + { 1.29 + is(document.activeElement, instance.presenter.canvas, 1.30 + "The visualizer canvas should be focused on initialization."); 1.31 + 1.32 + ok(Tilt.visualizers[id] instanceof TiltVisualizer, 1.33 + "A new instance of the visualizer wasn't created properly."); 1.34 + ok(Tilt.visualizers[id].isInitialized(), 1.35 + "The new instance of the visualizer wasn't initialized properly."); 1.36 + }, 1.37 + onTiltClose: function() 1.38 + { 1.39 + is(document.activeElement, gBrowser.selectedBrowser, 1.40 + "The focus wasn't correctly given back to the selectedBrowser."); 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 + onEnd: function() 1.46 + { 1.47 + cleanup(); 1.48 + } 1.49 + }, true, function suddenDeath() 1.50 + { 1.51 + info("Tilt could not be initialized properly."); 1.52 + cleanup(); 1.53 + }); 1.54 + }); 1.55 +} 1.56 + 1.57 +function cleanup() { 1.58 + gBrowser.removeCurrentTab(); 1.59 + finish(); 1.60 +}