Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 2 additions & 6 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,7 @@ inline void Environment::SetMethod(v8::Local<v8::Object> that,
v8::Local<v8::Context> context = isolate()->GetCurrentContext();
v8::Local<v8::Function> function =
NewFunctionTemplate(callback, v8::Local<v8::Signature>(),
// TODO(TimothyGu): Investigate if SetMethod is ever
// used for constructors.
v8::ConstructorBehavior::kAllow,
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasSideEffect)
->GetFunction(context)
.ToLocalChecked();
Expand All @@ -895,9 +893,7 @@ inline void Environment::SetMethodNoSideEffect(v8::Local<v8::Object> that,
v8::Local<v8::Context> context = isolate()->GetCurrentContext();
v8::Local<v8::Function> function =
NewFunctionTemplate(callback, v8::Local<v8::Signature>(),
// TODO(TimothyGu): Investigate if SetMethod is ever
// used for constructors.
v8::ConstructorBehavior::kAllow,
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasNoSideEffect)
->GetFunction(context)
.ToLocalChecked();
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-process-chdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be tested for any of our C++ methods.

Maybe it doesn't matter, but the one picked here means this isn't tested in Worker threads.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I’d say it doesn’t matter – these things are pretty independent, and I’ve chosen something that is likely to stay a directly C++-backed method for a long time. I’m happy to take other suggestions, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this conflicted with #27224 😄

assert.strictEqual(process.cwd.prototype, undefined);
assert.throws(() => new process.cwd(), /not a constructor/);
// Make sure that the above checks verify the right thing, i.e. that we're
// actually looking at a directly exposed C++ binding method.
assert.strictEqual(process.cwd.toString(), 'function cwd() { [native code] }');