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

Merge WorkerLocation/WorkerNavigator into Location/Navigator? #6390

Open
foolip opened this issue Feb 15, 2021 · 3 comments
Open

Merge WorkerLocation/WorkerNavigator into Location/Navigator? #6390

foolip opened this issue Feb 15, 2021 · 3 comments
Labels
impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation normative change

Comments

@foolip
Copy link
Member

foolip commented Feb 15, 2021

WorkerLocation and WorkerNavigator presumably predate the use of Exposed in Web IDL. Merging Navigator and WorkerNavigator was briefly discussed in #216.

The resulting Web IDL would be something like this:

[Exposed=(Window,Worker)]
interface Navigator {
  [Exposed=Window] readonly attribute boolean cookieEnabled;
  readonly attribute DOMString userAgent;
};

[Exposed=Window] is already used on some of the mixins that are included in both Navigator and WorkerNavigator, such as https://html.spec.whatwg.org/multipage/system-state.html#navigatorid.

However, doing so is not without risk because code could access self.WorkerNavigator.prototype, or perhaps even depend on self.Navigator not being exposed as a way to detect workers. I did some quick searching in httparchive for "WorkerLocation" and "WorkerNavigator" and got few enough matches that maybe it would be fine.

I'm not sure it's worth the effort to make this change, but am filing the issue since I can't find any existing issue about just this.

@annevk
Copy link
Member

annevk commented Feb 15, 2021

I'm supportive for Navigator as that never made a lot of sense to me, but WorkerLocation is quite distinct (e.g., readonly members).

@domenic
Copy link
Member

domenic commented Feb 15, 2021

This would require a lot of specs which add to Navigator to start using Exposed.

@foolip
Copy link
Member Author

foolip commented Feb 15, 2021

@annevk, oops, I only looked closely at WorkerNavigator and didn't notice that Location and WorkerLocation are so different:
https://html.spec.whatwg.org/multipage/history.html#the-location-interface
https://html.spec.whatwg.org/multipage/workers.html#worker-locations

It looks like the origin attribute is the only thing that has no differences that matter to web developers, but still [LegacyUnforgeable] is only for Location.

@domenic, very good point, I count 30 specs using "partial interface Navigator" in https://github.com/w3c/webref and some more for "Navigator includes". Plenty of specs seem to extend both Navigator and WorkerNavigator, but somewhat to my surprise I didn't spot anything very broken indicating a misunderstanding of Navigator exposure.

I don't think it's possible to make these changes without being in a broken state during the transition, but the best case would be something like:

  • Redundantly add [Exposed=Window] to everything now extending only Navigator
  • Merge WorkerNavigator into Navigator in HTML
  • Merge any WorkerNavigator reference in any other spec

Or one prepares all the PRs and merges them in whatever order maintainers are responsive, and have things even more broken during the transition.

But before doing any of this, one would have to have high confidence that it will be web compatible to remove self.WorkerNavigator and add self.Navigator in workers, since a revert would be even messier.

If WorkerLocation is here forever, then my suggestions doesn't look so great anymore :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation normative change
Development

No branches or pull requests

3 participants