michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that TraceActor is available and returns correct responses to michael@0: * startTrace and stopTrace requests. michael@0: */ michael@0: michael@0: var gDebuggee; michael@0: var gClient; michael@0: var gTraceClient; michael@0: michael@0: function run_test() michael@0: { michael@0: initTestTracerServer(); michael@0: gDebuggee = addTestGlobal("test-tracer-actor"); michael@0: gClient = new DebuggerClient(DebuggerServer.connectPipe()); michael@0: gClient.connect(function() { michael@0: attachTestTab(gClient, "test-tracer-actor", function(aResponse, aTabClient) { michael@0: do_check_true(!!aResponse.traceActor, "TraceActor should be visible in tab"); michael@0: gClient.attachTracer(aResponse.traceActor, function(aResponse, aTraceClient) { michael@0: gTraceClient = aTraceClient; michael@0: test_start_stop_response(); michael@0: }); michael@0: }); michael@0: }); michael@0: do_test_pending(); michael@0: } michael@0: michael@0: function test_start_stop_response() michael@0: { michael@0: do_check_true(!gTraceClient.tracing, "TraceClient should start in idle state"); michael@0: gTraceClient.startTrace([], null, function(aResponse) { michael@0: do_check_true(!!gTraceClient.tracing, "TraceClient should be in tracing state"); michael@0: do_check_true(!aResponse.error, michael@0: 'startTrace should not respond with error: ' + aResponse.error); michael@0: do_check_eq(aResponse.type, "startedTrace", michael@0: 'startTrace response should have "type":"startedTrace" property'); michael@0: do_check_eq(aResponse.why, "requested", michael@0: 'startTrace response should have "why":"requested" property'); michael@0: michael@0: gTraceClient.stopTrace(null, function(aResponse) { michael@0: do_check_true(!gTraceClient.tracing, "TraceClient should be in idle state"); michael@0: do_check_true(!aResponse.error, michael@0: 'stopTrace should not respond with error: ' + aResponse.error); michael@0: do_check_eq(aResponse.type, "stoppedTrace", michael@0: 'stopTrace response should have "type":"stoppedTrace" property'); michael@0: do_check_eq(aResponse.why, "requested", michael@0: 'stopTrace response should have "why":"requested" property'); michael@0: michael@0: finishClient(gClient); michael@0: }); michael@0: }); michael@0: }