browser/devtools/debugger/test/browser_dbg_variables-view-popup-07.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:ae7e998316ad
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests the variable inspection popup behaves correctly when switching
6 * between simple and complex objects.
7 */
8
9 const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
10
11 function test() {
12 Task.spawn(function() {
13 let [tab, debuggee, panel] = yield initDebugger(TAB_URL);
14 let win = panel.panelWin;
15 let bubble = win.DebuggerView.VariableBubble;
16 let tooltip = bubble._tooltip.panel;
17
18 function verifySimpleContents(textContent, className) {
19 is(tooltip.querySelectorAll(".variables-view-container").length, 0,
20 "There should be no variables view container added to the tooltip.");
21 is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 1,
22 "There should be one simple text node added to the tooltip.");
23
24 is(tooltip.querySelector(".devtools-tooltip-simple-text").textContent, textContent,
25 "The inspected property's value is correct.");
26 ok(tooltip.querySelector(".devtools-tooltip-simple-text").className.contains(className),
27 "The inspected property's value is colorized correctly.");
28 }
29
30 function verifyComplexContents(propertyCount) {
31 is(tooltip.querySelectorAll(".variables-view-container").length, 1,
32 "There should be one variables view container added to the tooltip.");
33 is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 0,
34 "There should be no simple text node added to the tooltip.");
35
36 is(tooltip.querySelectorAll(".variables-view-scope[untitled]").length, 1,
37 "There should be one scope with no header displayed.");
38 is(tooltip.querySelectorAll(".variables-view-variable[untitled]").length, 1,
39 "There should be one variable with no header displayed.");
40
41 ok(tooltip.querySelectorAll(".variables-view-property").length >= propertyCount,
42 "There should be some properties displayed.");
43 }
44
45 // Allow this generator function to yield first.
46 executeSoon(() => debuggee.start());
47 yield waitForSourceAndCaretAndScopes(panel, ".html", 24);
48
49 // Inspect variables.
50 yield openVarPopup(panel, { line: 15, ch: 12 });
51 verifySimpleContents("1", "token-number");
52
53 yield reopenVarPopup(panel, { line: 16, ch: 12 }, true);
54 verifyComplexContents(2);
55
56 yield reopenVarPopup(panel, { line: 19, ch: 10 });
57 verifySimpleContents("42", "token-number");
58
59 yield reopenVarPopup(panel, { line: 31, ch: 10 }, true);
60 verifyComplexContents(100);
61
62 yield resumeDebuggerThenCloseAndFinish(panel);
63 });
64 }

mercurial