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.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Tests that the watch expression button is added in variable view popup. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_watch-expression-button.html"; |
michael@0 | 9 | |
michael@0 | 10 | function test() { |
michael@0 | 11 | Task.spawn(function() { |
michael@0 | 12 | let [tab, debuggee, panel] = yield initDebugger(TAB_URL); |
michael@0 | 13 | let win = panel.panelWin; |
michael@0 | 14 | let events = win.EVENTS; |
michael@0 | 15 | let watch = win.DebuggerView.WatchExpressions; |
michael@0 | 16 | let bubble = win.DebuggerView.VariableBubble; |
michael@0 | 17 | let tooltip = bubble._tooltip.panel; |
michael@0 | 18 | |
michael@0 | 19 | let label = win.L10N.getStr("addWatchExpressionButton"); |
michael@0 | 20 | let className = "dbg-expression-button"; |
michael@0 | 21 | |
michael@0 | 22 | function testExpressionButton(aLabel, aClassName, aExpression) { |
michael@0 | 23 | ok(tooltip.querySelector("button"), |
michael@0 | 24 | "There should be a button available in variable view popup."); |
michael@0 | 25 | is(tooltip.querySelector("button").label, aLabel, |
michael@0 | 26 | "The button available is labeled correctly."); |
michael@0 | 27 | is(tooltip.querySelector("button").className, aClassName, |
michael@0 | 28 | "The button available is styled correctly."); |
michael@0 | 29 | |
michael@0 | 30 | tooltip.querySelector("button").click(); |
michael@0 | 31 | |
michael@0 | 32 | ok(!tooltip.querySelector("button"), |
michael@0 | 33 | "There should be no button available in variable view popup."); |
michael@0 | 34 | ok(watch.getItemAtIndex(0), |
michael@0 | 35 | "The expression at index 0 should be available."); |
michael@0 | 36 | is(watch.getItemAtIndex(0).attachment.initialExpression, aExpression, |
michael@0 | 37 | "The expression at index 0 is correct."); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | // Allow this generator function to yield first. |
michael@0 | 41 | executeSoon(() => debuggee.start()); |
michael@0 | 42 | yield waitForSourceAndCaretAndScopes(panel, ".html", 19); |
michael@0 | 43 | |
michael@0 | 44 | // Inspect primitive value variable. |
michael@0 | 45 | yield openVarPopup(panel, { line: 15, ch: 12 }); |
michael@0 | 46 | let popupHiding = once(tooltip, "popuphiding"); |
michael@0 | 47 | let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
michael@0 | 48 | testExpressionButton(label, className, "a"); |
michael@0 | 49 | yield promise.all([popupHiding, expressionsEvaluated]); |
michael@0 | 50 | ok(true, "The new watch expressions were re-evaluated and the panel got hidden (1)."); |
michael@0 | 51 | |
michael@0 | 52 | // Inspect non primitive value variable. |
michael@0 | 53 | let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
michael@0 | 54 | yield openVarPopup(panel, { line: 16, ch: 12 }, true); |
michael@0 | 55 | yield expressionsEvaluated; |
michael@0 | 56 | ok(true, "The watch expressions were re-evaluated when a new panel opened (1)."); |
michael@0 | 57 | |
michael@0 | 58 | let popupHiding = once(tooltip, "popuphiding"); |
michael@0 | 59 | let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
michael@0 | 60 | testExpressionButton(label, className, "b"); |
michael@0 | 61 | yield promise.all([popupHiding, expressionsEvaluated]); |
michael@0 | 62 | ok(true, "The new watch expressions were re-evaluated and the panel got hidden (2)."); |
michael@0 | 63 | |
michael@0 | 64 | // Inspect property of an object. |
michael@0 | 65 | let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
michael@0 | 66 | yield openVarPopup(panel, { line: 17, ch: 10 }); |
michael@0 | 67 | yield expressionsEvaluated; |
michael@0 | 68 | ok(true, "The watch expressions were re-evaluated when a new panel opened (2)."); |
michael@0 | 69 | |
michael@0 | 70 | let popupHiding = once(tooltip, "popuphiding"); |
michael@0 | 71 | let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS); |
michael@0 | 72 | testExpressionButton(label, className, "b.a"); |
michael@0 | 73 | yield promise.all([popupHiding, expressionsEvaluated]); |
michael@0 | 74 | ok(true, "The new watch expressions were re-evaluated and the panel got hidden (3)."); |
michael@0 | 75 | |
michael@0 | 76 | yield resumeDebuggerThenCloseAndFinish(panel); |
michael@0 | 77 | }); |
michael@0 | 78 | } |