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: * Test that when we click on logs, we get the parameters/return value in the variables view. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: michael@0: function test() { michael@0: SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]}, () => { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: michael@0: waitForSourceShown(gPanel, "code_tracing-01.js") michael@0: .then(() => startTracing(gPanel)) michael@0: .then(clickButton) michael@0: .then(() => waitForClientEvents(aPanel, "traces")) michael@0: .then(clickTraceCall) michael@0: .then(testParams) michael@0: .then(clickTraceReturn) michael@0: .then(testReturn) michael@0: .then(() => stopTracing(gPanel)) michael@0: .then(() => { michael@0: const deferred = promise.defer(); michael@0: SpecialPowers.popPrefEnv(deferred.resolve); michael@0: return deferred.promise; michael@0: }) michael@0: .then(() => closeDebuggerAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: DevToolsUtils.reportException("browser_dbg_tracing-04.js", aError); michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function clickButton() { michael@0: EventUtils.sendMouseEvent({ type: "click" }, michael@0: gDebuggee.document.querySelector("button"), michael@0: gDebuggee); michael@0: } michael@0: michael@0: function clickTraceCall() { michael@0: filterTraces(gPanel, t => t.querySelector(".trace-name[value=factorial]"))[0] michael@0: .click(); michael@0: } michael@0: michael@0: function testParams() { michael@0: const name = gDebugger.document.querySelector(".variables-view-variable .name"); michael@0: ok(name, "Should have a variable name"); michael@0: is(name.getAttribute("value"), "n", "The variable name should be n"); michael@0: michael@0: const value = gDebugger.document.querySelector(".variables-view-variable .value.token-number"); michael@0: ok(value, "Should have a variable value"); michael@0: is(value.getAttribute("value"), "5", "The variable value should be 5"); michael@0: } michael@0: michael@0: function clickTraceReturn() { michael@0: filterTraces(gPanel, t => t.querySelector(".trace-name[value=factorial]")) michael@0: .pop().click(); michael@0: } michael@0: michael@0: function testReturn() { michael@0: const name = gDebugger.document.querySelector(".variables-view-variable .name"); michael@0: ok(name, "Should have a variable name"); michael@0: is(name.getAttribute("value"), "", "The variable name should be "); michael@0: michael@0: const value = gDebugger.document.querySelector(".variables-view-variable .value.token-number"); michael@0: ok(value, "Should have a variable value"); michael@0: is(value.getAttribute("value"), "120", "The variable value should be 120"); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: });