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

Should the Window named properties object return supported named properties in [[OwnPropertyKeys]]? #9068

Closed
delan opened this issue Mar 23, 2023 · 4 comments
Labels
clarification Standard could be clearer

Comments

@delan
Copy link
Contributor

delan commented Mar 23, 2023

Given data:text/html,<iframe name=123> with Reflect.ownKeys(window.__proto__.__proto__)

  • Gecko returns ["123", Symbol(Symbol.toStringTag)]
  • Blink returns [Symbol(Symbol.toStringTag)]
  • WebKit returns [Symbol(Symbol.toStringTag)]

This seems to be why Firefox fails the [[OwnPropertyKeys]] subtest of /webidl/ecmascript-binding/window-named-properties-object.html, but I can’t figure out what the correct behaviour is according to the spec. This is how far I got:

Have I missed something? Does this mean both Gecko and Blink and WebKit are correct?

(cc @domenic, on behalf of servo/servo#29396)

@domenic
Copy link
Member

domenic commented Mar 23, 2023

web-platform-tests/wpt#36746 was recently opened and seems related.

  • but for other platform objects the behaviour of [[OwnPropertyKeys]] is undefined?

No, just the order. The behavior is given by the ordinary non-exotic [[OwnPropertyKeys]], for which ES262 says is "in ascending chronological order of property creation". So the quoted part of Web IDL is saying that the exact order in which properties are created for platform objects is not defined.

I guess this is somewhat of a lie, because https://webidl.spec.whatwg.org/#interface-prototype-object step 11-12 has a sort of order: attributes, operations, iteration methods, async iteration methods, constants. But within those categories ordering is not defined. And this ordering is unintentional and wasn't thought through. whatwg/webidl#432 is the canonical issue for discussing this.

Have I missed something? Does this mean both Gecko and Blink and WebKit are correct?

No. Blink and WebKit are correct. The named properties object uses OrdinaryOwnPropertyKeys, which iterates over the property keys of the object. But there are no property keys of the named properties object; instead it has custom behavior in its [[GetOwnProperty]] handler. web-platform-tests/wpt#36746 discusses this in detail.

@delan
Copy link
Contributor Author

delan commented Mar 23, 2023

Thanks! Do you think it would be helpful if I added a note clarifying that named properties objects don’t have any real properties, so its ordinary [[OwnPropertyKeys]] won’t return any supported named properties, and a note clarifying that Window’s named properties use the rules for named properties objects rather than legacy platform objects?

@domenic
Copy link
Member

domenic commented Mar 24, 2023

I added a note clarifying that named properties objects don’t have any real properties, so its ordinary [[OwnPropertyKeys]] won’t return any supported named properties,

Yes, I think that'd definitely be helpful.

a note clarifying that Window’s named properties use the rules for named properties objects rather than legacy platform objects?

Yeah, adding something like that around https://html.spec.whatwg.org/multipage/nav-history-apis.html#named-access-on-the-window-object would make sense to me.

@delan
Copy link
Contributor Author

delan commented Mar 28, 2023

Done in #9080 and whatwg/webidl#1285 :)

domenic pushed a commit to whatwg/webidl that referenced this issue Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer
Development

No branches or pull requests

2 participants