Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | "use strict"; |
michael@0 | 4 | |
michael@0 | 5 | let nodeHighlighted = false; |
michael@0 | 6 | let presenter; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | if (!isTiltEnabled()) { |
michael@0 | 10 | info("Skipping highlight test because Tilt isn't enabled."); |
michael@0 | 11 | return; |
michael@0 | 12 | } |
michael@0 | 13 | if (!isWebGLSupported()) { |
michael@0 | 14 | info("Skipping highlight test because WebGL isn't supported."); |
michael@0 | 15 | return; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | waitForExplicitFinish(); |
michael@0 | 19 | |
michael@0 | 20 | createTab(function() { |
michael@0 | 21 | createTilt({ |
michael@0 | 22 | onTiltOpen: function(instance) |
michael@0 | 23 | { |
michael@0 | 24 | presenter = instance.presenter; |
michael@0 | 25 | Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false); |
michael@0 | 26 | |
michael@0 | 27 | presenter._onInitializationFinished = function() { |
michael@0 | 28 | let contentDocument = presenter.contentWindow.document; |
michael@0 | 29 | let div = contentDocument.getElementById("far-far-away"); |
michael@0 | 30 | |
michael@0 | 31 | nodeHighlighted = true; |
michael@0 | 32 | presenter.highlightNode(div); |
michael@0 | 33 | }; |
michael@0 | 34 | } |
michael@0 | 35 | }, false, function suddenDeath() |
michael@0 | 36 | { |
michael@0 | 37 | info("Tilt could not be initialized properly."); |
michael@0 | 38 | cleanup(); |
michael@0 | 39 | }); |
michael@0 | 40 | }); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function whenHighlighting() { |
michael@0 | 44 | ok(presenter._currentSelection > 0, |
michael@0 | 45 | "Highlighting a node didn't work properly."); |
michael@0 | 46 | ok(!presenter._highlight.disabled, |
michael@0 | 47 | "After highlighting a node, it should be highlighted. D'oh."); |
michael@0 | 48 | ok(!presenter.controller.arcball._resetInProgress, |
michael@0 | 49 | "Highlighting a node that's not already visible shouldn't trigger a reset " + |
michael@0 | 50 | "without this being explicitly requested!"); |
michael@0 | 51 | |
michael@0 | 52 | EventUtils.sendKey("F"); |
michael@0 | 53 | executeSoon(whenBringingIntoView); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function whenBringingIntoView() { |
michael@0 | 57 | ok(presenter._currentSelection > 0, |
michael@0 | 58 | "The node should still be selected."); |
michael@0 | 59 | ok(!presenter._highlight.disabled, |
michael@0 | 60 | "The node should still be highlighted"); |
michael@0 | 61 | ok(presenter.controller.arcball._resetInProgress, |
michael@0 | 62 | "Highlighting a node that's not already visible should trigger a reset " + |
michael@0 | 63 | "when this is being explicitly requested!"); |
michael@0 | 64 | |
michael@0 | 65 | executeSoon(function() { |
michael@0 | 66 | Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING); |
michael@0 | 67 | Services.obs.addObserver(cleanup, DESTROYED, false); |
michael@0 | 68 | Tilt.destroy(Tilt.currentWindowId); |
michael@0 | 69 | }); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function cleanup() { |
michael@0 | 73 | if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); } |
michael@0 | 74 | gBrowser.removeCurrentTab(); |
michael@0 | 75 | finish(); |
michael@0 | 76 | } |