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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_tracing-04.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,84 @@
     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 when we click on logs, we get the parameters/return value in the variables view.
     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(clickTraceCall)
    1.28 +        .then(testParams)
    1.29 +        .then(clickTraceReturn)
    1.30 +        .then(testReturn)
    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 +          DevToolsUtils.reportException("browser_dbg_tracing-04.js", aError);
    1.40 +          ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    1.41 +        });
    1.42 +    });
    1.43 +  });
    1.44 +}
    1.45 +
    1.46 +function clickButton() {
    1.47 +  EventUtils.sendMouseEvent({ type: "click" },
    1.48 +                            gDebuggee.document.querySelector("button"),
    1.49 +                            gDebuggee);
    1.50 +}
    1.51 +
    1.52 +function clickTraceCall() {
    1.53 +  filterTraces(gPanel, t => t.querySelector(".trace-name[value=factorial]"))[0]
    1.54 +    .click();
    1.55 +}
    1.56 +
    1.57 +function testParams() {
    1.58 +  const name = gDebugger.document.querySelector(".variables-view-variable .name");
    1.59 +  ok(name, "Should have a variable name");
    1.60 +  is(name.getAttribute("value"), "n", "The variable name should be n");
    1.61 +
    1.62 +  const value = gDebugger.document.querySelector(".variables-view-variable .value.token-number");
    1.63 +  ok(value, "Should have a variable value");
    1.64 +  is(value.getAttribute("value"), "5", "The variable value should be 5");
    1.65 +}
    1.66 +
    1.67 +function clickTraceReturn() {
    1.68 +  filterTraces(gPanel, t => t.querySelector(".trace-name[value=factorial]"))
    1.69 +    .pop().click();
    1.70 +}
    1.71 +
    1.72 +function testReturn() {
    1.73 +  const name = gDebugger.document.querySelector(".variables-view-variable .name");
    1.74 +  ok(name, "Should have a variable name");
    1.75 +  is(name.getAttribute("value"), "<return>", "The variable name should be <return>");
    1.76 +
    1.77 +  const value = gDebugger.document.querySelector(".variables-view-variable .value.token-number");
    1.78 +  ok(value, "Should have a variable value");
    1.79 +  is(value.getAttribute("value"), "120", "The variable value should be 120");
    1.80 +}
    1.81 +
    1.82 +registerCleanupFunction(function() {
    1.83 +  gTab = null;
    1.84 +  gDebuggee = null;
    1.85 +  gPanel = null;
    1.86 +  gDebugger = null;
    1.87 +});

mercurial