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 navigator.productSub/vendor/vendorSub be exposed to workers? #216

Closed
foolip opened this issue Sep 30, 2015 · 19 comments
Closed

Should navigator.productSub/vendor/vendorSub be exposed to workers? #216

foolip opened this issue Sep 30, 2015 · 19 comments
Assignees

Comments

@foolip
Copy link
Member

foolip commented Sep 30, 2015

Updating Blink to the recent NavigatorID changes, it makes productSub, vendor and vendorSub exposed on Worker where it previously was not. I've tested with this script:

['appCodeName',
 'appName',
 'appVersion',
 'platform',
 'product',
 'productSub',
 'userAgent',
 'vendor',
 'vendorSub'].forEach(function(attr) {
     console.log(attr + ': ' + (attr in navigator ? 'exposed' : 'NOT exposed'));
 });

Blink (Opera) and Gecko (Firefox) both agree that productSub/vendor/vendorSub are not exposed on workers.

Should we limit these to Window in the spec as well, or just go ahead and expose them?

CC @bzbarsky

@bzbarsky
Copy link
Contributor

I'm all in favor of not exposing this legacy cruft in workers....

@foolip
Copy link
Member Author

foolip commented Sep 30, 2015

I have tested Edge. All of the tested attributes are exposed on Window, as expected, but all except appCodeName are exposed on Worker :(

@annevk
Copy link
Member

annevk commented Sep 30, 2015

@travisleithead can you fix that?

@travisleithead
Copy link
Member

Internal Edge bug filed (reference: VSO4790009). Thanks for the tip!

@foolip
Copy link
Member Author

foolip commented Oct 1, 2015

@travisleithead, any thoughts on what to do with productSub, vendor and vendorSub?

The one thing that bugs me is that it's going to look entirely arbitrary which attributes are exposed and not. It's pretty likely that more of this legacy cruft could be hidden from workers, but the effort to measure that hardly seems worth it.

@domenic
Copy link
Member

domenic commented Oct 1, 2015

@foolip it seems clear that we should not expose those three in workers? If Blink and Gecko agree and Edge is interested in aligning, then why not split them off?

@foolip
Copy link
Member Author

foolip commented Oct 1, 2015

I've now also tested in Safari and it exposes appName, appVersion, platform, and userAgent, but does not expose appCodeName, product, productSub, vendor and vendorSub.

Adding all of this up, it seems pretty likely that it's web-compatible not not expose appCodeName, product, productSub, vendor and vendorSub to workers, so how about trying that and changing only if it turns out that one of them is in fact needed?

@domenic
Copy link
Member

domenic commented Oct 1, 2015

SGTM

@domenic
Copy link
Member

domenic commented Oct 1, 2015

Someone should write web-platform-tests for this too :)

foolip added a commit that referenced this issue Oct 1, 2015
The set of attributes with [Exposed=Window] is the union of attributes
NOT exposed on Worker in shipping browsers:

Blink: productSub, vendor, vendorSub
Edge: appCodeName
Gecko: productSub, vendor, vendorSub
WebKit: appCodeName, product, productSub, vendor, vendorSub

Fixes #216
foolip added a commit that referenced this issue Oct 1, 2015
The set of attributes without [Exposed=(Window,Worker)] is the
union of attributes NOT exposed on Worker in shipping browsers:

Blink: productSub, vendor, vendorSub
Edge: appCodeName
Gecko: productSub, vendor, vendorSub
WebKit: appCodeName, product, productSub, vendor, vendorSub

Fixes #216
@foolip
Copy link
Member Author

foolip commented Oct 2, 2015

Oops, bad news. It's invalid per WebIDL to use [Exposed=Window] on a NavigatorID member, because WorkerNavigator has only [Exposed=Worker] and implements NavigatorID. The exposure set of a member must be a subset of the interface it's on.

This ought to be a problem for taintEnabled() as well.

Ideas?

@domenic
Copy link
Member

domenic commented Oct 2, 2015

It would presumably work to split things up into a few different mixin interfaces, right?

@annevk
Copy link
Member

annevk commented Oct 2, 2015

Merge Navigator and WorkerNavigator? Although I guess that might be incompatible as well because WorkerNavigator would no longer exist. Failing that, put the Window-only stuff on its own mixin.

@bzbarsky
Copy link
Contributor

bzbarsky commented Oct 2, 2015

Why is that invalid?

There are three interfaces here: Navigator, WorkerNavigator, and NavigatorID. These are exposed on Window, Worker, and (Window, Worker) respectively. The relevant spec statements here are:

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.

This is satisfied for members of NavigatorID that have [Exposed=Window], since the exposure set of NavigatorID includes Window.

An interface's exposure set MUST be a subset of the exposure set of all of the interface's consequential interfaces.

This is satisfied for both Navigator and WorkerNavigator.

So what is the problem exactly?

But yes, simply using two mixins would also work, and would be robust even in the face of changes to IDL that attempt to make the "mixin being mixed into interfaces with different exposure sets contains things that would only be exposed in one of them" pattern illegal. Then again, I believe the current spec is explicitly written to allow that pattern.

@Ms2ger
Copy link
Member

Ms2ger commented Oct 2, 2015

Inlining the Window-only members in the definition of Navigator seems simplest, or partial if we want to hide them.

@foolip
Copy link
Member Author

foolip commented Oct 3, 2015

@bzbarsky, I didn't check what the WebIDL spec says before writing, I just got an error from Blink's IDL compiler and assumed it was right about this.

I don't have the error in front of me, but I think Blink's IDL compiler treats the [Exposed=Window] attribute as a member of WorkerNavigator, and then this rule from the spec doesn't hold:

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.

How is this supposed to work with A implements B? It would be pretty strange if A is [Exposed=Window] but all of B's members are [Exposed=Worker], but maybe this is just nonsensical and not invalid?

@bzbarsky
Copy link
Contributor

bzbarsky commented Oct 4, 2015

How is this supposed to work with A implements B?

Like I said in #216 (comment): The check is done against the interface the member is actually defined on, which is NavigatorID.

but maybe this is just nonsensical and not invalid?

That is the situation right now, yes.

I do think that the simplest thing to do in this situation is to put the non-shared stuff on Navigator directly or a partial interface Navigator as @Ms2ger suggests. The point of mixins is that you want to mix them into multiple things, so if we only want this property in one place we should just put it there.

@foolip
Copy link
Member Author

foolip commented Oct 4, 2015

Thanks, reopening so that I remember to fix this somehow.

@foolip foolip reopened this Oct 4, 2015
@foolip foolip self-assigned this Oct 4, 2015
@annevk
Copy link
Member

annevk commented Oct 5, 2015

Putting them directly on Navigator seems fine, but it also sounds like what we have now is fine, no?

@foolip
Copy link
Member Author

foolip commented Oct 5, 2015

Yeah, if this is valid per Web IDL I guess we could keep it the way it is. Closing again, but if anyone thinks it's too confusing like this or wants to lobby for Web IDL to make it invalid, just say the word.

@foolip foolip closed this as completed Oct 5, 2015
foolip added a commit that referenced this issue Oct 6, 2016
Tests: web-platform-tests/wpt#3881

Attempting to write tests for the current spec revealed that product was
already exposed in all engines, and appCodeName in all but Edge.

This leaves productSub, vendor and vendorSub restricted, where there is
a 2/2 split between engines.

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

No branches or pull requests

6 participants