|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that the variable inspection popup has inspector links for DOMNode |
|
6 * properties and that the popup closes when the link is clicked |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_domnode-variables.html"; |
|
10 |
|
11 function test() { |
|
12 Task.spawn(function() { |
|
13 let [tab, debuggee, panel] = yield initDebugger(TAB_URL); |
|
14 let win = panel.panelWin; |
|
15 let bubble = win.DebuggerView.VariableBubble; |
|
16 let tooltip = bubble._tooltip.panel; |
|
17 let toolbox = gDevTools.getToolbox(panel.target); |
|
18 |
|
19 function getDomNodeInTooltip(propertyName) { |
|
20 let domNodeProperties = tooltip.querySelectorAll(".token-domnode"); |
|
21 for (let prop of domNodeProperties) { |
|
22 let propName = prop.parentNode.querySelector(".name"); |
|
23 if (propName.getAttribute("value") === propertyName) { |
|
24 ok(true, "DOMNode " + propertyName + " was found in the tooltip"); |
|
25 return prop; |
|
26 } |
|
27 } |
|
28 ok(false, "DOMNode " + propertyName + " wasn't found in the tooltip"); |
|
29 } |
|
30 |
|
31 // Allow this generator function to yield first. |
|
32 executeSoon(() => debuggee.start()); |
|
33 yield waitForSourceAndCaretAndScopes(panel, ".html", 19); |
|
34 |
|
35 // Inspect the div DOM variable. |
|
36 yield openVarPopup(panel, { line: 17, ch: 38 }, true); |
|
37 let property = getDomNodeInTooltip("firstElementChild"); |
|
38 |
|
39 // Simulate mouseover on the property value |
|
40 let highlighted = once(toolbox, "node-highlight"); |
|
41 EventUtils.sendMouseEvent({ type: "mouseover" }, property, |
|
42 property.ownerDocument.defaultView); |
|
43 yield highlighted; |
|
44 ok(true, "The node-highlight event was fired on hover of the DOMNode"); |
|
45 |
|
46 // Simulate a click on the "select in inspector" button |
|
47 let button = property.parentNode.querySelector(".variables-view-open-inspector"); |
|
48 ok(button, "The select-in-inspector button is present"); |
|
49 let inspectorSelected = once(toolbox, "inspector-selected"); |
|
50 EventUtils.sendMouseEvent({ type: "mousedown" }, button, |
|
51 button.ownerDocument.defaultView); |
|
52 yield inspectorSelected; |
|
53 ok(true, "The inspector got selected when clicked on the select-in-inspector"); |
|
54 |
|
55 // Make sure the inspector's initialization is finalized before ending the test |
|
56 // Listening to the event *after* triggering the switch to the inspector isn't |
|
57 // a problem as the inspector is asynchronously loaded. |
|
58 yield once(toolbox.getPanel("inspector"), "inspector-updated"); |
|
59 |
|
60 yield resumeDebuggerThenCloseAndFinish(panel); |
|
61 }); |
|
62 } |