|
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. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html"; |
|
10 |
|
11 function test() { |
|
12 let gTab, gDebuggee, gPanel, gDebugger; |
|
13 let gSources, gBreakpoints, gLocation; |
|
14 |
|
15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
16 gTab = aTab; |
|
17 gDebuggee = aDebuggee; |
|
18 gPanel = aPanel; |
|
19 gDebugger = gPanel.panelWin; |
|
20 gSources = gDebugger.DebuggerView.Sources; |
|
21 gBreakpoints = gDebugger.DebuggerController.Breakpoints; |
|
22 |
|
23 // This test forces conditional breakpoints to be evaluated on the |
|
24 // client-side |
|
25 var client = gPanel.target.client; |
|
26 client.mainRoot.traits.conditionalBreakpoints = false; |
|
27 |
|
28 gLocation = { url: gSources.selectedValue, line: 18 }; |
|
29 |
|
30 waitForSourceAndCaretAndScopes(gPanel, ".html", 17) |
|
31 .then(addBreakpoint) |
|
32 .then(setDummyConditional) |
|
33 .then(() => { |
|
34 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED); |
|
35 toggleBreakpoint(); |
|
36 return finished; |
|
37 }) |
|
38 .then(() => { |
|
39 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED); |
|
40 toggleBreakpoint(); |
|
41 return finished; |
|
42 }) |
|
43 .then(testConditionalExpressionOnClient) |
|
44 .then(() => { |
|
45 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING); |
|
46 openConditionalPopup(); |
|
47 finished.then(() => ok(false, "The popup shouldn't have opened.")); |
|
48 return waitForTime(1000); |
|
49 }) |
|
50 .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
|
51 .then(null, aError => { |
|
52 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
53 }); |
|
54 |
|
55 gDebuggee.ermahgerd(); |
|
56 }); |
|
57 |
|
58 function addBreakpoint() { |
|
59 return gPanel.addBreakpoint(gLocation); |
|
60 } |
|
61 |
|
62 function setDummyConditional(aClient) { |
|
63 // This happens when a conditional expression input popup is shown |
|
64 // but the user doesn't type anything into it. |
|
65 aClient.conditionalExpression = ""; |
|
66 } |
|
67 |
|
68 function toggleBreakpoint() { |
|
69 EventUtils.sendMouseEvent({ type: "click" }, |
|
70 gDebugger.document.querySelector(".dbg-breakpoint-checkbox"), |
|
71 gDebugger); |
|
72 } |
|
73 |
|
74 function openConditionalPopup() { |
|
75 EventUtils.sendMouseEvent({ type: "click" }, |
|
76 gDebugger.document.querySelector(".dbg-breakpoint"), |
|
77 gDebugger); |
|
78 } |
|
79 |
|
80 function testConditionalExpressionOnClient() { |
|
81 return gBreakpoints._getAdded(gLocation).then(aClient => { |
|
82 if ("conditionalExpression" in aClient) { |
|
83 ok(false, "A conditional expression shouldn't have been set."); |
|
84 } else { |
|
85 ok(true, "The conditional expression wasn't set, as expected."); |
|
86 } |
|
87 }); |
|
88 } |
|
89 } |