1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_breakpoint-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 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 that setting breakpoints when the debuggee is running works. 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_breakpoint_running(); 1.24 + }); 1.25 + }); 1.26 + do_test_pending(); 1.27 +} 1.28 + 1.29 +function test_breakpoint_running() 1.30 +{ 1.31 + gDebuggee.eval("var line0 = Error().lineNumber;\n" + 1.32 + "var a = 1;\n" + // line0 + 1 1.33 + "var b = 2;\n"); // line0 + 2 1.34 + 1.35 + let path = getFilePath('test_breakpoint-02.js'); 1.36 + let location = { url: path, line: gDebuggee.line0 + 2}; 1.37 + 1.38 + // Setting the breakpoint later should interrupt the debuggee. 1.39 + gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { 1.40 + do_check_eq(aPacket.type, "paused"); 1.41 + do_check_eq(aPacket.why.type, "interrupted"); 1.42 + }); 1.43 + 1.44 + gThreadClient.setBreakpoint(location, function(aResponse) { 1.45 + // Eval scripts don't stick around long enough for the breakpoint to be set, 1.46 + // so just make sure we got the expected response from the actor. 1.47 + do_check_neq(aResponse.error, "noScript"); 1.48 + 1.49 + do_execute_soon(function() { 1.50 + finishClient(gClient); 1.51 + }); 1.52 + }); 1.53 +}