consider exposing self.clients on window and other worker globals
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 3.6k
- Forks
- 324
- Avg merge
- 14d 22h
- Merged PRs (30d)
- 1
Description
The Clients and Client interfaces are pretty close to being a generic API for querying and manipulating windows/workers in the browser. Its nicer than things like window.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 and Client interfaces on windows and other worker globals. Perhaps as navigator.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.- The behavior of
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing Clients and Client interfaces and the service-worker-specific behavior described in the issue. Compare navigator.clients exposure, Clients.claim(), Client.postMessage(), and clients.matchAll() across window and worker globals. Done means the supported globals, event targets, control rules, and secure-context restrictions are specified.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100