Skip to content

Commit

Permalink
fix: step into eval when pauseForSourceMap is true does not pause…
Browse files Browse the repository at this point in the history
… on next available line (#1692)

Fixes #1665
  • Loading branch information
connor4312 authored May 3, 2023
1 parent 2c2f2d8 commit adb9887
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/adapter/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ export class Thread implements IVariableStoreLocationProvider {
event.data.__rewriteAs = 'breakpoint';
}

const expectedPauseReason = this._expectedPauseReason;
if (scriptId && (await this._handleSourceMapPause(scriptId, location))) {
// Pause if we just resolved a breakpoint that's on this
// location; this won't have existed before now.
Expand All @@ -853,14 +854,15 @@ export class Thread implements IVariableStoreLocationProvider {
)
) {
// Check if there are any user-defined breakpoints on this line
} else if (
this._expectedPauseReason?.reason === 'step' &&
this._expectedPauseReason.direction === StepDirection.Over
) {
// Check if we're in the middle of a step over, e.g. stepping over a
} else if (expectedPauseReason?.reason === 'step') {
// Check if we're in the middle of a step, e.g. stepping over a
// function compilation. Stepping in should still remain paused,
// and an instrumentation pause in step out should not be possible.
return this._cdp.Debugger.stepOut({});
if (expectedPauseReason.direction === StepDirection.In) {
// no-op
} else {
return this._cdp.Debugger.stepOut({});
}
} else {
// If none of this above, it's pure instrumentation.
return this.resume();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Evaluating#1: test()
{
allThreadsStopped : false
description : Paused on debugger statement
reason : pause
threadId : <number>
}
test @ <eval>/VM<xx>:4:13
<anonymous> @ eval1.js:1:1
{
allThreadsStopped : false
description : Paused
reason : step
threadId : <number>
}
test @ <eval>/VM<xx>:5:13
<anonymous> @ eval1.js:1:1
{
allThreadsStopped : false
description : Paused
reason : step
threadId : <number>
}
<anonymous> @ foo.js:2:15
test @ <eval>/VM<xx>:5:15
<anonymous> @ eval1.js:1:1
36 changes: 36 additions & 0 deletions src/test/breakpoints/breakpointsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,42 @@ describe('breakpoints', () => {
},
);

itIntegrates(
'does not interrupt stepIn with instrumentation breakpoint (#1665)',
async ({ r }) => {
const p = await r.launchAndLoad(`
<script>
function test() {
debugger;
f=eval(\`
(function (a, b) {
c = a + b;
return c;
});
//# sourceURL=foo.js
//# sourceMappingURL=foo.js.map
\`);
f(1, 2);
}
</script>`);

const evaluate = p.evaluate('test()');

const a = p.log(await p.dap.once('stopped')); // debugger statement
await p.logger.logStackTrace(a.threadId);
await p.dap.stepIn({ threadId: a.threadId });

const b = p.log(await p.dap.once('stopped')); // f=eval(...
await p.logger.logStackTrace(b.threadId);
await p.dap.stepIn({ threadId: b.threadId });

await waitForPause(p); // should now be on (function (a, b)

await evaluate;
p.assertLog();
},
);

itIntegrates('deals with removed execution contexts (#1582)', async ({ r }) => {
const p = await r.launchUrlAndLoad('iframe-1582/index.html');

Expand Down

0 comments on commit adb9887

Please sign in to comment.