Skip to content

Commit 6281143

Browse files
committed
Fix the control flow of update() method
This patch fixes the control flow of registration.update() method such that the algorithm returns a promise rejected with an exception on error conditions. Before this patch, the steps rejected a non-returned promise and aborted the steps right away. Issue raised through #1152.
1 parent 60aba38 commit 6281143

File tree

4 files changed

+339
-337
lines changed

4 files changed

+339
-337
lines changed

docs/index.bs

+8-8
Original file line numberDiff line numberDiff line change
@@ -475,15 +475,15 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
475475

476476
<dfn method for="ServiceWorkerRegistration"><code>update()</code></dfn> method *must* run these steps:
477477

478-
1. Let |p| be a <a>promise</a>.
479478
1. Let |registration| be the [=ServiceWorkerRegistration/service worker registration=].
480479
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as its argument.
481-
1. If |newestWorker| is null, reject |p| with an "{{InvalidStateError}}" exception and abort these steps.
482-
1. If the <a>context object</a>'s <a>relevant settings object</a>'s [=environment settings object/global object=] |globalObject| is a {{ServiceWorkerGlobalScope}} object, and |globalObject|'s associated [=ServiceWorkerGlobalScope/service worker=]'s <a>state</a> is *installing*, reject |p| with an "{{InvalidStateError}}" exception and abort these steps.
483-
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/scope url=], |newestWorker|'s [=service worker/script url=], |p|, and the <a>context object</a>'s <a>relevant settings object</a>.
480+
1. If |newestWorker| is null, return [=a promise rejected with=] an "{{InvalidStateError}}" exception and abort these steps.
481+
1. If the <a>context object</a>'s <a>relevant settings object</a>'s [=environment settings object/global object=] |globalObject| is a {{ServiceWorkerGlobalScope}} object, and |globalObject|'s associated [=ServiceWorkerGlobalScope/service worker=]'s <a>state</a> is *installing*, return [=a promise rejected with=] an "{{InvalidStateError}}" exception and abort these steps.
482+
1. Let |promise| be a <a>promise</a>.
483+
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/scope url=], |newestWorker|'s [=service worker/script url=], |promise|, and the <a>context object</a>'s <a>relevant settings object</a>.
484484
1. Set |job|'s <a>worker type</a> to |newestWorker|'s [=service worker/type=].
485485
1. Invoke <a>Schedule Job</a> with |job|.
486-
1. Return |p|.
486+
1. Return |promise|.
487487
</section>
488488

489489
<section algorithm="navigator-service-worker-unregister">
@@ -493,10 +493,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
493493

494494
<dfn method for="ServiceWorkerRegistration"><code>unregister()</code></dfn> method *must* run these steps:
495495

496-
1. Let |p| be a <a>promise</a>.
497-
1. Let |job| be the result of running <a>Create Job</a> with *unregister*, the [=service worker registration/scope url=] of the [=ServiceWorkerRegistration/service worker registration=], null, |p|, and the <a>context object</a>'s <a>relevant settings object</a>.
496+
1. Let |promise| be a <a>promise</a>.
497+
1. Let |job| be the result of running <a>Create Job</a> with *unregister*, the [=service worker registration/scope url=] of the [=ServiceWorkerRegistration/service worker registration=], null, |promise|, and the <a>context object</a>'s <a>relevant settings object</a>.
498498
1. Invoke <a>Schedule Job</a> with |job|.
499-
1. Return |p|.
499+
1. Return |promise|.
500500
</section>
501501

502502
<section>

0 commit comments

Comments
 (0)