diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js new file mode 100644 index 0000000000..99d0dde458 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js @@ -0,0 +1,158 @@ +/* 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/>. */ + +"use strict"; + +// Tests for stepping through Babel's compile output. +requestLongerTimeout(4); + +add_task(async function () { + const dbg = await initDebugger("doc-sourcemapped.html"); + + await testStepOverForOf(dbg); + await testStepOverForOfArray(dbg); + await testStepOveForOfClosure(dbg); + await testStepOverForOfArrayClosure(dbg); + await testStepOverFunctionParams(dbg); + await testStepOverRegeneratorAwait(dbg); +}); + +async function breakpointSteps(dbg, target, fixture, { line, column }, steps) { + const filename = `${target}://./${fixture}/input.`; + const fnName = `${target}-${fixture}`.replace(/-([a-z])/g, (s, c) => + c.toUpperCase() + ); + + await invokeWithBreakpoint( + dbg, + fnName, + filename, + { line, column }, + async source => { + await runSteps(dbg, source, steps); + } + ); + + ok(true, `Ran tests for ${fixture} at line ${line} column ${column}`); +} + +async function runSteps(dbg, source, steps) { + for (const [i, [type, position]] of steps.entries()) { + info(`Step ${i}`); + switch (type) { + case "stepOver": + await stepOver(dbg); + break; + case "stepIn": + await stepIn(dbg); + break; + default: + throw new Error("Unknown stepping type"); + } + + assertPausedAtSourceAndLine(dbg, source.id, position.line, position.column); + } +} + +function testStepOverForOf(dbg) { + return breakpointSteps( + dbg, + "webpack3-babel6", + "step-over-for-of", + { line: 4, column: 2 }, + [ + ["stepOver", { line: 6, column: 20 }], + ["stepOver", { line: 6, column: 2 }], + ["stepOver", { line: 7, column: 4 }], + ["stepOver", { line: 6, column: 2 }], + ["stepOver", { line: 7, column: 4 }], + ["stepOver", { line: 6, column: 2 }], + ["stepOver", { line: 10, column: 2 }], + ] + ); +} + +// This codifies the current behavior, but stepping twice over the for +// header isn't ideal. +function testStepOverForOfArray(dbg) { + return breakpointSteps( + dbg, + "webpack3-babel6", + "step-over-for-of-array", + { line: 3, column: 2 }, + [ + ["stepOver", { line: 5, column: 2 }], + ["stepOver", { line: 5, column: 13 }], + ["stepOver", { line: 6, column: 4 }], + ["stepOver", { line: 5, column: 2 }], + ["stepOver", { line: 5, column: 13 }], + ["stepOver", { line: 6, column: 4 }], + ["stepOver", { line: 5, column: 2 }], + ["stepOver", { line: 9, column: 2 }], + ] + ); +} + +// The closure means it isn't actually possible to step into the for body, +// and Babel doesn't map the _loop() call, so we step past it automatically. +function testStepOveForOfClosure(dbg) { + return breakpointSteps( + dbg, + "webpack3-babel6", + "step-over-for-of-closure", + { line: 6, column: 2 }, + [ + ["stepOver", { line: 8, column: 20 }], + ["stepOver", { line: 8, column: 2 }], + ["stepOver", { line: 12, column: 2 }], + ] + ); +} + +// Same as the previous, not possible to step into the body. The less +// complicated array logic makes it possible to step into the header at least, +// but this does end up double-visiting the for head. +function testStepOverForOfArrayClosure(dbg) { + return breakpointSteps( + dbg, + "webpack3-babel6", + "step-over-for-of-array-closure", + { line: 3, column: 2 }, + [ + ["stepOver", { line: 5, column: 2 }], + ["stepOver", { line: 5, column: 13 }], + ["stepOver", { line: 5, column: 2 }], + ["stepOver", { line: 5, column: 13 }], + ["stepOver", { line: 5, column: 2 }], + ["stepOver", { line: 9, column: 2 }], + ] + ); +} + +function testStepOverFunctionParams(dbg) { + return breakpointSteps( + dbg, + "webpack3-babel6", + "step-over-function-params", + { line: 6, column: 2 }, + [ + ["stepOver", { line: 7, column: 2 }], + ["stepIn", { line: 2, column: 2 }], + ] + ); +} + +function testStepOverRegeneratorAwait(dbg) { + return breakpointSteps( + dbg, + "webpack3-babel6", + "step-over-regenerator-await", + { line: 2, column: 2 }, + [ + // Won't work until a fix to regenerator lands and we rebuild. + // https://github.com/facebook/regenerator/issues/342 + // ["stepOver", { line: 4, column: 2 }], + ] + ); +} |