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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:46c04cf78ec7
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Test that text describing the tracing state is correctly displayed.
6 */
7
8 const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html";
9
10 let gTab, gDebuggee, gPanel, gDebugger;
11 let gTracer, gL10N;
12
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;
22
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 }
49
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 }
57
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 }
65
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 }
71
72 function clickButton() {
73 EventUtils.sendMouseEvent({ type: "click" },
74 gDebuggee.document.querySelector("button"),
75 gDebuggee);
76 }
77
78 registerCleanupFunction(function() {
79 gTab = null;
80 gDebuggee = null;
81 gPanel = null;
82 gDebugger = null;
83 gTracer = null;
84 gL10N = null;
85 });

mercurial