Re: [w3c/manifest] Add support for 'serviceworkers' member (#507)

marcoscaceres requested changes on this pull request.

Maybe I missed it, but did you also add processing the manifest member to: https://www.w3.org/TR/appmanifest/#processing

>                manifest</a>.
               </li>
               <li>If <a>obtaining the manifest</a> results in an error, a user
               agent can, at this point, fall back to using the <a>top-level
               browsing context</a>' <code>Document</code>'s metadata to
               populate an <a>installation process</a>' UI.
               </li>
+              <li>If <a>obtaining the manifest</a> succeeds, and the result of running the
+              <a>steps for processing the serviceworker member</a> with <a>manifest</a>
+              returns a valid <var>registration</var>, a user agent can at this point
+              <ol>
+                <li>Let <var>client</var> be the <a>top-level browsing context</a>'
+                <code>Document</code>'s
+                <a href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">
+                relevant settings object</a>, or <code>null</code> if unavailable.
+                <li>Invoke <a>Start Register</a> with <var>scope</var> and <var>src</var>
+                members of the <var>registration</var>, a new <var>promise</var>,
+                <var>client</var>, <a>manifest URL</a>, plus the <var>type</var> and <var>use_cache</var>
+                members of the <var>registration</var>,
+                </li>
+              </ol>
+              in which case the state of the settled <var>promise</var> determine whether the

nit: determines

>                manifest</a>.
               </li>
               <li>If <a>obtaining the manifest</a> results in an error, a user
               agent can, at this point, fall back to using the <a>top-level
               browsing context</a>' <code>Document</code>'s metadata to
               populate an <a>installation process</a>' UI.
               </li>
+              <li>If <a>obtaining the manifest</a> succeeds, and the result of running the
+              <a>steps for processing the serviceworker member</a> with <a>manifest</a>
+              returns a valid <var>registration</var>, a user agent can at this point
+              <ol>
+                <li>Let <var>client</var> be the <a>top-level browsing context</a>'
+                <code>Document</code>'s
+                <a href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">
+                relevant settings object</a>, or <code>null</code> if unavailable.
+                <li>Invoke <a>Start Register</a> with <var>scope</var> and <var>src</var>

q: should this be "Let registration be the result of Start Registration". 

The way this is spec'ed is a bit strange - I was expecting some kind of flow with the resulting promise... but it all seems to magically result in a registration. 

> @@ -2033,6 +2055,99 @@ <h3 id="applying">
           </p>
         </section>
       </section>
+
+      <section>
+        <h3>
+          <code>serviceworker</code> member
+        </h3>
+        <p>
+          The <dfn><code>serviceworker</code> member</dfn> describes a
+          service worker as defined in [[!SERVICE-WORKERS-1]].

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

> @@ -2033,6 +2055,99 @@ <h3 id="applying">
           </p>
         </section>
       </section>
+
+      <section>
+        <h3>
+          <code>serviceworker</code> member
+        </h3>
+        <p>
+          The <dfn><code>serviceworker</code> member</dfn> describes a
+          service worker as defined in [[!SERVICE-WORKERS-1]].
+        </p>
+        <p>
+          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

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

> @@ -2033,6 +2055,99 @@ <h3 id="applying">
           </p>
         </section>
       </section>
+
+      <section>
+        <h3>
+          <code>serviceworker</code> member
+        </h3>
+        <p>
+          The <dfn><code>serviceworker</code> member</dfn> describes a
+          service worker as defined in [[!SERVICE-WORKERS-1]].
+        </p>
+        <p>
+          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

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"

> +          The <dfn><code>serviceworker</code> member</dfn> describes a
+          service worker as defined in [[!SERVICE-WORKERS-1]].
+        </p>
+        <p>
+          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
+          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>
+          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>. This algorithm returns a
+          registration object <var>registration</var>, which can be <code>undefined</code>.

nit: link to registration object? 

> +        <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>. This algorithm returns a
+          registration object <var>registration</var>, which can be <code>undefined</code>.
+        </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>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>Is origin potentially trustworthy</a>

nit: capital "Is"

> +          with the origin of <var>src</var> is <code>Not Trusted</code>, abort
+          these steps and return <code>undefined</code>.
+          </li>
+          <li>Otherwise, let <var>registration</var> be an object with
+          properties <code>src</code>, <code>scope</code>, <code>type</code> and
+          <code>use_cache</code>. All properties initially set to
+          <code>undefined</code>.
+          </li>
+          <li>Set <var>registration</var>'s <code>src</code> property to be
+          <var>src</var>.
+          </li>
+          <li>Let <var>scope</var> be the result of running the <a>steps
+          for processing the <code>scope</code> member of a service worker</a>
+          passing <var>unprocessed registration</var>.
+          </li>
+          <li>If <var>scope</var> is <code>undefined</code> abort these steps and

Warn developer? 

> +        <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>. This algorithm returns a
+          registration object <var>registration</var>, which can be <code>undefined</code>.
+        </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>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>Is origin potentially trustworthy</a>

Probably warn developer here too

> +          <li>Let <var>scope</var> be the result of running the <a>steps
+          for processing the <code>scope</code> member of a service worker</a>
+          passing <var>unprocessed registration</var>.
+          </li>
+          <li>If <var>scope</var> is <code>undefined</code> abort these steps and
+          return <code>undefined</code>.
+          </li>
+          <li>Otherwise, set <var>registration</var>'s <code>scope</code>
+          property to be <var>scope</var>.
+          </li>
+          <li>Let <var>type</var> be the result of running the <a>steps
+          for processing the <code>type</code> member of a service worker</a>
+          passing <var>unprocessed registration</var>.
+          </li>
+          <li>If <var>type</var> is <code>undefined</code> abort these steps and
+          return <code>undefined</code>.

Warn developer? ... so touchy, these service workers! 

> +          passing <var>unprocessed registration</var>.
+          </li>
+          <li>If <var>use cache</var> is <code>undefined</code> abort these steps
+          and return <code>undefined</code>.
+          </li>
+          <li>Otherwise, set <var>registration</var>'s <code>use_cache</code>
+          property to be <var>use cache</var>.
+          </li>
+          <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, bypassing the user agent cache
+          when fetching the <code>"sw.js"</code> source:
+<pre class="example">

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

> @@ -2816,6 +2931,181 @@ <h3 id="applying">
     </section>
     <section>
       <h2>
+        The serviceworker object and its members
+      </h2>
+      <p>
+        A <dfn>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.

You might want to check if this is the same in the SW spec. Just the wording seems odd as SWs are just script resources. 

> +          <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>.

nit, scope URL should be defined at the end of the document, so not to include the link to the SW spec here.

> +      </section>
+      <section>
+        <h3>
+          <code>type</code> member
+        </h3>
+        <p>
+          The <dfn data-lt="serviceworker-type"><code>type</code> member</dfn> of a
+          <a>serviceworker object</a> is the service worker's
+          <a href="https://html.spec.whatwg.org/multipage/workers.html#workertype">worker type</a>.
+        </p>
+        <p>
+          The <dfn>steps for processing the <code>type</code> member of a
+          service worker</dfn> are given by the following algorithm. The algorithm takes
+          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

Hmm... what if the manifest redirected during fetch... we might need to clarify that somewhere. 

> +          </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 and
+              return <code>undefined</code>.
+              </li>
+              <li>Return <code>"classic"</code>.
+              </li>
+            </ol>
+          </li>
+          <li>If <a>Trim</a>(value) is the empty string, then:
+            <ol>
+              <li>Issue a developer warning that the type is unsupported.

This seems odd... you are returning undefined here, but "classic" above? 

> +          </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 and
+              return <code>undefined</code>.
+              </li>
+              <li>Return <code>"classic"</code>.
+              </li>
+            </ol>
+          </li>
+          <li>If <a>Trim</a>(value) is the empty string, then:
+            <ol>
+              <li>Issue a developer warning that the type is unsupported.

I.e., should we recover to "classic" in error cases for backwards compat? 

> +              <li>If <var>type</var> is not "<code>undefined</code>", issue a
+              developer warning that the type is unsupported and
+              return <code>undefined</code>.
+              </li>
+              <li>Return <code>"classic"</code>.
+              </li>
+            </ol>
+          </li>
+          <li>If <a>Trim</a>(value) is the empty string, then:
+            <ol>
+              <li>Issue a developer warning that the type is unsupported.
+              </li>
+              <li>Return <code>undefined</code>.
+              </li>
+            </ol>
+          <li>Otherwise, <a>Trim</a>(<var>value</var>) and return the result.

Also, should should this be restricted to just "classic" and "module"? 

> +          boolean.
+        </p>
+        <ol>
+          <li>Let <var>value</var> be the result of calling the
+          <a>[[\GetOwnProperty]]</a> internal method of <var>registration</var>
+          passing " <code>use_cache</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 "boolean", then:
+            <ol>
+              <li>If <var>type</var> is not "<code>undefined</code>", issue a
+              developer warning that the type is unsupported and
+              return <code>undefined</code>.
+              </li>
+              <li>Otherwise, return False</li>

nit: return `<code>false</code>` 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/pull/507#pullrequestreview-14529660

Received on Wednesday, 28 December 2016 07:08:58 UTC