1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_tracing-02.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 + * Test that we highlight matching calls and returns on hover. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html"; 1.12 + 1.13 +let gTab, gDebuggee, gPanel, gDebugger; 1.14 + 1.15 +function test() { 1.16 + SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]}, () => { 1.17 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.18 + gTab = aTab; 1.19 + gDebuggee = aDebuggee; 1.20 + gPanel = aPanel; 1.21 + gDebugger = gPanel.panelWin; 1.22 + 1.23 + waitForSourceShown(gPanel, "code_tracing-01.js") 1.24 + .then(() => startTracing(gPanel)) 1.25 + .then(clickButton) 1.26 + .then(() => waitForClientEvents(aPanel, "traces")) 1.27 + .then(highlightCall) 1.28 + .then(testReturnHighlighted) 1.29 + .then(unhighlightCall) 1.30 + .then(testNoneHighlighted) 1.31 + .then(() => stopTracing(gPanel)) 1.32 + .then(() => { 1.33 + const deferred = promise.defer(); 1.34 + SpecialPowers.popPrefEnv(deferred.resolve); 1.35 + return deferred.promise; 1.36 + }) 1.37 + .then(() => closeDebuggerAndFinish(gPanel)) 1.38 + .then(null, aError => { 1.39 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.40 + }); 1.41 + }); 1.42 + }); 1.43 +} 1.44 + 1.45 +function clickButton() { 1.46 + EventUtils.sendMouseEvent({ type: "click" }, 1.47 + gDebuggee.document.querySelector("button"), 1.48 + gDebuggee); 1.49 +} 1.50 + 1.51 +function highlightCall() { 1.52 + const callTrace = filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[0]; 1.53 + EventUtils.sendMouseEvent({ type: "mouseover" }, 1.54 + callTrace, 1.55 + gDebugger); 1.56 +} 1.57 + 1.58 +function testReturnHighlighted() { 1.59 + const returnTrace = filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[1]; 1.60 + ok(Array.indexOf(returnTrace.querySelector(".trace-item").classList, "selected-matching") >= 0, 1.61 + "The corresponding return log should be highlighted."); 1.62 +} 1.63 + 1.64 +function unhighlightCall() { 1.65 + const callTrace = filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[0]; 1.66 + EventUtils.sendMouseEvent({ type: "mouseout" }, 1.67 + callTrace, 1.68 + gDebugger); 1.69 +} 1.70 + 1.71 +function testNoneHighlighted() { 1.72 + const highlightedTraces = filterTraces(gPanel, t => t.querySelector(".selected-matching")); 1.73 + is(highlightedTraces.length, 0, "Shouldn't have any highlighted traces"); 1.74 +} 1.75 + 1.76 +registerCleanupFunction(function() { 1.77 + gTab = null; 1.78 + gDebuggee = null; 1.79 + gPanel = null; 1.80 + gDebugger = null; 1.81 +});