diff --git a/src/node.cc b/src/node.cc index 9883a5c5248..31aa7a50fe3 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1383,7 +1383,7 @@ InternalCallbackScope::InternalCallbackScope(Environment* env, HandleScope handle_scope(env->isolate()); // If you hit this assertion, you forgot to enter the v8::Context first. - CHECK_EQ(env->context(), env->isolate()->GetCurrentContext()); + CHECK_EQ(Environment::GetCurrent(env->isolate()), env); if (env->using_domains() && !object_.IsEmpty()) { DomainEnter(env, object_); diff --git a/test/inspector/test-scriptparsed-context.js b/test/inspector/test-scriptparsed-context.js index 6e89f05dc63..149173b7af5 100644 --- a/test/inspector/test-scriptparsed-context.js +++ b/test/inspector/test-scriptparsed-context.js @@ -37,6 +37,8 @@ const script = ` vm.runInNewContext('Array', {}); debugger; + + vm.runInNewContext('debugger', {}); `; async function getContext(session) { @@ -92,6 +94,12 @@ async function runTests() { await checkScriptContext(session, thirdContext); await session.waitForBreakOnLine(33, '[eval]'); + console.error('[test]', 'vm.runInNewContext can contain debugger statements'); + await session.send({ 'method': 'Debugger.resume' }); + const fourthContext = await getContext(session); + await checkScriptContext(session, fourthContext); + await session.waitForBreakOnLine(0, 'evalmachine.'); + await session.runToCompletion(); assert.strictEqual(0, (await instance.expectShutdown()).exitCode); }