browser_dbg-breakpoints-debugger-statement.js (3278B)
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 // Test enabling and disabling a debugger statement using editor context menu 6 7 "use strict"; 8 9 add_task(async function () { 10 const dbg = await initDebugger("doc-pause-points.html", "pause-points.js"); 11 await selectSource(dbg, "pause-points.js"); 12 await waitForSelectedSource(dbg, "pause-points.js"); 13 14 info("Disable the first debugger statement on line 12 by gutter menu"); 15 rightClickElement(dbg, "gutterElement", 12); 16 await waitForContextMenu(dbg); 17 selectContextMenuItem( 18 dbg, 19 selectors.breakpointContextMenu.disableDbgStatement 20 ); 21 await waitForCondition(dbg, "false"); 22 23 let bp = findBreakpoint(dbg, "pause-points.js", 12); 24 is( 25 bp.options.condition, 26 "false", 27 "The debugger statement has a conditional breakpoint with 'false' as statement" 28 ); 29 30 info("Enable the previously disabled debugger statement by gutter menu"); 31 rightClickElement(dbg, "gutterElement", 12); 32 await waitForContextMenu(dbg); 33 selectContextMenuItem( 34 dbg, 35 selectors.breakpointContextMenu.enableDbgStatement 36 ); 37 await waitForBreakpointWithoutCondition(dbg, "pause-points.js", 12, 0); 38 39 bp = findBreakpoint(dbg, "pause-points.js", 12); 40 is(bp.options.condition, null, "The conditional statement is removed"); 41 42 info("Enable the breakpoint for the second debugger statement on line 12"); 43 let bpElements = await waitForAllElements(dbg, "columnBreakpoints"); 44 Assert.strictEqual(bpElements.length, 2, "2 column breakpoints"); 45 assertClass(bpElements[0], "active"); 46 assertClass(bpElements[1], "active", false); 47 48 bpElements[1].click(); 49 await waitForBreakpointCount(dbg, 2); 50 bpElements = findAllElements(dbg, "columnBreakpoints"); 51 assertClass(bpElements[1], "active"); 52 53 info("Disable the second debugger statement by breakpoint menu"); 54 rightClickEl(dbg, bpElements[1]); 55 await waitForContextMenu(dbg); 56 selectContextMenuItem( 57 dbg, 58 selectors.breakpointContextMenu.disableDbgStatement 59 ); 60 await waitForCondition(dbg, "false"); 61 62 bp = findBreakpoints(dbg, "pause-points.js", 12)[1]; 63 is( 64 bp.options.condition, 65 "false", 66 "The second debugger statement has a conditional breakpoint with 'false' as statement" 67 ); 68 69 info("Enable the second debugger statement by breakpoint menu"); 70 bpElements = findAllElements(dbg, "columnBreakpoints"); 71 assertClass(bpElements[1], "has-condition"); 72 rightClickEl(dbg, bpElements[1]); 73 await waitForContextMenu(dbg); 74 selectContextMenuItem( 75 dbg, 76 selectors.breakpointContextMenu.enableDbgStatement 77 ); 78 await waitForBreakpointWithoutCondition(dbg, "pause-points.js", 12, 1); 79 80 bp = findBreakpoints(dbg, "pause-points.js", 12)[1]; 81 is(bp.options.condition, null, "The conditional statement is removed"); 82 }); 83 84 function waitForBreakpointWithoutCondition(dbg, url, line, index) { 85 return waitForState(dbg, () => { 86 const bp = findBreakpoints(dbg, url, line)[index]; 87 return bp && !bp.options.condition; 88 }); 89 } 90 91 function findBreakpoints(dbg, url, line) { 92 const source = findSource(dbg, url); 93 return dbg.selectors.getBreakpointsForSource(source, line); 94 }