Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Test that text describing the tracing state is correctly displayed. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html"; |
michael@0 | 9 | |
michael@0 | 10 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 11 | let gTracer, gL10N; |
michael@0 | 12 | |
michael@0 | 13 | function test() { |
michael@0 | 14 | SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]}, () => { |
michael@0 | 15 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 16 | gTab = aTab; |
michael@0 | 17 | gDebuggee = aDebuggee; |
michael@0 | 18 | gPanel = aPanel; |
michael@0 | 19 | gDebugger = gPanel.panelWin; |
michael@0 | 20 | gTracer = gDebugger.DebuggerView.Tracer; |
michael@0 | 21 | gL10N = gDebugger.L10N; |
michael@0 | 22 | |
michael@0 | 23 | waitForSourceShown(gPanel, "code_tracing-01.js") |
michael@0 | 24 | .then(testTracingNotStartedText) |
michael@0 | 25 | .then(() => gTracer._onStartTracing()) |
michael@0 | 26 | .then(testFunctionCallsUnavailableText) |
michael@0 | 27 | .then(clickButton) |
michael@0 | 28 | .then(() => waitForClientEvents(aPanel, "traces")) |
michael@0 | 29 | .then(testNoEmptyText) |
michael@0 | 30 | .then(() => gTracer._onClear()) |
michael@0 | 31 | .then(testFunctionCallsUnavailableText) |
michael@0 | 32 | .then(() => gTracer._onStopTracing()) |
michael@0 | 33 | .then(testTracingNotStartedText) |
michael@0 | 34 | .then(() => gTracer._onClear()) |
michael@0 | 35 | .then(testTracingNotStartedText) |
michael@0 | 36 | .then(() => { |
michael@0 | 37 | const deferred = promise.defer(); |
michael@0 | 38 | SpecialPowers.popPrefEnv(deferred.resolve); |
michael@0 | 39 | return deferred.promise; |
michael@0 | 40 | }) |
michael@0 | 41 | .then(() => closeDebuggerAndFinish(gPanel)) |
michael@0 | 42 | .then(null, aError => { |
michael@0 | 43 | DevToolsUtils.reportException("browser_dbg_tracing-05.js", aError); |
michael@0 | 44 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 45 | }); |
michael@0 | 46 | }); |
michael@0 | 47 | }); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function testTracingNotStartedText() { |
michael@0 | 51 | let label = gDebugger.document.querySelector("#tracer-tabpanel .fast-list-widget-empty-text"); |
michael@0 | 52 | ok(label, |
michael@0 | 53 | "A label is displayed in the tracer tabpanel."); |
michael@0 | 54 | is(label.getAttribute("value"), gL10N.getStr("tracingNotStartedText"), |
michael@0 | 55 | "The correct {{tracingNotStartedText}} is displayed in the tracer tabpanel."); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function testFunctionCallsUnavailableText() { |
michael@0 | 59 | let label = gDebugger.document.querySelector("#tracer-tabpanel .fast-list-widget-empty-text"); |
michael@0 | 60 | ok(label, |
michael@0 | 61 | "A label is displayed in the tracer tabpanel."); |
michael@0 | 62 | is(label.getAttribute("value"), gL10N.getStr("noFunctionCallsText"), |
michael@0 | 63 | "The correct {{noFunctionCallsText}} is displayed in the tracer tabpanel."); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | function testNoEmptyText() { |
michael@0 | 67 | let label = gDebugger.document.querySelector("#tracer-tabpanel .fast-list-widget-empty-text"); |
michael@0 | 68 | ok(!label, |
michael@0 | 69 | "No label should be displayed in the tracer tabpanel."); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function clickButton() { |
michael@0 | 73 | EventUtils.sendMouseEvent({ type: "click" }, |
michael@0 | 74 | gDebuggee.document.querySelector("button"), |
michael@0 | 75 | gDebuggee); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | registerCleanupFunction(function() { |
michael@0 | 79 | gTab = null; |
michael@0 | 80 | gDebuggee = null; |
michael@0 | 81 | gPanel = null; |
michael@0 | 82 | gDebugger = null; |
michael@0 | 83 | gTracer = null; |
michael@0 | 84 | gL10N = null; |
michael@0 | 85 | }); |