1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-popup-11.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 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 watch expression button is added in variable view popup. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_watch-expression-button.html"; 1.12 + 1.13 +function test() { 1.14 + Task.spawn(function() { 1.15 + let [tab, debuggee, panel] = yield initDebugger(TAB_URL); 1.16 + let win = panel.panelWin; 1.17 + let events = win.EVENTS; 1.18 + let watch = win.DebuggerView.WatchExpressions; 1.19 + let bubble = win.DebuggerView.VariableBubble; 1.20 + let tooltip = bubble._tooltip.panel; 1.21 + 1.22 + let label = win.L10N.getStr("addWatchExpressionButton"); 1.23 + let className = "dbg-expression-button"; 1.24 + 1.25 + function testExpressionButton(aLabel, aClassName, aExpression) { 1.26 + ok(tooltip.querySelector("button"), 1.27 + "There should be a button available in variable view popup."); 1.28 + is(tooltip.querySelector("button").label, aLabel, 1.29 + "The button available is labeled correctly."); 1.30 + is(tooltip.querySelector("button").className, aClassName, 1.31 + "The button available is styled correctly."); 1.32 + 1.33 + tooltip.querySelector("button").click(); 1.34 + 1.35 + ok(!tooltip.querySelector("button"), 1.36 + "There should be no button available in variable view popup."); 1.37 + ok(watch.getItemAtIndex(0), 1.38 + "The expression at index 0 should be available."); 1.39 + is(watch.getItemAtIndex(0).attachment.initialExpression, aExpression, 1.40 + "The expression at index 0 is correct."); 1.41 + } 1.42 + 1.43 + // Allow this generator function to yield first. 1.44 + executeSoon(() => debuggee.start()); 1.45 + yield waitForSourceAndCaretAndScopes(panel, ".html", 19); 1.46 + 1.47 + // Inspect primitive value variable. 1.48 + yield openVarPopup(panel, { line: 15, ch: 12 }); 1.49 + let popupHiding = once(tooltip, "popuphiding"); 1.50 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.51 + testExpressionButton(label, className, "a"); 1.52 + yield promise.all([popupHiding, expressionsEvaluated]); 1.53 + ok(true, "The new watch expressions were re-evaluated and the panel got hidden (1)."); 1.54 + 1.55 + // Inspect non primitive value variable. 1.56 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.57 + yield openVarPopup(panel, { line: 16, ch: 12 }, true); 1.58 + yield expressionsEvaluated; 1.59 + ok(true, "The watch expressions were re-evaluated when a new panel opened (1)."); 1.60 + 1.61 + let popupHiding = once(tooltip, "popuphiding"); 1.62 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.63 + testExpressionButton(label, className, "b"); 1.64 + yield promise.all([popupHiding, expressionsEvaluated]); 1.65 + ok(true, "The new watch expressions were re-evaluated and the panel got hidden (2)."); 1.66 + 1.67 + // Inspect property of an object. 1.68 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.69 + yield openVarPopup(panel, { line: 17, ch: 10 }); 1.70 + yield expressionsEvaluated; 1.71 + ok(true, "The watch expressions were re-evaluated when a new panel opened (2)."); 1.72 + 1.73 + let popupHiding = once(tooltip, "popuphiding"); 1.74 + let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); 1.75 + testExpressionButton(label, className, "b.a"); 1.76 + yield promise.all([popupHiding, expressionsEvaluated]); 1.77 + ok(true, "The new watch expressions were re-evaluated and the panel got hidden (3)."); 1.78 + 1.79 + yield resumeDebuggerThenCloseAndFinish(panel); 1.80 + }); 1.81 +}