1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_eval-04.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 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 evals against different frames. 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 + 1.33 + gThreadClient.getFrames(0, 2, function(aResponse) { 1.34 + let frame0 = aResponse.frames[0]; 1.35 + let frame1 = aResponse.frames[1]; 1.36 + 1.37 + // Eval against the top frame... 1.38 + gThreadClient.eval(frame0.actor, "arg", function(aResponse) { 1.39 + do_check_eq(aResponse.type, "resumed"); 1.40 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { 1.41 + // 'arg' should have been evaluated in frame0 1.42 + do_check_eq(aPacket.type, "paused"); 1.43 + do_check_eq(aPacket.why.type, "clientEvaluated"); 1.44 + do_check_eq(aPacket.why.frameFinished.return, "arg0"); 1.45 + 1.46 + // Now eval against the second frame. 1.47 + gThreadClient.eval(frame1.actor, "arg", function(aResponse) { 1.48 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { 1.49 + // 'arg' should have been evaluated in frame1 1.50 + do_check_eq(aPacket.type, "paused"); 1.51 + do_check_eq(aPacket.why.frameFinished.return, "arg1"); 1.52 + 1.53 + gThreadClient.resume(function() { 1.54 + finishClient(gClient); 1.55 + }); 1.56 + }); 1.57 + }); 1.58 + }); 1.59 + }); 1.60 + }); 1.61 + }); 1.62 + 1.63 + gDebuggee.eval("(" + function() { 1.64 + function frame0(arg) { 1.65 + debugger; 1.66 + } 1.67 + function frame1(arg) { 1.68 + frame0("arg0"); 1.69 + } 1.70 + frame1("arg1"); 1.71 + } + ")()"); 1.72 +}