From 855d54f2755380a39d238f6e6d392032ac375304 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Tue, 6 Sep 2016 21:14:16 +0900 Subject: [PATCH] Backport https://github.com/w3c/ServiceWorker/commit/883fe798a178d5f5a5de653b1be21bb78949d81b and https://github.com/w3c/ServiceWorker/commit/352dc931b0c89f87907e4ec9f770c224c1630bee to V1 and fix xrefs --- spec/service_worker/index.bs | 18 ++++---- spec/service_worker/index.html | 68 +++++++++++++--------------- spec/service_worker_1/index.bs | 66 +++++++++++++-------------- spec/service_worker_1/index.html | 76 +++++++++++++++----------------- 4 files changed, 107 insertions(+), 121 deletions(-) diff --git a/spec/service_worker/index.bs b/spec/service_worker/index.bs index 704cb7b3..21c48790 100644 --- a/spec/service_worker/index.bs +++ b/spec/service_worker/index.bs @@ -92,13 +92,13 @@ spec: html; type: dfn text: structured clone text: task sources text: tasks - text: the environment settings object's global object text: the global object's realm + text: the Realm's global object text: the worker's documents text: top-level browsing context text: triggered by user activation text: trusted event - text: unicode serialisation of an origin + text: Unicode serialization of an origin text: unload a document text: user interaction task source text: utf-8 decode @@ -527,7 +527,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
  1. Create an event e that uses the {{ExtendableMessageEvent}} interface, with the event type message, which does not bubble and is not cancelable.
  2. Let the {{ExtendableMessageEvent/data}} attribute of e be initialized to clonedMessage.
  3. -
  4. Let the {{ExtendableMessageEvent/origin}} attribute of e be initialized to the Unicode serialisation of incumbentSettings's origin.
  5. +
  6. Let the {{ExtendableMessageEvent/origin}} attribute of e be initialized to the Unicode serialization of incumbentSettings's origin.
  7. If incumbentGlobal is a {{ServiceWorkerGlobalScope}} object, let the {{ExtendableMessageEvent/source}} attribute of e be initialized to a new {{ServiceWorker}} object that represents incumbentGlobal's service worker.
  8. Else if incumbentGlobal is a {{Window}} object, let the {{ExtendableMessageEvent/source}} attribute of e be initialized to a new {{WindowClient}} object that represents incumbentGlobal's browsing context.
  9. Else, let it be initialized to a new {{Client}} object that represents the worker associated with incumbentGlobal.
  10. @@ -1231,7 +1231,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
    1. Create an event e that uses the {{ServiceWorkerMessageEvent}} interface, with the event type message, which does not bubble and is not cancelable.
    2. Let the {{ServiceWorkerMessageEvent/data}} attribute of e be initialized to clonedMessage.
    3. -
    4. Let the {{ServiceWorkerMessageEvent/origin}} attribute of e be initialized to the Unicode serialisation of sourceSettings's origin.
    5. +
    6. Let the {{ServiceWorkerMessageEvent/origin}} attribute of e be initialized to the Unicode serialization of sourceSettings's origin.
    7. Let the {{ServiceWorkerMessageEvent/source}} attribute of e be initialized to a {{ServiceWorker}} object, which represents the service worker associated with sourceSettings's global object.
    8. Let the {{ServiceWorkerMessageEvent/ports}} attribute of e be initialized to newPorts.
    9. Dispatch e at destination.
    10. @@ -2669,7 +2669,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

      The user agent must create a {{CacheStorage}} object when a {{Window}} object or a {{WorkerGlobalScope}} object is created and associate it with that object.

      -

      A CacheStorage object represents a name to cache map of its associated global object's environment settings object's origin. Multiple separate objects implementing the {{CacheStorage}} interface across documents and workers can all be associated with the same name to cache map simultaneously.

      +

      A CacheStorage object represents a name to cache map of its associated global object's environment settings object's origin. Multiple separate objects implementing the {{CacheStorage}} interface across documents and workers can all be associated with the same name to cache map simultaneously.

      {{CacheStorage/match(request, options)}}

      @@ -2929,7 +2929,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/ // e.g. define an API namespace readonly attribute APISpaceType APISpace; // e.g. define a method - Promise<T> methodName(list of arguments); + Promise<T> methodName(/* list of arguments */); };
      @@ -3510,7 +3510,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
    11. Let workerEventLoop be a newly created event loop.
    12. -
    13. Let workerGlobalScope be realmExecutionContext's global object.
    14. +
    15. Let workerGlobalScope be realmExecutionContext's global object.
    16. Let settingsObject be a new environment settings object whose algorithms are defined as follows:
      The realm execution context
      @@ -3710,7 +3710,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
      1. Create a trusted event e that uses the {{ForeignFetchEvent}} interface, with the event type foreignfetch, which does not bubble.
      2. Let the {{ForeignFetchEvent/request}} attribute of e be initialized to r.
      3. -
      4. Let the {{ForeignFetchEvent/origin}} attribute of e be initialized to the Unicode serialization of request's origin.
      5. +
      6. Let the {{ForeignFetchEvent/origin}} attribute of e be initialized to the Unicode serialization of request's origin.
      7. Dispatch e at activeWorker's environment settings object's global object.
      8. If e's respond-with entered flag is set, set respondWithEntered to true.
      9. If e's wait to respond flag is set, wait until e's wait to respond flag is unset.
      10. @@ -3724,7 +3724,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
      11. Else set response to an opaque filtered response of internalResponse.
    17. -
    18. Else if e's origin is not equal to the Unicode serialization of request's origin, set handleFetchFailed to true.
    19. +
    20. Else if e's origin is not equal to the Unicode serialization of request's origin, set handleFetchFailed to true.
    21. Else if e's potential response is an opaque filtered response or is an opaque-redirect filtered response, set response to e's potential response.
    22. Else if request's response tainting is "opaque", set response to an opaque filtered response of internalResponse.
    23. Else: diff --git a/spec/service_worker/index.html b/spec/service_worker/index.html index 627f5e60..d320ee41 100644 --- a/spec/service_worker/index.html +++ b/spec/service_worker/index.html @@ -1409,7 +1409,7 @@

      Service Workers Nightly

      -

      Editor’s Draft,

      +

      Editor’s Draft,

      This version: @@ -1819,7 +1819,7 @@

      3. Client Context

      Bootstrapping with a ServiceWorker: -
      // scope defaults to the path the script sits in
      +
      // scope defaults to the path the script sits in
       // "/" in this example
       navigator.serviceWorker.register("/serviceworker.js").then(
         function(registration) {
      @@ -1830,8 +1830,7 @@ 

      }, function(why) { console.error("Installing the worker failed!:", why); - }); -

      + });

      3.1. ServiceWorker

      @@ -1862,9 +1861,8 @@

      For example, consider a document created by a navigation to https://example.com/app.html which matches via the following registration call which has been previously executed:

      -
      // Script on the page https://example.com/app.html
      -navigator.serviceWorker.register("/service_worker.js", { scope: "/" });
      -
      +
      // Script on the page https://example.com/app.html
      +navigator.serviceWorker.register("/service_worker.js", { scope: "/" });

      The value of navigator.serviceWorker.controller.scriptURL will be "https://example.com/service_worker.js".

      @@ -1890,7 +1888,7 @@

      <
      1. Create an event e that uses the ExtendableMessageEvent interface, with the event type message, which does not bubble and is not cancelable.
      2. Let the data attribute of e be initialized to clonedMessage. -
      3. Let the origin attribute of e be initialized to the Unicode serialisation of incumbentSettings’s origin. +
      4. Let the origin attribute of e be initialized to the Unicode serialization of incumbentSettings’s origin.
      5. If incumbentGlobal is a ServiceWorkerGlobalScope object, let the source attribute of e be initialized to a new ServiceWorker object that represents incumbentGlobal’s service worker.
      6. Else if incumbentGlobal is a Window object, let the source attribute of e be initialized to a new WindowClient object that represents incumbentGlobal’s browsing context.
      7. Else, let it be initialized to a new Client object that represents the worker associated with incumbentGlobal. @@ -2252,7 +2250,7 @@

        4. Execution Context

        Serving Cached Resources: -
        // caching.js
        +
        // caching.js
         this.addEventListener("install", function(e) {
           e.waitUntil(
             // Open a cache of resources.
        @@ -2283,8 +2281,7 @@ 

        return caches.match("/fallback.html"); }) ); -}); -

        +});

        4.1. ServiceWorkerGlobalScope

        @@ -2435,7 +2432,7 @@

      8. Create an event e that uses the ServiceWorkerMessageEvent interface, with the event type message, which does not bubble and is not cancelable.
      9. Let the data attribute of e be initialized to clonedMessage. -
      10. Let the origin attribute of e be initialized to the Unicode serialisation of sourceSettings’s origin. +
      11. Let the origin attribute of e be initialized to the Unicode serialization of sourceSettings’s origin.
      12. Let the source attribute of e be initialized to a ServiceWorker object, which represents the service worker associated with sourceSettings’s global object.
      13. Let the ports attribute of e be initialized to newPorts.
      14. Dispatch e at destination. @@ -3245,11 +3242,9 @@

      @@ -3699,7 +3694,7 @@

      CacheStorage interface is designed to largely conform to ECMAScript 6 Map objects but entirely async, and with additional convenience methods. The methods, clear, forEach, entries and values, are intentionally excluded from the scope of the first version resorting to the ongoing discussion about the async iteration by TC39.

      The user agent must create a CacheStorage object when a Window object or a WorkerGlobalScope object is created and associate it with that object.

      -

      A CacheStorage object represents a name to cache map of its associated global object’s environment settings object’s origin. Multiple separate objects implementing the CacheStorage interface across documents and workers can all be associated with the same name to cache map simultaneously.

      +

      A CacheStorage object represents a name to cache map of its associated global object’s environment settings object’s origin. Multiple separate objects implementing the CacheStorage interface across documents and workers can all be associated with the same name to cache map simultaneously.

      6.5.1. match(request, options)

      match(request, options) method must run these steps:

      @@ -3910,19 +3905,19 @@

      9.1. Define API bound to Service Worker Registration

      Specifications may define an API tied to a service worker registration by using partial interface definition to the ServiceWorkerRegistration interface where it may define the specification specific attributes and methods:

      -
      partial interface ServiceWorkerRegistration {
      +
      partial interface ServiceWorkerRegistration {
         // e.g. define an API namespace
      -  readonly attribute APISpaceType APISpace;
      +  readonly attribute APISpaceType APISpace;
         // e.g. define a method
      -  Promise<T> methodName(list of arguments);
      +  Promise<T> methodName(/* list of arguments */);
       };
       

      9.2. Define Functional Event

      Specifications may define a functional event by extending ExtendableEvent interface:

      -
      // e.g. define FunctionalEvent interface
      -interface FunctionalEvent : ExtendableEvent {
      +
      // e.g. define FunctionalEvent interface
      +interface FunctionalEvent : ExtendableEvent {
         // add a functional event’s own attributes and methods
       };
       
      @@ -3930,8 +3925,8 @@

      9.3. Define Event Handler

      Specifications may define an event handler attribute for the corresponding functional event using partial interface definition to the ServiceWorkerGlobalScope interface:

      -
      partial interface ServiceWorkerGlobalScope {
      -  attribute EventHandler onfunctionalevent;
      +
      partial interface ServiceWorkerGlobalScope {
      +  attribute EventHandler onfunctionalevent;
       };
       
      @@ -4440,7 +4435,7 @@

      JavaScript execution context.
    24. Let workerEventLoop be a newly created event loop. -
    25. Let workerGlobalScope be realmExecutionContext’s global object. +
    26. Let workerGlobalScope be realmExecutionContext’s global object.
    27. Let settingsObject be a new environment settings object whose algorithms are defined as follows:
      @@ -5249,39 +5244,35 @@

      Default scope: -
      // Maximum allowed scope defaults to the path the script sits in
      +
      // Maximum allowed scope defaults to the path the script sits in
       // "/js" in this example
       navigator.serviceWorker.register("/js/sw.js").then(function() {
         console.log("Install succeeded with the default scope '/js'.");
      -});
      -
      +});
      Upper path without Service-Worker-Allowed header: -
      // Set the scope to an upper path of the script location
      +
      // Set the scope to an upper path of the script location
       // Response has no Service-Worker-Allowed header
       navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).catch(function() {
         console.error("Install failed due to the path restriction violation.");
      -});
      -
      +});
      Upper path with Service-Worker-Allowed header: -
      // Set the scope to an upper path of the script location
      +
      // Set the scope to an upper path of the script location
       // Response included "Service-Worker-Allowed : /"
       navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).then(function() {
         console.log("Install succeeded as the max allowed scope was overriden to '/'.");
      -});
      -
      +});
      A path restriction voliation even with Service-Worker-Allowed header: -
      // Set the scope to an upper path of the script location
      +
      // Set the scope to an upper path of the script location
       // Response included "Service-Worker-Allowed : /foo"
       navigator.serviceWorker.register("/foo/bar/sw.js", { scope: "/" }).catch(function() {
         console.error("Install failed as the scope is still out of the overriden maximum allowed scope.");
      -});
      -
      +});

    28. @@ -5934,12 +5925,13 @@

      tasks
    29. terminate a worker
    30. the global object's realm +
    31. the realm's global object
    32. the worker's documents
    33. top-level browsing context
    34. triggered by user activation
    35. trusted event
    36. type -
    37. unicode serialisation of an origin +
    38. unicode serialization of an origin
    39. unload a document
    40. unsafe response
    41. url diff --git a/spec/service_worker_1/index.bs b/spec/service_worker_1/index.bs index 0f1bfac4..3b0d6ee3 100644 --- a/spec/service_worker_1/index.bs +++ b/spec/service_worker_1/index.bs @@ -89,13 +89,13 @@ spec: html; type: dfn text: structured clone text: task sources text: tasks - text: the environment settings object's global object text: the global object's realm + text: the Realm's global object text: the worker's documents text: top-level browsing context text: triggered by user activation text: trusted event - text: unicode serialisation of an origin + text: Unicode serialization of an origin text: unload a document text: user interaction task source text: utf-8 decode @@ -310,7 +310,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

      Model

      -
      +

      Service Worker

      A service worker is a type of web worker. A service worker executes in the registering service worker client's origin.

      @@ -368,11 +368,11 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

      A service worker client has an associated frame type, which is one of auxiliary, top-level, nested, and none. Unless stated otherwise it is none. -

      A window client is a service worker client whose global object is a {{Window}} object.

      +

      A window client is a service worker client whose global object is a {{Window}} object.

      -

      A dedicated worker client is a service worker client whose global object is a {{DedicatedWorkerGlobalScope}} object.

      +

      A dedicated worker client is a service worker client whose global object is a {{DedicatedWorkerGlobalScope}} object.

      -

      A shared worker client is a service worker client whose global object is a {{SharedWorkerGlobalScope}} object.

      +

      A shared worker client is a service worker client whose global object is a {{SharedWorkerGlobalScope}} object.

      A worker client is either a dedicated worker client or a shared worker client.

      @@ -502,7 +502,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
    42. Invoke Run Service Worker algorithm with serviceWorker as the argument.
    43. Let destination be the {{ServiceWorkerGlobalScope}} object associated with serviceWorker.
    44. Let targetRealm be destination's Realm.
    45. -
    46. Let incumbentSettings be the incumbent settings object, and incumbentGlobal its global object.
    47. +
    48. Let incumbentSettings be the incumbent settings object, and incumbentGlobal its global object.
    49. Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). If this throws an exception, rethrow that exception and abort these steps.
    50. Let clonedMessage be cloneRecord.\[[Clone]].
    51. Let newPorts be a new frozen array consisting of all {{MessagePort}} objects in cloneRecord.\[[TransferList]], if any, maintaining their relative order.
    52. @@ -510,7 +510,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
      1. Create an event e that uses the {{ExtendableMessageEvent}} interface, with the event type message, which does not bubble and is not cancelable.
      2. Let the {{ExtendableMessageEvent/data}} attribute of e be initialized to clonedMessage.
      3. -
      4. Let the {{ExtendableMessageEvent/origin}} attribute of e be initialized to the Unicode serialisation of incumbentSettings's origin.
      5. +
      6. Let the {{ExtendableMessageEvent/origin}} attribute of e be initialized to the Unicode serialization of incumbentSettings's origin.
      7. If incumbentGlobal is a {{ServiceWorkerGlobalScope}} object, let the {{ExtendableMessageEvent/source}} attribute of e be initialized to a new {{ServiceWorker}} object that represents incumbentGlobal's service worker.
      8. Else if incumbentGlobal is a {{Window}} object, let the {{ExtendableMessageEvent/source}} attribute of e be initialized to a new {{WindowClient}} object that represents incumbentGlobal's browsing context.
      9. Else, let it be initialized to a new {{Client}} object that represents the worker associated with incumbentGlobal.
      10. @@ -608,7 +608,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
      11. Let registration be the service worker registration.
      12. Let newestWorker be the result of running Get Newest Worker algorithm passing registration as its argument.
      13. If newestWorker is null, reject p with an "{{InvalidStateError}}" exception and abort these steps.
      14. -
      15. If the context object's relevant settings object's global object globalObject is a {{ServiceWorkerGlobalScope}} object, and globalObject's associated service worker's state is installing, reject p with an "{{InvalidStateError}}" exception and abort these steps.
      16. +
      17. If the context object's relevant settings object's global object globalObject is a {{ServiceWorkerGlobalScope}} object, and globalObject's associated service worker's state is installing, reject p with an "{{InvalidStateError}}" exception and abort these steps.
      18. Let job be the result of running Create Job with update, registration's scope url, newestWorker's script url, p, and the context object's relevant settings object client.
      19. Set job's worker type to newestWorker's type.
      20. Invoke Schedule Job with job.
      21. @@ -702,7 +702,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

        A ServiceWorkerContainer provides capabilities to register, unregister, and update the service worker registrations, and provides access to the state of the service worker registrations and their associated service workers.

        -

        A {{ServiceWorkerContainer}} has an associated service worker client, which is a service worker client whose global object is associated with the {{Navigator}} object or the {{WorkerNavigator}} object that the {{ServiceWorkerContainer}} is retrieved from.

        +

        A {{ServiceWorkerContainer}} has an associated service worker client, which is a service worker client whose global object is associated with the {{Navigator}} object or the {{WorkerNavigator}} object that the {{ServiceWorkerContainer}} is retrieved from.

        A {{ServiceWorkerContainer}} object has an associated ready promise (a promise). It is initially set to a new promise.

        @@ -1181,15 +1181,15 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
        auxiliary
        "auxiliary" -

        The window client's global object's browsing context is an auxiliary browsing context.

        +

        The window client's global object's browsing context is an auxiliary browsing context.

        top-level
        "top-level" -

        The window client's global object's browsing context is a top-level browsing context.

        +

        The window client's global object's browsing context is a top-level browsing context.

        nested
        "nested" -

        The window client's global object's browsing context is a nested browsing context.

        +

        The window client's global object's browsing context is a nested browsing context.

        none
        "none"
        @@ -1219,8 +1219,8 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
        1. Create an event e that uses the {{ServiceWorkerMessageEvent}} interface, with the event type message, which does not bubble and is not cancelable.
        2. Let the {{ServiceWorkerMessageEvent/data}} attribute of e be initialized to clonedMessage.
        3. -
        4. Let the {{ServiceWorkerMessageEvent/origin}} attribute of e be initialized to the Unicode serialisation of sourceSettings's origin.
        5. -
        6. Let the {{ServiceWorkerMessageEvent/source}} attribute of e be initialized to a {{ServiceWorker}} object, which represents the service worker associated with sourceSettings's global object.
        7. +
        8. Let the {{ServiceWorkerMessageEvent/origin}} attribute of e be initialized to the Unicode serialization of sourceSettings's origin.
        9. +
        10. Let the {{ServiceWorkerMessageEvent/source}} attribute of e be initialized to a {{ServiceWorker}} object, which represents the service worker associated with sourceSettings's global object.
        11. Let the {{ServiceWorkerMessageEvent/ports}} attribute of e be initialized to newPorts.
        12. Dispatch e at destination.
        @@ -1250,7 +1250,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
      22. Let promise be a new promise.
      23. Run these substeps in parallel:
          -
        1. Let browsingContext be the context object's associated service worker client's global object's browsing context.
        2. +
        3. Let browsingContext be the context object's associated service worker client's global object's browsing context.
        4. Let visibilityState be null.
        5. Let focusState be null.
        6. Queue a task task to run the following substeps on the context object's associated service worker client's responsible event loop using the user interaction task source: @@ -1283,7 +1283,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
        7. Let promise be a new promise.
        8. Run these substeps in parallel:
            -
          1. Let browsingContext be the context object's associated service worker client's global object's browsing context.
          2. +
          3. Let browsingContext be the context object's associated service worker client's global object's browsing context.
          4. If browsingContext has discarded its {{Document}}, reject promise with a TypeError and abort these steps.
          5. Let navigateFailed to false.
          6. Let visibilityState be null.
          7. @@ -1359,7 +1359,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
          8. If client is not a secure context, reject promise with a "{{SecurityError}}" exception and abort these steps.
          9. If client is a window client, then:
              -
            1. Let browsingContext be client's global object's browsing context.
            2. +
            3. Let browsingContext be client's global object's browsing context.
            4. Let visibilityState be null.
            5. Let focusState be null.
            6. Queue a task task to run the following substeps: @@ -1420,7 +1420,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
              1. If options.{{ClientQueryOptions/type}} is "window", and client is a window client, then:
                  -
                1. Let browsingContext be client's global object's browsing context.
                2. +
                3. Let browsingContext be client's global object's browsing context.
                4. Let isClientEnumerable be false.
                5. Let visibilityState be the empty string.
                6. Let focusState be false.
                7. @@ -1456,7 +1456,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
                  1. If client is a window client, then:
                      -
                    1. Let browsingContext be client's global object's browsing context.
                    2. +
                    3. Let browsingContext be client's global object's browsing context.
                    4. Let isClientEnumerable be false.
                    5. Let visibilityState be the empty string.
                    6. Let focusState be false.
                    7. @@ -1609,7 +1609,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
                    -

                    The user agent should not terminate the service worker associated with e's relevant settings object's global object until e's extensions allowed flag is unset. However, the user agent may impose a time limit to this lifetime extension.

                    +

                    The user agent should not terminate the service worker associated with e's relevant settings object's global object until e's extensions allowed flag is unset. However, the user agent may impose a time limit to this lifetime extension.

                    {{ExtendableEvent/waitUntil(f)|event.waitUntil(f)}}

                    @@ -2371,7 +2371,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

                    The user agent must create a {{CacheStorage}} object when a {{Window}} object or a {{WorkerGlobalScope}} object is created and associate it with that object.

                    -

                    A CacheStorage object represents a name to cache map of its associated global object's environment settings object's origin. Multiple separate objects implementing the {{CacheStorage}} interface across documents and workers can all be associated with the same name to cache map simultaneously.

                    +

                    A CacheStorage object represents a name to cache map of its associated global object's environment settings object's origin. Multiple separate objects implementing the {{CacheStorage}} interface across documents and workers can all be associated with the same name to cache map simultaneously.

                    {{CacheStorage/match(request, options)}}

                    @@ -2557,7 +2557,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/

                    When the importScripts(urls) method is called on a {{ServiceWorkerGlobalScope}} object, the user agent must import scripts into worker global scope, given this {{ServiceWorkerGlobalScope}} object and urls, and with the following steps to perform the fetch given the request request:

                      -
                    1. Let serviceWorker be request's client's global object's service worker.
                    2. +
                    3. Let serviceWorker be request's client's global object's service worker.
                    4. If serviceWorker's imported scripts updated flag is unset, then:
                      1. Let response be the result of fetching request.
                      2. @@ -2631,7 +2631,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/ // e.g. define an API namespace readonly attribute APISpaceType APISpace; // e.g. define a method - Promise<T> methodName(list of arguments); + Promise<T> methodName(/* list of arguments */); };
                    @@ -3055,7 +3055,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
                  2. Queue a task task to run the following substeps:
                    1. Create a trusted event e that uses the {{ExtendableEvent}} interface, with the event type install, which does not bubble and is not cancelable.
                    2. -
                    3. Dispatch e at installingWorker's environment settings object's global object globalObject.
                    4. +
                    5. Dispatch e at installingWorker's environment settings object's global object globalObject.
                    6. WaitForAsynchronousExtensions: Run the following substeps in parallel:
                      1. Wait until e's extensions allowed flag is unset.
                      2. @@ -3130,7 +3130,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
                      3. 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.
                        2. -
                        3. Else if client is a shared worker client, unassociate client's global object from its application cache, if it has one.
                        4. +
                        5. Else if client is a shared worker client, unassociate client's global object from its application cache, if it has one.

                        Resources will now use the service worker registration instead of the existing application cache.

                      4. @@ -3145,7 +3145,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
                      5. Queue a task task to run the following substeps:
                        1. Create a trusted event e that uses the {{ExtendableEvent}} interface, with the event type activate, which does not bubble and is not cancelable.
                        2. -
                        3. Dispatch e at activeWorker's environment settings object's global object.
                        4. +
                        5. Dispatch e at activeWorker's environment settings object's global object.
                        6. WaitForAsynchronousExtensions: Wait, in parallel, until e's extensions allowed flag is unset.
                      6. @@ -3176,12 +3176,12 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
                      7. Let workerEventLoop be a newly created event loop.
                      8. -
                      9. Let workerGlobalScope be realmExecutionContext's global object.
                      10. +
                      11. Let workerGlobalScope be realmExecutionContext's global object.
                      12. Let settingsObject be a new environment settings object whose algorithms are defined as follows:
                        The realm execution context
                        Return realmExecutionContext.
                        -
                        The global object
                        +
                        The global object
                        Return workerGlobalScope.
                        The responsible event loop
                        Return workerEventLoop.
                        @@ -3210,7 +3210,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
                      13. If script's has ever been evaluated flag is unset, then:
                          -
                        1. Set workerGlobalScope's associated service worker's set of event types to handle to the set of event types created from settingsObject's global object's associated list of event listeners' event types. +
                        2. Set workerGlobalScope's associated service worker's set of event types to handle to the set of event types created from settingsObject's global object's associated list of event listeners' event types.

                          If the global object's associated list of event listeners does not have any event listener added at this moment, the service worker's set of event types to handle is set to an empty set. The user agents are encouraged to show a warning that the event listeners must be added on the very first evaluation of the worker script.

                        3. Set script's has ever been evaluated flag.
                        4. @@ -3232,7 +3232,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
        1. If serviceWorker is not running, abort these steps.
        2. -
        3. Let serviceWorkerGlobalScope be serviceWorker's environment settings object's global object.
        4. +
        5. Let serviceWorkerGlobalScope be serviceWorker's environment settings object's global object.
        6. Set serviceWorkerGlobalScope's closing flag to true.
        7. If there are any tasks, whose task source is either the handle fetch task source or the handle functional event task source, queued in serviceWorkerGlobalScope's event loop's task queues, queue them to serviceWorker's containing service worker registration's corresponding task queues in the same order using their original task sources, and discard all the tasks (including tasks whose task source is neither the handle fetch task source nor the handle functional event task source) from serviceWorkerGlobalScope's event loop's task queues without processing them.

          This effectively means that the fetch events and the other functional events such as push events are backed up by the registration's task queues while the other tasks including message events are discarded.

          @@ -3297,7 +3297,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
        8. Let the request attribute of e be initialized to r.
        9. Let the clientId attribute of e be initialized to client's id if request is not a non-subresource request, and to null otherwise.
        10. Let the isReload attribute of e be initialized to true if request's client is a window client and the event was dispatched with the user's intention for the page reload, and false otherwise.
        11. -
        12. Dispatch e at activeWorker's environment settings object's global object.
        13. +
        14. Dispatch e at activeWorker's environment settings object's global object.
        15. If e's respond-with entered flag is set, set respondWithEntered to true.
        16. If e's wait to respond flag is set, then:
            @@ -3354,7 +3354,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
          1. If activeWorker's state is activating, wait for activeWorker's state to become activated.
          2. Invoke Run Service Worker algorithm with activeWorker as the argument.
          3. -
          4. Queue a task task to invoke callbackSteps with activeWorker's environment settings object's global object as its argument. +
          5. Queue a task task to invoke callbackSteps with activeWorker's environment settings object's global object as its argument.

            The task must use activeWorker's event loop and the handle functional event task source.

          6. Wait for task to have executed or been discarded.
          7. diff --git a/spec/service_worker_1/index.html b/spec/service_worker_1/index.html index f84dac2b..8e90be01 100644 --- a/spec/service_worker_1/index.html +++ b/spec/service_worker_1/index.html @@ -1409,7 +1409,7 @@

            Service Workers 1

            -

            Editor’s Draft,

            +

            Editor’s Draft,

            This version: @@ -1712,18 +1712,18 @@

            2. Model

            2.1. Service Worker

            -

            A service worker is a type of web worker. A service worker executes in the registering service worker client’s origin.

            -

            A service worker has an associated state, which is one of parsed, installing, installed, activating, activated, and redundant. It is initially parsed.

            -

            A service worker has an associated script url (a URL).

            -

            A service worker has an associated type which is either "classic" or "module". Unless stated otherwise, it is "classic".

            -

            A service worker has an associated containing service worker registration (a service worker registration), which contains itself.

            -

            A service worker has an associated id (an opaque string), which uniquely identifies itself during the lifetime of its containing service worker registration.

            -

            A service worker is dispatched a set of lifecycle events, install and activate, and functional events including fetch.

            -

            A service worker has an associated script resource (a script), which represents its own script resource. It is initially set to null. A script resource has an associated has ever been evaluated flag. It is initially unset. A script resource has an associated HTTPS state which is "none", "deprecated", or "modern". Unless stated otherwise, it is "none".

            -

            A service worker has an associated script resource map which is a List of the Record {[[key]], [[value]]} where [[key]] is a URL and [[value]] is a response.

            -

            A service worker has an associated skip waiting flag. Unless stated otherwise it is unset.

            -

            A service worker has an associated imported scripts updated flag. It is initially unset.

            -

            A service worker has an associated set of event types to handle whose element type is an event listener’s event type. It is initially set to null.

            +

            A service worker is a type of web worker. A service worker executes in the registering service worker client’s origin.

            +

            A service worker has an associated state, which is one of parsed, installing, installed, activating, activated, and redundant. It is initially parsed.

            +

            A service worker has an associated script url (a URL).

            +

            A service worker has an associated type which is either "classic" or "module". Unless stated otherwise, it is "classic".

            +

            A service worker has an associated containing service worker registration (a service worker registration), which contains itself.

            +

            A service worker has an associated id (an opaque string), which uniquely identifies itself during the lifetime of its containing service worker registration.

            +

            A service worker is dispatched a set of lifecycle events, install and activate, and functional events including fetch.

            +

            A service worker has an associated script resource (a script), which represents its own script resource. It is initially set to null. A script resource has an associated has ever been evaluated flag. It is initially unset. A script resource has an associated HTTPS state which is "none", "deprecated", or "modern". Unless stated otherwise, it is "none".

            +

            A service worker has an associated script resource map which is a List of the Record {[[key]], [[value]]} where [[key]] is a URL and [[value]] is a response.

            +

            A service worker has an associated skip waiting flag. Unless stated otherwise it is unset.

            +

            A service worker has an associated imported scripts updated flag. It is initially unset.

            +

            A service worker has an associated set of event types to handle whose element type is an event listener’s event type. It is initially set to null.

            2.1.1. Lifetime

            The lifetime of a service worker is tied to the execution lifetime of events and not references held by service worker clients to the ServiceWorker object.

            @@ -1806,8 +1806,7 @@

            }, function(why) { console.error("Installing the worker failed!:", why); - }); - + });

            3.1. ServiceWorker

            @@ -1839,8 +1838,7 @@

            For example, consider a document created by a navigation to https://example.com/app.html which matches via the following registration call which has been previously executed:

            // Script on the page https://example.com/app.html
            -navigator.serviceWorker.register("/service_worker.js", { scope: "/" });
            -
            +navigator.serviceWorker.register("/service_worker.js", { scope: "/" });

            The value of navigator.serviceWorker.controller.scriptURL will be "https://example.com/service_worker.js".

      @@ -1857,7 +1855,7 @@

      <
    53. Invoke Run Service Worker algorithm with serviceWorker as the argument.
    54. Let destination be the ServiceWorkerGlobalScope object associated with serviceWorker.
    55. Let targetRealm be destination’s Realm. -
    56. Let incumbentSettings be the incumbent settings object, and incumbentGlobal its global object. +
    57. Let incumbentSettings be the incumbent settings object, and incumbentGlobal its global object.
    58. Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). If this throws an exception, rethrow that exception and abort these steps.
    59. Let clonedMessage be cloneRecord.[[Clone]].
    60. Let newPorts be a new frozen array consisting of all MessagePort objects in cloneRecord.[[TransferList]], if any, maintaining their relative order. @@ -1866,7 +1864,7 @@

      <
      1. Create an event e that uses the ExtendableMessageEvent interface, with the event type message, which does not bubble and is not cancelable.
      2. Let the data attribute of e be initialized to clonedMessage. -
      3. Let the origin attribute of e be initialized to the Unicode serialisation of incumbentSettings’s origin. +
      4. Let the origin attribute of e be initialized to the Unicode serialization of incumbentSettings’s origin.
      5. If incumbentGlobal is a ServiceWorkerGlobalScope object, let the source attribute of e be initialized to a new ServiceWorker object that represents incumbentGlobal’s service worker.
      6. Else if incumbentGlobal is a Window object, let the source attribute of e be initialized to a new WindowClient object that represents incumbentGlobal’s browsing context.
      7. Else, let it be initialized to a new Client object that represents the worker associated with incumbentGlobal. @@ -2269,8 +2267,7 @@

        return caches.match("/fallback.html"); }) ); -}); - +});

        4.1. ServiceWorkerGlobalScope

        @@ -2417,8 +2414,8 @@

      8. Create an event e that uses the ServiceWorkerMessageEvent interface, with the event type message, which does not bubble and is not cancelable.
      9. Let the data attribute of e be initialized to clonedMessage. -
      10. Let the origin attribute of e be initialized to the Unicode serialisation of sourceSettings’s origin. -
      11. Let the source attribute of e be initialized to a ServiceWorker object, which represents the service worker associated with sourceSettings’s global object. +
      12. Let the origin attribute of e be initialized to the Unicode serialization of sourceSettings’s origin. +
      13. Let the source attribute of e be initialized to a ServiceWorker object, which represents the service worker associated with sourceSettings’s global object.
      14. Let the ports attribute of e be initialized to newPorts.
      15. Dispatch e at destination.
      @@ -3431,7 +3428,7 @@

      CacheStorage interface is designed to largely conform to ECMAScript 6 Map objects but entirely async, and with additional convenience methods. The methods, clear, forEach, entries and values, are intentionally excluded from the scope of the first version resorting to the ongoing discussion about the async iteration by TC39.

      The user agent must create a CacheStorage object when a Window object or a WorkerGlobalScope object is created and associate it with that object.

      -

      A CacheStorage object represents a name to cache map of its associated global object’s environment settings object’s origin. Multiple separate objects implementing the CacheStorage interface across documents and workers can all be associated with the same name to cache map simultaneously.

      +

      A CacheStorage object represents a name to cache map of its associated global object’s environment settings object’s origin. Multiple separate objects implementing the CacheStorage interface across documents and workers can all be associated with the same name to cache map simultaneously.

      5.5.1. match(request, options)

      match(request, options) method must run these steps:

      @@ -3642,19 +3639,19 @@

      8.1. Define API bound to Service Worker Registration

      Specifications may define an API tied to a service worker registration by using partial interface definition to the ServiceWorkerRegistration interface where it may define the specification specific attributes and methods:

      -
      partial interface ServiceWorkerRegistration {
      +
      partial interface ServiceWorkerRegistration {
         // e.g. define an API namespace
      -  readonly attribute APISpaceType APISpace;
      +  readonly attribute APISpaceType APISpace;
         // e.g. define a method
      -  Promise<T> methodName(list of arguments);
      +  Promise<T> methodName(/* list of arguments */);
       };
       

      8.2. Define Functional Event

      Specifications may define a functional event by extending ExtendableEvent interface:

      -
      // e.g. define FunctionalEvent interface
      -interface FunctionalEvent : ExtendableEvent {
      +
      // e.g. define FunctionalEvent interface
      +interface FunctionalEvent : ExtendableEvent {
         // add a functional event’s own attributes and methods
       };
       
      @@ -3662,8 +3659,8 @@

      8.3. Define Event Handler

      Specifications may define an event handler attribute for the corresponding functional event using partial interface definition to the ServiceWorkerGlobalScope interface:

      -
      partial interface ServiceWorkerGlobalScope {
      -  attribute EventHandler onfunctionalevent;
      +
      partial interface ServiceWorkerGlobalScope {
      +  attribute EventHandler onfunctionalevent;
       };
       
      @@ -4139,7 +4136,7 @@

      JavaScript execution context.
    61. Let workerEventLoop be a newly created event loop. -
    62. Let workerGlobalScope be realmExecutionContext’s global object. +
    63. Let workerGlobalScope be realmExecutionContext’s global object.
    64. Let settingsObject be a new environment settings object whose algorithms are defined as follows:
      @@ -4832,8 +4829,7 @@

      // "/js" in this example navigator.serviceWorker.register("/js/sw.js").then(function() { console.log("Install succeeded with the default scope '/js'."); -}); -

    65. +});
      Upper path without Service-Worker-Allowed header: @@ -4841,8 +4837,7 @@

      // Response has no Service-Worker-Allowed header navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).catch(function() { console.error("Install failed due to the path restriction violation."); -}); - +});

      Upper path with Service-Worker-Allowed header: @@ -4850,8 +4845,7 @@

      // Response included "Service-Worker-Allowed : /" navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).then(function() { console.log("Install succeeded as the max allowed scope was overriden to '/'."); -}); - +});

      A path restriction voliation even with Service-Worker-Allowed header: @@ -4859,8 +4853,7 @@

      // Response included "Service-Worker-Allowed : /foo" navigator.serviceWorker.register("/foo/bar/sw.js", { scope: "/" }).catch(function() { console.error("Install failed as the scope is still out of the overriden maximum allowed scope."); -}); - +});

      @@ -5440,12 +5433,13 @@

      tasks
    66. terminate a worker
    67. the global object's realm +
    68. the realm's global object
    69. the worker's documents
    70. top-level browsing context
    71. triggered by user activation
    72. trusted event
    73. type -
    74. unicode serialisation of an origin +
    75. unicode serialization of an origin
    76. unload a document
    77. unsafe response
    78. url