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 that the clicking "Watch" button twice, for the same expression, only adds it
6 * once.
7 */
9 const TAB_URL = EXAMPLE_URL + "doc_watch-expression-button.html";
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;
20 function verifyContent(aExpression, aItemCount) {
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 }
30 // Allow this generator function to yield first.
31 executeSoon(() => debuggee.start());
32 yield waitForSourceAndCaretAndScopes(panel, ".html", 19);
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).");
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).");
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).");
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).");
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).");
69 yield resumeDebuggerThenCloseAndFinish(panel);
70 });
71 }