browser/devtools/debugger/test/browser_dbg_variables-view-popup-13.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial