Intent to Ship: ServiceWorker's WindowClient interface / Clients.openWindow() / ServiceWorkerRegistration in SW scope

79 views
Skip to first unread message

Mounir Lamouri

unread,
Feb 6, 2015, 11:55:25 AM2/6/15
to blin...@chromium.org, Kenji Baheux, nhi...@chromium.org
Contact emails:
- mlam...@chromium.org (WindowClient / Clients.openWindow)
- nhi...@chromium.org (ServiceWorkerRegistration in SW scope)
- kenji...@chromium.org (PM)

Spec:
https://slightlyoff.github.io/ServiceWorker/spec/service_worker/

Summary:
This intent to ship exposes several new methods,interfaces and
properties:
- 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
Notifications).

Annoyance/Security considerations:
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()
and openWindow()
- these methods can only be called in a notification click handler;
- only one call (either focus() or openWindow()) will be allowed per
notification click;
- 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
though).

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:
https://mounirlamouri.github.io/sandbox/sw-open-focus-window/test.html
- fully featured website with Push/Notifications using these features:
https://johnme-gcm.appspot.com/chat/

Debuggability:
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.

Compatibility Risk:;
+ 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
way).
- openWindow() can't open cross origins windows even if allowed by the
spec, we will work to loosen this restriction.

OWP launch tracking bug:
https://crbug.com/446843

Link to entry on the feature dashboard:
Service Worker generic entry:
https://www.chromestatus.com/feature/6561526227927040

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.

-- Mounir

Kenji Baheux

unread,
Feb 6, 2015, 1:25:47 PM2/6/15
to blin...@chromium.org, kenji...@chromium.org, nhi...@chromium.org
Sorry everyone for the mis-communication, here is the intent to ship we intended to send (has a few extra details and positioned as an enabler for Push and Notifications with links to the relevant intents).

I should have had an intent to send intent to ship plan :) 

Alex Russell

unread,
Feb 6, 2015, 7:26:16 PM2/6/15
to Kenji Baheux, Hiroki Nakagawa, blink-dev

As an enabler for end-to-end push/notification flows, this couldn't be more important. Very excited by this. Make it so!

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
Reply all
Reply to author
Forward
0 new messages