This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
The behavior of interface members with no explicit annotation is: the interface member – or a partial interface definition the interface member was declared on – was not declared with an [Exposed] extended attribute, and the ECMAScript global object implements the primary global interface. That means that if some interface is exposed in workers, all its members _also_ need to be annotated with [Exposed=Workers] (or be in a partial interface thus annotated). It would make more sense to me to make exposure be true by default for interface members, so you only need to annotate the ones that shouldn't be exposed somewhere, no?
I agree with Boris here, I think the current prose results in a weird behavior.
Also, note that we disallow [Exposed] on both a partial interface and one of its members, but do allow it on both an interface and one of its members. That seems fine to me, for what it's worth; it means we can expose an interface on both Window and Worker but restrict some of the members to one or the other, while for partial interfaces that sort of thing is not needed because we can just use separate partials for different [Exposed] values.
https://github.com/heycam/webidl/pull/12
Also, it probably makes no sense to support this: [Exposed=Worker] interface Foo { [Exposed=Window] void method(); }; in that the [Exposed] on interface members should be a subset of the [Exposed] of the interface itself, I believe. Similarly for: [Exposed=Worker] interface Foo {}; [Exposed=Window] partial interface Foo { void method(); };
Also, how should this stuff interact with "implements"? See NavigatorOnLine.
My preference for this would be that [Exposed] on an interface applies to the interface, that everything on an interface that isn't annotated with its own [Exposed] is always visible on that interface, and that the UA additionally adds any "implements" and "partial" interfaces that are themselves Exposed appropriately. So: [Exposed=A,B] interface Foo { void f1(); }; Foo implements Bar; [Exposed=A] partial interface Foo { void F2(); }; [Exposed=B] partial interface Foo { void F3(); }; [Exposed=A] interface Bar { void f4(); }; ...would result in an interface Foo in contexts A and B but not C, and in A it would have f1, f2, and f4, while in B it would have f2 and f3.
The simplest way to describe that is probably as follows: 1) Every interface member has a set of globals where it's exposed. If it has an [Exposed] extended attribute this is the set specified in that extended attribute. Otherwise, if the interface or partial interface it was originally defined on has an [Exposed] extended attribute it is the set specified in that extended attribute. Otherwise, this set is { "Window" } (though I think ms2ger would prefer to nix this defaulting behavior and just make it an error to not have [Exposed] on an interface). 2) Every interface that is not [NoInterfaceObject] has a set of globals where it its interface object is a property of the global. This is given by the [Exposed] extended attribute on the interface, or { "Window" } if there is no such extended attribute. 3) Optionally, make it an error to have a member of an interface, or one of its consequential interfaces, that is exposed in a global the interface itself is not exposed in.
That all sounds good. How does this look? https://github.com/heycam/webidl/commit/71a44ff9e1dcb1f467656f71b78f77abbf9427bf http://heycam.github.io/webidl/#Exposed The name "exposure set" sounds a bit silly but oh well.
"exposure set" seems fine. The new setup looks great with two caveats: 1) This bit: If [Exposed] appears on both an interface and one of its interface members, then the interface member's exposure set MUST be a subset of the interface's exposure set. should not require [Exposed] to appear on the interface itself. In other words, this: interface Foo { [Exposed=Worker] void method(); }; should be invalid. 2) Would it makes sense to require that if A inherits from B then the exposure set of A is a subset of the one for B? This is not covered by the consequential interfaces bit, since B is not a consequential interface of A.
This should be fixed in https://github.com/heycam/webidl/pull/433/commits/8900c39