Closed Bug 1007334 Opened 10 years ago Closed 10 years ago

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

Categories

(Core :: JavaScript: Standard Library, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: efaust, Assigned: efaust)

References

Details

(Keywords: compat, dev-doc-complete)

Attachments

(1 file)

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: 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?
> 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
https://hg.mozilla.org/mozilla-central/rev/cdb97e86cc74
https://hg.mozilla.org/mozilla-central/rev/799a2838ed86
https://hg.mozilla.org/mozilla-central/rev/74fd773a5319
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
Depends on: 1038427
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.

Attachment

General

Created:
Updated:
Size: