Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
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 */
9 const TAB_URL = EXAMPLE_URL + "doc_domnode-variables.html";
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);
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 }
31 // Allow this generator function to yield first.
32 executeSoon(() => debuggee.start());
33 yield waitForSourceAndCaretAndScopes(panel, ".html", 19);
35 // Inspect the div DOM variable.
36 yield openVarPopup(panel, { line: 17, ch: 38 }, true);
37 let property = getDomNodeInTooltip("firstElementChild");
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");
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");
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");
60 yield resumeDebuggerThenCloseAndFinish(panel);
61 });
62 }