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 | * Test that we highlight matching calls and returns on hover. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html"; |
michael@0 | 9 | |
michael@0 | 10 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 11 | |
michael@0 | 12 | function test() { |
michael@0 | 13 | SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]}, () => { |
michael@0 | 14 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 15 | gTab = aTab; |
michael@0 | 16 | gDebuggee = aDebuggee; |
michael@0 | 17 | gPanel = aPanel; |
michael@0 | 18 | gDebugger = gPanel.panelWin; |
michael@0 | 19 | |
michael@0 | 20 | waitForSourceShown(gPanel, "code_tracing-01.js") |
michael@0 | 21 | .then(() => startTracing(gPanel)) |
michael@0 | 22 | .then(clickButton) |
michael@0 | 23 | .then(() => waitForClientEvents(aPanel, "traces")) |
michael@0 | 24 | .then(highlightCall) |
michael@0 | 25 | .then(testReturnHighlighted) |
michael@0 | 26 | .then(unhighlightCall) |
michael@0 | 27 | .then(testNoneHighlighted) |
michael@0 | 28 | .then(() => stopTracing(gPanel)) |
michael@0 | 29 | .then(() => { |
michael@0 | 30 | const deferred = promise.defer(); |
michael@0 | 31 | SpecialPowers.popPrefEnv(deferred.resolve); |
michael@0 | 32 | return deferred.promise; |
michael@0 | 33 | }) |
michael@0 | 34 | .then(() => closeDebuggerAndFinish(gPanel)) |
michael@0 | 35 | .then(null, aError => { |
michael@0 | 36 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 37 | }); |
michael@0 | 38 | }); |
michael@0 | 39 | }); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | function clickButton() { |
michael@0 | 43 | EventUtils.sendMouseEvent({ type: "click" }, |
michael@0 | 44 | gDebuggee.document.querySelector("button"), |
michael@0 | 45 | gDebuggee); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function highlightCall() { |
michael@0 | 49 | const callTrace = filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[0]; |
michael@0 | 50 | EventUtils.sendMouseEvent({ type: "mouseover" }, |
michael@0 | 51 | callTrace, |
michael@0 | 52 | gDebugger); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function testReturnHighlighted() { |
michael@0 | 56 | const returnTrace = filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[1]; |
michael@0 | 57 | ok(Array.indexOf(returnTrace.querySelector(".trace-item").classList, "selected-matching") >= 0, |
michael@0 | 58 | "The corresponding return log should be highlighted."); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function unhighlightCall() { |
michael@0 | 62 | const callTrace = filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[0]; |
michael@0 | 63 | EventUtils.sendMouseEvent({ type: "mouseout" }, |
michael@0 | 64 | callTrace, |
michael@0 | 65 | gDebugger); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function testNoneHighlighted() { |
michael@0 | 69 | const highlightedTraces = filterTraces(gPanel, t => t.querySelector(".selected-matching")); |
michael@0 | 70 | is(highlightedTraces.length, 0, "Shouldn't have any highlighted traces"); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | registerCleanupFunction(function() { |
michael@0 | 74 | gTab = null; |
michael@0 | 75 | gDebuggee = null; |
michael@0 | 76 | gPanel = null; |
michael@0 | 77 | gDebugger = null; |
michael@0 | 78 | }); |