browser_dbg-pretty-print-breakpoints-delete.js (3349B)
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 // Tests that breakpoints in pretty printed files 6 // are properly removed when the user deletes them on either the generated or original files. 7 8 "use strict"; 9 10 add_task(async function () { 11 info( 12 "Test removing the breakpoint from the minified file (generated source) works" 13 ); 14 15 const dbg = await initDebugger("doc-pretty.html", "pretty.js"); 16 17 await selectSource(dbg, "pretty.js"); 18 19 await togglePrettyPrint(dbg); 20 21 await addBreakpointToPrettyPrintedFile(dbg); 22 23 info( 24 `Go back to the minimized source, so it is not automatically reopened on reload` 25 ); 26 await togglePrettyPrint(dbg); 27 28 info( 29 "Assert that a equivalent breakpoint was set in pretty.js (generated source)" 30 ); 31 await assertBreakpoint(dbg, 4); 32 33 info(`Remove the breakpoint from pretty.js (generated source)`); 34 await clickGutter(dbg, 4); 35 36 await waitForBreakpointCount(dbg, 0); 37 38 await reloadAndCheckNoBreakpointExists(dbg); 39 }); 40 41 add_task(async function () { 42 info( 43 "Test removing the breakpoint from the pretty printed (original source) works" 44 ); 45 46 const dbg = await initDebugger("doc-pretty.html", "pretty.js"); 47 48 await selectSource(dbg, "pretty.js"); 49 50 await togglePrettyPrint(dbg); 51 52 await addBreakpointToPrettyPrintedFile(dbg); 53 54 info("Check that breakpoint gets added to pretty.js (generated source)"); 55 await togglePrettyPrint(dbg); 56 await assertBreakpoint(dbg, 4); 57 58 info("Switch back to the pretty printed version"); 59 await togglePrettyPrint(dbg); 60 61 info(`Remove the breakpoint from pretty.js:formatted (original source)`); 62 await clickGutter(dbg, 5); 63 64 await waitForBreakpointCount(dbg, 0); 65 66 info( 67 `Close the pretty-printed source, so it is not automatically reopened on reload` 68 ); 69 await closeTab(dbg, "pretty.js:formatted"); 70 71 await reloadAndCheckNoBreakpointExists(dbg); 72 }); 73 74 async function addBreakpointToPrettyPrintedFile(dbg) { 75 // This breakpoint would be set before the debugger statement 76 // and should be hit first. 77 info("Add breakpoint to pretty.js:formatted (original source)"); 78 await addBreakpoint(dbg, "pretty.js:formatted", 5); 79 await waitForBreakpointCount(dbg, 1); 80 } 81 82 async function reloadAndCheckNoBreakpointExists(dbg) { 83 info("Reload and pretty print pretty.js"); 84 await reload(dbg, "pretty.js"); 85 await selectSource(dbg, "pretty.js"); 86 await togglePrettyPrint(dbg); 87 88 info("Check that we do not pause on the removed breakpoint"); 89 invokeInTab("stuff"); 90 await waitForPaused(dbg); 91 92 const sourcePretty = findSource(dbg, "pretty.js:formatted"); 93 info( 94 "Assert pause at the debugger statement in pretty.js:formatted (original source) and not the removed breakpoint" 95 ); 96 await assertPausedAtSourceAndLine(dbg, sourcePretty.id, 8); 97 98 await togglePrettyPrint(dbg); 99 const source = findSource(dbg, "pretty.js"); 100 101 info( 102 "Assert pause at the debugger statement in pretty.js (generated source) and not the removed breakpoint" 103 ); 104 await assertPausedAtSourceAndLine(dbg, source.id, 6); 105 106 info(`Confirm that pretty.js:formatted does not have any breakpoints`); 107 is(dbg.selectors.getBreakpointCount(), 0, "Breakpoints should be cleared"); 108 109 await resume(dbg); 110 }