1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-popup-08.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests opening inspecting variables works across scopes. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_scope-variable.html"; 1.12 + 1.13 +function test() { 1.14 + Task.spawn(function() { 1.15 + let [tab, debuggee, panel] = yield initDebugger(TAB_URL); 1.16 + let win = panel.panelWin; 1.17 + let events = win.EVENTS; 1.18 + let editor = win.DebuggerView.editor; 1.19 + let frames = win.DebuggerView.StackFrames; 1.20 + let bubble = win.DebuggerView.VariableBubble; 1.21 + let tooltip = bubble._tooltip.panel; 1.22 + 1.23 + function verifyContents(textContent, className) { 1.24 + is(tooltip.querySelectorAll(".variables-view-container").length, 0, 1.25 + "There should be no variables view containers added to the tooltip."); 1.26 + is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 1, 1.27 + "There should be a simple text node added to the tooltip instead."); 1.28 + 1.29 + is(tooltip.querySelector(".devtools-tooltip-simple-text").textContent, textContent, 1.30 + "The inspected property's value is correct."); 1.31 + ok(tooltip.querySelector(".devtools-tooltip-simple-text").className.contains(className), 1.32 + "The inspected property's value is colorized correctly."); 1.33 + } 1.34 + 1.35 + function checkView(selectedFrame, caretLine) { 1.36 + is(win.gThreadClient.state, "paused", 1.37 + "Should only be getting stack frames while paused."); 1.38 + is(frames.itemCount, 2, 1.39 + "Should have two frames."); 1.40 + is(frames.selectedDepth, selectedFrame, 1.41 + "The correct frame is selected in the widget."); 1.42 + ok(isCaretPos(panel, caretLine), 1.43 + "Editor caret location is correct."); 1.44 + } 1.45 + 1.46 + // Allow this generator function to yield first. 1.47 + executeSoon(() => debuggee.test()); 1.48 + yield waitForSourceAndCaretAndScopes(panel, ".html", 20); 1.49 + checkView(0, 20); 1.50 + 1.51 + // Inspect variable in topmost frame. 1.52 + yield openVarPopup(panel, { line: 18, ch: 12 }); 1.53 + verifyContents("\"second scope\"", "token-string"); 1.54 + checkView(0, 20); 1.55 + 1.56 + // Hide the popup and change the frame. 1.57 + yield hideVarPopup(panel); 1.58 + 1.59 + let updatedFrame = waitForDebuggerEvents(panel, events.FETCHED_SCOPES); 1.60 + frames.selectedDepth = 1; 1.61 + yield updatedFrame; 1.62 + checkView(1, 15); 1.63 + 1.64 + // Inspect variable in oldest frame. 1.65 + yield openVarPopup(panel, { line: 13, ch: 12 }); 1.66 + verifyContents("\"first scope\"", "token-string"); 1.67 + checkView(1, 15); 1.68 + 1.69 + yield resumeDebuggerThenCloseAndFinish(panel); 1.70 + }); 1.71 +}