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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Test that when we click on logs, we get the parameters/return value in the variables view.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    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;
    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 }
    43 function clickButton() {
    44   EventUtils.sendMouseEvent({ type: "click" },
    45                             gDebuggee.document.querySelector("button"),
    46                             gDebuggee);
    47 }
    49 function clickTraceCall() {
    50   filterTraces(gPanel, t => t.querySelector(".trace-name[value=factorial]"))[0]
    51     .click();
    52 }
    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");
    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 }
    64 function clickTraceReturn() {
    65   filterTraces(gPanel, t => t.querySelector(".trace-name[value=factorial]"))
    66     .pop().click();
    67 }
    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>");
    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 }
    79 registerCleanupFunction(function() {
    80   gTab = null;
    81   gDebuggee = null;
    82   gPanel = null;
    83   gDebugger = null;
    84 });

mercurial