1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_eval-05.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 + * Check pauses within evals. 1.9 + */ 1.10 + 1.11 +var gDebuggee; 1.12 +var gClient; 1.13 +var gThreadClient; 1.14 + 1.15 +function run_test() 1.16 +{ 1.17 + initTestDebuggerServer(); 1.18 + gDebuggee = addTestGlobal("test-stack"); 1.19 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.20 + gClient.connect(function() { 1.21 + attachTestTabAndResume(gClient, "test-stack", function(aResponse, aTabClient, aThreadClient) { 1.22 + gThreadClient = aThreadClient; 1.23 + test_syntax_error_eval(); 1.24 + }); 1.25 + }); 1.26 + do_test_pending(); 1.27 +} 1.28 + 1.29 +function test_syntax_error_eval() 1.30 +{ 1.31 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { 1.32 + gThreadClient.eval(null, "debugger", function(aResponse) { 1.33 + // Expect a resume then a debuggerStatement pause. 1.34 + do_check_eq(aResponse.type, "resumed"); 1.35 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { 1.36 + do_check_eq(aPacket.why.type, "debuggerStatement"); 1.37 + // Resume from the debugger statement should immediately re-pause 1.38 + // with a clientEvaluated reason. 1.39 + gThreadClient.resume(function(aPacket) { 1.40 + do_check_eq(aPacket.type, "resumed"); 1.41 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { 1.42 + do_check_eq(aPacket.why.type, "clientEvaluated"); 1.43 + gThreadClient.resume(function() { 1.44 + finishClient(gClient); 1.45 + }); 1.46 + }); 1.47 + }); 1.48 + }); 1.49 + }); 1.50 + }); 1.51 + gDebuggee.eval("(" + function() { 1.52 + function stopMe(arg) { 1.53 + debugger; 1.54 + } 1.55 + stopMe(); 1.56 + } + ")()"); 1.57 +}