|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Bug 1008372: Setting a breakpoint in a line without code should move |
|
6 * the icon to the actual location, and if a breakpoint already exists |
|
7 * on the new location don't duplicate |
|
8 */ |
|
9 |
|
10 const TAB_URL = EXAMPLE_URL + "doc_breakpoint-move.html"; |
|
11 |
|
12 function test() { |
|
13 let gTab, gDebuggee, gPanel, gDebugger; |
|
14 let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving; |
|
15 |
|
16 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
17 gTab = aTab; |
|
18 gDebuggee = aDebuggee; |
|
19 gPanel = aPanel; |
|
20 gDebugger = gPanel.panelWin; |
|
21 gEditor = gDebugger.DebuggerView.editor; |
|
22 gSources = gDebugger.DebuggerView.Sources; |
|
23 gBreakpoints = gDebugger.DebuggerController.Breakpoints; |
|
24 gBreakpointsAdded = gBreakpoints._added; |
|
25 gBreakpointsRemoving = gBreakpoints._removing; |
|
26 |
|
27 waitForSourceAndCaretAndScopes(gPanel, ".html", 1).then(performTest); |
|
28 gDebuggee.ermahgerd(); |
|
29 }); |
|
30 |
|
31 function performTest() { |
|
32 is(gBreakpointsAdded.size, 0, |
|
33 "No breakpoints currently added."); |
|
34 is(gBreakpointsRemoving.size, 0, |
|
35 "No breakpoints currently being removed."); |
|
36 is(gEditor.getBreakpoints().length, 0, |
|
37 "No breakpoints currently shown in the editor."); |
|
38 |
|
39 Task.spawn(function*() { |
|
40 let bpClient = yield gPanel.addBreakpoint({ |
|
41 url: gSources.selectedValue, |
|
42 line: 19 |
|
43 }); |
|
44 yield gPanel.addBreakpoint({ |
|
45 url: gSources.selectedValue, |
|
46 line: 20 |
|
47 }); |
|
48 |
|
49 let movedBpClient = yield gPanel.addBreakpoint({ |
|
50 url: gSources.selectedValue, |
|
51 line: 17 |
|
52 }); |
|
53 testMovedLocation(movedBpClient); |
|
54 |
|
55 yield resumeAndTestBreakpoint(19); |
|
56 |
|
57 yield gPanel.removeBreakpoint({ |
|
58 url: gSources.selectedValue, |
|
59 line: 19 |
|
60 }); |
|
61 |
|
62 yield resumeAndTestBreakpoint(20); |
|
63 yield doResume(gPanel); |
|
64 |
|
65 executeSoon(() => gDebuggee.ermahgerd()); |
|
66 yield waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES); |
|
67 |
|
68 yield resumeAndTestBreakpoint(20); |
|
69 resumeDebuggerThenCloseAndFinish(gPanel); |
|
70 }); |
|
71 } |
|
72 |
|
73 function resumeAndTestBreakpoint(line) { |
|
74 return Task.spawn(function*() { |
|
75 let event = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES); |
|
76 doResume(gPanel); |
|
77 yield event; |
|
78 testBreakpoint(line); |
|
79 }); |
|
80 }; |
|
81 |
|
82 function testBreakpoint(line) { |
|
83 let selectedBreakpoint = gSources._selectedBreakpointItem; |
|
84 ok(selectedBreakpoint, |
|
85 "There should be a selected breakpoint on line " + line); |
|
86 is(selectedBreakpoint.attachment.line, line, |
|
87 "The breakpoint on line " + line + " was not hit"); |
|
88 } |
|
89 |
|
90 function testMovedLocation(breakpointClient) { |
|
91 ok(breakpointClient, |
|
92 "Breakpoint added, client received."); |
|
93 is(breakpointClient.location.url, gSources.selectedValue, |
|
94 "Breakpoint client url is the same."); |
|
95 is(breakpointClient.location.line, 19, |
|
96 "Breakpoint client line is new."); |
|
97 |
|
98 is(breakpointClient.requestedLocation.url, gSources.selectedValue, |
|
99 "Requested location url is correct"); |
|
100 is(breakpointClient.requestedLocation.line, 17, |
|
101 "Requested location line is correct"); |
|
102 } |
|
103 } |