From ac8e8a1c5a887097c43629c818768f92e605f09d Mon Sep 17 00:00:00 2001 From: asakusuma Date: Fri, 21 Jun 2019 16:58:36 -0700 Subject: [PATCH] Create a Kill Service Workers algorithm Intended to be a killswitch mechanism for all service workers associated with an origin. 1. "Unclaim" all service workers for the origin. In other words, ensure no clients are controlled by any service worker under the origin 2. Terminate all in-flight tasks, but allow fetch tasks to fallback to network 3. Immediately unregister all registrations under the origin --- docs/index.bs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/docs/index.bs b/docs/index.bs index 7ce82190..9dd41a12 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -2819,6 +2819,52 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Return |serviceWorker|'s [=start status=]. +
+

Terminate Task Queue

+ : Input + :: |event loop|, an event loop + : Output + :: None + + 1. For each |task| in |event loop|'s corresponding [=/task queues=] + 1. If |task|'s task source is handle fetch task source + 1. Let |client| be |task|'s |request|'s [=request/client=]. + 2. Queue |task| to |clients|'s responsible event loop using the networking task source. + 2. Discard |task| + + Note: This effectively means that the in-flight fetch events are handled by the network, and all other events are discarded. +
+ +
+

Kill Service Workers

+ + The [=Kill Service Workers=] algorithm is intended to be a killswitch mechanism for all service workers associated with an origin. + + : Input + :: |origin|, an [=/origin=] + : Output + :: None + + 1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the same as the |origin| + 1. Set |client|'s active service worker to null. + + 2. For each |registration| in the user agent's set of service worker registrations: + + 1. If |registration|'s scope URL's [=url/origin=] is |origin|: + + 1. Run Terminate Task Queue on each of |registration|'s event loop's + 1. If |registration|'s installing worker is not null, then: + 1. Discard, without processing, every task in |registration|'s installing worker's event loop's corresponding [=/task queues=] + 1. If |registration|'s waiting worker is not null, then: + 1. Discard, without processing, every task in |registration|'s waiting worker's event loop's corresponding [=/task queues=] + 1. If |registration|'s active worker is not null, then: + 1. Run Terminate Task Queue on each of |registration|'s waiting worker's event loop's + + 3. [=map/For each=] |scope| → |registration| of [=scope to registration map=]: + 1. If the [=url/origin=] of the result of [=URL parser|parsing=] |scope| is the [=same origin|same=] as |origin|, then [=map/remove=] [=scope to registration map=][|registration|'s [=service worker registration/scope url=], [[=URL serializer|serialized=]]. + 2. Run Clear Registration, passing |registration| +
+

Terminate Service Worker