endo
endo copied to clipboard
test: Replace misleading test
arguments objects don't have a special prototype
Ref 5c41bdc0628d69a83a1c9378e986573444f2bb1d
I was aiming at showing this particular kind of hack is prevented by lockdown, because it's not obvious to everyone what the prototype of arguments is.
Perhaps it would be instructive to capture an assertion that the arguments prototype is in fact null. It is frozen by virtue of Object.isFrozen(null) === true.
On Fri, Aug 19, 2022 at 1:56 AM Zbyszek Tenerowicz @.***> wrote:
@.**** approved this pull request.
— Reply to this email directly, view it on GitHub https://github.com/endojs/endo/pull/1258#pullrequestreview-1078507098, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOXBVKKPSLXMGXNOXH3PLVZ5D3JANCNFSM566MC5VA . You are receiving this because you commented.Message ID: @.***>
The prototype isn't null, it's Object.prototype.
Pardon, as it were!
On Fri, Aug 19, 2022 at 6:51 PM Richard Gibson @.***> wrote:
The prototype isn't null, it's Object.prototype.
— Reply to this email directly, view it on GitHub https://github.com/endojs/endo/pull/1258#issuecomment-1221204040, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOXBW5NAKS3QQJE4O2PKDV2A22TANCNFSM566MC5VA . You are receiving this because you commented.Message ID: @.***>
^ I'd say that adds grounds to my claim that we need to demonstrate arguments.proto is frozen regardless of what you think it is.
What's special about arguments objects? %Object.prototype% is used as the prototype for many other built-in objects as well:
- Property descriptors from Reflect.getOwnPropertyDescriptor and Object.getOwnPropertyDescriptor{,s} (and also the object from Object.getOwnPropertyDescriptor that contains the property descriptors).
- Iteration result objects from every built-in iterator, including userland generators.
- Promise settlement objects from Promise.allSettled.
- Revocable proxy objects (i.e.,
assert(Object.getPrototypeOf(Proxy.revocable({}, {})) === Object.prototype)). - Destructure-rest objects (i.e.,
{ ...rest } = {}; assert(Object.getPrototypeOf(rest) === Object.prototype)). - The prototype of function/class prototypes (i.e.,
assert(Object.getPrototypeOf(Object.getPrototypeOf(new class {})) === Object.prototype)). - etc.
The only thing that's special is the number of people knowing JS very well that were unsure what's the prototype of arguments. I have this occasional itch to document surprising stuff with tests if not too time consuming. But I'm not orthodox about it ;)