-
Notifications
You must be signed in to change notification settings - Fork 30k
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
util: freeze kEnumerableProperty
#43390
util: freeze kEnumerableProperty
#43390
Conversation
assert.strictEqual( | ||
Object.isExtensible(kEnumerableProperty), | ||
false | ||
); | ||
assert.strictEqual( | ||
Object.isSealed(kEnumerableProperty), | ||
true | ||
); | ||
assert.strictEqual( | ||
Object.isFrozen(kEnumerableProperty), | ||
true | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really seem like something we need to care in our tests (in no credible scenario will anyone tries to check what's the value of Object.isSealed(kEnumerableProperty)
in core, and if there was a way to make sure the object always behaves as we want it to that doesn't involve freezing it, that'd be fine too), the consequences are what's really important to test imo:
assert.strictEqual( | |
Object.isExtensible(kEnumerableProperty), | |
false | |
); | |
assert.strictEqual( | |
Object.isSealed(kEnumerableProperty), | |
true | |
); | |
assert.strictEqual( | |
Object.isFrozen(kEnumerableProperty), | |
true | |
); | |
assert.throws( | |
() => { kEnumerableProperty.configurable = false; }, | |
TypeError | |
); | |
assert.throws( | |
() => Object.assign(kEnumerableProperty, { configurable: false }), | |
TypeError | |
); | |
assert.throws( | |
() => Object.assign(kEnumerableProperty, { enumerable: false }), | |
TypeError | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually agreed. :)
My concern here is that by assuming alternatives to freezing and possibility of something dangerous (e.g. if there will be unavoidable exposing reference to kEnumerableProperty
for userland) we must keep in mind every single way to break it.
If that approach will become common in core, we'll have to create an exhaustive isImmutable()
helper function instead.
This comment was marked as duplicate.
This comment was marked as duplicate.
174856c
to
7a84b9b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
PR-URL: nodejs#43390 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
7a84b9b
to
0f90879
Compare
Landed in 0f90879 |
PR-URL: #43390 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #43390 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #43390 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs/node#43390 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Refs: #43159 (comment)