# HG changeset patch # Parent 6eaacf124f1b522e14f957d38de7d29267a4067a # User Patrick Brosset Bug 952277 - DOMNodes can be highlighted and selected from the debugger - Debugger test; r=vporof diff --git a/browser/devtools/debugger/test/browser.ini b/browser/devtools/debugger/test/browser.ini --- a/browser/devtools/debugger/test/browser.ini +++ b/browser/devtools/debugger/test/browser.ini @@ -31,16 +31,17 @@ support-files = doc_auto-pretty-print-01.html doc_auto-pretty-print-02.html doc_binary_search.html doc_blackboxing.html doc_closures.html doc_cmd-break.html doc_cmd-dbg.html doc_conditional-breakpoints.html + doc_domnode-variables.html doc_editor-mode.html doc_empty-tab-01.html doc_empty-tab-02.html doc_event-listeners.html doc_event-listeners-02.html doc_frame-parameters.html doc_function-display-name.html doc_function-search.html @@ -238,16 +239,17 @@ support-files = [browser_dbg_variables-view-popup-02.js] [browser_dbg_variables-view-popup-03.js] [browser_dbg_variables-view-popup-04.js] [browser_dbg_variables-view-popup-05.js] [browser_dbg_variables-view-popup-06.js] [browser_dbg_variables-view-popup-07.js] [browser_dbg_variables-view-popup-08.js] [browser_dbg_variables-view-popup-09.js] +[browser_dbg_variables-view-popup-10.js] [browser_dbg_variables-view-reexpand-01.js] [browser_dbg_variables-view-reexpand-02.js] [browser_dbg_variables-view-webidl.js] [browser_dbg_watch-expressions-01.js] [browser_dbg_watch-expressions-02.js] [browser_dbg_chrome-create.js] skip-if = os == "linux" # Bug 847558 [browser_dbg_on-pause-raise.js] diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-popup-10.js b/browser/devtools/debugger/test/browser_dbg_variables-view-popup-10.js new file mode 100644 --- /dev/null +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-popup-10.js @@ -0,0 +1,62 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Tests that the variable inspection popup has inspector links for DOMNode + * properties and that the popup closes when the link is clicked + */ + +const TAB_URL = EXAMPLE_URL + "doc_domnode-variables.html"; + +function test() { + Task.spawn(function() { + let [tab, debuggee, panel] = yield initDebugger(TAB_URL); + let win = panel.panelWin; + let bubble = win.DebuggerView.VariableBubble; + let tooltip = bubble._tooltip.panel; + let toolbox = gDevTools.getToolbox(panel.target); + + function getDomNodeInTooltip(propertyName) { + let domNodeProperties = tooltip.querySelectorAll(".token-domnode"); + for (let prop of domNodeProperties) { + let propName = prop.parentNode.querySelector(".name"); + if (propName.getAttribute("value") === propertyName) { + ok(true, "DOMNode " + propertyName + " was found in the tooltip"); + return prop; + } + } + ok(false, "DOMNode " + propertyName + " wasn't found in the tooltip"); + } + + // Allow this generator function to yield first. + executeSoon(() => debuggee.start()); + yield waitForSourceAndCaretAndScopes(panel, ".html", 19); + + // Inspect the div DOM variable. + yield openVarPopup(panel, { line: 17, ch: 38 }, true); + let property = getDomNodeInTooltip("firstElementChild"); + + // Simulate mouseover on the property value + let highlighted = once(toolbox, "node-highlight"); + EventUtils.sendMouseEvent({ type: "mouseover" }, property, + property.ownerDocument.defaultView); + yield highlighted; + ok(true, "The node-highlight event was fired on hover of the DOMNode"); + + // Simulate a click on the "select in inspector" button + let button = property.parentNode.querySelector(".variables-view-open-inspector"); + ok(button, "The select-in-inspector button is present"); + let inspectorSelected = once(toolbox, "inspector-selected"); + EventUtils.sendMouseEvent({ type: "mousedown" }, button, + button.ownerDocument.defaultView); + yield inspectorSelected; + ok(true, "The inspector got selected when clicked on the select-in-inspector"); + + // Make sure the inspector's initialization is finalized before ending the test + // Listening to the event *after* triggering the switch to the inspector isn't + // a problem as the inspector is asynchronously loaded. + yield once(toolbox.getPanel("inspector"), "inspector-updated"); + + yield resumeDebuggerThenCloseAndFinish(panel); + }); +} diff --git a/browser/devtools/debugger/test/doc_domnode-variables.html b/browser/devtools/debugger/test/doc_domnode-variables.html new file mode 100644 --- /dev/null +++ b/browser/devtools/debugger/test/doc_domnode-variables.html @@ -0,0 +1,24 @@ + + + + + + + Debugger test page + + + +
Look at this DIV! Just look at it!
+ + + + +