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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:9a8248708d7a
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests that the watch expression button is added in variable view popup.
6 */
7
8 const TAB_URL = EXAMPLE_URL + "doc_watch-expression-button.html";
9
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 watch = win.DebuggerView.WatchExpressions;
16 let bubble = win.DebuggerView.VariableBubble;
17 let tooltip = bubble._tooltip.panel;
18
19 let label = win.L10N.getStr("addWatchExpressionButton");
20 let className = "dbg-expression-button";
21
22 function testExpressionButton(aLabel, aClassName, aExpression) {
23 ok(tooltip.querySelector("button"),
24 "There should be a button available in variable view popup.");
25 is(tooltip.querySelector("button").label, aLabel,
26 "The button available is labeled correctly.");
27 is(tooltip.querySelector("button").className, aClassName,
28 "The button available is styled correctly.");
29
30 tooltip.querySelector("button").click();
31
32 ok(!tooltip.querySelector("button"),
33 "There should be no button available in variable view popup.");
34 ok(watch.getItemAtIndex(0),
35 "The expression at index 0 should be available.");
36 is(watch.getItemAtIndex(0).attachment.initialExpression, aExpression,
37 "The expression at index 0 is correct.");
38 }
39
40 // Allow this generator function to yield first.
41 executeSoon(() => debuggee.start());
42 yield waitForSourceAndCaretAndScopes(panel, ".html", 19);
43
44 // Inspect primitive value variable.
45 yield openVarPopup(panel, { line: 15, ch: 12 });
46 let popupHiding = once(tooltip, "popuphiding");
47 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
48 testExpressionButton(label, className, "a");
49 yield promise.all([popupHiding, expressionsEvaluated]);
50 ok(true, "The new watch expressions were re-evaluated and the panel got hidden (1).");
51
52 // Inspect non primitive value variable.
53 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
54 yield openVarPopup(panel, { line: 16, ch: 12 }, true);
55 yield expressionsEvaluated;
56 ok(true, "The watch expressions were re-evaluated when a new panel opened (1).");
57
58 let popupHiding = once(tooltip, "popuphiding");
59 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
60 testExpressionButton(label, className, "b");
61 yield promise.all([popupHiding, expressionsEvaluated]);
62 ok(true, "The new watch expressions were re-evaluated and the panel got hidden (2).");
63
64 // Inspect property of an object.
65 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
66 yield openVarPopup(panel, { line: 17, ch: 10 });
67 yield expressionsEvaluated;
68 ok(true, "The watch expressions were re-evaluated when a new panel opened (2).");
69
70 let popupHiding = once(tooltip, "popuphiding");
71 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
72 testExpressionButton(label, className, "b.a");
73 yield promise.all([popupHiding, expressionsEvaluated]);
74 ok(true, "The new watch expressions were re-evaluated and the panel got hidden (3).");
75
76 yield resumeDebuggerThenCloseAndFinish(panel);
77 });
78 }

mercurial