Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: step into eval when pauseForSourceMap is true does not pause on next available line #1692

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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