diff --git a/src/env-inl.h b/src/env-inl.h index aff12e57bf2418..51605eb335d732 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -875,9 +875,7 @@ inline void Environment::SetMethod(v8::Local that, v8::Local context = isolate()->GetCurrentContext(); v8::Local function = NewFunctionTemplate(callback, v8::Local(), - // TODO(TimothyGu): Investigate if SetMethod is ever - // used for constructors. - v8::ConstructorBehavior::kAllow, + v8::ConstructorBehavior::kThrow, v8::SideEffectType::kHasSideEffect) ->GetFunction(context) .ToLocalChecked(); @@ -895,9 +893,7 @@ inline void Environment::SetMethodNoSideEffect(v8::Local that, v8::Local context = isolate()->GetCurrentContext(); v8::Local function = NewFunctionTemplate(callback, v8::Local(), - // TODO(TimothyGu): Investigate if SetMethod is ever - // used for constructors. - v8::ConstructorBehavior::kAllow, + v8::ConstructorBehavior::kThrow, v8::SideEffectType::kHasNoSideEffect) ->GetFunction(context) .ToLocalChecked(); diff --git a/test/parallel/test-process-chdir.js b/test/parallel/test-process-chdir.js index e66d366fb7874f..005e17fac25a90 100644 --- a/test/parallel/test-process-chdir.js +++ b/test/parallel/test-process-chdir.js @@ -42,3 +42,8 @@ const err = { }; common.expectsError(function() { process.chdir({}); }, err); common.expectsError(function() { process.chdir(); }, err); + +// Check that our built-in methods do not have a prototype/constructor behaviour +// if they don't need to. This could be tested for any of our C++ methods. +assert.strictEqual(process.cwd.prototype, undefined); +assert.throws(() => new process.cwd(), TypeError);