(WindowClient / Clients.openWindow)
(ServiceWorkerRegistration in SW scope)
This intent to ship exposes several new methods,interfaces and
- Addition of the WindowClient interface. It reflects some properties of
the Client like visibilityState, focused and frameType;
- Ability for a ServiceWorker to focus() a WindowClient;
- Ability for a ServiceWorker to openWindow();
- Expose ServiceWorkerRegistration in the ServiceWorkerGlobalScope.
All these capabilities are meant to support use cases for Notifications;
when a notification is clicked, a ServiceWorker might want to check
which pages are opened, focus() it if one is opened but not focused or
create a new one if none.
ServiceWorkerRegistration allows APIs that are hooked to the
registration object to be usable from a ServiceWorker (like Push or
Focusing or opening a window from a ServiceWorker can be confusing or
even a security threat with regards to opening new windows. In order to
mitigate this concerns the following restrictions will apply to focus()
- these methods can only be called in a notification click handler;
- only one call (either focus() or openWindow()) will be allowed per
- event.waitUntil() will allow to delay the call in case some data needs
to be fetched;
- there is a 10 second limit between the time the event was sent and the
time one can call focus()/openWindow();
- openWindow() must be same-origin (it can open an uncontrolled window
Is this feature supported on all six Blink platforms (Windows, Mac,
Linux, Chrome OS, Android, and Android WebView)?
- WebView: ServiceWorkerRegistration should have the same level as
support as usual SW features. openWindow() and focus() should not work
(see the Notifications intent to ship). Generally speaking ServiceWorker
is not fully supported on WebView;
- Android: peter@ is finishing the implementation there;
- Everything else: Yes
Demo link (requires top of tree and experimental flag):
- very basic page demoing only those features on top of Notifications:
- fully featured website with Push/Notifications using these features:
Usual ServiceWorker debug tools should be enough to debug this feature
(chrome://inspect and chrome://serviceworker-internals).
In addition, if focus() or openWindow() are rejected, an error message
explains the reason why it happened.
+ Jake Archibald (Google) worked closely with Anne van Kesteren
(Mozilla) on the spec changes.
+ There have been a few iterations and there is a general agreement on
the additions we are making.
+ There are test harness tests for all those features.
- First to ship;
- For openWindow() and focus() these tests will have to be run as manual
tests by other vendors because they use our own test tools (no other
- openWindow() can't open cross origins windows even if allowed by the
spec, we will work to loosen this restriction.
OWP launch tracking bug:
Link to entry on the feature dashboard:
Service Worker generic entry:
Thanks to michaeln@, jochen@, mkwst@, dominicc@, creis@ for the reviews.
Thanks to jsbell@ for doing a first prototype of openWindow(). Thanks to
peter@ for doing the window opening implementation on Android. Thanks to
jakearchibald@ for his amazing spec work and support.