Skip to content

Commit

Permalink
Fix the control flow of update() method
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jungkees committed May 30, 2017
1 parent 60aba38 commit 6281143
Show file tree
Hide file tree
Showing 4 changed files with 339 additions and 337 deletions.
16 changes: 8 additions & 8 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,15 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

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

1. Let |p| be a <a>promise</a>.
1. Let |registration| be the [=ServiceWorkerRegistration/service worker registration=].
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as its argument.
1. If |newestWorker| is null, reject |p| with an "{{InvalidStateError}}" exception and abort these steps.
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.
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>.
1. If |newestWorker| is null, return [=a promise rejected with=] an "{{InvalidStateError}}" exception and abort these steps.
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.
1. Let |promise| be a <a>promise</a>.
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>.
1. Set |job|'s <a>worker type</a> to |newestWorker|'s [=service worker/type=].
1. Invoke <a>Schedule Job</a> with |job|.
1. Return |p|.
1. Return |promise|.
</section>

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

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

1. Let |p| be a <a>promise</a>.
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>.
1. Let |promise| be a <a>promise</a>.
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>.
1. Invoke <a>Schedule Job</a> with |job|.
1. Return |p|.
1. Return |promise|.
</section>

<section>
Expand Down
Loading

0 comments on commit 6281143

Please sign in to comment.