-
Notifications
You must be signed in to change notification settings - Fork 313
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
consider exposing self.clients on window and other worker globals #955
Comments
I like this idea, and wish we'd done it in the first place. Just need to work out the API details. |
I see the reason but it would be at weird because |
Do you mean |
@wanderview Yes, I meant |
In regards to this item, perhaps we could make the message event fire at |
A better solution is to fire two separate events |
I don't disagree, but why's it better? |
Is this in reference to firing two message events instead of "bubbling" the event? This came out of talking with @smaug---- and @bzbarsky about it. They suggested it was a safer way to spec it since it prevents an event listener on one target from blocking a listener on the other from getting it. Firing separate message events for each target is just more predictable. |
The
Clients
andClient
interfaces are pretty close to being a generic API for querying and manipulating windows/workers in the browser. Its nicer than things likewindow.open()
though because its designed to be async and is less permissive in what the caller can do.I think we should consider exposing
Clients
andClient
interfaces on windows and other worker globals. Perhaps asnavigator.clients
to avoid name collisions.To do this we would need to specialize the interface for service workers a bit, though:
Clients.claim()
does not make sense outside of a service worker global.Client.postMessage()
currently goes tonavigator.serviceWorker.onmessage
. This would need to still happen for service worker globals. When used from other globals we would need to fire the event at a different target. Perhapsnavigator.clients.onmessage
.clients.matchAll()
only returning controlled Client objects only makes sense for service worker globals. Other globals should probably implyincludeUncontrolled:true
.All same-origin restrictions would still apply. I assume we would only support this in secure contexts.
If we think we might want to do this it would be nice to do it sooner rather than later. Over time we will probably have more service worker specific features creep into the API.
The text was updated successfully, but these errors were encountered: