|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Test that conditional breakpoints survive disabled breakpoints |
|
6 * (with server-side support) |
|
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 gLocation = { url: gSources.selectedValue, line: 18 }; |
|
24 |
|
25 waitForSourceAndCaretAndScopes(gPanel, ".html", 17) |
|
26 .then(addBreakpoint) |
|
27 .then(setConditional) |
|
28 .then(() => { |
|
29 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED); |
|
30 toggleBreakpoint(); |
|
31 return finished; |
|
32 }) |
|
33 .then(() => { |
|
34 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED); |
|
35 toggleBreakpoint(); |
|
36 return finished; |
|
37 }) |
|
38 .then(testConditionalExpressionOnClient) |
|
39 .then(() => { |
|
40 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING); |
|
41 openConditionalPopup(); |
|
42 return finished; |
|
43 }) |
|
44 .then(testConditionalExpressionInPopup) |
|
45 .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
|
46 .then(null, aError => { |
|
47 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
48 }); |
|
49 |
|
50 gDebuggee.ermahgerd(); |
|
51 }); |
|
52 |
|
53 function addBreakpoint() { |
|
54 return gPanel.addBreakpoint(gLocation); |
|
55 } |
|
56 |
|
57 function setConditional(aClient) { |
|
58 return gBreakpoints.updateCondition(aClient.location, "hello"); |
|
59 } |
|
60 |
|
61 function toggleBreakpoint() { |
|
62 EventUtils.sendMouseEvent({ type: "click" }, |
|
63 gDebugger.document.querySelector(".dbg-breakpoint-checkbox"), |
|
64 gDebugger); |
|
65 } |
|
66 |
|
67 function openConditionalPopup() { |
|
68 EventUtils.sendMouseEvent({ type: "click" }, |
|
69 gDebugger.document.querySelector(".dbg-breakpoint"), |
|
70 gDebugger); |
|
71 } |
|
72 |
|
73 function testConditionalExpressionOnClient() { |
|
74 return gBreakpoints._getAdded(gLocation).then(aClient => { |
|
75 is(aClient.condition, "hello", "The expression is correct (1)."); |
|
76 }); |
|
77 } |
|
78 |
|
79 function testConditionalExpressionInPopup() { |
|
80 let textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox"); |
|
81 is(textbox.value, "hello", "The expression is correct (2).") |
|
82 } |
|
83 } |