|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that the clicking "Watch" button twice, for the same expression, only adds it |
|
6 * once. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_watch-expression-button.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 events = win.EVENTS; |
|
16 let watch = win.DebuggerView.WatchExpressions; |
|
17 let bubble = win.DebuggerView.VariableBubble; |
|
18 let tooltip = bubble._tooltip.panel; |
|
19 |
|
20 function verifyContent(aExpression, aItemCount) { |
|
21 |
|
22 ok(watch.getItemAtIndex(0), |
|
23 "The expression at index 0 should be available."); |
|
24 is(watch.getItemAtIndex(0).attachment.initialExpression, aExpression, |
|
25 "The expression at index 0 is correct."); |
|
26 is(watch.itemCount, aItemCount, |
|
27 "The expression count is correct."); |
|
28 } |
|
29 |
|
30 // Allow this generator function to yield first. |
|
31 executeSoon(() => debuggee.start()); |
|
32 yield waitForSourceAndCaretAndScopes(panel, ".html", 19); |
|
33 |
|
34 // Inspect primitive value variable. |
|
35 yield openVarPopup(panel, { line: 15, ch: 12 }); |
|
36 let popupHiding = once(tooltip, "popuphiding"); |
|
37 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
|
38 tooltip.querySelector("button").click(); |
|
39 verifyContent("a", 1); |
|
40 yield promise.all([popupHiding, expressionsEvaluated]); |
|
41 ok(true, "The new watch expressions were re-evaluated and the panel got hidden (1)."); |
|
42 |
|
43 // Inspect property of an object. |
|
44 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
|
45 yield openVarPopup(panel, { line: 17, ch: 10 }); |
|
46 yield expressionsEvaluated; |
|
47 ok(true, "The watch expressions were re-evaluated when a new panel opened (1)."); |
|
48 |
|
49 let popupHiding = once(tooltip, "popuphiding"); |
|
50 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
|
51 tooltip.querySelector("button").click(); |
|
52 verifyContent("b.a", 2); |
|
53 yield promise.all([popupHiding, expressionsEvaluated]); |
|
54 ok(true, "The new watch expressions were re-evaluated and the panel got hidden (2)."); |
|
55 |
|
56 // Re-inspect primitive value variable. |
|
57 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
|
58 yield openVarPopup(panel, { line: 15, ch: 12 }); |
|
59 yield expressionsEvaluated; |
|
60 ok(true, "The watch expressions were re-evaluated when a new panel opened (2)."); |
|
61 |
|
62 let popupHiding = once(tooltip, "popuphiding"); |
|
63 let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
|
64 tooltip.querySelector("button").click(); |
|
65 verifyContent("b.a", 2); |
|
66 yield promise.all([popupHiding, expressionsEvaluated]); |
|
67 ok(true, "The new watch expressions were re-evaluated and the panel got hidden (3)."); |
|
68 |
|
69 yield resumeDebuggerThenCloseAndFinish(panel); |
|
70 }); |
|
71 } |