1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_tracing-05.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 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 text describing the tracing state is correctly displayed. 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 +let gTracer, gL10N; 1.15 + 1.16 +function test() { 1.17 + SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]}, () => { 1.18 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.19 + gTab = aTab; 1.20 + gDebuggee = aDebuggee; 1.21 + gPanel = aPanel; 1.22 + gDebugger = gPanel.panelWin; 1.23 + gTracer = gDebugger.DebuggerView.Tracer; 1.24 + gL10N = gDebugger.L10N; 1.25 + 1.26 + waitForSourceShown(gPanel, "code_tracing-01.js") 1.27 + .then(testTracingNotStartedText) 1.28 + .then(() => gTracer._onStartTracing()) 1.29 + .then(testFunctionCallsUnavailableText) 1.30 + .then(clickButton) 1.31 + .then(() => waitForClientEvents(aPanel, "traces")) 1.32 + .then(testNoEmptyText) 1.33 + .then(() => gTracer._onClear()) 1.34 + .then(testFunctionCallsUnavailableText) 1.35 + .then(() => gTracer._onStopTracing()) 1.36 + .then(testTracingNotStartedText) 1.37 + .then(() => gTracer._onClear()) 1.38 + .then(testTracingNotStartedText) 1.39 + .then(() => { 1.40 + const deferred = promise.defer(); 1.41 + SpecialPowers.popPrefEnv(deferred.resolve); 1.42 + return deferred.promise; 1.43 + }) 1.44 + .then(() => closeDebuggerAndFinish(gPanel)) 1.45 + .then(null, aError => { 1.46 + DevToolsUtils.reportException("browser_dbg_tracing-05.js", 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 testTracingNotStartedText() { 1.54 + let label = gDebugger.document.querySelector("#tracer-tabpanel .fast-list-widget-empty-text"); 1.55 + ok(label, 1.56 + "A label is displayed in the tracer tabpanel."); 1.57 + is(label.getAttribute("value"), gL10N.getStr("tracingNotStartedText"), 1.58 + "The correct {{tracingNotStartedText}} is displayed in the tracer tabpanel."); 1.59 +} 1.60 + 1.61 +function testFunctionCallsUnavailableText() { 1.62 + let label = gDebugger.document.querySelector("#tracer-tabpanel .fast-list-widget-empty-text"); 1.63 + ok(label, 1.64 + "A label is displayed in the tracer tabpanel."); 1.65 + is(label.getAttribute("value"), gL10N.getStr("noFunctionCallsText"), 1.66 + "The correct {{noFunctionCallsText}} is displayed in the tracer tabpanel."); 1.67 +} 1.68 + 1.69 +function testNoEmptyText() { 1.70 + let label = gDebugger.document.querySelector("#tracer-tabpanel .fast-list-widget-empty-text"); 1.71 + ok(!label, 1.72 + "No label should be displayed in the tracer tabpanel."); 1.73 +} 1.74 + 1.75 +function clickButton() { 1.76 + EventUtils.sendMouseEvent({ type: "click" }, 1.77 + gDebuggee.document.querySelector("button"), 1.78 + gDebuggee); 1.79 +} 1.80 + 1.81 +registerCleanupFunction(function() { 1.82 + gTab = null; 1.83 + gDebuggee = null; 1.84 + gPanel = null; 1.85 + gDebugger = null; 1.86 + gTracer = null; 1.87 + gL10N = null; 1.88 +});