Uh oh!
There was an error while loading. Please reload this page.
util: freeze kEnumerableProperty - #43390
Conversation
nodejs-github-bot
commented
Jun 12, 2022
There was a problem hiding this comment.
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.
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.
nodejs-github-bot
commented
Jun 12, 2022
LiviaMedeiros
commented
Jun 13, 2022
This comment was marked as duplicate.
This comment was marked as duplicate.
174856c to
7a84b9bCompare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
nodejs-github-bot
commented
Jun 15, 2022
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
0f90879CompareLiviaMedeiros
commented
Jun 15, 2022
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)