diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/client/debugger/test/mochitest/browser_dbg-old-breakpoint.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-old-breakpoint.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg-old-breakpoint.js | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-old-breakpoint.js b/devtools/client/debugger/test/mochitest/browser_dbg-old-breakpoint.js new file mode 100644 index 0000000000..850c8ad964 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-old-breakpoint.js @@ -0,0 +1,98 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ + +// Test that we show a breakpoint in the UI when there is an old pending +// breakpoint with an invalid original location. +add_task(async function() { + clearDebuggerPreferences(); + + const pending = { + bp1: { + location: { + sourceId: "", + sourceUrl: EXAMPLE_URL + "nowhere2.js", + line: 5, + column: 0 + }, + generatedLocation: { + sourceUrl: EXAMPLE_URL + "simple1.js", + line: 4, + column: 0 + }, + options: {}, + disabled: false + }, + bp2: { + location: { + sourceId: "", + sourceUrl: EXAMPLE_URL + "nowhere.js", + line: 5, + column: 0 + }, + generatedLocation: { + sourceUrl: EXAMPLE_URL + "simple3.js", + line: 2, + column: 0 + }, + options: {}, + disabled: false + }, + }; + asyncStorage.setItem("debugger.pending-breakpoints", pending); + + const toolbox = await openNewTabAndToolbox(EXAMPLE_URL + "doc-scripts.html", "jsdebugger"); + const dbg = createDebuggerContext(toolbox); + const onBreakpoint = waitForDispatch(dbg, "SET_BREAKPOINT", 2); + + // Pending breakpoints are installed asynchronously, keep invoking the entry + // function until the debugger pauses. + await waitUntil(() => { + invokeInTab("main"); + return isPaused(dbg); + }); + await onBreakpoint; + + ok(true, "paused at unmapped breakpoint"); + await waitForState(dbg, state => dbg.selectors.getBreakpointCount(state) == 2); + ok(true, "unmapped breakpoints shown in UI"); +}); + +// Test that if we show a breakpoint with an old generated location, it is +// removed after we load the original source and find the new generated +// location. +add_task(async function() { + clearDebuggerPreferences(); + + const pending = { + bp1: { + location: { + sourceId: "", + sourceUrl: "webpack:///entry.js", + line: 15, + column: 0 + }, + generatedLocation: { + sourceUrl: EXAMPLE_URL + "sourcemaps/bundle.js", + line: 47, + column: 16 + }, + astLocation: {}, + options: {}, + disabled: false + }, + }; + asyncStorage.setItem("debugger.pending-breakpoints", pending); + + const toolbox = await openNewTabAndToolbox(EXAMPLE_URL + "doc-sourcemaps.html", "jsdebugger"); + const dbg = createDebuggerContext(toolbox); + + await waitForState(dbg, state => { + const bps = dbg.selectors.getBreakpointsList(state); + return bps.length == 1 + && bps[0].location.sourceUrl.includes("entry.js") + && bps[0].location.line == 15; + }); + ok(true, "removed old breakpoint during sync"); + await waitForRequestsToSettle(dbg); +}); |