|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that conditional breakpoint expressions survive disabled breakpoints. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html"; |
|
9 |
|
10 function test() { |
|
11 let gTab, gDebuggee, gPanel, gDebugger; |
|
12 let gSources, gBreakpoints, gLocation; |
|
13 |
|
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
15 gTab = aTab; |
|
16 gDebuggee = aDebuggee; |
|
17 gPanel = aPanel; |
|
18 gDebugger = gPanel.panelWin; |
|
19 gSources = gDebugger.DebuggerView.Sources; |
|
20 gBreakpoints = gDebugger.DebuggerController.Breakpoints; |
|
21 |
|
22 // This test forces conditional breakpoints to be evaluated on the |
|
23 // client-side |
|
24 var client = gPanel.target.client; |
|
25 client.mainRoot.traits.conditionalBreakpoints = false; |
|
26 |
|
27 gLocation = { url: gSources.selectedValue, line: 18 }; |
|
28 |
|
29 waitForSourceAndCaretAndScopes(gPanel, ".html", 17) |
|
30 .then(addBreakpoint) |
|
31 .then(setConditional) |
|
32 .then(() => { |
|
33 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED); |
|
34 toggleBreakpoint(); |
|
35 return finished; |
|
36 }) |
|
37 .then(() => { |
|
38 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED); |
|
39 toggleBreakpoint(); |
|
40 return finished; |
|
41 }) |
|
42 .then(testConditionalExpressionOnClient) |
|
43 .then(() => { |
|
44 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING); |
|
45 openConditionalPopup(); |
|
46 return finished; |
|
47 }) |
|
48 .then(testConditionalExpressionInPopup) |
|
49 .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
|
50 .then(null, aError => { |
|
51 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
52 }); |
|
53 |
|
54 gDebuggee.ermahgerd(); |
|
55 }); |
|
56 |
|
57 function addBreakpoint() { |
|
58 return gPanel.addBreakpoint(gLocation); |
|
59 } |
|
60 |
|
61 function setConditional(aClient) { |
|
62 aClient.conditionalExpression = "hello"; |
|
63 } |
|
64 |
|
65 function toggleBreakpoint() { |
|
66 EventUtils.sendMouseEvent({ type: "click" }, |
|
67 gDebugger.document.querySelector(".dbg-breakpoint-checkbox"), |
|
68 gDebugger); |
|
69 } |
|
70 |
|
71 function openConditionalPopup() { |
|
72 EventUtils.sendMouseEvent({ type: "click" }, |
|
73 gDebugger.document.querySelector(".dbg-breakpoint"), |
|
74 gDebugger); |
|
75 } |
|
76 |
|
77 function testConditionalExpressionOnClient() { |
|
78 return gBreakpoints._getAdded(gLocation).then(aClient => { |
|
79 is(aClient.conditionalExpression, "hello", "The expression is correct (1)."); |
|
80 }); |
|
81 } |
|
82 |
|
83 function testConditionalExpressionInPopup() { |
|
84 let textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox"); |
|
85 is(textbox.value, "hello", "The expression is correct (2).") |
|
86 } |
|
87 } |