browser/devtools/debugger/test/browser_dbg_tracing-03.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-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,70 @@
     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 can jump to function definitions by clicking on logs.
     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(() => {
    1.28 +          // Switch away from the JS file so we can make sure that clicking on a
    1.29 +          // log will switch us back to the correct JS file.
    1.30 +          aPanel.panelWin.DebuggerView.Sources.selectedValue = TAB_URL;
    1.31 +          return ensureSourceIs(aPanel, TAB_URL, true);
    1.32 +        })
    1.33 +        .then(() => {
    1.34 +          const finished = waitForSourceShown(gPanel, "code_tracing-01.js");
    1.35 +          clickTraceLog();
    1.36 +          return finished;
    1.37 +        })
    1.38 +        .then(testCorrectLine)
    1.39 +        .then(() => stopTracing(gPanel))
    1.40 +        .then(() => {
    1.41 +          const deferred = promise.defer();
    1.42 +          SpecialPowers.popPrefEnv(deferred.resolve);
    1.43 +          return deferred.promise;
    1.44 +        })
    1.45 +        .then(() => closeDebuggerAndFinish(gPanel))
    1.46 +        .then(null, aError => {
    1.47 +          ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    1.48 +        });
    1.49 +    });
    1.50 +  });
    1.51 +}
    1.52 +
    1.53 +function clickButton() {
    1.54 +  EventUtils.sendMouseEvent({ type: "click" },
    1.55 +                            gDebuggee.document.querySelector("button"),
    1.56 +                            gDebuggee);
    1.57 +}
    1.58 +
    1.59 +function clickTraceLog() {
    1.60 +  filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[0].click();
    1.61 +}
    1.62 +
    1.63 +function testCorrectLine() {
    1.64 +  is(gDebugger.DebuggerView.editor.getCursor().line, 19,
    1.65 +     "The editor should have the function definition site's line selected.");
    1.66 +}
    1.67 +
    1.68 +registerCleanupFunction(function() {
    1.69 +  gTab = null;
    1.70 +  gDebuggee = null;
    1.71 +  gPanel = null;
    1.72 +  gDebugger = null;
    1.73 +});

mercurial