From 79437cdac1c8638677f10387f58cde5f055ae318 Mon Sep 17 00:00:00 2001 From: "Michael[tm] Smith" Date: Mon, 12 Jun 2017 17:55:51 +0900 Subject: [PATCH] =?UTF-8?q?Update=20the=20=E2=80=9CLink=20type=20"servicew?= =?UTF-8?q?orker"=E2=80=9D=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add new section “Declaring a "serviceworker" Link header” * Drop normative requirement to fire an error if link[workertype] value isn’t a valid worker type; instead just abort. * Drop the partial interface IDL for the HTMLLinkElement interface (the definitions for the IDL attributes have already been merged directly into the HTMLLinkElement interface IDL definition in the HTML spec). Fixes #1073 --- docs/index.bs | 55 ++++++------ docs/index.html | 222 ++++++++++++++++++++---------------------------- 2 files changed, 125 insertions(+), 152 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 490deb0d..1f8e394b 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -86,6 +86,7 @@ spec: rfc5988; urlPrefix: https://tools.ietf.org/html/rfc5988 type: dfn text: context IRI; url: section-5.2 text: target attribute; url: section-5.4 + text: target attributes; url: section-5.4 text: target IRI; url: section-5.1 spec: rfc7230; urlPrefix: https://tools.ietf.org/html/rfc7230 @@ -1769,12 +1770,36 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
- + - The serviceworker keyword may be used with <{link}> elements. This keyword creates an external resource link (serviceworker link) that is used to declare a [=/service worker registration=] and its [=service worker registration/scope url=]. + A [=/service worker registration=] and its [=service worker registration/scope url=] are created by a serviceworker link, which is declared using a "serviceworker" `Link` header or a <{link}> element whose <{link/rel}> attribute contains the keyword "<{link/rel/serviceworker}>".
- + + + A serviceworker link can be declared using a `Link` header [[!RFC5988]] with "`serviceworker`" as the value of the "`rel`" parameter and a [=service worker/script url=] as the target IRI, and the following optional target attributes: + + : `scope` + :: Value: A [=service worker registration/scope url=]. + + : `workertype` + :: Value: A [=job/worker type=]. + + : `updateviacache` + :: Value: An [=service worker registration/update via cache mode=]. + + The "`anchor`" parameter must not be specified. + +
+
+        Link: <sw.js>; rel="serviceworker"; scope="/"; workertype="module"; updateviacache="all"
+      
+
+ +
+ +
+ When a user agent that supports [[!RFC5988]] processes a Link header that contains a serviceworker link, the user agent *should* run these steps: @@ -1793,7 +1818,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
- + When a serviceworker link's <{link}> element is inserted into a document, or a serviceworker link is created on a <{link}> element that is already in a document tree, or the <{link/href}>, <{link/scope}>, or <{link/updateviacache}> attributes of the <{link}> element of a serviceworker link is changed, the user agent *should* run these steps: @@ -1803,8 +1828,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |scriptURL| be the result of parsing the <{link/href}> attribute with the <{link}> element's node document's document base URL. 1. Let |scopeURL| be null. 1. If the <{link/scope}> attribute is present, set |scopeURL| to the result of parsing the <{link/scope}> attribute with the <{link}> element's node document's document base URL. - 1. Let |workerType| be the <{link/workertype}> attribute, or "classic" if the <{link/workertype}> attribute is omitted. - 1. If |workerType| is not a valid {{WorkerType}} value, queue a task to fire an event named error at the <{link}> element, and abort these steps. + 1. Let |workerType| be the state of the <{link/workertype}> attribute. + 1. If |workerType| is invalid, abort these steps. 1. Let |updateViaCache| be the <{link/updateviacache}> attribute, or "`imports`" if the <{link/updateviacache}> attribute is omitted. 1. Let |promise| be a new promise. 1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |promise|, |client|, |client|'s creation URL, |workerType|, and |updateViaCache|. @@ -1836,24 +1861,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
- -
- - -
-      partial interface HTMLLinkElement {
-        [CEReactions] attribute USVString scope;
-        [CEReactions] attribute WorkerType workerType;
-        [CEReactions] attribute ServiceWorkerUpdateViaCache updateViaCache;
-      };
-    
- - The scope IDL attribute must reflect the element's scope content attribute. - - The workerType IDL attribute must reflect the element's workertype content attribute. - - The updateViaCache IDL attribute must reflect the element's updateViaCache content attribute. -
diff --git a/docs/index.html b/docs/index.html index dc7fc85b..e91be578 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1425,7 +1425,7 @@

Service Workers Nightly

-

Editor’s Draft,

+

Editor’s Draft,

This version: @@ -1616,9 +1616,9 @@

Table of Contents

  • 5 Link type "serviceworker"
      -
    1. 5.1 Processing the Link header -
    2. 5.2 Processing the link element -
    3. 5.3 Link element interface extensions +
    4. 5.1 Declaring a "serviceworker" Link header +
    5. 5.2 Processing a "serviceworker" Link header +
    6. 5.3 Processing a "serviceworker" link element
  • 6 Caches @@ -3639,10 +3639,31 @@

    -

    The serviceworker keyword may be used with link elements. This keyword creates an external resource link (serviceworker link) that is used to declare a service worker registration and its scope url.

    +

    A service worker registration and its scope url are created by a serviceworker link, which is declared using a "serviceworker" Link header or a link element whose rel attribute contains the keyword "serviceworker".

    - -

    When a user agent that supports [RFC5988] processes a Link header that contains a serviceworker link, the user agent should run these steps:

    + +

    A serviceworker link can be declared using a Link header [RFC5988] with "serviceworker" as the value of the "rel" parameter and a script url as the target IRI, and the following optional target attributes:

    +
    +
    scope +
    +

    Value: A scope url.

    +
    workertype +
    +

    Value: A worker type.

    +
    updateviacache +
    +

    Value: An update via cache mode.

    +
    +

    The "anchor" parameter must not be specified.

    +
    + +
    Link: <sw.js>; rel="serviceworker"; scope="/"; workertype="module"; updateviacache="all"
    +
    +
    +
    +
    + +

    When a user agent that supports [RFC5988] processes a Link header that contains a serviceworker link, the user agent should run these steps:

    1. If the Link header has an "anchor" parameter, abort these steps.

      @@ -3671,8 +3692,8 @@
    - -

    When a serviceworker link’s link element is inserted into a document, or a serviceworker link is created on a link element that is already in a document tree, or the href, scope, or updateviacache attributes of the link element of a serviceworker link is changed, the user agent should run these steps:

    + +

    When a serviceworker link’s link element is inserted into a document, or a serviceworker link is created on a link element that is already in a document tree, or the href, scope, or updateviacache attributes of the link element of a serviceworker link is changed, the user agent should run these steps:

    1. If the href attribute is the empty string, abort these steps.

      @@ -3685,13 +3706,13 @@
    -

    The serviceworker link element must not delay the load event of the element’s node document.

    +

    The serviceworker link element must not delay the load event of the element’s node document.

    A resource being loaded with the following response header:
    Link: </js/sw.js>; rel="serviceworker"; scope="/"
    @@ -3720,18 +3741,6 @@ 
    -
    - -
    partial interface HTMLLinkElement {
    -  [CEReactions] attribute USVString scope;
    -  [CEReactions] attribute WorkerType workerType;
    -  [CEReactions] attribute ServiceWorkerUpdateViaCache updateViaCache;
    -};
    -
    -

    The scope IDL attribute must reflect the element’s scope content attribute.

    -

    The workerType IDL attribute must reflect the element’s workertype content attribute.

    -

    The updateViaCache IDL attribute must reflect the element’s updateViaCache content attribute.

    -

    6. Caches

    @@ -4478,7 +4487,7 @@

    cache mode to "no-cache" if any of the following are true:

    -

    A job queue is a thread safe queue used to synchronize the set of concurrent jobs. The job queue contains jobs as its elements. The job queue should satisfy the general properties of FIFO queue. A user agent must maintain a separate job queue for each service worker registration keyed by its scope url. A job queue is initially empty. Unless stated otherwise, the job queue referenced from the algorithm steps is a job queue for the job’s scope url.

    +

    A job queue is a thread safe queue used to synchronize the set of concurrent jobs. The job queue contains jobs as its elements. The job queue should satisfy the general properties of FIFO queue. A user agent must maintain a separate job queue for each service worker registration keyed by its scope url. A job queue is initially empty. Unless stated otherwise, the job queue referenced from the algorithm steps is a job queue for the job’s scope url.

    Create Job

    @@ -4768,9 +4777,9 @@

    referrer, a URL

    -

    workerType, a worker type

    +

    workerType, a worker type

    -

    updateViaCache, an update via cache mode

    +

    updateViaCache, an update via cache mode

    Output

    none

    @@ -4794,7 +4803,7 @@

  • Let job be the result of running Create Job with register, scopeURL, scriptURL, promise, and client.

  • -

    Set job’s worker type to workerType.

    +

    Set job’s worker type to workerType.

  • Set job’s update via cache mode to updateViaCache.

  • @@ -4848,7 +4857,7 @@

    Let newestWorker be the result of running the Get Newest Worker algorithm passing registration as the argument.

  • -

    If newestWorker is not null, job’s script url equals newestWorker’s script url with the exclude fragments flag set, and job’s update via cache mode's value equals registration’s update via cache mode, then:

    +

    If newestWorker is not null, job’s script url equals newestWorker’s script url with the exclude fragments flag set, and job’s update via cache mode's value equals registration’s update via cache mode, then:

    1. Invoke Resolve Job Promise with job and the ServiceWorkerRegistration object which represents registration.

      @@ -4890,7 +4899,7 @@

      Let newestWorker be the result of running Get Newest Worker algorithm passing registration as the argument.

    2. -

      If job’s job type is update, and newestWorker’s script url does not equal job’s script url with the exclude fragments flag set, then:

      +

      If job’s job type is update, and newestWorker’s script url does not equal job’s script url with the exclude fragments flag set, then:

      1. Invoke Reject Job Promise with job and a TypeError.

        @@ -4902,7 +4911,7 @@

        Let referrerPolicy be the empty string.

      2. -

        Switching on job’s worker type, run these substeps with the following options:

        +

        Switching on job’s worker type, run these substeps with the following options:

        "classic"
        @@ -4920,7 +4929,7 @@

        Set request’s cache mode to "no-cache" if any of the following are true:

    3. -

      Let scopeURL be registration’s scope url.

      +

      Let scopeURL be registration’s scope url.

    4. Let maxScopeString be null.

    5. @@ -5004,7 +5013,7 @@

      Else, continue the rest of these steps after the algorithm’s asynchronous completion, with script being the asynchronous completion value.

    6. -

      If newestWorker is not null, newestWorker’s script url equals job’s script url with the exclude fragments flag set, and script’s source text is a byte-for-byte match with newestWorker’s script resource's source text, if script is a classic script, and script’s module record's [[ECMAScriptCode]] is a byte-for-byte match with newestWorker’s script resource's module record's [[ECMAScriptCode]] otherwise, then:

      +

      If newestWorker is not null, newestWorker’s script url equals job’s script url with the exclude fragments flag set, and script’s source text is a byte-for-byte match with newestWorker’s script resource's source text, if script is a classic script, and script’s module record's [[ECMAScriptCode]] is a byte-for-byte match with newestWorker’s script resource's module record's [[ECMAScriptCode]] otherwise, then:

      1. Invoke Resolve Job Promise with job and the ServiceWorkerRegistration object which represents registration.

        @@ -5019,7 +5028,7 @@

        Generate a unique opaque string and set worker’s id to the value.

      2. -

        Set worker’s script url to job’s script url, worker’s script resource to script, and worker’s type to job’s worker type.

        +

        Set worker’s script url to job’s script url, worker’s script resource to script, and worker’s type to job’s worker type.

      3. Set worker’s script resource’s HTTPS state to httpsState.

      4. @@ -5061,9 +5070,9 @@

        If newestWorker is null, abort these steps.

      5. -

        Let job be the result of running Create Job with update, registration’s scope url, newestWorker’s script url, null, and null.

        +

        Let job be the result of running Create Job with update, registration’s scope url, newestWorker’s script url, null, and null.

      6. -

        Set job’s worker type to newestWorker’s type.

        +

        Set job’s worker type to newestWorker’s type.

      7. Set job’s force bypass cache flag if the force bypass cache flag is set.

      8. @@ -5098,7 +5107,7 @@

        Invoke Resolve Job Promise with job and the ServiceWorkerRegistration object which represents registration.

      9. -

        Queue a task to fire an event named updatefound at all the ServiceWorkerRegistration objects for all the service worker clients whose creation URL matches registration’s scope url and all the service workers whose containing service worker registration is registration.

        +

        Queue a task to fire an event named updatefound at all the ServiceWorkerRegistration objects for all the service worker clients whose creation URL matches registration’s scope url and all the service workers whose containing service worker registration is registration.

      10. Let installingWorker be registration’s installing worker.

      11. @@ -5192,7 +5201,7 @@

        Run the Update Worker State algorithm passing registration’s active worker and activating as the arguments.

        Note: Once an active worker is activating, neither a runtime script error nor a force termination of the active worker prevents the active worker from getting activated.

      12. -

        For each service worker client client whose creation URL matches registration’s scope url:

        +

        For each service worker client client whose creation URL matches registration’s scope url:

        1. If client is a window client, unassociate client’s responsible document from its application cache, if it has one.

          @@ -5311,7 +5320,7 @@

          The API base URL
          -

          Return serviceWorker’s script url.

          +

          Return serviceWorker’s script url.

          The origin

          Return its registering service worker client's origin.

          @@ -5323,7 +5332,7 @@

          HTTPS state.

  • -

    Set workerGlobalScope’s url to serviceWorker’s script url.

    +

    Set workerGlobalScope’s url to serviceWorker’s script url.

  • Set workerGlobalScope’s HTTPS state to serviceWorker’s script resource’s HTTPS state.

  • @@ -5903,7 +5912,7 @@

    scope, a URL

    -

    updateViaCache, an update via cache mode

    +

    updateViaCache, an update via cache mode

    Output

    registration, a service worker registration

    @@ -5914,7 +5923,7 @@

    Let scopeString be serialized scope with the exclude fragment flag set.

  • -

    Let registration be a new service worker registration whose scope url is set to scope and update via cache mode is set to updateViaCache.

    +

    Let registration be a new service worker registration whose scope url is set to scope and update via cache mode is set to updateViaCache.

  • Set scope to registration map[scopeString] to registration.

  • @@ -5965,7 +5974,7 @@

    Update Registration State algorithm passing registration, "active" and null as the arguments.

  • -

    Let scopeString be serialized registration’s scope url with the exclude fragment flag set.

    +

    Let scopeString be serialized registration’s scope url with the exclude fragment flag set.

  • Remove scope to registration map[scopeString].

    @@ -6559,7 +6568,7 @@

    `Service-Worker-Allowed`
    -

    Indicates the user agent will override the path restriction, which limits the maximum allowed scope url that the script can control, to the given value.

    +

    Indicates the user agent will override the path restriction, which limits the maximum allowed scope url that the script can control, to the given value.

    Note: The value is a URL. If a relative URL is given, it is parsed against the script’s URL.

  • @@ -7001,8 +7010,6 @@

    attribute for ServiceWorkerRegistration, in §3.2.5
  • dict-member for RegistrationOptions, in §3.4 -
  • attribute for HTMLLinkElement, in §5.3 -
  • element-attr for link, in §5.3
  • scopes, in §4.5
  • scope to registration map, in §Unnumbered section @@ -7043,7 +7050,6 @@

    ServiceWorkerGlobalScope, in §4.1
  • Service Worker Has No Pending Events, in §Unnumbered section
  • serviceworker link, in §5 -
  • serviceworker link type, in §5
  • ServiceWorkerRegistration, in §3.2
  • service worker registration @@ -7110,8 +7116,6 @@

    attribute for ServiceWorkerRegistration, in §3.2.6
  • dict-member for RegistrationOptions, in §3.4 -
  • attribute for HTMLLinkElement, in §5.3 -
  • element-attr for link, in §5.3
  • update via cache mode @@ -7142,8 +7146,6 @@

    worker, in §4.3
  • "worker", in §4.3
  • worker client, in §2.3 -
  • workertype, in §5.3 -
  • workerType, in §5.3
  • worker type, in §Unnumbered section

    Terms defined by reference

    @@ -7172,7 +7174,6 @@

    fire an event
  • in a document tree
  • node document -
  • reflect
  • stop immediate propagation flag
  • stop propagation flag
  • type @@ -7273,11 +7274,9 @@

    [HTML] defines the following terms:
  • [INFRA] defines the following terms: @@ -7433,6 +7436,7 @@

  • context iri
  • target attribute +
  • target attributes
  • target iri
  • @@ -7759,12 +7763,6 @@

    I sequence<MessagePort> ports = []; }; -partial interface HTMLLinkElement { - [CEReactions] attribute USVString scope; - [CEReactions] attribute WorkerType workerType; - [CEReactions] attribute ServiceWorkerUpdateViaCache updateViaCache; -}; - partial interface WindowOrWorkerGlobalScope { [SecureContext, SameObject] readonly attribute CacheStorage caches; }; @@ -7878,10 +7876,11 @@

    3.1.1. scriptURL
  • 3.2.7. update() -
  • Register -
  • Update (2) (3) -
  • Soft Update -
  • Run Service Worker (2) +
  • 5.1. Declaring a "serviceworker" Link header +
  • Register +
  • Update (2) (3) +
  • Soft Update +
  • Run Service Worker (2) @@ -9480,44 +9480,9 @@

    #dfn-serviceworker-linkReferenced in: - - - - - - -