browser/devtools/debugger/test/browser_dbg_tracing-05.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 text describing the tracing state is correctly displayed.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gTracer, gL10N;
    13 function test() {
    14   SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]}, () => {
    15     initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    16       gTab = aTab;
    17       gDebuggee = aDebuggee;
    18       gPanel = aPanel;
    19       gDebugger = gPanel.panelWin;
    20       gTracer = gDebugger.DebuggerView.Tracer;
    21       gL10N = gDebugger.L10N;
    23       waitForSourceShown(gPanel, "code_tracing-01.js")
    24         .then(testTracingNotStartedText)
    25         .then(() => gTracer._onStartTracing())
    26         .then(testFunctionCallsUnavailableText)
    27         .then(clickButton)
    28         .then(() => waitForClientEvents(aPanel, "traces"))
    29         .then(testNoEmptyText)
    30         .then(() => gTracer._onClear())
    31         .then(testFunctionCallsUnavailableText)
    32         .then(() => gTracer._onStopTracing())
    33         .then(testTracingNotStartedText)
    34         .then(() => gTracer._onClear())
    35         .then(testTracingNotStartedText)
    36         .then(() => {
    37           const deferred = promise.defer();
    38           SpecialPowers.popPrefEnv(deferred.resolve);
    39           return deferred.promise;
    40         })
    41         .then(() => closeDebuggerAndFinish(gPanel))
    42         .then(null, aError => {
    43           DevToolsUtils.reportException("browser_dbg_tracing-05.js", aError);
    44           ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    45         });
    46     });
    47   });
    48 }
    50 function testTracingNotStartedText() {
    51   let label = gDebugger.document.querySelector("#tracer-tabpanel .fast-list-widget-empty-text");
    52   ok(label,
    53     "A label is displayed in the tracer tabpanel.");
    54   is(label.getAttribute("value"), gL10N.getStr("tracingNotStartedText"),
    55     "The correct {{tracingNotStartedText}} is displayed in the tracer tabpanel.");
    56 }
    58 function testFunctionCallsUnavailableText() {
    59   let label = gDebugger.document.querySelector("#tracer-tabpanel .fast-list-widget-empty-text");
    60   ok(label,
    61     "A label is displayed in the tracer tabpanel.");
    62   is(label.getAttribute("value"), gL10N.getStr("noFunctionCallsText"),
    63     "The correct {{noFunctionCallsText}} is displayed in the tracer tabpanel.");
    64 }
    66 function testNoEmptyText() {
    67   let label = gDebugger.document.querySelector("#tracer-tabpanel .fast-list-widget-empty-text");
    68   ok(!label,
    69     "No label should be displayed in the tracer tabpanel.");
    70 }
    72 function clickButton() {
    73   EventUtils.sendMouseEvent({ type: "click" },
    74                             gDebuggee.document.querySelector("button"),
    75                             gDebuggee);
    76 }
    78 registerCleanupFunction(function() {
    79   gTab = null;
    80   gDebuggee = null;
    81   gPanel = null;
    82   gDebugger = null;
    83   gTracer = null;
    84   gL10N = null;
    85 });

mercurial