Object.getOwnPropertyNames does not correctly call Proxy's getOwnPropertyNames

RESOLVED INVALID

Status

()

RESOLVED INVALID
5 years ago
5 years ago

People

(Reporter: nathan, Unassigned, NeedInfo)

Tracking

Trunk
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 years ago
Note the below test in the shell.

js> var thing = new Proxy({}, { getOwnPropertyNames: function(target) { return ["An Entry"]; }});                
js> Object.getOwnPropertyNames(thing)                                                                        
[]

For some reason Object.getOwnPropertyNames does not correctly call the Proxy's version of getOwnPropertyNames. This did used to work, Fx30 does correctly handle this.
Flags: needinfo?(efaustbmo)
Nathan, thank you for the bug report.

Per current spec, there is no "getOwnPropertNames" trap on proxies.  If you look at the definition of Object.getOwnPropertyNames at http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.getownpropertynames it calls http://people.mozilla.org/~jorendorff/es6-draft.html#sec-getownpropertykeys which calls [[OwnPropertyKeys]].

This is defined for proxies at http://people.mozilla.org/~jorendorff/es6-draft.html#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys and calls the "ownKeys" trap on the proxy handler.

See bug 1007334 where the change to the current spec behavior was made.
Blocks: 1007334
No longer blocks: 937855
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Flags: needinfo?(efaustbmo)
Resolution: --- → INVALID
(Reporter)

Comment 2

5 years ago
(In reply to Boris Zbarsky [:bz] from comment #1)
> Nathan, thank you for the bug report.
> 
> Per current spec, there is no "getOwnPropertNames" trap on proxies.  If you
> look at the definition of Object.getOwnPropertyNames at
> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.
> getownpropertynames it calls
> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-getownpropertykeys
> which calls [[OwnPropertyKeys]].
> 
> This is defined for proxies at
> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-proxy-object-
> internal-methods-and-internal-slots-ownpropertykeys and calls the "ownKeys"
> trap on the proxy handler.
> 
> See bug 1007334 where the change to the current spec behavior was made.

Ahhh, I see. I had gone off of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
which hasn't been updated with the new change. Is there a way to flag it or something?
I did mark bug 1007334 as dev-doc-needed, but yeah, we should update the devmo documentation...
Flags: needinfo?(efaustbmo)
You need to log in before you can comment on or make changes to this bug.