michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Test that inspector links in webconsole outputs for DOM Nodes highlight michael@0: // the actual DOM Nodes on hover michael@0: michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-output-dom-elements.html"; michael@0: michael@0: function test() { michael@0: Task.spawn(function*() { michael@0: let {tab} = yield loadTab(TEST_URI); michael@0: let hud = yield openConsole(tab); michael@0: let toolbox = gDevTools.getToolbox(hud.target); michael@0: michael@0: // Loading the inspector panel at first, to make it possible to listen for michael@0: // new node selections michael@0: yield toolbox.loadTool("inspector"); michael@0: let inspector = toolbox.getPanel("inspector"); michael@0: michael@0: info("Executing 'testNode()' in the web console to output a DOM Node"); michael@0: let [result] = yield jsEval("testNode()", hud, { michael@0: text: '
' michael@0: }); michael@0: michael@0: let elementNodeWidget = yield getWidget(result); michael@0: michael@0: let nodeFront = yield hoverOverWidget(elementNodeWidget, toolbox); michael@0: let attrs = nodeFront.attributes; michael@0: is(nodeFront.tagName, "P", "The correct node was highlighted"); michael@0: is(attrs[0].name, "some-attribute", "The correct node was highlighted"); michael@0: is(attrs[0].value, "some-value", "The correct node was highlighted"); michael@0: }).then(finishTest); michael@0: } michael@0: michael@0: function jsEval(input, hud, message) { michael@0: hud.jsterm.execute(input); michael@0: return waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [message] michael@0: }); michael@0: } michael@0: michael@0: function* getWidget(result) { michael@0: info("Getting the output ElementNode widget"); michael@0: michael@0: let msg = [...result.matched][0]; michael@0: let elementNodeWidget = [...msg._messageObject.widgets][0]; michael@0: ok(elementNodeWidget, "ElementNode widget found in the output"); michael@0: michael@0: info("Waiting for the ElementNode widget to be linked to the inspector"); michael@0: yield elementNodeWidget.linkToInspector(); michael@0: michael@0: return elementNodeWidget; michael@0: } michael@0: michael@0: function* hoverOverWidget(widget, toolbox) { michael@0: info("Hovering over the output to highlight the node"); michael@0: michael@0: let onHighlight = toolbox.once("node-highlight"); michael@0: EventUtils.sendMouseEvent({type: "mouseover"}, widget.element, michael@0: widget.element.ownerDocument.defaultView); michael@0: let nodeFront = yield onHighlight; michael@0: ok(true, "The highlighter was shown on a node"); michael@0: return nodeFront; michael@0: }