Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: correct method control flow #1152

Merged
merged 1 commit into from
May 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,15 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
<section algorithm="service-worker-registration-update">
<h4 id="service-worker-registration-update">{{ServiceWorkerRegistration/update()}}</h4>

<dfn method for="ServiceWorkerRegistration"><code>update()</code></dfn> method *must* run these steps:
The <dfn method for="ServiceWorkerRegistration"><code>update()</code></dfn> method, when invoked, *must* return a new [=promise=] |promise| and run the following steps [=in parallel=]:

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, reject |promise| 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 |promise| 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=], |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|.
</section>

<section algorithm="navigator-service-worker-unregister">
Expand Down
12 changes: 4 additions & 8 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2017,26 +2017,22 @@ <h4 class="heading settled" data-level="3.2.6" id="service-worker-registration-u
</section>
<section class="algorithm" data-algorithm="service-worker-registration-update">
<h4 class="heading settled" data-level="3.2.7" id="service-worker-registration-update"><span class="secno">3.2.7. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#dom-serviceworkerregistration-update" id="ref-for-dom-serviceworkerregistration-update-2">update()</a></code></span><a class="self-link" href="#service-worker-registration-update"></a></h4>
<p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="method" data-export="" id="dom-serviceworkerregistration-update"><code>update()</code></dfn> method <em>must</em> run these steps:</p>
<p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="method" data-export="" id="dom-serviceworkerregistration-update"><code>update()</code></dfn> method, when invoked, <em>must</em> return a new <a data-link-type="dfn" href="http://tc39.github.io/ecma262/#sec-promise-objects">promise</a> <var>promise</var> and run the following steps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>:</p>
<ol>
<li data-md="">
<p>Let <var>p</var> be a <a data-link-type="dfn" href="http://tc39.github.io/ecma262/#sec-promise-objects">promise</a>.</p>
<li data-md="">
<p>Let <var>registration</var> be the <a data-link-type="dfn" href="#serviceworkerregistration-service-worker-registration" id="ref-for-serviceworkerregistration-service-worker-registration-4">service worker registration</a>.</p>
<li data-md="">
<p>Let <var>newestWorker</var> be the result of running <a data-link-type="dfn" href="#get-newest-worker" id="ref-for-get-newest-worker-1">Get Newest Worker</a> algorithm passing <var>registration</var> as its argument.</p>
<li data-md="">
<p>If <var>newestWorker</var> is null, reject <var>p</var> with an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception and abort these steps.</p>
<p>If <var>newestWorker</var> is null, reject <var>promise</var> with an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception and abort these steps.</p>
<li data-md="">
<p>If the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> <var>globalObject</var> is a <code class="idl"><a data-link-type="idl" href="#serviceworkerglobalscope" id="ref-for-serviceworkerglobalscope-4">ServiceWorkerGlobalScope</a></code> object, and <var>globalObject</var>’s associated <a data-link-type="dfn" href="#serviceworkerglobalscope-service-worker" id="ref-for-serviceworkerglobalscope-service-worker-2">service worker</a>'s <a data-link-type="dfn" href="#dfn-state" id="ref-for-dfn-state-5">state</a> is <em>installing</em>, reject <var>p</var> with an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception and abort these steps.</p>
<p>If the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> <var>globalObject</var> is a <code class="idl"><a data-link-type="idl" href="#serviceworkerglobalscope" id="ref-for-serviceworkerglobalscope-4">ServiceWorkerGlobalScope</a></code> object, and <var>globalObject</var>’s associated <a data-link-type="dfn" href="#serviceworkerglobalscope-service-worker" id="ref-for-serviceworkerglobalscope-service-worker-2">service worker</a>'s <a data-link-type="dfn" href="#dfn-state" id="ref-for-dfn-state-5">state</a> is <em>installing</em>, reject <var>promise</var> with an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception and abort these steps.</p>
<li data-md="">
<p>Let <var>job</var> be the result of running <a data-link-type="dfn" href="#create-job" id="ref-for-create-job-1">Create Job</a> with <em>update</em>, <var>registration</var>’s <a data-link-type="dfn" href="#dfn-scope-url" id="ref-for-dfn-scope-url-7">scope url</a>, <var>newestWorker</var>’s <a data-link-type="dfn" href="#dfn-script-url" id="ref-for-dfn-script-url-2">script url</a>, <var>p</var>, and the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>.</p>
<p>Let <var>job</var> be the result of running <a data-link-type="dfn" href="#create-job" id="ref-for-create-job-1">Create Job</a> with <em>update</em>, <var>registration</var>’s <a data-link-type="dfn" href="#dfn-scope-url" id="ref-for-dfn-scope-url-7">scope url</a>, <var>newestWorker</var>’s <a data-link-type="dfn" href="#dfn-script-url" id="ref-for-dfn-script-url-2">script url</a>, <var>promise</var>, and the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>.</p>
<li data-md="">
<p>Set <var>job</var>’s <a data-link-type="dfn" href="#dfn-job-worker-type" id="ref-for-dfn-job-worker-type-1">worker type</a> to <var>newestWorker</var>’s <a data-link-type="dfn" href="#dfn-type" id="ref-for-dfn-type-1">type</a>.</p>
<li data-md="">
<p>Invoke <a data-link-type="dfn" href="#schedule-job" id="ref-for-schedule-job-1">Schedule Job</a> with <var>job</var>.</p>
<li data-md="">
<p>Return <var>p</var>.</p>
</ol>
</section>
<section class="algorithm" data-algorithm="navigator-service-worker-unregister">
Expand Down