Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix legacy platform object [[Set]] operation #218

Merged

Conversation

ExE-Boss
Copy link
Contributor

@ExE-Boss ExE-Boss commented May 1, 2020

This fixes the legacy platform object [[Set]] operation implementation to match the WebIDL spec, which doesn’t exclude array index properties from named properties when indexed setters aren't supported.


It also fixes the bug that was caused by the receiver argument in a Proxy trap pointing to the Proxy exotic object or an object that inherits from it, rather than to the underlying Proxy target.

This can be verified with:

(new Proxy({}, { get(target,_,receiver) { console.log(target === receiver); } })).foo;

Which logs false.


review?(@domenic)

@domenic
Copy link
Member

domenic commented May 1, 2020

What does this impact? Can we add a web platform test for it?

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented May 9, 2020

It causes the webstorage/set.window.js test to fail with 4 failures in the last test.


The first two failures are caused by the bug assuming that the Proxy trap receiver argument may be equal to the target.

The other two failures are because WebIDL doesn't exclude array index properties from named properties when an object doesn't support indexed properties, which WebIDL2JS does anyway.

@ExE-Boss ExE-Boss changed the title In a ProxyHandler, target !== receiver Fix legacy platform object [[Set]] operation May 9, 2020
@ExE-Boss ExE-Boss force-pushed the fix/interface/proxy-target-receiver branch from 3166d58 to 5f2692d Compare May 9, 2020 18:52
Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I believe this is a relatively recent change in heycam/webidl#059491b4.

lib/constructs/interface.js Show resolved Hide resolved
@ExE-Boss
Copy link
Contributor Author

@TimothyGu The # symbol refers to an in issue, to refer to a commit, you have to use the whatwg/webidl@059491b syntax.

Also, array index properties weren’t excluded before whatwg/webidl@059491b either.

@ExE-Boss ExE-Boss requested a review from TimothyGu May 10, 2020 19:21
The "side effect" part never seemed to be necessary, while
whatwg/webidl@059491b4de91fdc45d26d simplified the conditions further.
@TimothyGu TimothyGu force-pushed the fix/interface/proxy-target-receiver branch from 818d3a3 to 2e4b6c1 Compare May 13, 2020 19:32
@TimothyGu TimothyGu merged commit ed3e991 into jsdom:master May 13, 2020
@ExE-Boss ExE-Boss deleted the fix/interface/proxy-target-receiver branch May 14, 2020 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants