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 watch expression button is added in variable view popup. 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: let label = win.L10N.getStr("addWatchExpressionButton"); michael@0: let className = "dbg-expression-button"; michael@0: michael@0: function testExpressionButton(aLabel, aClassName, aExpression) { michael@0: ok(tooltip.querySelector("button"), michael@0: "There should be a button available in variable view popup."); michael@0: is(tooltip.querySelector("button").label, aLabel, michael@0: "The button available is labeled correctly."); michael@0: is(tooltip.querySelector("button").className, aClassName, michael@0: "The button available is styled correctly."); michael@0: michael@0: tooltip.querySelector("button").click(); michael@0: michael@0: ok(!tooltip.querySelector("button"), michael@0: "There should be no button available in variable view popup."); 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: } 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: testExpressionButton(label, className, "a"); 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 non primitive value variable. michael@0: let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); michael@0: yield openVarPopup(panel, { line: 16, ch: 12 }, true); 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: testExpressionButton(label, className, "b"); 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: // 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 (2)."); michael@0: michael@0: let popupHiding = once(tooltip, "popuphiding"); michael@0: let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); michael@0: testExpressionButton(label, className, "b.a"); 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: }