1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple2");
await pushPref("devtools.debugger.features.column-breakpoints", true);
await selectSource(dbg, "simple2");
await waitForSelectedSource(dbg, "simple2");
info("Set condition `1`");
await setConditionalBreakpoint(dbg, 5, "1");
await waitForCondition(dbg, 1);
let bp = findBreakpoint(dbg, "simple2", 5);
is(bp.options.condition, "1", "breakpoint is created with the condition");
await assertEditorBreakpoint(dbg, 5, { hasCondition: true });
info("Edit the conditional breakpoint set above");
await setConditionalBreakpoint(dbg, 5, "2");
await waitForCondition(dbg, 12);
bp = findBreakpoint(dbg, "simple2", 5);
is(bp.options.condition, "12", "breakpoint is created with the condition");
await assertEditorBreakpoint(dbg, 5, { hasCondition: true });
info("Hit 'Enter' when the cursor is in the conditional statement");
rightClickElement(dbg, "gutter", 5);
selectContextMenuItem(dbg, `${selectors.editConditionItem}`);
await waitForConditionalPanelFocus(dbg);
pressKey(dbg, "Left");
pressKey(dbg, "Enter");
await waitForCondition(dbg, 12);
bp = findBreakpoint(dbg, "simple2", 5);
is(bp.options.condition, "12", "Hit 'Enter' doesn't add a new line");
info("Hit 'Alt+Enter' when the cursor is in the conditional statement");
rightClickElement(dbg, "gutter", 5);
selectContextMenuItem(dbg, `${selectors.editConditionItem}`);
await waitForConditionalPanelFocus(dbg);
pressKey(dbg, "Left");
pressKey(dbg, "AltEnter");
pressKey(dbg, "Enter");
await waitForCondition(dbg, "1\n2");
bp = findBreakpoint(dbg, "simple2", 5);
is(bp.options.condition, "1\n2", "Hit 'Alt+Enter' adds a new line");
clickElement(dbg, "gutter", 5);
await waitForDispatch(dbg, "REMOVE_BREAKPOINT");
bp = findBreakpoint(dbg, "simple2", 5);
is(bp, undefined, "breakpoint was removed");
await assertEditorBreakpoint(dbg, 5);
info("Adding a condition to a breakpoint");
clickElement(dbg, "gutter", 5);
await waitForDispatch(dbg, "SET_BREAKPOINT");
await setConditionalBreakpoint(dbg, 5, "1");
await waitForCondition(dbg, 1);
bp = findBreakpoint(dbg, "simple2", 5);
is(bp.options.condition, "1", "breakpoint is created with the condition");
await assertEditorBreakpoint(dbg, 5, { hasCondition: true });
info("Double click the conditional breakpoint in secondary pane");
dblClickElement(dbg, "conditionalBreakpointInSecPane");
is(
dbg.win.document.activeElement.tagName,
"TEXTAREA",
"The textarea of conditional breakpoint panel is focused"
);
info("Click the conditional breakpoint in secondary pane");
await clickElement(dbg, "conditionalBreakpointInSecPane");
const conditonalPanel = findElement(dbg, "conditionalPanel");
is(conditonalPanel, null, "The conditional breakpoint panel is closed");
rightClickElement(dbg, "breakpointItem", 2);
info('select "remove condition"');
selectContextMenuItem(dbg, selectors.breakpointContextMenu.removeCondition);
await waitForBreakpointWithoutCondition(dbg, "simple2", 5);
bp = findBreakpoint(dbg, "simple2", 5);
is(bp.options.condition, null, "breakpoint condition removed");
info('Add "log point"');
await setLogPoint(dbg, 5, "44");
await waitForLog(dbg, 44);
await assertEditorBreakpoint(dbg, 5, { hasLog: true });
bp = findBreakpoint(dbg, "simple2", 5);
is(bp.options.logValue, "44", "breakpoint condition removed");
await altClickElement(dbg, "gutter", 6);
bp = await waitForBreakpoint(dbg, "simple2", 6);
is(bp.options.logValue, "displayName", "logPoint has default value");
info("Double click the logpoint in secondary pane");
dblClickElement(dbg, "logPointInSecPane");
is(
dbg.win.document.activeElement.tagName,
"TEXTAREA",
"The textarea of logpoint panel is focused"
);
info("Click the logpoint in secondary pane");
await clickElement(dbg, "logPointInSecPane");
const logPointPanel = findElement(dbg, "logPointPanel");
is(logPointPanel, null, "The logpoint panel is closed");
});
function getLineEl(dbg, line) {
const lines = dbg.win.document.querySelectorAll(".CodeMirror-code > div");
return lines[line - 1];
}
function assertEditorBreakpoint(
dbg,
line,
{ hasCondition = false, hasLog = false } = {}
) {
const hasConditionClass = getLineEl(dbg, line).classList.contains(
"has-condition"
);
ok(
hasConditionClass === hasCondition,
`Breakpoint condition ${
hasCondition ? "exists" : "does not exist"
} on line ${line}`
);
const hasLogClass = getLineEl(dbg, line).classList.contains("has-log");
ok(
hasLogClass === hasLog,
`Breakpoint log ${hasLog ? "exists" : "does not exist"} on line ${line}`
);
}
function waitForBreakpointWithoutCondition(dbg, url, line) {
return waitForState(dbg, () => {
const bp = findBreakpoint(dbg, url, line);
return bp && !bp.options.condition;
});
}
async function setConditionalBreakpoint(dbg, index, condition) {
// Make this work with either add or edit menu items
const { addConditionItem, editConditionItem } = selectors;
const selector = `${addConditionItem},${editConditionItem}`;
rightClickElement(dbg, "gutter", index);
selectContextMenuItem(dbg, selector);
typeInPanel(dbg, condition);
}
async function setLogPoint(dbg, index, value) {
rightClickElement(dbg, "gutter", index);
selectContextMenuItem(
dbg,
`${selectors.addLogItem},${selectors.editLogItem}`
);
await typeInPanel(dbg, value);
}
async function waitForConditionalPanelFocus(dbg) {
await waitFor(() => dbg.win.document.activeElement.tagName === "TEXTAREA");
}
|