browser_dbg-breaking.js (2267B)
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 // Tests the breakpoints are hit in various situations. 8 9 add_task(async function () { 10 const dbg = await initDebugger("doc-scripts.html"); 11 const { 12 selectors: { getSelectedSource }, 13 } = dbg; 14 15 await selectSource(dbg, "doc-scripts.html"); 16 17 // Make sure we can set a top-level breakpoint and it will be hit on 18 // reload. 19 await addBreakpoint(dbg, "doc-scripts.html", 21); 20 21 const onReloaded = reload(dbg, "doc-scripts.html"); 22 23 await waitForPaused(dbg); 24 25 let whyPaused = await waitFor( 26 () => dbg.win.document.querySelector(".why-paused")?.innerText 27 ); 28 is(whyPaused, "Paused on breakpoint\n(global) - doc-scripts.html:21:6"); 29 30 await assertPausedAtSourceAndLine( 31 dbg, 32 findSource(dbg, "doc-scripts.html").id, 33 21 34 ); 35 await resume(dbg); 36 info("Wait for reload to complete after resume"); 37 await onReloaded; 38 39 info("Create an eval script that pauses itself."); 40 invokeInTab("doEval"); 41 await waitForPaused(dbg); 42 const source = getSelectedSource(); 43 ok(!source.url, "It is an eval source"); 44 await assertPausedAtSourceAndLine(dbg, source.id, 2); 45 46 whyPaused = await waitFor( 47 () => dbg.win.document.querySelector(".why-paused")?.innerText 48 ); 49 is(whyPaused, "Paused on debugger statement\n:2:8"); 50 51 await resume(dbg); 52 53 await addBreakpoint(dbg, source, 5); 54 invokeInTab("evaledFunc"); 55 await waitForPaused(dbg); 56 await assertPausedAtSourceAndLine(dbg, source.id, 5); 57 58 await resume(dbg); 59 60 info("Check that we pause in workers"); 61 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => { 62 const blob = new content.Blob( 63 [ 64 `onmessage = function(request) { 65 // Keep the bigint declaration here, this covers Bug 1956197 66 const bigint64 = new BigInt64Array([1n, 2n]); 67 debugger; 68 }`, 69 ], 70 { type: "text/javascript" } 71 ); 72 const url = content.URL.createObjectURL(blob); 73 const worker = new content.Worker(url); 74 worker.postMessage("break in debugger"); 75 }); 76 await waitForPaused(dbg); 77 await resume(dbg); 78 });