|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Check that setting a breakpoint in a line without code in a child script |
|
6 * will skip forward, in a file with two scripts. |
|
7 */ |
|
8 |
|
9 var gDebuggee; |
|
10 var gClient; |
|
11 var gThreadClient; |
|
12 |
|
13 function run_test() |
|
14 { |
|
15 initTestDebuggerServer(); |
|
16 gDebuggee = addTestGlobal("test-stack"); |
|
17 gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
|
18 gClient.connect(function () { |
|
19 attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { |
|
20 gThreadClient = aThreadClient; |
|
21 test_child_skip_breakpoint(); |
|
22 }); |
|
23 }); |
|
24 do_test_pending(); |
|
25 } |
|
26 |
|
27 function test_child_skip_breakpoint() |
|
28 { |
|
29 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
|
30 let path = getFilePath('test_breakpoint-08.js'); |
|
31 let location = { url: path, line: gDebuggee.line0 + 3}; |
|
32 gThreadClient.setBreakpoint(location, function (aResponse, bpClient) { |
|
33 // Check that the breakpoint has properly skipped forward one line. |
|
34 do_check_eq(aResponse.actualLocation.url, location.url); |
|
35 do_check_eq(aResponse.actualLocation.line, location.line + 1); |
|
36 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
|
37 // Check the return value. |
|
38 do_check_eq(aPacket.type, "paused"); |
|
39 do_check_eq(aPacket.frame.where.url, path); |
|
40 do_check_eq(aPacket.frame.where.line, location.line + 1); |
|
41 do_check_eq(aPacket.why.type, "breakpoint"); |
|
42 do_check_eq(aPacket.why.actors[0], bpClient.actor); |
|
43 // Check that the breakpoint worked. |
|
44 do_check_eq(gDebuggee.a, 1); |
|
45 do_check_eq(gDebuggee.b, undefined); |
|
46 |
|
47 // Remove the breakpoint. |
|
48 bpClient.remove(function (aResponse) { |
|
49 gThreadClient.resume(function () { |
|
50 finishClient(gClient); |
|
51 }); |
|
52 }); |
|
53 |
|
54 }); |
|
55 // Continue until the breakpoint is hit. |
|
56 gThreadClient.resume(); |
|
57 |
|
58 }); |
|
59 |
|
60 }); |
|
61 |
|
62 gDebuggee.eval("var line0 = Error().lineNumber;\n" + |
|
63 "function foo() {\n" + // line0 + 1 |
|
64 " this.a = 1;\n" + // line0 + 2 |
|
65 " // A comment.\n" + // line0 + 3 |
|
66 " this.b = 2;\n" + // line0 + 4 |
|
67 "}\n"); // line0 + 5 |
|
68 gDebuggee.eval("var line1 = Error().lineNumber;\n" + |
|
69 "debugger;\n" + // line1 + 1 |
|
70 "foo();\n"); // line1 + 2 |
|
71 } |