|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Bug 737803: Setting a breakpoint in a line without code should move |
|
6 * the icon to the actual location. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; |
|
10 |
|
11 function test() { |
|
12 let gTab, gDebuggee, gPanel, gDebugger; |
|
13 let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving; |
|
14 |
|
15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
16 gTab = aTab; |
|
17 gDebuggee = aDebuggee; |
|
18 gPanel = aPanel; |
|
19 gDebugger = gPanel.panelWin; |
|
20 gEditor = gDebugger.DebuggerView.editor; |
|
21 gSources = gDebugger.DebuggerView.Sources; |
|
22 gBreakpoints = gDebugger.DebuggerController.Breakpoints; |
|
23 gBreakpointsAdded = gBreakpoints._added; |
|
24 gBreakpointsRemoving = gBreakpoints._removing; |
|
25 |
|
26 waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest); |
|
27 gDebuggee.firstCall(); |
|
28 }); |
|
29 |
|
30 function performTest() { |
|
31 is(gBreakpointsAdded.size, 0, |
|
32 "No breakpoints currently added."); |
|
33 is(gBreakpointsRemoving.size, 0, |
|
34 "No breakpoints currently being removed."); |
|
35 is(gEditor.getBreakpoints().length, 0, |
|
36 "No breakpoints currently shown in the editor."); |
|
37 |
|
38 gEditor.on("breakpointAdded", onEditorBreakpointAdd); |
|
39 gPanel.addBreakpoint({ url: gSources.selectedValue, line: 4 }).then(onBreakpointAdd); |
|
40 } |
|
41 |
|
42 let onBpDebuggerAdd = false; |
|
43 let onBpEditorAdd = false; |
|
44 |
|
45 function onBreakpointAdd(aBreakpointClient) { |
|
46 ok(aBreakpointClient, |
|
47 "Breakpoint added, client received."); |
|
48 is(aBreakpointClient.location.url, gSources.selectedValue, |
|
49 "Breakpoint client url is the same."); |
|
50 is(aBreakpointClient.location.line, 6, |
|
51 "Breakpoint client line is new."); |
|
52 |
|
53 is(aBreakpointClient.requestedLocation.url, gSources.selectedValue, |
|
54 "Requested location url is correct"); |
|
55 is(aBreakpointClient.requestedLocation.line, 4, |
|
56 "Requested location line is correct"); |
|
57 |
|
58 onBpDebuggerAdd = true; |
|
59 maybeFinish(); |
|
60 } |
|
61 |
|
62 function onEditorBreakpointAdd() { |
|
63 gEditor.off("breakpointAdded", onEditorBreakpointAdd); |
|
64 |
|
65 is(gEditor.getBreakpoints().length, 1, |
|
66 "There is only one breakpoint in the editor"); |
|
67 |
|
68 ok(!gBreakpoints._getAdded({ url: gSources.selectedValue, line: 4 }), |
|
69 "There isn't any breakpoint added on an invalid line."); |
|
70 ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 4 }), |
|
71 "There isn't any breakpoint removed from an invalid line."); |
|
72 |
|
73 ok(gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }), |
|
74 "There is a breakpoint added on the actual line."); |
|
75 ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 6 }), |
|
76 "There isn't any breakpoint removed from the actual line."); |
|
77 |
|
78 gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }).then(aBreakpointClient => { |
|
79 is(aBreakpointClient.location.url, gSources.selectedValue, |
|
80 "Breakpoint client location url is correct."); |
|
81 is(aBreakpointClient.location.line, 6, |
|
82 "Breakpoint client location line is correct."); |
|
83 |
|
84 onBpEditorAdd = true; |
|
85 maybeFinish(); |
|
86 }); |
|
87 } |
|
88 |
|
89 function maybeFinish() { |
|
90 info("onBpDebuggerAdd: " + onBpDebuggerAdd); |
|
91 info("onBpEditorAdd: " + onBpEditorAdd); |
|
92 |
|
93 if (onBpDebuggerAdd && onBpEditorAdd) { |
|
94 resumeDebuggerThenCloseAndFinish(gPanel); |
|
95 } |
|
96 } |
|
97 } |