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

Add support for 'serviceworkers' member #507

Merged
merged 9 commits into from
Jan 17, 2017
41 changes: 24 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2048,51 +2048,54 @@ <h3>
service worker as defined in [[!SERVICE-WORKERS-1]].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is there some unversioned reference we can use here instead of V1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as far as I could see. @jungkees ?

</p>
<p>
The <a><code>serviceworker</code> member</a> represents a service worker
registration. Other service worker registrations can be done, for instance
The <a><code>serviceworker</code> member</a> represents a <a
href="https://w3c.github.io/ServiceWorker/#service-worker-registration-concept">
service worker registration</a>. Other service worker registrations can be done, for instance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text "Other service worker registrations can be done" should be in a non-normative note.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you are redefining the rules - which is a bit dangerous. That should point to the SW spec, like:

"For rules on how SWs interact, then see section X of Service Workers"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it a note now. @jungkees can you point me to the best place to refer to?

by a script; if these have different scopes they will be considered separate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably not re-specify the rules that are in the service worker spec; we should reference them.

registrations. If they have the same scope and script URL, they coalesce.
If they have different script URLs, last one wins.
</p>
<p>
The <dfn>steps for processing the <code>serviceworker</code>
member</dfn> are given by the following algorithm. The algorithm
takes a <a>manifest</a> <var>manifest</var> and <a>serviceworker object</a>
<var>serviceworker</var> as an argument. This algorithm returns a
serviceworker object <var>serviceworker</var>, which can be <code>undefined</code>.
takes a <a>manifest</a> <var>manifest</var>. This algorithm returns a
registration object <var>registration</var>, which can be <code>undefined</code>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: link to registration object?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

</p>
<ol>
<li>Let <var>unprocessed registration</var> be the result of calling the
<a>[[\GetOwnProperty]]</a> internal method of <var>manifest</var>
with argument "<code>serviceworker</code>".
<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>serviceworker</var> and <var>manifest URL</var>.
with <var>unprocessed registration</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>
running <a>Is origin potentially trustworthy</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: capital "Is"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably warn developer here too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

with the origin of <var>src</var> is <code>Not Trusted</code>, return
<code>undefined</code>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screwing up the security aspects of the registration is a pretty big error... so we should maybe pass this through and just allow service worker registration to fail (and kill the whole object then)

</li>
<li>Otherwise, let <var>serviceworker</var> be an object with
<li>Otherwise, let <var>registration</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>serviceworker</var>'s <code>src</code> property to be
<li>Set <var>registration</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>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this algorithm returns undefined, the steps to install the web application gets to pass nothing to Start Register. In this case, shouldn't there be an error handling such that Start Register is not invoked?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check that, it should not be invoked no

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

          <li>If <a>obtaining the manifest</a> succeeds, and the
          <var>service worker registration</var> of <a>manifest</a> is not
          <code>undefined</code>, a user agent can at this point...

It is not invoked if it fails

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good.

passing <var>serviceworker</var>.
passing <var>unprocessed registration</var>.
</li>
<li>If <var>scope</var> is not <code>undefined</code>,
set<var>serviceworker</var>'s <code>scope</code>
set <var>registration</var>'s <code>scope</code>
property to be <var>scope</var>.
</li>
<li>Return <var>serviceworker</var>.
<li>Return <var>registration</var>.
</li>
</ol>
<div class="example">
In the following example, the web application is listing
a service worker for the <code>/foo</code> scope:
<pre class="">
<pre class="example">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can indent this normally, ReSpec handles that for you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

"serviceworker": {
"src": "sw.js",
"scope": "/foo"
Expand Down Expand Up @@ -2904,14 +2907,14 @@ <h3>
<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
a <a>serviceworker object</a> <var>registration</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>
<a>[[\GetOwnProperty]]</a> internal method of <var>registration</var>
passing " <code>src</code>" as the argument.
</li>
<li>Let <var>type</var> be <a>Type</a>(<var>value</var>).
Expand Down Expand Up @@ -2945,14 +2948,14 @@ <h3>
<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
a <a>serviceworker object</a> <var>registration</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>
<a>[[\GetOwnProperty]]</a> internal method of <var>registration</var>
passing " <code>scope</code>" as the argument.
</li>
<li>Let <var>type</var> be <a>Type</a>(<var>value</var>).
Expand Down Expand Up @@ -3149,6 +3152,10 @@ <h2>
<dfn><code>default-src</code></dfn></a> directives are defined in
[[!CSP3]].
</p>
<p>
The <a href="https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy">
<dfn>Is origin potentially trustworthy</dfn></a> is defined in [[!SECURE-CONTEXTS]]
</p>
<p>
The <a href=
"https://www.ecma-international.org/ecma-402/1.0/#sec-6.2.2"><dfn>IsStructurallyValidLanguageTag</dfn></a>
Expand Down