diff --git a/browser/devtools/framework/test/browser_keybindings.js b/browser/devtools/framework/test/browser_keybindings.js index b49a8f822a1..c7b444700a6 100644 --- a/browser/devtools/framework/test/browser_keybindings.js +++ b/browser/devtools/framework/test/browser_keybindings.js @@ -17,6 +17,7 @@ function test() gBrowser.selectedBrowser.addEventListener("load", function onload() { gBrowser.selectedBrowser.removeEventListener("load", onload, true); doc = content.document; + node = doc.querySelector("h1"); waitForFocus(setupKeyBindingsTest, content); }, true); @@ -63,24 +64,37 @@ function test() keysetMap.inspector.synthesizeKey(); } + function moveMouseOver(aElement, aInspector, cb) + { + EventUtils.synthesizeMouse(aElement, 2, 2, {type: "mousemove"}, + aElement.ownerDocument.defaultView); + aInspector.toolbox.once("picker-node-hovered", () => { + executeSoon(cb); + }); + } + + function isHighlighting() + { + let outline = gBrowser.selectedBrowser.parentNode + .querySelector(".highlighter-container .highlighter-outline"); + return outline && !outline.hasAttribute("hidden"); + } + function inspectorShouldBeOpenAndHighlighting(aInspector, aToolbox) { is (aToolbox.currentToolId, "inspector", "Correct tool has been loaded"); - is (aInspector.highlighter.locked, true, "Highlighter should be locked"); - aInspector.highlighter.once("unlocked", () => { - is (aInspector.highlighter.locked, false, "Highlighter should be unlocked"); + aToolbox.once("picker-started", () => { + ok(true, "picker-started event received, highlighter started"); keysetMap.inspector.synthesizeKey(); - is (aInspector.highlighter.locked, true, "Highlighter should be locked"); - keysetMap.inspector.synthesizeKey(); - is (aInspector.highlighter.locked, false, "Highlighter should be unlocked"); - keysetMap.inspector.synthesizeKey(); - is (aInspector.highlighter.locked, true, "Highlighter should be locked"); - aToolbox.once("webconsole-ready", (e, panel) => { - webconsoleShouldBeSelected(aToolbox, panel); + aToolbox.once("picker-stopped", () => { + ok(true, "picker-stopped event received, highlighter stopped"); + aToolbox.once("webconsole-ready", (e, panel) => { + webconsoleShouldBeSelected(aToolbox, panel); + }); + keysetMap.webconsole.synthesizeKey(); }); - keysetMap.webconsole.synthesizeKey(); }); } diff --git a/browser/devtools/inspector/test/browser.ini b/browser/devtools/inspector/test/browser.ini index b87eef39f27..a60802b3d3b 100644 --- a/browser/devtools/inspector/test/browser.ini +++ b/browser/devtools/inspector/test/browser.ini @@ -24,14 +24,12 @@ support-files = [browser_inspector_bug_831693_input_suggestion.js] # [browser_inspector_bug_831693_searchbox_panel_navigation.js] # Disabled for too many intermittent failures (bug 851349) -[browser_inspector_bug_835722_infobar_reappears.js] [browser_inspector_bug_840156_destroy_after_navigation.js] [browser_inspector_changes.js] [browser_inspector_cmd_inspect.js] [browser_inspector_dead_node_exception.js] [browser_inspector_destroyselection.js] [browser_inspector_highlighter.js] -[browser_inspector_highlighter_autohide.js] [browser_inspector_iframeTest.js] [browser_inspector_infobar.js] [browser_inspector_initialization.js] diff --git a/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js b/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js index b1c2d3c804c..8ef0a0f8a92 100644 --- a/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js +++ b/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js @@ -2,13 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - function test() { - let inspector, doc; + let inspector, doc, toolbox; let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let {require} = devtools; let promise = require("sdk/core/promise"); - let { Task } = Cu.import("resource://gre/modules/Task.jsm", {}); + let {Task} = Cu.import("resource://gre/modules/Task.jsm", {}); waitForExplicitFinish(); @@ -19,75 +18,67 @@ function test() { waitForFocus(setupTest, content); }, true); - content.location = "data:text/html,

foo

bar

"; + content.location = "data:text/html,

foo

bar

"; function setupTest() { - let h = require("devtools/inspector/highlighter"); - h._forceBasic.value = true; - openInspector(runTests); + openInspector((aInspector, aToolbox) => { + toolbox = aToolbox; + inspector = aInspector; + inspector.selection.setNode(doc.querySelector("h2"), null); + inspector.once("inspector-updated", runTests); + }); } function runTests(aInspector) { - inspector = aInspector; - + getHighlighterOutline().setAttribute("disable-transitions", "true"); Task.spawn(function() { - yield selectH1(); - yield verifyH1Selected(); - yield deselect(); - yield verifyNoNodeSelected(); - - yield selectH1(); - yield verifyH1Selected(); - yield destroyInspector(); - yield verifyNoNodeSelected(); + yield hoverH1InMarkupView(); + yield assertH1Highlighted(); + yield mouseLeaveMarkupView(); + yield assertNoNodeHighlighted(); finishUp(); }).then(null, Cu.reportError); } - function selectH1() { + function hoverH1InMarkupView() { let deferred = promise.defer(); - let h1 = doc.querySelector("h1"); - inspector.selection.once("new-node-front", () => { - executeSoon(deferred.resolve); - }); - inspector.selection.setNode(h1); + + let container = getContainerForRawNode(inspector.markup, doc.querySelector("h1")); + EventUtils.synthesizeMouse(container.tagLine, 2, 2, {type: "mousemove"}, + inspector.markup.doc.defaultView); + inspector.markup.once("node-highlight", deferred.resolve); + return deferred.promise; } - function verifyH1Selected() { - let h1 = doc.querySelector("h1"); - let nodes = doc.querySelectorAll(":-moz-devtools-highlighted"); - is(nodes.length, 1, "only one node selected"); - is(nodes[0], h1, "h1 selected"); + function assertH1Highlighted() { + ok(isHighlighting(), "The highlighter is shown on a markup container hover"); + is(getHighlitNode(), doc.querySelector("h1"), "The highlighter highlights the right node"); return promise.resolve(); } - function deselect() { + function mouseLeaveMarkupView() { let deferred = promise.defer(); - inspector.selection.once("new-node-front", () => { - executeSoon(deferred.resolve); - }); - inspector.selection.setNode(null); + + // Find another element to mouseover over in order to leave the markup-view + let btn = toolbox.doc.querySelector(".toolbox-dock-button"); + + EventUtils.synthesizeMouse(btn, 2, 2, {type: "mousemove"}, + toolbox.doc.defaultView); + executeSoon(deferred.resolve); + return deferred.promise; } - function destroyInspector() { - return inspector.destroy(); - } - - function verifyNoNodeSelected() { - is(doc.querySelectorAll(":-moz-devtools-highlighted").length, 0, "no node selected"); + function assertNoNodeHighlighted() { + ok(!isHighlighting(), "After the mouse left the markup view, the highlighter is hidden"); return promise.resolve(); } function finishUp() { - let h = require("devtools/inspector/highlighter"); - h._forceBasic.value = false; - inspector = doc = null; + inspector = doc = toolbox = null; gBrowser.removeCurrentTab(); finish(); } } - - diff --git a/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js b/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js index d2b98a7c4d3..d6e35ea9109 100644 --- a/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js +++ b/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js @@ -57,7 +57,10 @@ function test() if (cursor >= nodes.length) { inspector.off("breadcrumbs-updated", nodeSelected); - finishUp(); + // breadcrumbs-updated is an event that is fired before the rest of the + // inspector is updated, so there'll be hanging connections if we finish + // up before waiting for everything to end. + inspector.once("inspector-updated", finishUp); } else { let node = nodes[cursor].node; inspector.selection.setNode(node); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_665880.js b/browser/devtools/inspector/test/browser_inspector_bug_665880.js index 58ddcabeeb6..724669f8596 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_665880.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_665880.js @@ -1,9 +1,7 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() -{ +function test() { waitForExplicitFinish(); ignoreAllUncaughtExceptions(); @@ -19,22 +17,18 @@ function test() content.location = "data:text/html,

foobar

"; - function setupObjectInspectionTest() - { + function setupObjectInspectionTest() { objectNode = doc.querySelector("object"); ok(objectNode, "we have the object node"); openInspector(runObjectInspectionTest); } - function runObjectInspectionTest(inspector) - { - inspector.highlighter.once("locked", performTestComparison); - inspector.highlighter.unlock(); + function runObjectInspectionTest(inspector) { + inspector.once("inspector-updated", performTestComparison); inspector.selection.setNode(objectNode, ""); } - function performTestComparison() - { + function performTestComparison() { is(getActiveInspector().selection.node, objectNode, "selection matches node"); let target = TargetFactory.forTab(gBrowser.selectedTab); executeSoon(function() { @@ -43,7 +37,6 @@ function test() }); } - function finishUp() { doc = objectNode = null; gBrowser.removeCurrentTab(); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_674871.js b/browser/devtools/inspector/test/browser_inspector_bug_674871.js index b4c0699879e..9337560932c 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_674871.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_674871.js @@ -7,6 +7,7 @@ function test() let doc; let iframeNode, iframeBodyNode; + let inspector; let iframeSrc = "