1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-popup-12.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests that the clicking "Watch" button twice, for the same expression, only adds it 1.9 + * once. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_watch-expression-button.html"; 1.13 + 1.14 +function test() { 1.15 + Task.spawn(function() { 1.16 + let [tab, debuggee, panel] = yield initDebugger(TAB_URL); 1.17 + let win = panel.panelWin; 1.18 + let events = win.EVENTS; 1.19 + let watch = win.DebuggerView.WatchExpressions; 1.20 + let bubble = win.DebuggerView.VariableBubble; 1.21 + let tooltip = bubble._tooltip.panel; 1.22 + 1.23 + function verifyContent(aExpression, aItemCount) { 1.24 + 1.25 + ok(watch.getItemAtIndex(0), 1.26 + "The expression at index 0 should be available."); 1.27 + is(watch.getItemAtIndex(0).attachment.initialExpression, aExpression, 1.28 + "The expression at index 0 is correct."); 1.29 + is(watch.itemCount, aItemCount, 1.30 + "The expression count is correct."); 1.31 + } 1.32 + 1.33 + // Allow this generator function to yield first. 1.34 + executeSoon(() => debuggee.start()); 1.35 + yield waitForSourceAndCaretAndScopes(panel, ".html", 19); 1.36 + 1.37 + // Inspect primitive value variable. 1.38 + yield openVarPopup(panel, { line: 15, ch: 12 }); 1.39 + let popupHiding = once(tooltip, "popuphiding"); 1.40 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.41 + tooltip.querySelector("button").click(); 1.42 + verifyContent("a", 1); 1.43 + yield promise.all([popupHiding, expressionsEvaluated]); 1.44 + ok(true, "The new watch expressions were re-evaluated and the panel got hidden (1)."); 1.45 + 1.46 + // Inspect property of an object. 1.47 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.48 + yield openVarPopup(panel, { line: 17, ch: 10 }); 1.49 + yield expressionsEvaluated; 1.50 + ok(true, "The watch expressions were re-evaluated when a new panel opened (1)."); 1.51 + 1.52 + let popupHiding = once(tooltip, "popuphiding"); 1.53 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.54 + tooltip.querySelector("button").click(); 1.55 + verifyContent("b.a", 2); 1.56 + yield promise.all([popupHiding, expressionsEvaluated]); 1.57 + ok(true, "The new watch expressions were re-evaluated and the panel got hidden (2)."); 1.58 + 1.59 + // Re-inspect primitive value variable. 1.60 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.61 + yield openVarPopup(panel, { line: 15, ch: 12 }); 1.62 + yield expressionsEvaluated; 1.63 + ok(true, "The watch expressions were re-evaluated when a new panel opened (2)."); 1.64 + 1.65 + let popupHiding = once(tooltip, "popuphiding"); 1.66 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.67 + tooltip.querySelector("button").click(); 1.68 + verifyContent("b.a", 2); 1.69 + yield promise.all([popupHiding, expressionsEvaluated]); 1.70 + ok(true, "The new watch expressions were re-evaluated and the panel got hidden (3)."); 1.71 + 1.72 + yield resumeDebuggerThenCloseAndFinish(panel); 1.73 + }); 1.74 +}