1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_trace_actor-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 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 + * Tests that TraceActor is available and returns correct responses to 1.9 + * startTrace and stopTrace requests. 1.10 + */ 1.11 + 1.12 +var gDebuggee; 1.13 +var gClient; 1.14 +var gTraceClient; 1.15 + 1.16 +function run_test() 1.17 +{ 1.18 + initTestTracerServer(); 1.19 + gDebuggee = addTestGlobal("test-tracer-actor"); 1.20 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.21 + gClient.connect(function() { 1.22 + attachTestTab(gClient, "test-tracer-actor", function(aResponse, aTabClient) { 1.23 + do_check_true(!!aResponse.traceActor, "TraceActor should be visible in tab"); 1.24 + gClient.attachTracer(aResponse.traceActor, function(aResponse, aTraceClient) { 1.25 + gTraceClient = aTraceClient; 1.26 + test_start_stop_response(); 1.27 + }); 1.28 + }); 1.29 + }); 1.30 + do_test_pending(); 1.31 +} 1.32 + 1.33 +function test_start_stop_response() 1.34 +{ 1.35 + do_check_true(!gTraceClient.tracing, "TraceClient should start in idle state"); 1.36 + gTraceClient.startTrace([], null, function(aResponse) { 1.37 + do_check_true(!!gTraceClient.tracing, "TraceClient should be in tracing state"); 1.38 + do_check_true(!aResponse.error, 1.39 + 'startTrace should not respond with error: ' + aResponse.error); 1.40 + do_check_eq(aResponse.type, "startedTrace", 1.41 + 'startTrace response should have "type":"startedTrace" property'); 1.42 + do_check_eq(aResponse.why, "requested", 1.43 + 'startTrace response should have "why":"requested" property'); 1.44 + 1.45 + gTraceClient.stopTrace(null, function(aResponse) { 1.46 + do_check_true(!gTraceClient.tracing, "TraceClient should be in idle state"); 1.47 + do_check_true(!aResponse.error, 1.48 + 'stopTrace should not respond with error: ' + aResponse.error); 1.49 + do_check_eq(aResponse.type, "stoppedTrace", 1.50 + 'stopTrace response should have "type":"stoppedTrace" property'); 1.51 + do_check_eq(aResponse.why, "requested", 1.52 + 'stopTrace response should have "why":"requested" property'); 1.53 + 1.54 + finishClient(gClient); 1.55 + }); 1.56 + }); 1.57 +}