Skip to content

Commit

Permalink
Don't associate ServiceWorker and ServiceWorkerRegistration with a cl…
Browse files Browse the repository at this point in the history
…ient.

The client is defined as being the environment settings object, so just use the
relevant settings object for the ServiceWorker and ServiceWorkerRegistration
instances rather than explicitly duplicating this association.
  • Loading branch information
mkruisselbrink committed Mar 15, 2016
1 parent e2a6d18 commit 08a506e
Show file tree
Hide file tree
Showing 4 changed files with 649 additions and 644 deletions.
28 changes: 11 additions & 17 deletions spec/service_worker/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ spec: html; type: dfn
text: neutered
text: parent browsing context
text: queue a task
text: relevant settings object
text: replacement enabled
text: responsible browsing context
text: responsible document
Expand Down Expand Up @@ -463,8 +464,6 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

<p>A {{ServiceWorker}} object has an associated {{ServiceWorkerState}} object which is itself associated with <a href="#dfn-service-worker">service worker</a>'s <a href="#dfn-state">state</a>.</p>

<p>A {{ServiceWorker}} object has an associated <dfn id="dfn-service-worker-interface-client">service worker client</dfn> (a <a href="#dfn-service-worker-client">service worker client</a>).</p>

<section>
<h4 id="service-worker-url">{{ServiceWorker/scriptURL}}</h4>

Expand Down Expand Up @@ -596,16 +595,13 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

<p>A <code><dfn interface id="service-worker-registration-interface">ServiceWorkerRegistration</dfn></code> object represents a <a href="#dfn-service-worker-registration">service worker registration</a>. Each {{ServiceWorkerRegistration}} object is associated with a <dfn id="dfn-service-worker-registration-interface-service-worker-registration">service worker registration</dfn> (a <a href="#dfn-service-worker-registration">service worker registration</a>). Multiple separate objects implementing the {{ServiceWorkerRegistration}} interface across <a>document environments</a> and <a>worker environments</a> can all be associated with the same <a href="#dfn-service-worker-registration">service worker registration</a> simultaneously.</p>

<p>A {{ServiceWorkerRegistration}} object has an associated <dfn id="dfn-service-worker-registration-interface-client">service worker client</dfn> (a <a href="#dfn-service-worker-client">service worker client</a>).</p>

<section algorithm="navigator-service-worker-installing">
<h4 id="navigator-service-worker-installing">{{ServiceWorkerRegistration/installing}}</h4>

<p><dfn attribute id="service-worker-registration-installing-attribute"><code>installing</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the result of running these steps or their <a href="#dfn-processing-equivalence">equivalent</a>:</p>

<ol>
<li>Let <var>installingWorker</var> be the {{ServiceWorker}} object that represents the <a href="#dfn-service-worker-registration-interface-service-worker-registration">service worker registration</a>'s <a href="#dfn-installing-worker">installing worker</a>.</li>
<li>Set <var>installingWorker</var>'s <a href="#dfn-service-worker-interface-client">service worker client</a> to the <a href="#dfn-service-worker-registration-interface-client">service worker client</a>.</li>
<li>Return <var>installingWorker</var>.</li>
</ol>

Expand All @@ -619,7 +615,6 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

<ol>
<li>Let <var>waitingWorker</var> be the {{ServiceWorker}} object that represents the <a href="#dfn-service-worker-registration-interface-service-worker-registration">service worker registration</a>'s <a href="#dfn-waiting-worker">waiting worker</a>.</li>
<li>Set <var>waitingWorker</var>'s <a href="#dfn-service-worker-interface-client">service worker client</a> to the <a href="#dfn-service-worker-registration-interface-client">service worker client</a>.</li>
<li>Return <var>waitingWorker</var>.</li>
</ol>

Expand All @@ -633,7 +628,6 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

<ol>
<li>Let <var>activeWorker</var> be the {{ServiceWorker}} object that represents the <a href="#dfn-service-worker-registration-interface-service-worker-registration">service worker registration</a>'s <a href="#dfn-active-worker">active worker</a>.</li>
<li>Set <var>activeWorker</var>'s <a href="#dfn-service-worker-interface-client">service worker client</a> to the <a href="#dfn-service-worker-registration-interface-client">service worker client</a>.</li>
<li>Return <var>activeWorker</var>.</li>
</ol>

Expand All @@ -658,7 +652,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Let <var>registration</var> be the <a href="#dfn-service-worker-registration-interface-service-worker-registration">service worker registration</a>.</li>
<li>Let <var>newestWorker</var> be the result of running <a href="#get-newest-worker-algorithm">Get Newest Worker</a> algorithm passing <var>registration</var> as its argument.</li>
<li>If <var>newestWorker</var> is null, reject <var>p</var> with an "{{InvalidStateError}}" exception and abort these steps.</li>
<li>Let <var>job</var> be the result of running <a href="#create-job-algorithm">Create Job</a> with <em>update</em>, <var>registration</var>'s <a href="#dfn-scope-url">scope url</a>, <var>newestWorker</var>'s <a href="#dfn-script-url">script url</a>, <var>p</var>, and the <a href="#dfn-service-worker-registration-interface-client">service worker client</a> <var>client</var>.</li>
<li>Let <var>job</var> be the result of running <a href="#create-job-algorithm">Create Job</a> with <em>update</em>, <var>registration</var>'s <a href="#dfn-scope-url">scope url</a>, <var>newestWorker</var>'s <a href="#dfn-script-url">script url</a>, <var>p</var>, and the <a>context object</a>'s <a>relevant settings object</a> <var>client</var>.</li>
<li>Run the following substep <a>in parallel</a>:
<ol>
<li>Invoke <a href="#schedule-job-algorithm">Schedule Job</a> with <var>job</var>.</li>
Expand All @@ -677,7 +671,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

<ol>
<li>Let <var>p</var> be a <a>promise</a>.</li>
<li>Let <var>job</var> be the result of running <a href="#create-job-algorithm">Create Job</a> with <em>unregister</em>, the <a href="#dfn-scope-url">scope url</a> of the <a href="#dfn-service-worker-registration-interface-service-worker-registration">service worker registration</a>, null, <var>p</var>, and the <a href="#dfn-service-worker-registration-interface-client">service worker client</a> <var>client</var>.</li>
<li>Let <var>job</var> be the result of running <a href="#create-job-algorithm">Create Job</a> with <em>unregister</em>, the <a href="#dfn-scope-url">scope url</a> of the <a href="#dfn-service-worker-registration-interface-service-worker-registration">service worker registration</a>, null, <var>p</var>, and the <a>context object</a>'s <a>relevant settings object</a> <var>client</var>.</li>
<li>Run the following substep <a>in parallel</a>:
<ol>
<li>Invoke <a href="#schedule-job-algorithm">Schedule Job</a> with <var>job</var>.</li>
Expand Down Expand Up @@ -804,7 +798,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>If <var>registration</var>'s <a href="#dfn-active-worker">active worker</a> is null, wait until <var>registration</var>'s <a href="#dfn-active-worker">active worker</a> changes.
<p class="note">Implementers should consider this condition is met when the corresponding registration request gets to the step 7 of <a href="#activation-algorithm">Activate</a> algorithm.</p>
</li>
<li>Resolve <a>context object</a>'s <a href="#dfn-ready-promise">ready promise</a> with the {{ServiceWorkerRegistration}} object, setting its <a href="#dfn-service-worker-registration-interface-client">service worker client</a> to <a href="#dfn-service-worker-container-interface-client">service worker client</a>, which represents <var>registration</var>.</li>
<li>Resolve <a>context object</a>'s <a href="#dfn-ready-promise">ready promise</a> with the {{ServiceWorkerRegistration}} object which represents <var>registration</var>.</li>
</ol>
</li>
<li>Return <a>context object</a>'s <a href="#dfn-ready-promise">ready promise</a>.</li>
Expand Down Expand Up @@ -863,7 +857,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Let <var>registration</var> be the result of running <a href="#scope-match-algorithm">Match Service Worker Registration</a> algorithm, or its equivalent, with <var>clientURL</var> as its argument.</li>
<li>If <var>registration</var> is not null, then:
<ol>
<li>Resolve <var>promise</var> with the {{ServiceWorkerRegistration}} object, setting its <a href="#dfn-service-worker-registration-interface-client">service worker client</a> to <var>client</var>, which represents <var>registration</var>.</li>
<li>Resolve <var>promise</var> with the {{ServiceWorkerRegistration}} object which represents <var>registration</var>.</li>
</ol>
</li>
<li>Else:
Expand Down Expand Up @@ -891,7 +885,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Let <var>array</var> be an empty array.</li>
<li>For each <a>Record</a> {\[[key]], \[[value]]} <var>entry</var> of <a href="#dfn-scope-to-registration-map">scope to registration map</a>:
<ol>
<li>If the <a for="resource">origin</a> of the result of <a for="url">parsing</a> <var>entry</var>.\[[key]] is the <a lt="same origin">same</a> as <var>client</var>'s <a for="resource">origin</a>, add the {{ServiceWorkerRegistration}} object, setting its <a href="#dfn-service-worker-registration-interface-client">service worker client</a> to <var>client</var>, associated with <var>entry</var>.\[[value]] to the <var>array</var>.</li>
<li>If the <a for="resource">origin</a> of the result of <a for="url">parsing</a> <var>entry</var>.\[[key]] is the <a lt="same origin">same</a> as <var>client</var>'s <a for="resource">origin</a>, add the {{ServiceWorkerRegistration}} object associated with <var>entry</var>.\[[value]] to the <var>array</var>.</li>
</ol>
</li>
<li>Resolve <var>promise</var> with <var>array</var>.</li>
Expand Down Expand Up @@ -1304,7 +1298,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Create an event <var>e</var> that uses the {{ServiceWorkerMessageEvent}} interface, with the event type <a href="#service-worker-container-message-event">message</a>, which does not bubble, is not cancelable, and has no default action.</li>
<li>Let the {{ServiceWorkerMessageEvent/data}} attribute of <var>e</var> be initialized to <var>clonedMessage</var>.</li>
<li>Let the {{ServiceWorkerMessageEvent/origin}} attribute of <var>e</var> be initialized to the <a lt="unicode serialisation of an origin">Unicode serialisation</a> of the <a for="resource">origin</a> specified by the <a>incumbent settings object</a>.</li>
<li>Let the {{ServiceWorkerMessageEvent/source}} attribute of <var>e</var> be initialized to a {{ServiceWorker}} object, setting its <a href="#dfn-service-worker-interface-client">service worker client</a> to <var>destination</var>'s <a href="#dfn-service-worker-container-interface-client">service worker client</a>, which represents the <a href="#dfn-service-worker-global-scope-service-worker">service worker</a> associated with the <a>global object</a> specified by the <a>incumbent settings object</a>.</li>
<li>Let the {{ServiceWorkerMessageEvent/source}} attribute of <var>e</var> be initialized to a {{ServiceWorker}} object, which represents the <a href="#dfn-service-worker-global-scope-service-worker">service worker</a> associated with the <a>global object</a> specified by the <a>incumbent settings object</a>.</li>
<li>Let the {{ServiceWorkerMessageEvent/ports}} attribute of <var>e</var> be initialized to <var>newPorts</var>.</li>
<li><a>Dispatch</a> <var>e</var> at <var>destination</var>.</li>
</ol>
Expand Down Expand Up @@ -3024,7 +3018,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<ol>
<li>If <var>newestWorker</var> is an <a href="#dfn-active-worker">active worker</a>, then:
<ol>
<li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and the {{ServiceWorkerRegistration}} object, setting its <a href="#dfn-service-worker-registration-interface-client">service worker client</a> to <var>job</var>'s <a href="#dfn-job-client">client</a>, which represents <var>registration</var>.</li>
<li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and the {{ServiceWorkerRegistration}} object which represents <var>registration</var>.</li>
<li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.</li>
</ol>
</li>
Expand Down Expand Up @@ -3138,7 +3132,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
</li>
<li>If <var>newestWorker</var> is not null, <var>newestWorker</var>'s <a href="#dfn-script-url">script url</a> <a for="url">equals</a> <var>job</var>'s <a href="#dfn-job-script-url">script url</a> with the <em>exclude fragments flag</em> set, and <var>script</var> is a byte-for-byte match with <var>newestWorker</var>'s <a href="#dfn-script-resource">script resource</a>, then:
<ol>
<li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and the {{ServiceWorkerRegistration}} object, setting its <a href="#dfn-service-worker-registration-interface-client">service worker client</a> to <var>job</var>'s <a href="#dfn-job-client">client</a>, which represents <var>registration</var>.</li>
<li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and the {{ServiceWorkerRegistration}} object which represents <var>registration</var>.</li>
<li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.</li>
</ol>
</li>
Expand Down Expand Up @@ -3204,7 +3198,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Set <var>registration</var>'s <a href="#dfn-installing-worker">installing worker</a> to <var>worker</var>.</li>
<li>Run the <a href="#update-state-algorithm">Update State</a> algorithm passing <var>registration</var>'s <a href="#dfn-installing-worker">installing worker</a> and <em>installing</em> as the arguments.</li>
<li><a>Assert</a>: <var>job</var>'s <a href="#dfn-job-promise">promise</a> is not null.</li>
<li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and the {{ServiceWorkerRegistration}} object, setting its <a href="#dfn-service-worker-registration-interface-client">service worker client</a> to <var>job</var>'s <a href="#dfn-job-client">client</a>, which represents <var>registration</var>.</li>
<li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and the {{ServiceWorkerRegistration}} object which represents <var>registration</var>.</li>
<li><a>Queue a task</a> to <a>fire a simple event</a> named <code>updatefound</code> at all the {{ServiceWorkerRegistration}} objects for all the <a href="#dfn-service-worker-client">service worker clients</a> whose <a>creation url</a> <a href="#scope-match-algorithm">matches</a> <var>registration</var>'s <a href="#dfn-scope-url">scope url</a> and all the <a href="#dfn-service-worker">service workers</a> whose <a href="#dfn-containing-service-worker-registration">containing service worker registration</a> is <var>registration</var>.</li>
<li>Let <var>installingWorker</var> be <var>registration</var>'s <a href="#dfn-installing-worker">installing worker</a>.</li>
<li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>installingWorker</var> as the argument.</li>
Expand Down Expand Up @@ -3818,7 +3812,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<ol>
<li><a>Queue a task</a> to <a>fire a simple event</a> named <code>statechange</code> at <var>serviceWorker</var>.</li>
</ol>
<p>The <a>task</a> <em class="rfc2119" title="MUST">must</em> use <var>serviceWorker</var>'s <a href="#dfn-service-worker-interface-client">service worker client</a>'s <a>responsible event loop</a> and the <a>DOM manipulation task source</a>.</p>
<p>The <a>task</a> <em class="rfc2119" title="MUST">must</em> use <var>serviceWorker</var>'s <a>relevant settings object</a>'s <a>responsible event loop</a> and the <a>DOM manipulation task source</a>.</p>
</li>
</ol>
</section>
Expand Down

0 comments on commit 08a506e

Please sign in to comment.