ES6 Proxies: There's no such thing as [[GetOwnPropertyNames]]

RESOLVED FIXED in mozilla33

Status

()

defect
RESOLVED FIXED
5 years ago
3 years ago

People

(Reporter: efaust, Assigned: efaust)

Tracking

({compat, dev-doc-complete})

unspecified
mozilla33
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Assignee

Description

5 years ago
The ES6 spec demands that Object.getOwnPropertyNames calls [[OwnPropertyKeys]] and then does some work on it. Currently, we have a getOwnPropertyNames trap, which will erroneously call a method on the handler with that name.
Assignee

Comment 1

5 years ago
Assignee: nobody → efaustbmo
Status: NEW → ASSIGNED
Attachment #8421202 - Flags: review?(jorendorff)
Comment on attachment 8421202 [details] [diff] [review]
Clean up the GetOwnPropertyNames/Keys situation for scripted proxies

Review of attachment 8421202 [details] [diff] [review]:
-----------------------------------------------------------------

Great!

Besides these tests, at least browser/extensions/shumway/content/shumway.js also needs to be changed. (Ask till if he wants to keep the old method around too, for compatibility with older Firefoxen.)

Definitely add a test checking that the getOwnPropertyDescriptor trap is called for each property during Object.keys().

::: js/src/jsproxy.cpp
@@ +1076,5 @@
>                       MutableHandleValue vp) MOZ_OVERRIDE;
>      virtual bool set(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id,
>                       bool strict, MutableHandleValue vp) MOZ_OVERRIDE;
> +    // Kick keys out to getOwnPropertyName and then filter. [[GetOwnProperty]] could potentially
> +    // change the enumerability of the target's properties.

getOwnPropertyName is missing its s in the first sentence.

In the second sentence, mentioning changing enumerability is making it more abstruse than it really is. The question is which traps are called when you do Object.keys(proxy): standard behavior that scripts can trivially observe.

I'd write:

    // The DirectProxyHandler implementation of keys() is observably different from
    // what the spec requires (see tests/ecma_6/Proxy/blahblah.js), so use the base
    // class implementation (call getOwnPropertyNames and then filter).

@@ +1663,5 @@
>      return true;
>  }
>  
> +// This is secretly [[OwnPropertyKeys]]. SM uses the old wiki name, internally.
> +// ES6 (5 April 2014) Proxy.[[OwnPropertyKeys]](O)

Follow-up bug. Let's rename everywhere.
Attachment #8421202 - Flags: review?(jorendorff) → review+
Can this land?
Assignee

Comment 4

5 years ago
> Can this land?

https://hg.mozilla.org/integration/mozilla-inbound/rev/cdb97e86cc74

> Follow-up bug. Let's rename everywhere.

I didn't file it, but it's filed as bug 1026918

Comment 6

5 years ago
If this bug is only about the renaming of "getOwnPropertyNames" and "keys" traps to "ownKeys", then I declare dev-doc-complete.
Thanks Yoric, evilpie and jorendorff!
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy$compare?to=641711&from=632073
(diff is hard to read, but at least it shows the 2 revisions between which the related changes happened)
Depends on: 1273235
You need to log in before you can comment on or make changes to this bug.