michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Check that setting breakpoints when the debuggee is running works. michael@0: */ michael@0: michael@0: var gDebuggee; michael@0: var gClient; michael@0: var gThreadClient; michael@0: michael@0: function run_test() michael@0: { michael@0: initTestDebuggerServer(); michael@0: gDebuggee = addTestGlobal("test-stack"); michael@0: gClient = new DebuggerClient(DebuggerServer.connectPipe()); michael@0: gClient.connect(function () { michael@0: attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { michael@0: gThreadClient = aThreadClient; michael@0: test_breakpoint_running(); michael@0: }); michael@0: }); michael@0: do_test_pending(); michael@0: } michael@0: michael@0: function test_breakpoint_running() michael@0: { michael@0: gDebuggee.eval("var line0 = Error().lineNumber;\n" + michael@0: "var a = 1;\n" + // line0 + 1 michael@0: "var b = 2;\n"); // line0 + 2 michael@0: michael@0: let path = getFilePath('test_breakpoint-02.js'); michael@0: let location = { url: path, line: gDebuggee.line0 + 2}; michael@0: michael@0: // Setting the breakpoint later should interrupt the debuggee. michael@0: gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { michael@0: do_check_eq(aPacket.type, "paused"); michael@0: do_check_eq(aPacket.why.type, "interrupted"); michael@0: }); michael@0: michael@0: gThreadClient.setBreakpoint(location, function(aResponse) { michael@0: // Eval scripts don't stick around long enough for the breakpoint to be set, michael@0: // so just make sure we got the expected response from the actor. michael@0: do_check_neq(aResponse.error, "noScript"); michael@0: michael@0: do_execute_soon(function() { michael@0: finishClient(gClient); michael@0: }); michael@0: }); michael@0: }