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

@shvaikalesh shvaikalesh commented Jun 15, 2021

Ref. whatwg/html#6767.

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

@Ms2ger Ms2ger Jun 15, 2021

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

Copy link
Member Author

@shvaikalesh shvaikalesh Jun 15, 2021

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

@Ms2ger Ms2ger Jun 16, 2021

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

@domenic
Copy link
Member

@domenic 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 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 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

@shvaikalesh shvaikalesh commented Jun 15, 2021

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
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants