michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests opening inspecting variables works across scopes. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_scope-variable.html"; michael@0: michael@0: function test() { michael@0: Task.spawn(function() { michael@0: let [tab, debuggee, panel] = yield initDebugger(TAB_URL); michael@0: let win = panel.panelWin; michael@0: let events = win.EVENTS; michael@0: let editor = win.DebuggerView.editor; michael@0: let frames = win.DebuggerView.StackFrames; michael@0: let bubble = win.DebuggerView.VariableBubble; michael@0: let tooltip = bubble._tooltip.panel; michael@0: michael@0: function verifyContents(textContent, className) { michael@0: is(tooltip.querySelectorAll(".variables-view-container").length, 0, michael@0: "There should be no variables view containers added to the tooltip."); michael@0: is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 1, michael@0: "There should be a simple text node added to the tooltip instead."); michael@0: michael@0: is(tooltip.querySelector(".devtools-tooltip-simple-text").textContent, textContent, michael@0: "The inspected property's value is correct."); michael@0: ok(tooltip.querySelector(".devtools-tooltip-simple-text").className.contains(className), michael@0: "The inspected property's value is colorized correctly."); michael@0: } michael@0: michael@0: function checkView(selectedFrame, caretLine) { michael@0: is(win.gThreadClient.state, "paused", michael@0: "Should only be getting stack frames while paused."); michael@0: is(frames.itemCount, 2, michael@0: "Should have two frames."); michael@0: is(frames.selectedDepth, selectedFrame, michael@0: "The correct frame is selected in the widget."); michael@0: ok(isCaretPos(panel, caretLine), michael@0: "Editor caret location is correct."); michael@0: } michael@0: michael@0: // Allow this generator function to yield first. michael@0: executeSoon(() => debuggee.test()); michael@0: yield waitForSourceAndCaretAndScopes(panel, ".html", 20); michael@0: checkView(0, 20); michael@0: michael@0: // Inspect variable in topmost frame. michael@0: yield openVarPopup(panel, { line: 18, ch: 12 }); michael@0: verifyContents("\"second scope\"", "token-string"); michael@0: checkView(0, 20); michael@0: michael@0: // Hide the popup and change the frame. michael@0: yield hideVarPopup(panel); michael@0: michael@0: let updatedFrame = waitForDebuggerEvents(panel, events.FETCHED_SCOPES); michael@0: frames.selectedDepth = 1; michael@0: yield updatedFrame; michael@0: checkView(1, 15); michael@0: michael@0: // Inspect variable in oldest frame. michael@0: yield openVarPopup(panel, { line: 13, ch: 12 }); michael@0: verifyContents("\"first scope\"", "token-string"); michael@0: checkView(1, 15); michael@0: michael@0: yield resumeDebuggerThenCloseAndFinish(panel); michael@0: }); michael@0: }