|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Check that we can set breakpoints in columns, not just lines. |
|
6 */ |
|
7 |
|
8 var gDebuggee; |
|
9 var gClient; |
|
10 var gThreadClient; |
|
11 |
|
12 function run_test() |
|
13 { |
|
14 initTestDebuggerServer(); |
|
15 gDebuggee = addTestGlobal("test-breakpoints"); |
|
16 gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
|
17 gClient.connect(function () { |
|
18 attachTestTabAndResume(gClient, |
|
19 "test-breakpoints", |
|
20 function (aResponse, aTabClient, aThreadClient) { |
|
21 gThreadClient = aThreadClient; |
|
22 test_column_breakpoint(); |
|
23 }); |
|
24 }); |
|
25 do_test_pending(); |
|
26 } |
|
27 |
|
28 function test_column_breakpoint() |
|
29 { |
|
30 const location = { |
|
31 url: "https://example.com/foo.js", |
|
32 line: 1, |
|
33 column: 55 |
|
34 }; |
|
35 |
|
36 // Debugger statement |
|
37 gClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
|
38 let timesBreakpointHit = 0; |
|
39 |
|
40 gThreadClient.setBreakpoint(location, function (aResponse, bpClient) { |
|
41 gThreadClient.addListener("paused", function _onPaused(aEvent, aPacket) { |
|
42 do_check_eq(aPacket.type, "paused"); |
|
43 do_check_eq(aPacket.why.type, "breakpoint"); |
|
44 do_check_eq(aPacket.why.actors[0], bpClient.actor); |
|
45 do_check_eq(aPacket.frame.where.url, location.url); |
|
46 do_check_eq(aPacket.frame.where.line, location.line); |
|
47 do_check_eq(aPacket.frame.where.column, location.column); |
|
48 |
|
49 do_check_eq(gDebuggee.acc, timesBreakpointHit); |
|
50 do_check_eq(aPacket.frame.environment.bindings.variables.i.value, |
|
51 timesBreakpointHit); |
|
52 |
|
53 if (++timesBreakpointHit === 3) { |
|
54 gThreadClient.removeListener("paused", _onPaused); |
|
55 bpClient.remove(function (aResponse) { |
|
56 gThreadClient.resume(() => finishClient(gClient)); |
|
57 }); |
|
58 } else { |
|
59 gThreadClient.resume(); |
|
60 } |
|
61 }); |
|
62 |
|
63 // Continue until the breakpoint is hit. |
|
64 gThreadClient.resume(); |
|
65 }); |
|
66 |
|
67 }); |
|
68 |
|
69 let code = |
|
70 "(function () { debugger; this.acc = 0; for (let i = 0; i < 3; i++) this.acc++; }());"; |
|
71 |
|
72 Components.utils.evalInSandbox(code, gDebuggee, "1.8", |
|
73 location.url, 1); |
|
74 } |