browser_dbg-breakpoints-columns.js (4622B)
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 "use strict"; 6 7 add_task(async function () { 8 const dbg = await initDebugger("doc-scripts.html", "simple1.js"); 9 await selectSource(dbg, "long.js"); 10 11 info("1. Add a column breakpoint on line 32"); 12 await enableFirstBreakpoint(dbg); 13 14 info("2. Click on the second breakpoint on line 32"); 15 await enableSecondBreakpoint(dbg); 16 17 info("3. Disable second breakpoint using shift-click"); 18 await shiftClickDisable(dbg); 19 20 info("4. Re-enable second breakpoint using shift-click"); 21 await shiftClickEnable(dbg); 22 23 info("5. Add a condition to the first breakpoint"); 24 await setConditionalBreakpointFromColumnMarker(dbg, 0, "foo"); 25 26 info("6. Add a log to the first breakpoint"); 27 await setLogPointFromColumnMarker(dbg, 0, "bar"); 28 29 info("7. Disable the first breakpoint"); 30 await disableBreakpoint(dbg, 0); 31 32 info("8. Remove the first breakpoint"); 33 await removeFirstBreakpoint(dbg); 34 35 info("9. Add a condition to the second breakpoint"); 36 await setConditionalBreakpointFromColumnMarker(dbg, 1, "foo2"); 37 38 info("10. Test removing the breakpoints by clicking in the gutter"); 39 await clickGutter(dbg, 32); 40 await waitForBreakpointCount(dbg, 0); 41 42 ok(!findAllElements(dbg, "columnBreakpoints").length); 43 }); 44 45 async function enableFirstBreakpoint(dbg) { 46 await addBreakpoint(dbg, "long.js", 32); 47 const bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 48 49 Assert.strictEqual(bpMarkers.length, 2, "2 column breakpoints"); 50 assertClass(bpMarkers[0], "active"); 51 assertClass(bpMarkers[1], "active", false); 52 } 53 54 async function enableSecondBreakpoint(dbg) { 55 let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 56 57 bpMarkers[1].click(); 58 await waitForBreakpointCount(dbg, 2); 59 60 bpMarkers = findAllElements(dbg, "columnBreakpoints"); 61 assertClass(bpMarkers[1], "active"); 62 await waitForAllElements(dbg, "breakpointItems", 2); 63 } 64 65 // disable active column bp with shift-click. 66 async function shiftClickDisable(dbg) { 67 let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 68 shiftClickElement(dbg, "columnBreakpoints"); 69 bpMarkers = findAllElements(dbg, "columnBreakpoints"); 70 assertClass(bpMarkers[0], "disabled"); 71 } 72 73 // re-enable disabled column bp with shift-click. 74 async function shiftClickEnable(dbg) { 75 let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 76 shiftClickElement(dbg, "columnBreakpoints"); 77 bpMarkers = findAllElements(dbg, "columnBreakpoints"); 78 assertClass(bpMarkers[0], "active"); 79 } 80 81 async function setConditionalBreakpointFromColumnMarker(dbg, index, condition) { 82 // Wait a bit for CM6 to complete any updates so the conditional panel 83 // does not lose focus after it has been opened 84 await waitForDocumentLoadComplete(dbg); 85 let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 86 rightClickEl(dbg, bpMarkers[index]); 87 await waitForContextMenu(dbg); 88 selectContextMenuItem(dbg, selectors.addConditionItem); 89 await typeInPanel(dbg, condition); 90 await waitForCondition(dbg, condition); 91 92 bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 93 assertClass(bpMarkers[index], "has-condition"); 94 } 95 96 async function setLogPointFromColumnMarker(dbg, index, expression) { 97 // Wait a bit for CM6 to complete any updates so the conditional panel 98 // does not lose focus after it has been opened 99 await waitForDocumentLoadComplete(dbg); 100 let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 101 rightClickEl(dbg, bpMarkers[index]); 102 await waitForContextMenu(dbg); 103 104 selectContextMenuItem(dbg, selectors.addLogItem); 105 await typeInPanel(dbg, expression); 106 await waitForLog(dbg, expression); 107 108 bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 109 assertClass(bpMarkers[index], "has-log"); 110 } 111 112 async function disableBreakpoint(dbg, index) { 113 rightClickElement(dbg, "columnBreakpoints"); 114 await waitForContextMenu(dbg); 115 selectContextMenuItem(dbg, selectors.disableItem); 116 117 await waitForState(dbg, () => { 118 const bp = dbg.selectors.getBreakpointsList()[index]; 119 return bp.disabled; 120 }); 121 122 const bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 123 assertClass(bpMarkers[0], "disabled"); 124 } 125 126 async function removeFirstBreakpoint(dbg) { 127 let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 128 129 bpMarkers[0].click(); 130 bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 131 assertClass(bpMarkers[0], "active", false); 132 }