browser/devtools/debugger/test/browser_dbg_tracing-04.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5066d7291d37
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Test that when we click on logs, we get the parameters/return value in the variables view.
6 */
7
8 const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html";
9
10 let gTab, gDebuggee, gPanel, gDebugger;
11
12 function test() {
13 SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]}, () => {
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
15 gTab = aTab;
16 gDebuggee = aDebuggee;
17 gPanel = aPanel;
18 gDebugger = gPanel.panelWin;
19
20 waitForSourceShown(gPanel, "code_tracing-01.js")
21 .then(() => startTracing(gPanel))
22 .then(clickButton)
23 .then(() => waitForClientEvents(aPanel, "traces"))
24 .then(clickTraceCall)
25 .then(testParams)
26 .then(clickTraceReturn)
27 .then(testReturn)
28 .then(() => stopTracing(gPanel))
29 .then(() => {
30 const deferred = promise.defer();
31 SpecialPowers.popPrefEnv(deferred.resolve);
32 return deferred.promise;
33 })
34 .then(() => closeDebuggerAndFinish(gPanel))
35 .then(null, aError => {
36 DevToolsUtils.reportException("browser_dbg_tracing-04.js", aError);
37 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
38 });
39 });
40 });
41 }
42
43 function clickButton() {
44 EventUtils.sendMouseEvent({ type: "click" },
45 gDebuggee.document.querySelector("button"),
46 gDebuggee);
47 }
48
49 function clickTraceCall() {
50 filterTraces(gPanel, t => t.querySelector(".trace-name[value=factorial]"))[0]
51 .click();
52 }
53
54 function testParams() {
55 const name = gDebugger.document.querySelector(".variables-view-variable .name");
56 ok(name, "Should have a variable name");
57 is(name.getAttribute("value"), "n", "The variable name should be n");
58
59 const value = gDebugger.document.querySelector(".variables-view-variable .value.token-number");
60 ok(value, "Should have a variable value");
61 is(value.getAttribute("value"), "5", "The variable value should be 5");
62 }
63
64 function clickTraceReturn() {
65 filterTraces(gPanel, t => t.querySelector(".trace-name[value=factorial]"))
66 .pop().click();
67 }
68
69 function testReturn() {
70 const name = gDebugger.document.querySelector(".variables-view-variable .name");
71 ok(name, "Should have a variable name");
72 is(name.getAttribute("value"), "<return>", "The variable name should be <return>");
73
74 const value = gDebugger.document.querySelector(".variables-view-variable .value.token-number");
75 ok(value, "Should have a variable value");
76 is(value.getAttribute("value"), "120", "The variable value should be 120");
77 }
78
79 registerCleanupFunction(function() {
80 gTab = null;
81 gDebuggee = null;
82 gPanel = null;
83 gDebugger = null;
84 });

mercurial