|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Make sure that conditional breakpoints with undefined expressions |
|
6 * are stored as plain breakpoints when re-enabling them (with |
|
7 * server-side support) |
|
8 */ |
|
9 |
|
10 const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html"; |
|
11 |
|
12 function test() { |
|
13 let gTab, gDebuggee, gPanel, gDebugger; |
|
14 let gSources, gBreakpoints, gLocation; |
|
15 |
|
16 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
17 gTab = aTab; |
|
18 gDebuggee = aDebuggee; |
|
19 gPanel = aPanel; |
|
20 gDebugger = gPanel.panelWin; |
|
21 gSources = gDebugger.DebuggerView.Sources; |
|
22 gBreakpoints = gDebugger.DebuggerController.Breakpoints; |
|
23 |
|
24 gLocation = { url: gSources.selectedValue, line: 18 }; |
|
25 |
|
26 waitForSourceAndCaretAndScopes(gPanel, ".html", 17) |
|
27 .then(addBreakpoint) |
|
28 .then(setDummyConditional) |
|
29 .then(() => { |
|
30 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED); |
|
31 toggleBreakpoint(); |
|
32 return finished; |
|
33 }) |
|
34 .then(() => { |
|
35 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED); |
|
36 toggleBreakpoint(); |
|
37 return finished; |
|
38 }) |
|
39 .then(testConditionalExpressionOnClient) |
|
40 .then(() => { |
|
41 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING); |
|
42 openConditionalPopup(); |
|
43 finished.then(() => ok(false, "The popup shouldn't have opened.")); |
|
44 return waitForTime(1000); |
|
45 }) |
|
46 .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
|
47 .then(null, aError => { |
|
48 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
49 }); |
|
50 |
|
51 gDebuggee.ermahgerd(); |
|
52 }); |
|
53 |
|
54 function addBreakpoint() { |
|
55 return gPanel.addBreakpoint(gLocation); |
|
56 } |
|
57 |
|
58 function setDummyConditional(aClient) { |
|
59 // This happens when a conditional expression input popup is shown |
|
60 // but the user doesn't type anything into it. |
|
61 return gBreakpoints.updateCondition(aClient.location, ''); |
|
62 } |
|
63 |
|
64 function toggleBreakpoint() { |
|
65 EventUtils.sendMouseEvent({ type: "click" }, |
|
66 gDebugger.document.querySelector(".dbg-breakpoint-checkbox"), |
|
67 gDebugger); |
|
68 } |
|
69 |
|
70 function openConditionalPopup() { |
|
71 EventUtils.sendMouseEvent({ type: "click" }, |
|
72 gDebugger.document.querySelector(".dbg-breakpoint"), |
|
73 gDebugger); |
|
74 } |
|
75 |
|
76 function testConditionalExpressionOnClient() { |
|
77 return gBreakpoints._getAdded(gLocation).then(aClient => { |
|
78 if ("condition" in aClient) { |
|
79 ok(false, "A conditional expression shouldn't have been set."); |
|
80 } else { |
|
81 ok(true, "The conditional expression wasn't set, as expected."); |
|
82 } |
|
83 }); |
|
84 } |
|
85 } |