|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Check that we only break on offsets that are entry points for the line we are |
|
6 * breaking on. Bug 907278. |
|
7 */ |
|
8 |
|
9 var gDebuggee; |
|
10 var gClient; |
|
11 var gThreadClient; |
|
12 |
|
13 function run_test() |
|
14 { |
|
15 initTestDebuggerServer(); |
|
16 gDebuggee = addTestGlobal("test-breakpoints"); |
|
17 gDebuggee.console = { log: x => void x }; |
|
18 gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
|
19 gClient.connect(function () { |
|
20 attachTestTabAndResume(gClient, |
|
21 "test-breakpoints", |
|
22 function (aResponse, aTabClient, aThreadClient) { |
|
23 gThreadClient = aThreadClient; |
|
24 setUpCode(); |
|
25 }); |
|
26 }); |
|
27 do_test_pending(); |
|
28 } |
|
29 |
|
30 const URL = "test.js"; |
|
31 |
|
32 function setUpCode() { |
|
33 gClient.addOneTimeListener("newSource", setBreakpoint); |
|
34 Cu.evalInSandbox( |
|
35 "" + function test() { |
|
36 console.log("foo bar"); |
|
37 debugger; |
|
38 }, |
|
39 gDebuggee, |
|
40 "1.8", |
|
41 URL |
|
42 ); |
|
43 } |
|
44 |
|
45 function setBreakpoint() { |
|
46 gClient.addOneTimeListener("resumed", runCode); |
|
47 gThreadClient.setBreakpoint({ |
|
48 url: URL, |
|
49 line: 1 |
|
50 }, ({ error }) => { |
|
51 do_check_true(!error); |
|
52 }); |
|
53 } |
|
54 |
|
55 function runCode() { |
|
56 gClient.addOneTimeListener("paused", testBPHit); |
|
57 gDebuggee.test(); |
|
58 } |
|
59 |
|
60 function testBPHit(event, { why }) { |
|
61 do_check_eq(why.type, "breakpoint"); |
|
62 gClient.addOneTimeListener("paused", testDbgStatement); |
|
63 gThreadClient.resume(); |
|
64 } |
|
65 |
|
66 function testDbgStatement(event, { why }) { |
|
67 // Should continue to the debugger statement. |
|
68 do_check_eq(why.type, "debuggerStatement"); |
|
69 // Not break on another offset from the same line (that isn't an entry point |
|
70 // to the line) |
|
71 do_check_neq(why.type, "breakpoint"); |
|
72 finishClient(gClient); |
|
73 } |