|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Bug 771452: Make sure that setting a breakpoint in an inline source doesn't |
|
6 * add it twice. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_inline-script.html"; |
|
10 |
|
11 let gTab, gDebuggee, gPanel, gDebugger; |
|
12 |
|
13 function test() { |
|
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
15 gTab = aTab; |
|
16 gDebuggee = aDebuggee; |
|
17 gPanel = aPanel; |
|
18 gDebugger = gPanel.panelWin; |
|
19 |
|
20 addBreakpoint(); |
|
21 }); |
|
22 } |
|
23 |
|
24 function addBreakpoint() { |
|
25 waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => { |
|
26 is(gDebugger.gThreadClient.state, "paused", |
|
27 "The debugger statement was reached."); |
|
28 ok(isCaretPos(gPanel, 16), |
|
29 "The source editor caret position is incorrect (1)."); |
|
30 |
|
31 gPanel.addBreakpoint({ url: TAB_URL, line: 20 }).then(() => { |
|
32 testResume(); |
|
33 }); |
|
34 }); |
|
35 |
|
36 gDebuggee.runDebuggerStatement(); |
|
37 } |
|
38 |
|
39 function testResume() { |
|
40 is(gDebugger.gThreadClient.state, "paused", |
|
41 "The breakpoint wasn't hit yet."); |
|
42 |
|
43 gDebugger.gThreadClient.resume(() => { |
|
44 gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => { |
|
45 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { |
|
46 is(aPacket.why.type, "breakpoint", |
|
47 "Execution has advanced to the next breakpoint."); |
|
48 isnot(aPacket.why.type, "debuggerStatement", |
|
49 "The breakpoint was hit before the debugger statement."); |
|
50 ok(isCaretPos(gPanel, 20), |
|
51 "The source editor caret position is incorrect (2)."); |
|
52 |
|
53 testBreakpointHit(); |
|
54 }); |
|
55 }); |
|
56 |
|
57 EventUtils.sendMouseEvent({ type: "click" }, |
|
58 gDebuggee.document.querySelector("button"), |
|
59 gDebuggee); |
|
60 }); |
|
61 } |
|
62 |
|
63 function testBreakpointHit() { |
|
64 is(gDebugger.gThreadClient.state, "paused", |
|
65 "The breakpoint was hit."); |
|
66 |
|
67 gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => { |
|
68 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { |
|
69 is(aPacket.why.type, "debuggerStatement", |
|
70 "Execution has advanced to the next line."); |
|
71 isnot(aPacket.why.type, "breakpoint", |
|
72 "No ghost breakpoint was hit."); |
|
73 ok(isCaretPos(gPanel, 20), |
|
74 "The source editor caret position is incorrect (3)."); |
|
75 |
|
76 resumeDebuggerThenCloseAndFinish(gPanel); |
|
77 }); |
|
78 }); |
|
79 |
|
80 EventUtils.sendMouseEvent({ type: "mousedown" }, |
|
81 gDebugger.document.getElementById("resume"), |
|
82 gDebugger); |
|
83 } |
|
84 |
|
85 registerCleanupFunction(function() { |
|
86 gTab = null; |
|
87 gDebuggee = null; |
|
88 gPanel = null; |
|
89 gDebugger = null; |
|
90 }); |