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

Test that WindowProxy's [[Set]] fails early for OOB indices #29377

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shvaikalesh
Copy link
Member

window[2] = 2;
assert_false(window.hasOwnProperty(2));
Object.defineProperty(EventTarget.prototype, 42, { set: t.unreached_func("EventTarget.prototype[42] setter should be unreachable!") });
assert_false(Reflect.set(window, 42, "foo"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a particular reason to use Reflect.set here?

Copy link
Member Author

Choose a reason for hiding this comment

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

In sloppy mode, there is no way to test return value of [[Set]] being false except using Reflect.set.
Chrome returns true instead of false.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use a normal set here, and put the Reflect check in a separate test() below?

@domenic
Copy link
Member

domenic commented Jun 15, 2021

Hmm maybe I shouldn't have merged the spec PR so quickly. You claim that all browsers have the behavior, but https://wpt.fyi/results/html/browsers/the-window-object/window-indexed-properties.html?diff&filter=ADC&run_id=5103827915112448&run_id=5652311210721280 shows that Chrome does not?

@shvaikalesh
Copy link
Member Author

shvaikalesh commented Jun 15, 2021

@domenic Chrome fails newly added test for the same reason it fails the existing "Borderline numeric key: 2 ** 32 - 2 is an index" one: Reflect.set doesn't return correct status of false; so the failure is unrelated.

@domenic
Copy link
Member

domenic commented Jun 15, 2021

I mean, if Reflect.set doesn't return false, then how do you know it failed to set?

@shvaikalesh
Copy link
Member Author

Since window's prototype chain is immutable, and its [[GetOwnProperty]] is non-ordinary, there is not much we can do beyond asserting that prototype's setter is unreachable (which is true).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants