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 a breakpoint in a line without code in the second child michael@0: * script will skip forward. 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_second_child_skip_breakpoint(); michael@0: }); michael@0: }); michael@0: do_test_pending(); michael@0: } michael@0: michael@0: function test_second_child_skip_breakpoint() michael@0: { michael@0: gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { michael@0: let path = getFilePath('test_breakpoint-07.js'); michael@0: let location = { url: path, line: gDebuggee.line0 + 6}; michael@0: gThreadClient.setBreakpoint(location, function (aResponse, bpClient) { michael@0: // Check that the breakpoint has properly skipped forward one line. michael@0: do_check_eq(aResponse.actualLocation.url, location.url); michael@0: do_check_eq(aResponse.actualLocation.line, location.line + 1); michael@0: gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { michael@0: // Check the return value. michael@0: do_check_eq(aPacket.type, "paused"); michael@0: do_check_eq(aPacket.frame.where.url, path); michael@0: do_check_eq(aPacket.frame.where.line, location.line + 1); michael@0: do_check_eq(aPacket.why.type, "breakpoint"); michael@0: do_check_eq(aPacket.why.actors[0], bpClient.actor); michael@0: // Check that the breakpoint worked. michael@0: do_check_eq(gDebuggee.a, 1); michael@0: do_check_eq(gDebuggee.b, undefined); michael@0: michael@0: // Remove the breakpoint. michael@0: bpClient.remove(function (aResponse) { michael@0: gThreadClient.resume(function () { michael@0: finishClient(gClient); michael@0: }); michael@0: }); michael@0: michael@0: }); michael@0: // Continue until the breakpoint is hit. michael@0: gThreadClient.resume(); michael@0: michael@0: }); michael@0: michael@0: }); michael@0: michael@0: gDebuggee.eval("var line0 = Error().lineNumber;\n" + michael@0: "function foo() {\n" + // line0 + 1 michael@0: " bar();\n" + // line0 + 2 michael@0: "}\n" + // line0 + 3 michael@0: "function bar() {\n" + // line0 + 4 michael@0: " this.a = 1;\n" + // line0 + 5 michael@0: " // A comment.\n" + // line0 + 6 michael@0: " this.b = 2;\n" + // line0 + 7 michael@0: "}\n" + // line0 + 8 michael@0: "debugger;\n" + // line0 + 9 michael@0: "foo();\n"); // line0 + 10 michael@0: }