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.
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 opening inspecting variables works across scopes. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_scope-variable.html"; |
michael@0 | 9 | |
michael@0 | 10 | function test() { |
michael@0 | 11 | Task.spawn(function() { |
michael@0 | 12 | let [tab, debuggee, panel] = yield initDebugger(TAB_URL); |
michael@0 | 13 | let win = panel.panelWin; |
michael@0 | 14 | let events = win.EVENTS; |
michael@0 | 15 | let editor = win.DebuggerView.editor; |
michael@0 | 16 | let frames = win.DebuggerView.StackFrames; |
michael@0 | 17 | let bubble = win.DebuggerView.VariableBubble; |
michael@0 | 18 | let tooltip = bubble._tooltip.panel; |
michael@0 | 19 | |
michael@0 | 20 | function verifyContents(textContent, className) { |
michael@0 | 21 | is(tooltip.querySelectorAll(".variables-view-container").length, 0, |
michael@0 | 22 | "There should be no variables view containers added to the tooltip."); |
michael@0 | 23 | is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 1, |
michael@0 | 24 | "There should be a simple text node added to the tooltip instead."); |
michael@0 | 25 | |
michael@0 | 26 | is(tooltip.querySelector(".devtools-tooltip-simple-text").textContent, textContent, |
michael@0 | 27 | "The inspected property's value is correct."); |
michael@0 | 28 | ok(tooltip.querySelector(".devtools-tooltip-simple-text").className.contains(className), |
michael@0 | 29 | "The inspected property's value is colorized correctly."); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function checkView(selectedFrame, caretLine) { |
michael@0 | 33 | is(win.gThreadClient.state, "paused", |
michael@0 | 34 | "Should only be getting stack frames while paused."); |
michael@0 | 35 | is(frames.itemCount, 2, |
michael@0 | 36 | "Should have two frames."); |
michael@0 | 37 | is(frames.selectedDepth, selectedFrame, |
michael@0 | 38 | "The correct frame is selected in the widget."); |
michael@0 | 39 | ok(isCaretPos(panel, caretLine), |
michael@0 | 40 | "Editor caret location is correct."); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | // Allow this generator function to yield first. |
michael@0 | 44 | executeSoon(() => debuggee.test()); |
michael@0 | 45 | yield waitForSourceAndCaretAndScopes(panel, ".html", 20); |
michael@0 | 46 | checkView(0, 20); |
michael@0 | 47 | |
michael@0 | 48 | // Inspect variable in topmost frame. |
michael@0 | 49 | yield openVarPopup(panel, { line: 18, ch: 12 }); |
michael@0 | 50 | verifyContents("\"second scope\"", "token-string"); |
michael@0 | 51 | checkView(0, 20); |
michael@0 | 52 | |
michael@0 | 53 | // Hide the popup and change the frame. |
michael@0 | 54 | yield hideVarPopup(panel); |
michael@0 | 55 | |
michael@0 | 56 | let updatedFrame = waitForDebuggerEvents(panel, events.FETCHED_SCOPES); |
michael@0 | 57 | frames.selectedDepth = 1; |
michael@0 | 58 | yield updatedFrame; |
michael@0 | 59 | checkView(1, 15); |
michael@0 | 60 | |
michael@0 | 61 | // Inspect variable in oldest frame. |
michael@0 | 62 | yield openVarPopup(panel, { line: 13, ch: 12 }); |
michael@0 | 63 | verifyContents("\"first scope\"", "token-string"); |
michael@0 | 64 | checkView(1, 15); |
michael@0 | 65 | |
michael@0 | 66 | yield resumeDebuggerThenCloseAndFinish(panel); |
michael@0 | 67 | }); |
michael@0 | 68 | } |