|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that TraceActor is available and returns correct responses to |
|
6 * startTrace and stopTrace requests. |
|
7 */ |
|
8 |
|
9 var gDebuggee; |
|
10 var gClient; |
|
11 var gTraceClient; |
|
12 |
|
13 function run_test() |
|
14 { |
|
15 initTestTracerServer(); |
|
16 gDebuggee = addTestGlobal("test-tracer-actor"); |
|
17 gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
|
18 gClient.connect(function() { |
|
19 attachTestTab(gClient, "test-tracer-actor", function(aResponse, aTabClient) { |
|
20 do_check_true(!!aResponse.traceActor, "TraceActor should be visible in tab"); |
|
21 gClient.attachTracer(aResponse.traceActor, function(aResponse, aTraceClient) { |
|
22 gTraceClient = aTraceClient; |
|
23 test_start_stop_response(); |
|
24 }); |
|
25 }); |
|
26 }); |
|
27 do_test_pending(); |
|
28 } |
|
29 |
|
30 function test_start_stop_response() |
|
31 { |
|
32 do_check_true(!gTraceClient.tracing, "TraceClient should start in idle state"); |
|
33 gTraceClient.startTrace([], null, function(aResponse) { |
|
34 do_check_true(!!gTraceClient.tracing, "TraceClient should be in tracing state"); |
|
35 do_check_true(!aResponse.error, |
|
36 'startTrace should not respond with error: ' + aResponse.error); |
|
37 do_check_eq(aResponse.type, "startedTrace", |
|
38 'startTrace response should have "type":"startedTrace" property'); |
|
39 do_check_eq(aResponse.why, "requested", |
|
40 'startTrace response should have "why":"requested" property'); |
|
41 |
|
42 gTraceClient.stopTrace(null, function(aResponse) { |
|
43 do_check_true(!gTraceClient.tracing, "TraceClient should be in idle state"); |
|
44 do_check_true(!aResponse.error, |
|
45 'stopTrace should not respond with error: ' + aResponse.error); |
|
46 do_check_eq(aResponse.type, "stoppedTrace", |
|
47 'stopTrace response should have "type":"stoppedTrace" property'); |
|
48 do_check_eq(aResponse.why, "requested", |
|
49 'stopTrace response should have "why":"requested" property'); |
|
50 |
|
51 finishClient(gClient); |
|
52 }); |
|
53 }); |
|
54 } |