michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that the clicking "Watch" button twice, for the same expression, only adds it michael@0: * once. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_watch-expression-button.html"; michael@0: michael@0: function test() { michael@0: Task.spawn(function() { michael@0: let [tab, debuggee, panel] = yield initDebugger(TAB_URL); michael@0: let win = panel.panelWin; michael@0: let events = win.EVENTS; michael@0: let watch = win.DebuggerView.WatchExpressions; michael@0: let bubble = win.DebuggerView.VariableBubble; michael@0: let tooltip = bubble._tooltip.panel; michael@0: michael@0: function verifyContent(aExpression, aItemCount) { michael@0: michael@0: ok(watch.getItemAtIndex(0), michael@0: "The expression at index 0 should be available."); michael@0: is(watch.getItemAtIndex(0).attachment.initialExpression, aExpression, michael@0: "The expression at index 0 is correct."); michael@0: is(watch.itemCount, aItemCount, michael@0: "The expression count is correct."); michael@0: } michael@0: michael@0: // Allow this generator function to yield first. michael@0: executeSoon(() => debuggee.start()); michael@0: yield waitForSourceAndCaretAndScopes(panel, ".html", 19); michael@0: michael@0: // Inspect primitive value variable. michael@0: yield openVarPopup(panel, { line: 15, ch: 12 }); michael@0: let popupHiding = once(tooltip, "popuphiding"); michael@0: let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); michael@0: tooltip.querySelector("button").click(); michael@0: verifyContent("a", 1); michael@0: yield promise.all([popupHiding, expressionsEvaluated]); michael@0: ok(true, "The new watch expressions were re-evaluated and the panel got hidden (1)."); michael@0: michael@0: // Inspect property of an object. michael@0: let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); michael@0: yield openVarPopup(panel, { line: 17, ch: 10 }); michael@0: yield expressionsEvaluated; michael@0: ok(true, "The watch expressions were re-evaluated when a new panel opened (1)."); michael@0: michael@0: let popupHiding = once(tooltip, "popuphiding"); michael@0: let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); michael@0: tooltip.querySelector("button").click(); michael@0: verifyContent("b.a", 2); michael@0: yield promise.all([popupHiding, expressionsEvaluated]); michael@0: ok(true, "The new watch expressions were re-evaluated and the panel got hidden (2)."); michael@0: michael@0: // Re-inspect primitive value variable. michael@0: let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); michael@0: yield openVarPopup(panel, { line: 15, ch: 12 }); michael@0: yield expressionsEvaluated; michael@0: ok(true, "The watch expressions were re-evaluated when a new panel opened (2)."); michael@0: michael@0: let popupHiding = once(tooltip, "popuphiding"); michael@0: let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); michael@0: tooltip.querySelector("button").click(); michael@0: verifyContent("b.a", 2); michael@0: yield promise.all([popupHiding, expressionsEvaluated]); michael@0: ok(true, "The new watch expressions were re-evaluated and the panel got hidden (3)."); michael@0: michael@0: yield resumeDebuggerThenCloseAndFinish(panel); michael@0: }); michael@0: }