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: * Tests that the variable inspection popup has inspector links for DOMNode michael@0: * properties and that the popup closes when the link is clicked michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_domnode-variables.html"; michael@0: michael@0: function test() { michael@0: Task.spawn(function() { michael@0: let [tab, debuggee, panel] = yield initDebugger(TAB_URL); michael@0: let win = panel.panelWin; michael@0: let bubble = win.DebuggerView.VariableBubble; michael@0: let tooltip = bubble._tooltip.panel; michael@0: let toolbox = gDevTools.getToolbox(panel.target); michael@0: michael@0: function getDomNodeInTooltip(propertyName) { michael@0: let domNodeProperties = tooltip.querySelectorAll(".token-domnode"); michael@0: for (let prop of domNodeProperties) { michael@0: let propName = prop.parentNode.querySelector(".name"); michael@0: if (propName.getAttribute("value") === propertyName) { michael@0: ok(true, "DOMNode " + propertyName + " was found in the tooltip"); michael@0: return prop; michael@0: } michael@0: } michael@0: ok(false, "DOMNode " + propertyName + " wasn't found in the tooltip"); michael@0: } michael@0: michael@0: // Allow this generator function to yield first. michael@0: executeSoon(() => debuggee.start()); michael@0: yield waitForSourceAndCaretAndScopes(panel, ".html", 19); michael@0: michael@0: // Inspect the div DOM variable. michael@0: yield openVarPopup(panel, { line: 17, ch: 38 }, true); michael@0: let property = getDomNodeInTooltip("firstElementChild"); michael@0: michael@0: // Simulate mouseover on the property value michael@0: let highlighted = once(toolbox, "node-highlight"); michael@0: EventUtils.sendMouseEvent({ type: "mouseover" }, property, michael@0: property.ownerDocument.defaultView); michael@0: yield highlighted; michael@0: ok(true, "The node-highlight event was fired on hover of the DOMNode"); michael@0: michael@0: // Simulate a click on the "select in inspector" button michael@0: let button = property.parentNode.querySelector(".variables-view-open-inspector"); michael@0: ok(button, "The select-in-inspector button is present"); michael@0: let inspectorSelected = once(toolbox, "inspector-selected"); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, button, michael@0: button.ownerDocument.defaultView); michael@0: yield inspectorSelected; michael@0: ok(true, "The inspector got selected when clicked on the select-in-inspector"); michael@0: michael@0: // Make sure the inspector's initialization is finalized before ending the test michael@0: // Listening to the event *after* triggering the switch to the inspector isn't michael@0: // a problem as the inspector is asynchronously loaded. michael@0: yield once(toolbox.getPanel("inspector"), "inspector-updated"); michael@0: michael@0: yield resumeDebuggerThenCloseAndFinish(panel); michael@0: }); michael@0: }