-
Notifications
You must be signed in to change notification settings - Fork 158
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
Named properties object / named property visibility algorithm with property on Window.prototype #607
Comments
Well yes, but the operations you're using here invoke [[Get]], no? And [[Get]] invokes OrdinaryGet which goes over a chain as browsers do. |
Yeah, to invoke [[GetOwnProperty]] you'd need to use |
Testcase that actually exercises [[GetOwnProperty]]: http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=6506 Looks to me like Safari and Firefox are following the spec here. Chrome is not: it returns a property descriptor from |
Ah, @Ms2ger clarified that he's talking about this case, specifically:
Per spec, those lookups should not find the element, because https://heycam.github.io/webidl/#named-properties-object-getownproperty step 2 does the visibility check on the window, not on the named properties object itself, finds the property on Window.prototype, and then says the named property object has no property named "foo". As @Ms2ger points out, no browsers do that. What's really at stake here is making sure that the named properties object doesn't shadow anything higher on the prototype chain, so that's what Firefox checks: that there is no such property on the prototype chain of the named properties object. Window.prototype is not on said proto chain, but also can't be shadowed by the named properties object, so doesn't have to be checked. I suspect we could take out step 2 there and remove the check for a "named properties object" in https://heycam.github.io/webidl/#dfn-named-property-visibility step 5.1 and things would be just fine web compat wise, and the behavior simpler/saner. |
When there's a property on
Window.prototype
, the named property visibility algorithm called onwindow
will return false in step 5.1, when prototype isWindow.prototype
. This implies that [[GetOwnProperty]] on the named properties object will fall back to callingOrdinaryGetOwnProperty(O, P)
, which returns undefined.However, the browsers I tested consistently return the result of the named getter.
Consider the following code:
This logs the same in Firefox, Chrome dev and Epiphany:
(Edit: ignore the results below; Chrome is doing something weirder and I didn't notice because I failed to actually include the span.)
The text was updated successfully, but these errors were encountered: