From 037d9085f1d1ed996dc8f4958b4e7f5e53a6fa39 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 29 Sep 2017 23:35:43 +0200 Subject: [PATCH] src: use more appropriate context-entered check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the context check in `MakeCallback` match what the comment says (and what actually makes sense). PR-URL: https://github.com/nodejs/node/pull/15691 Fixes: https://github.com/nodejs/node/issues/15672 Ref: https://github.com/nodejs/node/pull/15428 Ref: f27b5e4bdaafc73a830a0451ee3c641b8bcd08fe Reviewed-By: Refael Ackermann Reviewed-By: Ben Noordhuis Reviewed-By: Eugene Ostroukhov Reviewed-By: James M Snell Reviewed-By: Timothy Gu Reviewed-By: Tobias Nießen --- src/node.cc | 2 +- test/inspector/test-scriptparsed-context.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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); }