Skip to content

Commit

Permalink
Specify service worker registration selection
Browse files Browse the repository at this point in the history
This PR defines an active worker for a Document and a
WorkerGlobalScope and the corresponding steps that set the values when
they are created. It also defines an active worker algorithm in the
environment settings object that returns the stored active worker.

This PR also defines setting an active worker for an iframe srcdoc
document to the creator Document's active worker. (Fixes #321.)

R= @annevk, @mikewest.
  • Loading branch information
jungkees committed Mar 31, 2016
1 parent 8a843f2 commit f8b1380
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2808,6 +2808,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<li><dfn data-noexport="" data-x="default-user-agent-value" data-x-href="https://fetch.spec.whatwg.org/#default-user-agent-value">default `<code>User-Agent</code>` value</dfn>
<li><dfn data-noexport="" data-x-href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type">extract a MIME type</dfn>
<li><dfn data-noexport="" data-x="concept-fetch" data-x-href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</dfn>
<li><dfn data-noexport="" data-x="non-subresource-request" data-x-href="https://fetch.spec.whatwg.org/#non-subresource-request">non-subresource request</dfn>
<li><dfn data-noexport="" data-x-href="https://fetch.spec.whatwg.org/#ok-status">ok status</dfn>
<li>`<dfn data-noexport="" data-x="http-origin" data-x-href="https://fetch.spec.whatwg.org/#http-origin"><code>Origin</code></dfn>` header
<li><dfn data-noexport="" data-x-href="https://fetch.spec.whatwg.org/#process-response">process response</dfn>
Expand Down Expand Up @@ -3847,7 +3848,15 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<p>The following terms are defined in <cite>Service Workers</cite>: <ref spec="SW"></p>

<ul class="brief">
<li><dfn data-noexport="" data-x="active-worker" data-x-href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#dfn-active-worker">active worker</dfn></li>
<li><dfn data-noexport="" data-x="control" data-x-href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#dfn-control">control</dfn></li>
<li><dfn data-noexport="" data-x="on-fetch-request-algorithm" data-x-href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#on-fetch-request-algorithm">handle fetch</dfn></li>
<li><dfn data-noexport="" data-x="scope-match-algorithm" data-x-href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#scope-match-algorithm">match service worker registration</dfn></li>
<li><dfn data-noexport="" data-x="scope-url" data-x-href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#dfn-scope-url">scope url</dfn></li>
<li><dfn data-noexport="" data-x="service-worker" data-x-href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#dfn-service-worker">service worker</dfn></li>
<li><dfn data-noexport="" data-x="service-worker-registration" data-x-href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#dfn-service-worker-registration">service worker registration</dfn></li>
<li><dfn data-noexport="" data-x="window-client" data-x-href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#dfn-window-client">window client</dfn></li>
<li><dfn data-noexport="" data-x="worker-client" data-x-href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#dfn-worker-client">worker client</dfn></li>
</ul>

</dd>
Expand Down Expand Up @@ -8540,6 +8549,10 @@ partial /*sealed*/ interface <dfn>Document</dfn> {
data-x="concept-document-module-map">module map</dfn>, which is a <span>module map</span>,
initially empty.</p>

<p>The <code>Document</code> has an <dfn data-dfn-for="Document" data-x="concept-document-active-
worker">active worker</dfn> (null or a <span data-x="service-worker">service worker</span>). It is
initially null.</p>


<h4><dfn>Resource metadata management</dfn></h4>

Expand Down Expand Up @@ -27116,6 +27129,10 @@ href="?audio">audio&lt;/a> test instead.)&lt;/p></pre>
<p>The resulting <code>Document</code> must be considered <span>an <code>iframe</code> <code
data-x="attr-iframe-srcdoc">srcdoc</code> document</span>.</p>

<p>Set the resulting <code>Document</code>'s <span data-x="concept-document-active-
worker">active worker</span> to the <code>iframe</code> element's <span>node document</span>'s
<span data-x="concept-document-active-worker">active worker</span>.</p>

</dd>

<dt>Otherwise, if the element has no <code data-x="attr-iframe-src">src</code> attribute
Expand Down Expand Up @@ -76805,6 +76822,14 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {

</dd>

<dt>The <span>active worker</span></dt>
<dd>

<p>Return the <span data-x="concept-document-active-worker">active worker</span> of the
<code>Document</code> with which <var>window</var> is currently associated.</p>

</dd>

</dl>
</li>

Expand Down Expand Up @@ -81079,6 +81104,28 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
algorithm on the <code>Document</code> object and the resource used to generate the document.
<ref spec="CSP"></p>

<li>

<p>If <span>the document's address</span> <span data-x="scope-match-algorithm">matched</span>
a <span data-x="service-worker-registration">service worker registration</span>
<var>registration</var> when the fetch algorithm obtained the resource, and
<var>registration</var>'s <span data-x="active-worker">active worker</span> <var>active
worker</var> is not null, set the <code>Document</code>'s <span data-x="concept-document-
active-worker">active worker</span> to <var>active worker</var>.</p>

<p class="note"><span data-x="concept-fetch">Fetching</span> a <span data-x"non-subresource-
request">non-subresource</span> (except a <span data-x="service-worker">service worker</span>)
triggers a <span data-x="service-worker-registration">service worker registration</span> <span
data-x="scope-match-algorithm">matching</span> in the <span data-x="on-fetch-request-
algorithm">handle fetch</span> algorithm. If the <span data-x="concept-
request">request</span>'s <span data-x="concept-request-url">url</span> is under the <span
data-x="scope-url">scope</span> of a <span data-x="service-worker-registration">service worker
registration</span>, and it has an <span data-x="active-worker">active worker</span>, the
document's <code>Window</code> object's <span>environment settings object</span> represented
by a <span data-x="window-client">window client</span> starts to be <span data-x="control">controlled</span>.</p>

</li>

<li><p>Set <span>the document's referrer</span> to the <i>address of the resource from which
Request-URIs are obtained</i> as determined when the fetch algorithm obtained the resource, if
that algorithm was used and determined such a value; otherwise, set it to the empty
Expand Down Expand Up @@ -84952,6 +84999,13 @@ interface <dfn>NavigatorOnLine</dfn> {
while removing support for a hash function or cypher suite).</p>
</dd>

<dt>An <dfn>active worker</dfn></dt>

<dd>
<p>A <span data-x="service-worker">service worker</span> that <span data-x="control">controls</span> this <span>environment settings object</span>. The value will
be either null or a <span data-x="service-worker">service worker</span>.</p>
</dd>

</dl>

<p>An <span>environment settings object</span> also has an <dfn>outstanding rejected promises
Expand Down Expand Up @@ -94270,6 +94324,10 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> {
data-x="concept-WorkerGlobalScope-module-map">module map</dfn>. It is a <span>module map</span>,
initially empty.</p>

<p>A <code>WorkerGlobalScope</code> object has an associated <dfn data-dfn-for="WorkerGlobalScope"
data-x="concept-WorkerGlobalScope-active-worker">active worker</dfn> (null or a <span
data-x="service-worker">service worker</span>). It is initially null.

<p>The <dfn><code data-x="dom-WorkerGlobalScope-self">self</code></dfn> attribute must return the
<code>WorkerGlobalScope</code> object itself.</p>

Expand Down Expand Up @@ -94601,6 +94659,28 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> {
<li><p>Execute the <span>Initialize a <code data-x="">global object</code>'s CSP list</span>
algorithm on <var>worker global scope</var> and <var>response</var>. <ref spec="CSP"></p>

<li>

<p>If <var>url</var> <span data-x="scope-match-algorithm">matched</span> a <span data-
x="service-worker-registration">service worker registration</span> <var>registration</var> when
the fetch algorithm obtained the resource, and <var>registration</var>'s <span data-x="active-
worker">active worker</span> <var>active worker</var> is not null, set <var>worker global
scope</var>'s <span data-x="concept-WorkerGlobalScope-active-worker">active worker</span> to
<var>active worker</var>.</p>

<p class="note"><span data-x="concept-fetch">Fetching</span> a <span data-x"non-subresource-
request">non-subresource</span> (except a <span data-x="service-worker">service worker</span>)
triggers a <span data-x="service-worker-registration">service worker registration</span> <span
data-x="scope-match-algorithm">matching</span> in the <span data-x="on-fetch-request-
algorithm">handle fetch</span> algorithm. If the <span data-x="concept-request">request</span>'s
<span data-x="concept-request-url">url</span> is under the <span data-x="scope-url">scope</span>
of a <span data-x="service-worker-registration">service worker registration</span>, and it has
an <span data-x="active-worker">active worker</span>, the <code>WorkerGlobalScope</code>
object's <span>environment settings object</span> represented by a <span data-x="worker-
client">worker client</span> starts to be <span data-x="control">controlled</span>.</p>

</li>

<li><p>If <var>is shared</var> is true, and there are any <span data-x="relevant application
cache">relevant application caches</span> that are identified by a manifest URL with the
<span>same origin</span> as <var>url</var> and that have <var>url</var> as one of their
Expand Down Expand Up @@ -94926,6 +95006,14 @@ interface <dfn>AbstractWorker</dfn> {

</dd>

<dt>The <span>active worker</span></dt>
<dd>

<p>Return <var>worker global scope</var>'s <span
data-x="concept-WorkerGlobalScope-active-worker">active worker</span>.</p>

</dd>

</dl>

</li>
Expand Down

0 comments on commit f8b1380

Please sign in to comment.