|
1 | | -/* Any copyright is dedicated to the Public Domain. |
2 | | - * http://creativecommons.org/publicdomain/zero/1.0/ */ |
3 | | - |
4 | | -function getColumnBreakpointElements(dbg) { |
5 | | - return findAllElementsWithSelector(dbg, ".column-breakpoint"); |
| 1 | +/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ |
| 4 | + |
| 5 | +async function enableFirstBreakpoint(dbg) { |
| 6 | + getCM(dbg).setCursor({ line: 32, ch: 0 }); |
| 7 | + await addBreakpoint(dbg, "long", 32); |
| 8 | + const bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); |
| 9 | + |
| 10 | + ok(bpMarkers.length === 2, "2 column breakpoints"); |
| 11 | + assertClass(bpMarkers[0], "active"); |
| 12 | + assertClass(bpMarkers[1], "active", false); |
6 | 13 | } |
7 | 14 |
|
8 | | -async function assertConditionalBreakpointIsFocused(dbg) { |
9 | | - const input = findElement(dbg, "conditionalPanelInput"); |
10 | | - await waitForElementFocus(dbg, input); |
11 | | -} |
| 15 | +async function enableSecondBreakpoint(dbg) { |
| 16 | + let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); |
12 | 17 |
|
13 | | -function waitForElementFocus(dbg, el) { |
14 | | - const doc = dbg.win.document; |
15 | | - return waitFor(() => doc.activeElement == el && doc.hasFocus()); |
16 | | -} |
| 18 | + bpMarkers[1].click(); |
| 19 | + await waitForBreakpointCount(dbg, 2); |
17 | 20 |
|
18 | | -function hasCondition(marker) { |
19 | | - return marker.classList.contains("has-condition"); |
| 21 | + bpMarkers = findAllElements(dbg, "columnBreakpoints"); |
| 22 | + assertClass(bpMarkers[1], "active"); |
| 23 | + await waitForAllElements(dbg, "breakpointItems", 2); |
20 | 24 | } |
21 | 25 |
|
22 | 26 | async function setConditionalBreakpoint(dbg, index, condition) { |
23 | | - const { |
24 | | - addConditionalBreakpoint, |
25 | | - editConditionalBreakpoint |
26 | | - } = selectors.gutterContextMenu; |
27 | | - // Make this work with either add or edit menu items |
28 | | - const selector = `${addConditionalBreakpoint},${editConditionalBreakpoint}`; |
29 | | - |
30 | | - rightClickElement(dbg, "breakpointItem", index); |
31 | | - selectContextMenuItem(dbg, selector); |
32 | | - await waitForElement(dbg, "conditionalPanelInput"); |
33 | | - await assertConditionalBreakpointIsFocused(dbg); |
34 | | - |
35 | | - // Position cursor reliably at the end of the text. |
36 | | - pressKey(dbg, "End"); |
37 | | - type(dbg, condition); |
38 | | - pressKey(dbg, "Enter"); |
| 27 | + let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); |
| 28 | + rightClickEl(dbg, bpMarkers[index]); |
| 29 | + selectContextMenuItem(dbg, selectors.addConditionItem); |
| 30 | + await typeInPanel(dbg, condition); |
| 31 | + await waitForCondition(dbg, condition); |
| 32 | + |
| 33 | + bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); |
| 34 | + assertClass(bpMarkers[index], "has-condition"); |
39 | 35 | } |
40 | 36 |
|
41 | | -function removeBreakpointViaContext(dbg, index) { |
42 | | - rightClickElement(dbg, "breakpointItem", index); |
43 | | - selectContextMenuItem(dbg, "#node-menu-delete-self"); |
44 | | -} |
| 37 | +async function setLogPoint(dbg, index, expression) { |
| 38 | + let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); |
| 39 | + rightClickEl(dbg, bpMarkers[index]); |
45 | 40 |
|
46 | | -// Test enabling and disabling a breakpoint using the check boxes |
47 | | -add_task(async function() { |
48 | | - const dbg = await initDebugger("doc-scripts.html", "simple1"); |
49 | | - await pushPref("devtools.debugger.features.column-breakpoints", false); |
| 41 | + selectContextMenuItem(dbg, selectors.addLogItem); |
| 42 | + await typeInPanel(dbg, expression); |
| 43 | + await waitForLog(dbg, expression); |
50 | 44 |
|
51 | | - if(!Services.prefs.getBoolPref("devtools.debugger.features.column-breakpoints")) { |
52 | | - ok(true, "This test only applies when column breakpoints are on"); |
53 | | - return; |
54 | | - } |
| 45 | + bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); |
| 46 | + assertClass(bpMarkers[index], "has-log"); |
| 47 | +} |
55 | 48 |
|
56 | | - await selectSource(dbg, "simple1"); |
| 49 | +async function disableBreakpoint(dbg, index) { |
| 50 | + rightClickElement(dbg, "columnBreakpoints"); |
| 51 | + selectContextMenuItem(dbg, selectors.disableItem); |
57 | 52 |
|
58 | | - // Scroll down to desired line so that column breakpoints render |
59 | | - getCM(dbg).setCursor({ line: 15, ch: 0 }); |
| 53 | + await waitForState(dbg, state => { |
| 54 | + const bp = dbg.selectors.getBreakpointsList(state)[index]; |
| 55 | + return bp.disabled; |
| 56 | + }); |
60 | 57 |
|
61 | | - // Create a breakpoint at 15:undefined |
62 | | - await addBreakpoint(dbg, "simple1", 15); |
| 58 | + const bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); |
| 59 | + assertClass(bpMarkers[0], "disabled"); |
| 60 | +} |
63 | 61 |
|
64 | | - // Wait for column breakpoint markers |
65 | | - await waitForElementWithSelector(dbg, ".column-breakpoint"); |
| 62 | +async function removeFirstBreakpoint(dbg) { |
| 63 | + let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); |
66 | 64 |
|
67 | | - let columnBreakpointMarkers = getColumnBreakpointElements(dbg); |
68 | | - ok( |
69 | | - columnBreakpointMarkers.length === 2, |
70 | | - "2 column breakpoint markers display" |
71 | | - ); |
| 65 | + bpMarkers[0].click(); |
| 66 | + bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); |
| 67 | + assertClass(bpMarkers[0], "active", false); |
| 68 | +} |
72 | 69 |
|
73 | | - // Create a breakpoint at 15:8 |
74 | | - columnBreakpointMarkers[0].click(); |
| 70 | +async function removeAllBreakpoints(dbg, line, count) { |
| 71 | + clickGutter(dbg, 32); |
| 72 | + await waitForBreakpointCount(dbg, 0); |
75 | 73 |
|
76 | | - // Create a breakpoint at 15:28 |
77 | | - columnBreakpointMarkers[1].click(); |
| 74 | + ok(findAllElements(dbg, "columnBreakpoints").length == 0); |
| 75 | +} |
78 | 76 |
|
79 | | - // Wait for breakpoints in right panel to render |
80 | | - await waitForState(dbg, state => { |
81 | | - return dbg.win.document.querySelectorAll(".breakpoints-list .breakpoint").length === 3; |
82 | | - }) |
| 77 | +add_task(async function() { |
| 78 | + const dbg = await initDebugger("doc-scripts.html", "simple1"); |
| 79 | + await selectSource(dbg, "long"); |
83 | 80 |
|
84 | | - // Scroll down in secondary pane so element we want to right-click is showing |
85 | | - dbg.win.document.querySelector(".secondary-panes").scrollTop = 100; |
| 81 | + info("1. Add a column breakpoint on line 32"); |
| 82 | + await enableFirstBreakpoint(dbg); |
86 | 83 |
|
87 | | - // Set a condition at 15:8 |
88 | | - await setConditionalBreakpoint(dbg, 4, "Eight"); |
| 84 | + info("2. Click on the second breakpoint on line 32"); |
| 85 | + await enableSecondBreakpoint(dbg); |
89 | 86 |
|
90 | | - // Ensure column breakpoint is yellow |
91 | | - await waitForElementWithSelector(dbg, ".column-breakpoint.has-condition"); |
| 87 | + info("3. Add a condition to the first breakpoint"); |
| 88 | + await setConditionalBreakpoint(dbg, 0, "foo"); |
92 | 89 |
|
93 | | - // Remove the breakpoint from 15:undefined via the secondary pane context menu |
94 | | - removeBreakpointViaContext(dbg, 3); |
| 90 | + info("4. Add a log to the first breakpoint"); |
| 91 | + await setLogPoint(dbg, 0, "bar"); |
95 | 92 |
|
96 | | - // Ensure that there's still a marker on line 15 |
97 | | - await waitForState(dbg, state => dbg.selectors.getBreakpointCount(state) == 2); |
98 | | - await waitForElementWithSelector(dbg, ".column-breakpoint.has-condition"); |
99 | | - columnBreakpointMarkers = getColumnBreakpointElements(dbg); |
100 | | - ok(hasCondition(columnBreakpointMarkers[0]), "First column breakpoint has conditional style"); |
| 93 | + info("5. Disable the first breakpoint"); |
| 94 | + await disableBreakpoint(dbg, 0); |
101 | 95 |
|
102 | | - // Remove the breakpoint from 15:8 |
103 | | - removeBreakpointViaContext(dbg, 3); |
| 96 | + info("6. Remove the first breakpoint"); |
| 97 | + await removeFirstBreakpoint(dbg); |
104 | 98 |
|
105 | | - // Ensure there's still a marker and it has no condition |
106 | | - await waitForState(dbg, state => dbg.selectors.getBreakpointCount(state) == 1); |
107 | | - await waitForElementWithSelector(dbg, ".column-breakpoint"); |
| 99 | + info("7. Add a condition to the second breakpoint"); |
| 100 | + await setConditionalBreakpoint(dbg, 1, "foo2"); |
108 | 101 |
|
109 | | - // Ensure the first column breakpoint has no conditional style |
110 | | - await waitFor(() => !hasCondition(getColumnBreakpointElements(dbg)[0])); |
| 102 | + info("8. test removing the breakpoints by clicking in the gutter"); |
| 103 | + await removeAllBreakpoints(dbg, 32, 0); |
111 | 104 | }); |
0 commit comments