diff --git a/docs/index.bs b/docs/index.bs
index 91d09c11..2a775105 100644
--- a/docs/index.bs
+++ b/docs/index.bs
@@ -2659,19 +2659,18 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Wait for |task| to have executed or been discarded.
1. Wait for the step labeled *WaitForAsynchronousExtensions* to complete.
1. If |installFailed| is true, then:
- 1. Run the Update Worker State algorithm passing |registration|'s [=installing worker=] and "`redundant`" as the arguments.
- 1. Run the Update Registration State algorithm passing |registration|, "installing
" and null as the arguments.
+ 1. Run the [=Update Registration State=] algorithm passing |registration|, "`installing`" and null as the arguments.
+ 1. Run the [=Update Worker State=] algorithm passing |registration|'s [=installing worker=] and "`redundant`" as the arguments.
1. If |newestWorker| is null, then [=map/remove=] [=scope to registration map=][|registration|'s [=service worker registration/scope url=], [[=URL serializer|serialized=]].
1. Invoke Finish Job with |job| and abort these steps.
1. Let |map| be |registration|'s [=installing worker=]'s [=script resource map=].
1. Let |usedSet| be |registration|'s [=installing worker=]'s [=set of used scripts=].
1. [=map/For each=] |url| of |map|:
1. If |usedSet| does not [=list/contain=] |url|, then [=map/remove=] |map|[|url|].
- 1. If |registration|'s waiting worker is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=waiting worker=].
- 1. Run the [=Update Worker State=] algorithm passing |registration|'s [=waiting worker=] and "`redundant`" as the arguments.
+ 1. Let |redundantWorker| be |registration|'s [=waiting worker=].
1. Run the Update Registration State algorithm passing |registration|, "waiting
" and |registration|'s installing worker as the arguments.
1. Run the Update Registration State algorithm passing |registration|, "installing
" and null as the arguments.
+ 1. If |redundantWorker| is not null, then run the [=Update Worker State=] algorithm passing |redundantWorker| and "`redundant`" as the arguments.
1. Run the Update Worker State algorithm passing |registration|'s waiting worker and "`installed`" as the arguments.
1. Invoke Finish Job with |job|.
1. Wait for all the tasks queued by Update Worker State invoked in this algorithm to have executed.
@@ -2689,11 +2688,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
:: None
1. If |registration|'s waiting worker is null, abort these steps.
- 1. If |registration|'s [=active worker=] is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=active worker=].
- 1. Run the [=Update Worker State=] algorithm passing |registration|'s [=active worker=] and "`redundant`" as the arguments.
+ 1. Let |redundantWorker| be |registration|'s [=active worker=].
1. Run the Update Registration State algorithm passing |registration|, "active
" and |registration|'s waiting worker as the arguments.
1. Run the Update Registration State algorithm passing |registration|, "waiting
" and null as the arguments.
+ 1. If |redundantWorker| is not null, then run the [=Update Worker State=] algorithm passing |redundantWorker| and "`redundant`" as the arguments.
1. Run the Update Worker State algorithm passing |registration|'s active worker and "`activating`" as the arguments.
Note: Once an active worker is activating, neither a runtime script error nor a force termination of the active worker prevents the active worker from getting activated.
@@ -3094,18 +3092,17 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
:: None
1. Run the following steps atomically.
- 1. If |registration|'s installing worker is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=installing worker=].
- 1. Run the Update Worker State algorithm passing |registration|'s [=installing worker=] and "`redundant`" as the arguments.
- 1. Run the Update Registration State algorithm passing |registration|, "installing
" and null as the arguments.
- 1. If |registration|'s waiting worker is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=waiting worker=].
- 1. Run the Update Worker State algorithm passing |registration|'s [=waiting worker=] and "`redundant`" as the arguments.
- 1. Run the Update Registration State algorithm passing |registration|, "waiting
" and null as the arguments.
- 1. If |registration|'s active worker is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=active worker=].
- 1. Run the Update Worker State algorithm passing |registration|'s [=active worker=] and "`redundant`" as the arguments.
- 1. Run the Update Registration State algorithm passing |registration|, "active
" and null as the arguments.
+ 1. Let |redundantWorkers| be a new [=/list=].
+ 1. If |registration|'s [=installing worker=] is not null, then:
+ 1. Run the [=Update Registration State=] algorithm passing |registration|, "`installing`" and null as the arguments.
+ 1. [=list/Append=] |registration|'s [=installing worker=] to |redundantWorkers|.
+ 1. If |registration|'s [=waiting worker=] is not null, then:
+ 1. Run the [=Update Registration State=] algorithm passing |registration|, "`waiting`" and null as the arguments.
+ 1. [=list/Append=] |registration|'s [=waiting worker=] to |redundantWorkers|.
+ 1. If |registration|'s [=active worker=] is not null, then:
+ 1. Run the [=Update Registration State=] algorithm passing |registration|, "`active`" and null as the arguments.
+ 1. [=list/Append=] |registration|'s [=waiting worker=] to |redundantWorkers|.
+ 1. [=list/For each=] |redundantWorker| of |redundantWorkers|, run [=Update Worker State=] with |redundantWorker| and "`redundant`".
@@ -3159,6 +3156,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
:: None
1. Set |worker|'s [=service worker/state=] to |state|.
+ 1. If |state| is "`redundant`", then [=Terminate Service Worker|terminate=] |worker|.
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |worker|'s [=service worker/script url=]'s [=url/origin=].
1. For each |settingsObject| of |settingsObjects|, [=queue a task=] on |settingsObject|'s [=responsible event loop=] in the [=DOM manipulation task source=] to run the following steps:
1. Let |objectMap| be |settingsObject|'s [=environment settings object/service worker object map=].
diff --git a/docs/v1/index.bs b/docs/v1/index.bs
index 733fb38e..4a0b957e 100644
--- a/docs/v1/index.bs
+++ b/docs/v1/index.bs
@@ -2480,15 +2480,14 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Wait for |task| to have executed or been discarded.
1. Wait for the step labeled *WaitForAsynchronousExtensions* to complete.
1. If |installFailed| is true, then:
- 1. Run the Update Worker State algorithm passing |registration|'s [=installing worker=] and "`redundant`" as the arguments.
- 1. Run the Update Registration State algorithm passing |registration|, "installing
" and null as the arguments.
+ 1. Run the [=Update Registration State=] algorithm passing |registration|, "`installing`" and null as the arguments.
+ 1. Run the [=Update Worker State=] algorithm passing |registration|'s [=installing worker=] and "`redundant`" as the arguments.
1. If |newestWorker| is null, then [=map/remove=] [=scope to registration map=][|registration|'s [=service worker registration/scope url=], [[=URL serializer|serialized=]].
1. Invoke Finish Job with |job| and abort these steps.
- 1. If |registration|'s waiting worker is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=waiting worker=].
- 1. Run the [=Update Worker State=] algorithm passing |registration|'s [=waiting worker=] and "`redundant`" as the arguments.
+ 1. Let |redundantWorker| be |registration|'s [=waiting worker=].
1. Run the Update Registration State algorithm passing |registration|, "waiting
" and |registration|'s installing worker as the arguments.
1. Run the Update Registration State algorithm passing |registration|, "installing
" and null as the arguments.
+ 1. If |redundantWorker| is not null, then run the [=Update Worker State=] algorithm passing |redundantWorker| and "`redundant`" as the arguments.
1. Run the Update Worker State algorithm passing |registration|'s waiting worker and "`installed`" as the arguments.
1. Invoke Finish Job with |job|.
1. Wait for all the tasks queued by Update Worker State invoked in this algorithm to have executed.
@@ -2506,11 +2505,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
:: None
1. If |registration|'s waiting worker is null, abort these steps.
- 1. If |registration|'s [=active worker=] is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=active worker=].
- 1. Run the [=Update Worker State=] algorithm passing |registration|'s [=active worker=] and "`redundant`" as the arguments.
+ 1. Let |redundantWorker| be |registration|'s [=active worker=].
1. Run the Update Registration State algorithm passing |registration|, "active
" and |registration|'s waiting worker as the arguments.
1. Run the Update Registration State algorithm passing |registration|, "waiting
" and null as the arguments.
+ 1. If |redundantWorker| is not null, then run the [=Update Worker State=] algorithm passing |redundantWorker| and "`redundant`" as the arguments.
1. Run the Update Worker State algorithm passing |registration|'s active worker and "`activating`" as the arguments.
Note: Once an active worker is activating, neither a runtime script error nor a force termination of the active worker prevents the active worker from getting activated.
@@ -2885,18 +2883,17 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
:: None
1. Run the following steps atomically.
- 1. If |registration|'s installing worker is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=installing worker=].
- 1. Run the Update Worker State algorithm passing |registration|'s [=installing worker=] and "`redundant`" as the arguments.
- 1. Run the Update Registration State algorithm passing |registration|, "installing
" and null as the arguments.
- 1. If |registration|'s waiting worker is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=waiting worker=].
- 1. Run the Update Worker State algorithm passing |registration|'s [=waiting worker=] and "`redundant`" as the arguments.
- 1. Run the Update Registration State algorithm passing |registration|, "waiting
" and null as the arguments.
- 1. If |registration|'s active worker is not null, then:
- 1. [=Terminate Service Worker|Terminate=] |registration|'s [=active worker=].
- 1. Run the Update Worker State algorithm passing |registration|'s [=active worker=] and "`redundant`" as the arguments.
- 1. Run the Update Registration State algorithm passing |registration|, "active
" and null as the arguments.
+ 1. Let |redundantWorkers| be a new [=/list=].
+ 1. If |registration|'s [=installing worker=] is not null, then:
+ 1. Run the [=Update Registration State=] algorithm passing |registration|, "`installing`" and null as the arguments.
+ 1. [=list/Append=] |registration|'s [=installing worker=] to |redundantWorkers|.
+ 1. If |registration|'s [=waiting worker=] is not null, then:
+ 1. Run the [=Update Registration State=] algorithm passing |registration|, "`waiting`" and null as the arguments.
+ 1. [=list/Append=] |registration|'s [=waiting worker=] to |redundantWorkers|.
+ 1. If |registration|'s [=active worker=] is not null, then:
+ 1. Run the [=Update Registration State=] algorithm passing |registration|, "`active`" and null as the arguments.
+ 1. [=list/Append=] |registration|'s [=waiting worker=] to |redundantWorkers|.
+ 1. [=list/For each=] |redundantWorker| of |redundantWorkers|, run [=Update Worker State=] with |redundantWorker| and "`redundant`".
@@ -2950,6 +2947,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
:: None
1. Set |worker|'s [=service worker/state=] to |state|.
+ 1. If |state| is "`redundant`", then [=Terminate Service Worker|terminate=] |worker|.
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |worker|'s [=service worker/script url=]'s [=url/origin=].
1. For each |settingsObject| of |settingsObjects|, [=queue a task=] on |settingsObject|'s [=responsible event loop=] in the [=DOM manipulation task source=] to run the following steps:
1. Let |objectMap| be |settingsObject|'s [=environment settings object/service worker object map=].