Skip to content

Commit

Permalink
Add support for 'serviceworkers' member
Browse files Browse the repository at this point in the history
  • Loading branch information
kenchris committed Oct 20, 2016
1 parent 12691c2 commit f9d9715
Showing 1 changed file with 199 additions and 2 deletions.
201 changes: 199 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ <h2>
</p>
<p>
A developer specifies the navigation scope via the
<a><code>scope</code> member</a>. In the case where the
<a><code>scope</code> member</a> is missing or in error, the navigation
<a data-lt="member-scope"><code>scope</code> member</a>. In the case where the
<a data-lt="member-scope"><code>scope</code> member</a> is missing or in error, the navigation
scope is treated as <dfn>unbounded</dfn> (represented as the value
<code>undefined</code>). In such a case, the manifest is applied to all
URLs the application context is <a>navigated</a> to (see related
Expand Down Expand Up @@ -1143,6 +1143,11 @@ <h3>
<code>start_url</code> member</a> with <var>manifest</var>,
<var>manifest URL,</var> and <var>document URL</var> as arguments.
</li>
<li>Let <var>service workers</var> of <var>parsed manifest</var> be
the result of running the <a>steps for processing an array of
service workers</a> with <var>manifest</var>, <var>manifest URL</var>,
and "serviceworkers" as arguments.
</li>
<li>Let <var>display mode</var> of <var>parsed manifest</var> be the
result of running the <a>steps for processing the
<code>display</code> member</a> with <var>manifest</var> as the
Expand Down Expand Up @@ -1937,6 +1942,39 @@ <h3>
</p>
</section>
</section>

<section>
<h3>
<code>serviceworkers</code> member
</h3>
<p>
The <dfn><code>serviceworkers</code> member</dfn> is a <a>string</a> that
represents any associated <dfn>service worker</dfn>.
</p>
<p>
The <a><code>serviceworkers</code> member</a> represents a service worker
registration. Other service worker registrations can be done, for instance
by a script; if these have different scopes they will be considered separate
registrations. If they have the same scope and script URL, they coalesce.
If they have different script URLs, last one wins.
</p>
<p class="note">
The <code>serviceworkers</code> member is processed using the <a>steps for
processing an array of service workers</a>.
</p>
<div class="example">
<pre class="">
"serviceworkers": [{
"src": "sw.js",
"scope": "/foo",
"options": {}
}
</pre>
</div>
</section>



<section>
<h3>
<code title="">theme_color</code> member
Expand Down Expand Up @@ -2711,6 +2749,165 @@ <h3>
</ol>
</section>
</section>
<section>
<h2>
The serviceworker object and its members
</h2>
<p>
Each <dfn data-lt="serviceworker objects">serviceworker object</dfn> represents a service worker
registration for the web application.
</p>
<section>
<h3>
<code>src</code> member
</h3>
<p>
The <dfn data-lt="serviceworker-src"><code>src</code> member</dfn> of a
<a>serviceworker object</a> is a <a>URL</a> representing a
service worker.
</p>
<p>
The <dfn>steps for processing the <code>src</code> member of a
service worker</dfn> are given by the following algorithm. The algorithm takes
a <a>serviceworker object</a> <var>serviceworker</var>, and a <a>URL</a> <var>manifest
URL</var>, which is the <a>URL</a> from which the
<var>manifest</var> was fetched. This algorithm will return a
<a>URL</a> or <code>undefined</code>.
</p>
<ol>
<li>Let <var>value</var> be the result of calling the
<a>[[\GetOwnProperty]]</a> internal method of <var>serviceworker</var>
passing " <code>src</code>" as the argument.
</li>
<li>Let <var>type</var> be <a>Type</a>(<var>value</var>).
</li>
<li>If <var>type</var> is not "string", then:
<ol>
<li>If <var>type</var> is not "<code>undefined</code>", issue a
developer warning that the type is unsupported.
</li>
<li>Return <code>undefined</code>.
</li>
</ol>
</li>
<li>If <a>Trim</a>(value) is the empty string, then return
<code>undefined</code>.
</li>
<li>Otherwise, <a>parse</a> <var>value</var> using <var>manifest
URL</var> as the base URL and return the result.
</li>
</ol>
</section>
<section>
<h3>
<code>scope</code> member
</h3>
<p>
The <dfn data-lt="serviceworker-scope"><code>scope</code> member</dfn> of a
<a>serviceworker object</a> is the service worker's associated
<a href="https://w3c.github.io/ServiceWorker/#dfn-scope-url">scope URL</a>.
</p>
<p>
The <dfn>steps for processing the <code>scope</code> member of a
service worker</dfn> are given by the following algorithm. The algorithm takes
a <a>serviceworker object</a> <var>serviceworker</var>, and a <a>URL</a> <var>manifest
URL</var>, which is the <a>URL</a> from which the
<var>manifest</var> was fetched. This algorithm will return a
<a>URL</a> or <code>undefined</code>.
</p>
<ol>
<li>Let <var>value</var> be the result of calling the
<a>[[\GetOwnProperty]]</a> internal method of <var>serviceworker</var>
passing " <code>scope</code>" as the argument.
</li>
<li>Let <var>type</var> be <a>Type</a>(<var>value</var>).
</li>
<li>If <var>type</var> is not "string", then:
<ol>
<li>If <var>type</var> is not "<code>undefined</code>", issue a
developer warning that the type is unsupported.
</li>
<li>Return <code>undefined</code>.
</li>
</ol>
</li>
<li>If <a>Trim</a>(value) is the empty string, then return
<code>undefined</code>.
</li>
<li>Otherwise, <a>parse</a> <var>value</var> using <var>manifest
URL</var> as the base URL and return the result.
</li>
</ol>
</section>
<section>
<h3>
Processing an array of service workers
</h3>
<p>
The <dfn>steps for processing an array of service workers</dfn> are given by
the following algorithm. The algorithm takes a manifest, a <a>URL</a>
<var>manifest URL</var>, which is the URL from which the
<var>manifest</var> was fetched. This algorithm returns a list of <a>serviceworker
objects</a>, which can be empty.
</p>
<ol>
<li>Let <var>serviceworkers</var> be an empty list.
</li>
<li>Let <var>unprocessed serviceworkers</var> be the result of calling the
<a>[[\GetOwnProperty]]</a> internal method of <var>manifest</var>
with <var>"serviceworkers</var> as the argument.
</li>
<li>If <var>unprocessed serviceworkers</var> is an <a>array</a>, then:
<ol>
<li>From unprocessed serviceworkers, filter out any <var>item</var> where
<a>HasOwnProperty</a>(item,"src") returns <code>false</code>.
</li>
<li>For each <var>potential service worker</var> in the array:
<ol>
<li>Let <var>src</var> be the result of running the <a>steps
for processing the <code>src</code> member of a service worker</a>
with <var>potential service worker</var> and <var>manifest URL</var>.
</li>
<li>If <var>src</var> is <code>undefined</code>, or if the result of
running <a href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#is-origin-trustworthy">Is origin potentially trustworthy</a>
with the origin of <var>src</var> is <code>Not Trusted</code>, move onto
the next item in <var>serviceworkers</var> (if any are left).
</li>
<li>Otherwise, let <var>serviceworker</var> be an object with
properties <code>src</code> and <code>scope</code>. All properties
initially set to <code>undefined</code>.
</li>
<li>Set <var>serviceworkers</var>'s <code>src</code> property to be
<var>src</var>.
</li>
<li>Let <var>type</var> be the result of running the <a>steps
for processing the <code>scope</code> member of a service worker</a>
passing <var>potential service worker</var>.
</li>
<li>If <var>scope</var> is not <code>undefined</code>, set
<var>serviceworkers</var>'s <code>scope</code> property to be
<var>scope</var>.
</li>
<li>Append <var>serviceworker</var> to <var>serviceworkers</var>.
</li>
</ol>
</li>
</ol>
</li>
<li>Otherwise, if <var>unprocessed serviceworkers</var> is not
<code>undefined</code>:
<ol>
<li>
<a>Issue a developer warning</a> that the type is not
supported.
</li>
</ol>
</li>
<li>Return <var>serviceworkers</var>.
</li>
</ol>
</section>
</section>
<section>
<h2>
Application object and its members
Expand Down

0 comments on commit f9d9715

Please sign in to comment.