1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-popup-13.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests that the variable inspection popup has inspector links for DOMNode 1.9 + * properties and that the popup closes when the link is clicked 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_domnode-variables.html"; 1.13 + 1.14 +function test() { 1.15 + Task.spawn(function() { 1.16 + let [tab, debuggee, panel] = yield initDebugger(TAB_URL); 1.17 + let win = panel.panelWin; 1.18 + let bubble = win.DebuggerView.VariableBubble; 1.19 + let tooltip = bubble._tooltip.panel; 1.20 + let toolbox = gDevTools.getToolbox(panel.target); 1.21 + 1.22 + function getDomNodeInTooltip(propertyName) { 1.23 + let domNodeProperties = tooltip.querySelectorAll(".token-domnode"); 1.24 + for (let prop of domNodeProperties) { 1.25 + let propName = prop.parentNode.querySelector(".name"); 1.26 + if (propName.getAttribute("value") === propertyName) { 1.27 + ok(true, "DOMNode " + propertyName + " was found in the tooltip"); 1.28 + return prop; 1.29 + } 1.30 + } 1.31 + ok(false, "DOMNode " + propertyName + " wasn't found in the tooltip"); 1.32 + } 1.33 + 1.34 + // Allow this generator function to yield first. 1.35 + executeSoon(() => debuggee.start()); 1.36 + yield waitForSourceAndCaretAndScopes(panel, ".html", 19); 1.37 + 1.38 + // Inspect the div DOM variable. 1.39 + yield openVarPopup(panel, { line: 17, ch: 38 }, true); 1.40 + let property = getDomNodeInTooltip("firstElementChild"); 1.41 + 1.42 + // Simulate mouseover on the property value 1.43 + let highlighted = once(toolbox, "node-highlight"); 1.44 + EventUtils.sendMouseEvent({ type: "mouseover" }, property, 1.45 + property.ownerDocument.defaultView); 1.46 + yield highlighted; 1.47 + ok(true, "The node-highlight event was fired on hover of the DOMNode"); 1.48 + 1.49 + // Simulate a click on the "select in inspector" button 1.50 + let button = property.parentNode.querySelector(".variables-view-open-inspector"); 1.51 + ok(button, "The select-in-inspector button is present"); 1.52 + let inspectorSelected = once(toolbox, "inspector-selected"); 1.53 + EventUtils.sendMouseEvent({ type: "mousedown" }, button, 1.54 + button.ownerDocument.defaultView); 1.55 + yield inspectorSelected; 1.56 + ok(true, "The inspector got selected when clicked on the select-in-inspector"); 1.57 + 1.58 + // Make sure the inspector's initialization is finalized before ending the test 1.59 + // Listening to the event *after* triggering the switch to the inspector isn't 1.60 + // a problem as the inspector is asynchronously loaded. 1.61 + yield once(toolbox.getPanel("inspector"), "inspector-updated"); 1.62 + 1.63 + yield resumeDebuggerThenCloseAndFinish(panel); 1.64 + }); 1.65 +}