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