1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/tilt/test/browser_tilt_picking_highlight03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 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 nodeHighlighted = false; 1.9 +let presenter; 1.10 + 1.11 +function test() { 1.12 + if (!isTiltEnabled()) { 1.13 + info("Skipping highlight test because Tilt isn't enabled."); 1.14 + return; 1.15 + } 1.16 + if (!isWebGLSupported()) { 1.17 + info("Skipping highlight test because WebGL isn't supported."); 1.18 + return; 1.19 + } 1.20 + 1.21 + waitForExplicitFinish(); 1.22 + 1.23 + createTab(function() { 1.24 + createTilt({ 1.25 + onTiltOpen: function(instance) 1.26 + { 1.27 + presenter = instance.presenter; 1.28 + Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false); 1.29 + 1.30 + presenter._onInitializationFinished = function() { 1.31 + nodeHighlighted = true; 1.32 + presenter.highlightNodeFor(3); // 1 = html, 2 = body, 3 = first div 1.33 + }; 1.34 + } 1.35 + }, false, function suddenDeath() 1.36 + { 1.37 + info("Tilt could not be initialized properly."); 1.38 + cleanup(); 1.39 + }); 1.40 + }); 1.41 +} 1.42 + 1.43 +function whenHighlighting() { 1.44 + ok(presenter._currentSelection > 0, 1.45 + "Highlighting a node didn't work properly."); 1.46 + ok(!presenter._highlight.disabled, 1.47 + "After highlighting a node, it should be highlighted. D'oh."); 1.48 + 1.49 + executeSoon(function() { 1.50 + Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING); 1.51 + Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false); 1.52 + presenter.highlightNodeFor(-1); 1.53 + }); 1.54 +} 1.55 + 1.56 +function whenUnhighlighting() { 1.57 + ok(presenter._currentSelection < 0, 1.58 + "Unhighlighting a should remove the current selection."); 1.59 + ok(presenter._highlight.disabled, 1.60 + "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh."); 1.61 + 1.62 + executeSoon(function() { 1.63 + Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING); 1.64 + Services.obs.addObserver(cleanup, DESTROYED, false); 1.65 + Tilt.destroy(Tilt.currentWindowId); 1.66 + }); 1.67 +} 1.68 + 1.69 +function cleanup() { 1.70 + if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); } 1.71 + gBrowser.removeCurrentTab(); 1.72 + finish(); 1.73 +}