From 8b483b091e0f0bae6b698cf05d915c2029748ae0 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Wed, 5 Oct 2016 18:08:10 +0900 Subject: [PATCH] Use environment, reserved client, and target client id This patch fixes the steps in Handle Fetch that - Get various clients' info and expose them to fetch event handlers - Match/attach a controller, if available, to the given environment by referencing the request's reserved client and target client id. Related commits: - HTML: https://github.com/whatwg/html/commit/2b93f9ec35b152e58d3e181bea8c45d789bac949 - Fetch: https://github.com/whatwg/fetch/commit/fb87b70df0af3a5e6bc7bb9a91b4dc7eb4924acb NOTE: Changing the methods of Clients/Client will be done as a separate patch. --- docs/index.bs | 73 +++++--- docs/index.html | 417 ++++++++++++++++++++++++--------------------- docs/v1/index.bs | 73 +++++--- docs/v1/index.html | 401 ++++++++++++++++++++++++------------------- 4 files changed, 550 insertions(+), 414 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index a418d654..75862f9f 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -119,7 +119,9 @@ spec: fetch; urlPrefix: https://fetch.spec.whatwg.org/ text: origin text: redirect mode text: request + text: reserved client text: response tainting + text: target client id text: url for: response; urlPrefix: #concept-response- text: body @@ -153,7 +155,9 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/ urlPrefix: semantics.html text: external resource link urlPrefix: webappapis.html + text: active service worker; for: environment text: dom manipulation task source + text: environment text: run a classic script text: run a module script text: task queue; for: event loop @@ -169,9 +173,10 @@ spec: page-visibility; urlPrefix: https://www.w3.org/TR/page-visibility/ type: enum; text: VisibilityState; url: VisibilityState type: attribute; text: visibilityState; for: Document; url: dom-document-visibilitystate -spec: powerful-features; urlPrefix: https://w3c.github.io/webappsec/specs/powerfulfeatures/# +spec: secure-contexts; urlPrefix: https://w3c.github.io/webappsec-secure-contexts/# type: dfn text: is origin potentially trustworthy; url: is-origin-trustworthy + text: potentially trustworthy url; url: potentially-trustworthy-url text: risks associated with insecure contexts; url: threat-risks text: secure context @@ -278,11 +283,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/

Service Worker Client

-

A service worker client is a type of environment settings object.

- -

A service worker client has an associated active worker (an active worker) which currently controls it. It is initially set to null.

- -

A service worker client has an associated id (an opaque string), which uniquely identifies itself during its lifetime. It is initially set to a new unique value when the corresponding environment settings object that it represents is created.

+

A service worker client is a type of environment or environment settings object.

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. @@ -537,7 +538,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/

-

The {{ServiceWorkerRegistration/unregister()}} method unregisters the service worker registration. It is important to note that the currently controlled service worker client's active worker's containing service worker registration is effective until all the service worker clients (including itself) using this service worker registration unload. That is, the {{ServiceWorkerRegistration/unregister()}} method only affects subsequent navigations.

+

The {{ServiceWorkerRegistration/unregister()}} method unregisters the service worker registration. It is important to note that the currently controlled service worker client's active service worker's containing service worker registration is effective until all the service worker clients (including itself) using this service worker registration unload. That is, the {{ServiceWorkerRegistration/unregister()}} method only affects subsequent navigations.

unregister() method must run these steps:

@@ -633,7 +634,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
  1. Let client be the context object's service worker client.
  2. -
  3. Return the {{ServiceWorker}} object that represents client's active worker.
  4. +
  5. Return the {{ServiceWorker}} object that represents client's active service worker.

{{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} returns null if the request is a force refresh (shift+refresh). The {{ServiceWorker}} objects returned from this attribute getter that represent the same service worker are the same objects.

@@ -891,7 +892,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/ controllerchange {{Event}} - The service worker client's active worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a service worker causes activation of the service worker registration to occur while service worker clients are using the service worker registration, {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} immediately reflects the active worker as the service worker that controls the service worker client.) + The service worker client's active service worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a service worker causes activation of the service worker registration to occur while service worker clients are using the service worker registration, {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} immediately reflects the active worker as the service worker that controls the service worker client.) message @@ -1112,7 +1113,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/

{{Client/id}}

-

The id attribute must return its associated service worker client's id.

+

The id attribute must return its associated service worker client's id.

@@ -1192,7 +1193,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
  • Let url be the result of parsing url with the context object's relevant settings object's API base URL.
  • If url is failure, return a promise rejected with a TypeError.
  • If url is about:blank, return a promise rejected with a TypeError.
  • -
  • If the context object's associated service worker client's active worker is not the context object's relevant global object's service worker, return a promise rejected with a TypeError.
  • +
  • If the context object's associated service worker client's active service worker is not the context object's relevant global object's service worker, return a promise rejected with a TypeError.
  • Let promise be a new promise.
  • Run these substeps in parallel:
      @@ -1267,7 +1268,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
      1. For each service worker client client whose origin is the same as the associated service worker's origin:
          -
        1. If client's id is id, then: +
        2. If client's id is id, then:
          1. If client is not a secure context, reject promise with a "{{SecurityError}}" exception and abort these steps.
          2. If client is a window client, then: @@ -1318,7 +1319,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
          3. If client is not a secure context, continue to the next iteration of the loop.
          4. If options.{{ClientQueryOptions/includeUncontrolled}} is false, then:
              -
            1. If client's active worker is the associated service worker, add client to targetClients.
            2. +
            3. If client's active service worker is the associated service worker, add client to targetClients.
          5. Else: @@ -1617,7 +1618,9 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/ [Constructor(DOMString type, FetchEventInit eventInitDict), Exposed=ServiceWorker] interface FetchEvent : ExtendableEvent { [SameObject] readonly attribute Request request; - readonly attribute DOMString? clientId; + readonly attribute DOMString clientId; + readonly attribute DOMString reservedClientId; + readonly attribute DOMString targetClientId; readonly attribute boolean isReload; void respondWith(Promise<Response> r); @@ -1626,7 +1629,9 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
                   dictionary FetchEventInit : ExtendableEventInit {
                     required Request request;
            -        DOMString? clientId = null;
            +        DOMString clientId = "";
            +        DOMString reservedClientId = "";
            +        DOMString targetClientId = "";
                     boolean isReload = false;
                   };
                 
            @@ -1650,7 +1655,19 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/

            {{FetchEvent/clientId|event.clientId}}

            -

            clientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to null.

            +

            clientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

            +
            + +
            +

            {{FetchEvent/reservedClientId|event.reservedClientId}}

            + +

            reservedClientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

            +
            + +
            +

            {{FetchEvent/targetClientId|event.targetClientId}}

            + +

            targetClientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

            @@ -3502,7 +3519,8 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
          6. Set headersObject's guard to immutable.
          7. Let response be null.
          8. Let registration be null.
          9. -
          10. Let client be the service worker client that corresponds to request's client.
          11. +
          12. Let client be request's client.
          13. +
          14. Let reservedClient be request's reserved client.
          15. Assert: request's destination is not "serviceworker".
          16. If request is a potential-navigation-or-subresource request, then:
              @@ -3512,17 +3530,26 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
            1. Else if request is a non-subresource request, then:

              If the non-subresource request is under the scope of a service worker registration, application cache is completely bypassed regardless of whether the non-subresource request uses the service worker registration.

                -
              1. If client is not a secure context, return null.
              2. +
              3. If reservedClient is not null and is an environment settings object, then: +
                  +
                1. If reservedClient is not a secure context, return null.
                2. +
                +
              4. +
              5. Else: +
                  +
                1. If request's url is not a potentially trustworthy URL, return null.
                2. +
                +
              6. If request is a navigation request and the navigation triggering it was initiated with a shift+reload or equivalent, return null.
              7. Set registration to the result of running Match Service Worker Registration algorithm passing request's url as the argument.
              8. If registration is null or registration's active worker is null, return null.
              9. -
              10. Set client's active worker to registration's active worker.
              11. +
              12. If request's destination is not "report", set reservedClient's active service worker to registration's active worker.
              -

              From this point, the service worker client starts to use its active worker's containing service worker registration.

              +

              From this point, the service worker client starts to use its active service worker's containing service worker registration.

            2. Else if request is a subresource request, then:
                -
              1. If client's active worker is non-null, set registration to client's active worker's containing service worker registration.
              2. +
              3. If client's active service worker is non-null, set registration to client's active service worker's containing service worker registration.
              4. Else, return null.
            3. @@ -3536,7 +3563,9 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
              1. Create a trusted event e that uses the {{FetchEvent}} interface, with the event type fetch, which does not bubble.
              2. Let the request attribute of e be initialized to r.
              3. -
              4. Let the clientId attribute of e be initialized to client's id if request is not a non-subresource request, and to null otherwise.
              5. +
              6. Initialize e's {{FetchEvent/clientId}} attribute to client's id.
              7. +
              8. If request is a non-subresource request and request's destination is not "report", initialize e's {{FetchEvent/reservedClientId}} attribute to reservedClient's id, and to the empty string otherwise.
              9. +
              10. If request is a navigation request, initialize e's {{FetchEvent/targetClientId}} attribute to request's target client id, and to the empty string otherwise.
              11. 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.
              12. Dispatch e at activeWorker's environment settings object's global object.
              13. If e's respond-with entered flag is set, set respondWithEntered to true.
              14. diff --git a/docs/index.html b/docs/index.html index abc9ac5f..04c51cca 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1422,7 +1422,7 @@

                Service Workers Nightly

                -

                Editor’s Draft,

                +

                Editor’s Draft,

                This version: @@ -1583,8 +1583,10 @@

                Table of Contents

                1. 4.6.1 event.request
                2. 4.6.2 event.clientId -
                3. 4.6.3 event.isReload -
                4. 4.6.4 event.respondWith(r) +
                5. 4.6.3 event.reservedClientId +
                6. 4.6.4 event.targetClientId +
                7. 4.6.5 event.isReload +
                8. 4.6.6 event.respondWith(r)
              15. 4.7 ForeignFetchEvent @@ -1789,21 +1791,19 @@

                2.3. Service Worker Client

                -

                A service worker client is a type of environment settings object.

                -

                A service worker client has an associated active worker (an active worker) which currently controls it. It is initially set to null.

                -

                A service worker client has an associated id (an opaque string), which uniquely identifies itself during its lifetime. It is initially set to a new unique value when the corresponding environment settings object that it represents is created.

                -

                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 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 service worker client is a type of environment or environment settings object.

                +

                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 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 worker client is either a dedicated worker client or a shared worker client.

          17. 2.4. Selection and Use

            -

            A service worker client independently selects and uses a service worker registration for its own loading and its subresources. The selection of a service worker registration, upon a non-subresource request, is a process of either matching a service worker registration from scope to registration map or inheriting an existing service worker registration from its parent or owner context depending on the request’s url.

            -

            When the request’s url is not local, a service worker client matches a service worker registration from scope to registration map. That is, the service worker client attempts to consult a service worker registration whose scope url matches its creation url.

            -

            When the request’s url is local, if the service worker client’s responsible browsing context is a nested browsing context or the service worker client is a worker client, the service worker client inherits the service worker registration from its parent browsing context’s environment or one of the worker’s Documents' environment, respectively, if it exists.

            -

            If the selection was successful, the selected service worker registration’s active worker starts to control the service worker client. Otherwise, the flow returns to fetch where it falls back to the default behavior. When a service worker client is controlled by an active worker, it is considered that the service worker client is using the active worker’s containing service worker registration.

            +

            A service worker client independently selects and uses a service worker registration for its own loading and its subresources. The selection of a service worker registration, upon a non-subresource request, is a process of either matching a service worker registration from scope to registration map or inheriting an existing service worker registration from its parent or owner context depending on the request’s url.

            +

            When the request’s url is not local, a service worker client matches a service worker registration from scope to registration map. That is, the service worker client attempts to consult a service worker registration whose scope url matches its creation url.

            +

            When the request’s url is local, if the service worker client’s responsible browsing context is a nested browsing context or the service worker client is a worker client, the service worker client inherits the service worker registration from its parent browsing context’s environment or one of the worker’s Documents' environment, respectively, if it exists.

            +

            If the selection was successful, the selected service worker registration’s active worker starts to control the service worker client. Otherwise, the flow returns to fetch where it falls back to the default behavior. When a service worker client is controlled by an active worker, it is considered that the service worker client is using the active worker’s containing service worker registration.

            2.5. Task Sources

            @@ -1822,7 +1822,7 @@

            A user agent must maintain the state of its stored service worker registrations across restarts with the following rules:

            To attain this, the user agent must invoke Handle User Agent Shutdown when it terminates.

            @@ -1983,7 +1983,7 @@

            -

            The unregister() method unregisters the service worker registration. It is important to note that the currently controlled service worker client’s active worker’s containing service worker registration is effective until all the service worker clients (including itself) using this service worker registration unload. That is, the unregister() method only affects subsequent navigations.

            +

            The unregister() method unregisters the service worker registration. It is important to note that the currently controlled service worker client’s active service worker’s containing service worker registration is effective until all the service worker clients (including itself) using this service worker registration unload. That is, the unregister() method only affects subsequent navigations.

            unregister() method must run these steps:

            1. Let p be a promise. @@ -2046,7 +2046,7 @@

              The user agent must create a ServiceWorkerContainer object when a Navigator object or a WorkerNavigator object is created and associate it with that object.

              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.

              A ServiceWorkerContainer object has a task source called the client message queue, initially empty. A client message queue can be enabled or disabled, and is initially disabled. When a ServiceWorkerContainer object’s client message queue is enabled, the event loop must use it as one of its task sources. When the ServiceWorkerContainer object’s relevant global object is a Window object, all tasks queued on its client message queue must be associated with its relevant settings object’s responsible document.

              @@ -2054,7 +2054,7 @@
              @@ -2081,13 +2081,13 @@

          18. Return context object’s ready promise.
          -

          When the ready attribute is accessed, the returned promise will never reject. Instead, it waits until the promise resolves with a service worker registration that has an active worker.

          +

          When the ready attribute is accessed, the returned promise will never reject. Instead, it waits until the promise resolves with a service worker registration that has an active worker.

  • @@ -2253,7 +2253,7 @@

    controllerchange Event - The service worker client’s active worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a service worker causes activation of the service worker registration to occur while service worker clients are using the service worker registration, navigator.serviceWorker.controller immediately reflects the active worker as the service worker that controls the service worker client.) + The service worker client’s active service worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a service worker causes activation of the service worker registration to occur while service worker clients are using the service worker registration, navigator.serviceWorker.controller immediately reflects the active worker as the service worker that controls the service worker client.) message ServiceWorkerMessageEvent @@ -2320,7 +2320,7 @@

    A ServiceWorkerGlobalScope object represents the global execution context of a service worker. A ServiceWorkerGlobalScope object has an associated service worker (a service worker).

    -

    ServiceWorkerGlobalScope object provides generic, event-driven, time-limited script execution contexts that run at an origin. Once successfully registered, a service worker is started, kept alive and killed by their relationship to events, not service worker clients. Any type of synchronous requests must not be initiated inside of a service worker.

    +

    ServiceWorkerGlobalScope object provides generic, event-driven, time-limited script execution contexts that run at an origin. Once successfully registered, a service worker is started, kept alive and killed by their relationship to events, not service worker clients. Any type of synchronous requests must not be initiated inside of a service worker.

    4.1.1. clients

    clients attribute must return the Clients object that is associated with the context object.

    @@ -2331,7 +2331,7 @@

    4.1.3. skipWaiting()

    -

    The skipWaiting() method allows this service worker to progress from the registration’s waiting position to active even while service worker clients are using the registration.

    +

    The skipWaiting() method allows this service worker to progress from the registration’s waiting position to active even while service worker clients are using the registration.

    skipWaiting() method must run these steps:

    1. Let promise be a new promise. @@ -2401,7 +2401,7 @@

      4.2 "none" }; -

      A Client object has an associated service worker client (a service worker client).

      +

      A Client object has an associated service worker client (a service worker client).

      A WindowClient object has an associated visibility state, which is one of visibilityState attribute value.

      A WindowClient object has an associated focus state, which is either true or false (initially false).

      @@ -2430,7 +2430,7 @@

      4.2.3. id

      -

      The id attribute must return its associated service worker client’s id.

      +

      The id attribute must return its associated service worker client’s id.

      4.2.4. postMessage(message, transfer)

      @@ -2497,7 +2497,7 @@

      Let url be the result of parsing url with the context object’s relevant settings object’s API base URL.
    2. If url is failure, return a promise rejected with a TypeError.
    3. If url is about:blank, return a promise rejected with a TypeError. -
    4. If the context object’s associated service worker client’s active worker is not the context object’s relevant global object’s service worker, return a promise rejected with a TypeError. +
    5. If the context object’s associated service worker client’s active service worker is not the context object’s relevant global object’s service worker, return a promise rejected with a TypeError.
    6. Let promise be a new promise.
    7. Run these substeps in parallel: @@ -2563,12 +2563,12 @@

      in parallel:
      1. - For each service worker client client whose origin is the same as the associated service worker’s origin: + For each service worker client client whose origin is the same as the associated service worker’s origin:
        1. - If client’s id is id, then: + If client’s id is id, then:
            -
          1. If client is not a secure context, reject promise with a "SecurityError" exception and abort these steps. +
          2. If client is not a secure context, reject promise with a "SecurityError" exception and abort these steps.
          3. If client is a window client, then:
              @@ -2608,13 +2608,13 @@

              service worker client client whose origin is the same as the associated service worker’s origin: + For each service worker client client whose origin is the same as the associated service worker’s origin:
                -
              1. If client is not a secure context, continue to the next iteration of the loop. +
              2. If client is not a secure context, continue to the next iteration of the loop.
              3. If options.includeUncontrolled is false, then:
                  -
                1. If client’s active worker is the associated service worker, add client to targetClients. +
                2. If client’s active service worker is the associated service worker, add client to targetClients.
              4. Else: @@ -2624,7 +2624,7 @@

                service worker client client in targetClients, in the most recently focused order for window clients: + For each service worker client client in targetClients, in the most recently focused order for window clients:
                1. If options.type is "window", and client is a window client, then: @@ -2746,22 +2746,22 @@

                  4.3.4. claim()

                  The claim() method must run these steps:

                    -
                  1. If the service worker is not an active worker, return a promise rejected with an "InvalidStateError" exception. +
                  2. If the service worker is not an active worker, return a promise rejected with an "InvalidStateError" exception.
                  3. Let promise be a new promise.
                  4. Run the following substeps in parallel:
                    1. - For each service worker client client whose origin is the same as the service worker’s origin: + For each service worker client client whose origin is the same as the service worker’s origin:
                        -
                      1. If client is not a secure context, continue to the next iteration of the loop. +
                      2. If client is not a secure context, continue to the next iteration of the loop.
                      3. Let registration be the result of running Match Service Worker Registration algorithm passing client’s creation url as the argument.
                      4. If registration is not the service worker’s containing service worker registration, continue to the next iteration of the loop.
                      5. - If client’s active worker is not the service worker, then: + If client’s active worker is not the service worker, then:
                        1. Invoke Handle Service Worker Client Unload with client as the argument. -
                        2. Set client’s active worker to service worker. +
                        3. Set client’s active worker to service worker.
                        4. Invoke Notify Controller Change algorithm with client as the argument.
                      @@ -2818,7 +2818,7 @@

                      Service workers define the following behaviors for install event and activate event, respectively:

    8. @@ -2878,7 +2878,9 @@

      [Constructor(DOMString type, FetchEventInit eventInitDict), Exposed=ServiceWorker] interface FetchEvent : ExtendableEvent { [SameObject] readonly attribute Request request; - readonly attribute DOMString? clientId; + readonly attribute DOMString clientId; + readonly attribute DOMString reservedClientId; + readonly attribute DOMString targetClientId; readonly attribute boolean isReload; void respondWith(Promise<Response> r); @@ -2886,7 +2888,9 @@

      dictionary FetchEventInit : ExtendableEventInit {
         required Request request;
      -  DOMString? clientId = null;
      +  DOMString clientId = "";
      +  DOMString reservedClientId = "";
      +  DOMString targetClientId = "";
         boolean isReload = false;
       };
       
      @@ -2904,15 +2908,23 @@

      4.6.2. event.clientId

      -

      clientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to null.

      +

      clientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

      -

      4.6.3. event.isReload

      +

      4.6.3. event.reservedClientId

      +

      reservedClientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

      +
      +
      +

      4.6.4. event.targetClientId

      +

      targetClientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

      +
      +
      +

      4.6.5. event.isReload

      isReload attribute must return the value it was initialized to. When an event is created the attribute must be initialized to false.

      Pressing the refresh button should be considered a reload while clicking a link and pressing the back button should not. The behavior of the Ctrl+l enter is left to the implementations of the user agents.

      -

      4.6.4. event.respondWith(r)

      +

      4.6.6. event.respondWith(r)

      Developers can set the argument r with either a promise that resolves with a Response object or a Response object (which is automatically cast to a promise). Otherwise, a network error is returned to Fetch. Renderer-side security checks about tainting for cross-origin content are tied to the types of filtered responses defined in Fetch.

      respondWith(r) method must run these steps:

        @@ -3167,7 +3179,7 @@

        4.8.2. event.origin

        -

        The origin attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents the origin of the service worker client that sent the message.

        +

        The origin attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents the origin of the service worker client that sent the message.

        4.8.3. event.lastEventId

        @@ -3199,7 +3211,7 @@

        activate ExtendableEvent - [Lifecycle event] The service worker’s containing service worker registration’s active worker changes. (See step 12.2 of the Activate algorithm.) + [Lifecycle event] The service worker’s containing service worker registration’s active worker changes. (See step 12.2 of the Activate algorithm.) fetch FetchEvent @@ -3224,9 +3236,9 @@

    9. Wait for task to have executed or been discarded, or the script to have been aborted by the termination of activeWorker.
    10. Wait for the step labeled WaitForAsynchronousExtensions to complete. -
    11. Run the Update Worker State algorithm passing registration’s active worker and activated as the arguments. +
    12. Run the Update Worker State algorithm passing registration’s active worker and activated as the arguments.
    @@ -4476,7 +4488,7 @@

    API base URL
    Return serviceWorker’s script url.
    The origin -
    Return its registering service worker client’s origin. +
    Return its registering service worker client’s origin.
    The creation URL
    Return workerGlobalScope’s url.
    The HTTPS state @@ -4487,7 +4499,7 @@

    referrer policy to serviceWorker’s script resource’s referrer policy.
  • Set workerGlobalScope’s type to serviceWorker’s type.
  • Create a new WorkerLocation object and associate it with workerGlobalScope. -
  • If serviceWorker is an active worker, and there are any tasks queued in serviceWorker’s containing service worker registration’s task queues, queue them to serviceWorker’s event loop’s task queues in the same order using their original task sources. +
  • If serviceWorker is an active worker, and there are any tasks queued in serviceWorker’s containing service worker registration’s task queues, queue them to serviceWorker’s event loop’s task queues in the same order using their original task sources.
  • If script is a classic script, then run the classic script script. Otherwise, it is a module script; run the module script script.

    In addition to the usual possibilities of returning a value or failing due to an exception, this could be prematurely aborted by the kill a worker or terminate a worker algorithms.

    @@ -4539,7 +4551,8 @@

    guard to immutable.
  • Let response be null.
  • Let registration be null. -
  • Let client be the service worker client that corresponds to request’s client. +
  • Let client be request’s client. +
  • Let reservedClient be request’s reserved client.
  • Assert: request’s destination is not "serviceworker".
  • If request is a potential-navigation-or-subresource request, then: @@ -4550,20 +4563,29 @@

    non-subresource request, then:

    If the non-subresource request is under the scope of a service worker registration, application cache is completely bypassed regardless of whether the non-subresource request uses the service worker registration.

      -
    1. If client is not a secure context, return null. +
    2. + If reservedClient is not null and is an environment settings object, then: +
        +
      1. If reservedClient is not a secure context, return null. +
      +
    3. + Else: +
        +
      1. If request’s url is not a potentially trustworthy URL, return null. +
    4. If request is a navigation request and the navigation triggering it was initiated with a shift+reload or equivalent, return null.
    5. Set registration to the result of running Match Service Worker Registration algorithm passing request’s url as the argument. -
    6. If registration is null or registration’s active worker is null, return null. -
    7. Set client’s active worker to registration’s active worker. +
    8. If registration is null or registration’s active worker is null, return null. +
    9. If request’s destination is not "report", set reservedClient’s active service worker to registration’s active worker.
    -

    From this point, the service worker client starts to use its active worker’s containing service worker registration.

    +

    From this point, the service worker client starts to use its active service worker’s containing service worker registration.

  • Else if request is a subresource request, then:
      -
    1. If client’s active worker is non-null, set registration to client’s active worker’s containing service worker registration. +
    2. If client’s active service worker is non-null, set registration to client’s active service worker’s containing service worker registration.
    3. Else, return null.
    -
  • Let activeWorker be registration’s active worker. +
  • Let activeWorker be registration’s active worker.
  • If activeWorker’s set of event types to handle does not contain fetch, return null.

    To avoid unnecessary delays, the Handle Fetch enforces early return when no event listeners have been deterministically added in the service worker’s global during the very first script execution.

    @@ -4574,7 +4596,9 @@

    FetchEvent interface, with the event type fetch, which does not bubble.
  • Let the request attribute of e be initialized to r. -
  • Let the clientId attribute of e be initialized to client’s id if request is not a non-subresource request, and to null otherwise. +
  • Initialize e’s clientId attribute to client’s id. +
  • If request is a non-subresource request and request’s destination is not "report", initialize e’s reservedClientId attribute to reservedClient’s id, and to the empty string otherwise. +
  • If request is a navigation request, initialize e’s targetClientId attribute to request’s target client id, and to the empty string otherwise.
  • 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.
  • Dispatch e at activeWorker’s environment settings object’s global object.
  • If e’s respond-with entered flag is set, set respondWithEntered to true. @@ -4628,7 +4652,7 @@

    If request is not a subresource request, return null and abort these steps.

    Foreign fetch only allows intercepting of subresource requests. Navigation requests can be intercepted by the regular fetch event anyway, so there is no benefit to supporting those requests here as well.

    -
  • If request’s client is not a secure context, return null and abort these steps. +
  • If request’s client is not a secure context, return null and abort these steps.
  • Let activeWorker be the result of running the Match Service Worker for Foreign Fetch algorithm passing request’s url as the argument.
  • If activeWorker is null, return null.
  • @@ -4719,8 +4743,8 @@

    Assert: a Record with the [[value]] equals to registration is contained in scope to registration map. -
  • Assert: registration’s active worker is not null. -
  • Let activeWorker be registration’s active worker. +
  • Assert: registration’s active worker is not null. +
  • Let activeWorker be registration’s active worker.
  • If activeWorker’s set of event types to handle does not contain the event type for this functional event, return.

    To avoid unnecessary delays, the Handle Functional Event enforces early return when no event listeners have been deterministically added in the service worker’s global during the very first script execution.

    @@ -4735,10 +4759,10 @@

    Handle Service Worker Client Unload

    -

    The user agent must run these steps when a service worker client unloads by unloading, being killed, or terminating.

    +

    The user agent must run these steps when a service worker client unloads by unloading, being killed, or terminating.

    Input -
    client, a service worker client +
    client, a service worker client
    Output
    None
    @@ -4746,7 +4770,7 @@

    service worker registration used by client.
  • If registration is null, abort these steps. -
  • If any other service worker client is using registration, abort these steps. +
  • If any other service worker client is using registration, abort these steps.
  • If registration’s uninstalling flag is set, invoke Clear Registration algorithm passing registration as its argument and abort these steps.
  • If registration’s waiting worker is not null, run Activate algorithm with registration as the argument. @@ -4803,7 +4827,7 @@

    Unre
  • Set registration’s uninstalling flag.
  • Invoke Resolve Job Promise with job and true.
  • - If no service worker client is using registration, invoke Clear Registration algorithm passing registration as its argument. + If no service worker client is using registration, invoke Clear Registration algorithm passing registration as its argument.

    When the registration is being used for a client, the deletion of the registration is handled by the Handle Service Worker Client Unload algorithm.

  • Invoke Finish Job with job. @@ -4854,9 +4878,9 @@

    Update Worker State algorithm passing redundantWorker and redundant as the arguments.
  • - If registration’s active worker is not null, then: + If registration’s active worker is not null, then:
      -
    1. Set redundantWorker to registration’s active worker. +
    2. Set redundantWorker to registration’s active worker.
    3. Terminate redundantWorker.
    4. The user agent may abort in-flight requests triggered by redundantWorker.
    5. Run the Update Registration State algorithm passing registration, "active" and null as the arguments. @@ -4900,11 +4924,11 @@

      Else if target is "active", then:
        -
      1. Set registration’s active worker to source. +
      2. Set registration’s active worker to source.
      3. For each registrationObject in registrationObjects:
          -
        1. Queue a task to set the active attribute of registrationObject to the ServiceWorker object that represents registration’s active worker, or null if registration’s active worker is null. +
        2. Queue a task to set the active attribute of registrationObject to the ServiceWorker object that represents registration’s active worker, or null if registration’s active worker is null.

      The task must use registrationObject’s relevant settings object’s responsible event loop and the DOM manipulation task source.

      @@ -4942,11 +4966,11 @@

      Up
      activating
      "activating" -

      The service worker in this state is considered an active worker. During this state, event.waitUntil(f) can be called inside the onactivate event handler to extend the life of the active worker until the passed promise resolves successfully. No functional events are dispatched until the state becomes activated.

      +

      The service worker in this state is considered an active worker. During this state, event.waitUntil(f) can be called inside the onactivate event handler to extend the life of the active worker until the passed promise resolves successfully. No functional events are dispatched until the state becomes activated.

      activated
      "activated" -

      The service worker in this state is considered an active worker ready to handle functional events.

      +

      The service worker in this state is considered an active worker ready to handle functional events.

      redundant
      "redundant" @@ -4962,7 +4986,7 @@

      Up

      Notify Controller Change

      Input -
      client, a service worker client +
      client, a service worker client
      Output
      None
      @@ -5006,7 +5030,7 @@

      Run the following steps atomically.
    6. Let registration be the result of running the Match Service Worker Registration algorithm passing requestURL as the argument.
    7. If registration is null, return null. -
    8. Let worker be registration’s active worker. +
    9. Let worker be registration’s active worker.
    10. If worker is null, return null.
    11. Let requestURLString be the serialized requestURL.
    12. @@ -5052,7 +5076,7 @@

      installing worker is not null, set newestWorker to registration’s installing worker.
    13. Else if registration’s waiting worker is not null, set newestWorker to registration’s waiting worker. -
    14. Else if registration’s active worker is not null, set newestWorker to registration’s active worker. +
    15. Else if registration’s active worker is not null, set newestWorker to registration’s active worker.
    16. Return newestWorker.
  • @@ -5060,7 +5084,7 @@

    Create Client

    Input -
    client, a service worker client +
    client, a service worker client
    Output
    clientObject, a Client object
    @@ -5074,7 +5098,7 @@

    C

    Create Window Client

    Input -
    client, a service worker client +
    client, a service worker client
    visibilityState, a string
    focusState, a boolean
    Output @@ -5263,7 +5287,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.

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

    @@ -5365,12 +5389,7 @@

    activating, in §3.1
  • "activating", in §3.1
  • active, in §3.2.3 -
  • - active worker - +
  • active worker, in §2.2
  • addAll(requests), in §6.4.4
  • add(request), in §6.4.3
  • all, in §4.3 @@ -5458,7 +5477,6 @@

    dfn for service worker, in §2.1 -
  • dfn for service worker client, in §2.3
  • attribute for Client, in §4.2.3
  • ignoreMethod, in §6.4 @@ -5486,7 +5504,7 @@

    dict-member for FetchEventInit, in §4.6 -
  • attribute for FetchEvent, in §4.6.3 +
  • attribute for FetchEvent, in §4.6.5
  • job, in §Unnumbered section
  • job promise, in §Unnumbered section @@ -5621,6 +5639,12 @@

    dict-member for CacheBatchOperation, in §6.4
  • request to response map, in §6.1 +
  • + reservedClientId +
  • respond-with entered flag
  • @@ -5726,6 +5750,12 @@

    attribute for ServiceWorker, in §3.1.2
  • statechange, in §3.6 +
  • + targetClientId +
  • task queues, in §2.2
  • top-level, in §4.2
  • "top-level", in §4.2 @@ -5866,6 +5896,7 @@

    redirect mode
  • request (for fetch)
  • request (for request) +
  • reserved client
  • response (for fetch)
  • response (for response)
  • response tainting @@ -5873,6 +5904,7 @@

    status
  • stream
  • subresource request +
  • target client id
  • terminate
  • termination reason
  • type @@ -5900,6 +5932,7 @@

    WorkerType
  • a browsing context is discarded
  • active document +
  • active service worker
  • api base url
  • api url character encoding
  • application cache @@ -5910,6 +5943,7 @@

    discard a document
  • document base url
  • dom manipulation task source +
  • environment
  • environment settings object
  • event handler
  • event handler event type @@ -5981,13 +6015,6 @@

    VisibilityState
  • visibilityState -
  • - [secure-contexts] defines the following terms: -
  • [promises-guide] defines the following terms:
      @@ -6017,6 +6044,14 @@

    • vary
    +
  • + [secure-contexts] defines the following terms: +
  • [WHATWG-URL] defines the following terms: - - - + + @@ -7591,7 +7628,7 @@

    #fetch-event-respondwith-methodReferenced in: diff --git a/docs/v1/index.bs b/docs/v1/index.bs index 67f40d1d..90596499 100644 --- a/docs/v1/index.bs +++ b/docs/v1/index.bs @@ -116,6 +116,8 @@ spec: fetch; urlPrefix: https://fetch.spec.whatwg.org/ text: method text: redirect mode text: request + text: reserved client + text: target client id text: url for: response; urlPrefix: #concept-response- text: body @@ -144,7 +146,9 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/ urlPrefix: interaction.html text: has focus steps urlPrefix: webappapis.html + text: active service worker; for: environment text: dom manipulation task source + text: environment text: run a classic script text: run a module script text: task queue; for: event loop @@ -160,9 +164,10 @@ spec: page-visibility; urlPrefix: https://www.w3.org/TR/page-visibility/ type: enum; text: VisibilityState; url: VisibilityState type: attribute; text: visibilityState; for: Document; url: dom-document-visibilitystate -spec: powerful-features; urlPrefix: https://w3c.github.io/webappsec/specs/powerfulfeatures/# +spec: secure-contexts; urlPrefix: https://w3c.github.io/webappsec-secure-contexts/# type: dfn text: is origin potentially trustworthy; url: is-origin-trustworthy + text: potentially-trustworthy-url; url: potentially-trustworthy-url text: risks associated with insecure contexts; url: threat-risks text: secure context @@ -261,11 +266,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/

    Service Worker Client

    -

    A service worker client is a type of environment settings object.

    - -

    A service worker client has an associated active worker (an active worker) which currently controls it. It is initially set to null.

    - -

    A service worker client has an associated id (an opaque string), which uniquely identifies itself during its lifetime. It is initially set to a new unique value when the corresponding environment settings object that it represents is created.

    +

    A service worker client is a type of environment or environment settings object.

    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. @@ -520,7 +521,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/

    -

    The {{ServiceWorkerRegistration/unregister()}} method unregisters the service worker registration. It is important to note that the currently controlled service worker client's active worker's containing service worker registration is effective until all the service worker clients (including itself) using this service worker registration unload. That is, the {{ServiceWorkerRegistration/unregister()}} method only affects subsequent navigations.

    +

    The {{ServiceWorkerRegistration/unregister()}} method unregisters the service worker registration. It is important to note that the currently controlled service worker client's active service worker's containing service worker registration is effective until all the service worker clients (including itself) using this service worker registration unload. That is, the {{ServiceWorkerRegistration/unregister()}} method only affects subsequent navigations.

    unregister() method must run these steps:

    @@ -616,7 +617,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
    1. Let client be the context object's service worker client.
    2. -
    3. Return the {{ServiceWorker}} object that represents client's active worker.
    4. +
    5. Return the {{ServiceWorker}} object that represents client's active service worker.

    {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} returns null if the request is a force refresh (shift+refresh). The {{ServiceWorker}} objects returned from this attribute getter that represent the same service worker are the same objects.

    @@ -884,7 +885,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/ controllerchange {{Event}} - The service worker client's active worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a service worker causes activation of the service worker registration to occur while service worker clients are using the service worker registration, {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} immediately reflects the active worker as the service worker that controls the service worker client.) + The service worker client's active service worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a service worker causes activation of the service worker registration to occur while service worker clients are using the service worker registration, {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} immediately reflects the active worker as the service worker that controls the service worker client.) message @@ -1100,7 +1101,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/

    {{Client/id}}

    -

    The id attribute must return its associated service worker client's id.

    +

    The id attribute must return its associated service worker client's id.

    @@ -1180,7 +1181,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
  • Let url be the result of parsing url with the context object's relevant settings object's API base URL.
  • If url is failure, return a promise rejected with a TypeError.
  • If url is about:blank, return a promise rejected with a TypeError.
  • -
  • If the context object's associated service worker client's active worker is not the context object's relevant global object's service worker, return a promise rejected with a TypeError.
  • +
  • If the context object's associated service worker client's active service worker is not the context object's relevant global object's service worker, return a promise rejected with a TypeError.
  • Let promise be a new promise.
  • Run these substeps in parallel:
      @@ -1255,7 +1256,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
      1. For each service worker client client whose origin is the same as the associated service worker's origin:
          -
        1. If client's id is id, then: +
        2. If client's id is id, then:
          1. If client is not a secure context, reject promise with a "{{SecurityError}}" exception and abort these steps.
          2. If client is a window client, then: @@ -1306,7 +1307,7 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
          3. If client is not a secure context, continue to the next iteration of the loop.
          4. If options.{{ClientQueryOptions/includeUncontrolled}} is false, then:
              -
            1. If client's active worker is the associated service worker, add client to targetClients.
            2. +
            3. If client's active service worker is the associated service worker, add client to targetClients.
          5. Else: @@ -1547,7 +1548,9 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/ [Constructor(DOMString type, FetchEventInit eventInitDict), Exposed=ServiceWorker] interface FetchEvent : ExtendableEvent { [SameObject] readonly attribute Request request; - readonly attribute DOMString? clientId; + readonly attribute DOMString clientId; + readonly attribute DOMString reservedClientId; + readonly attribute DOMString targetClientId; readonly attribute boolean isReload; void respondWith(Promise<Response> r); @@ -1556,7 +1559,9 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
                   dictionary FetchEventInit : ExtendableEventInit {
                     required Request request;
            -        DOMString? clientId = null;
            +        DOMString clientId = null;
            +        DOMString reservedClientId = "";
            +        DOMString targetClientId = "";
                     boolean isReload = false;
                   };
                 
            @@ -1580,7 +1585,19 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/

            {{FetchEvent/clientId|event.clientId}}

            -

            clientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to null.

            +

            clientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

            +
            + +
            +

            {{FetchEvent/reservedClientId|event.reservedClientId}}

            + +

            reservedClientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

            +
            + +
            +

            {{FetchEvent/targetClientId|event.targetClientId}}

            + +

            targetClientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

            @@ -3168,7 +3185,8 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
          6. Set headersObject's guard to immutable.
          7. Let response be null.
          8. Let registration be null.
          9. -
          10. Let client be the service worker client that corresponds to request's client.
          11. +
          12. Let client be request's client.
          13. +
          14. Let reservedClient be request's reserved client.
          15. Assert: request's destination is not "serviceworker".
          16. If request is a potential-navigation-or-subresource request, then:
              @@ -3178,17 +3196,26 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
            1. Else if request is a non-subresource request, then:

              If the non-subresource request is under the scope of a service worker registration, application cache is completely bypassed regardless of whether the non-subresource request uses the service worker registration.

                -
              1. If client is not a secure context, return null.
              2. +
              3. If reservedClient is not null and is an environment settings object, then: +
                  +
                1. If reservedClient is not a secure context, return null.
                2. +
                +
              4. +
              5. Else: +
                  +
                1. If request's url is not a potentially trustworthy URL, return null.
                2. +
                +
              6. If request is a navigation request and the navigation triggering it was initiated with a shift+reload or equivalent, return null.
              7. Set registration to the result of running Match Service Worker Registration algorithm passing request's url as the argument.
              8. If registration is null or registration's active worker is null, return null.
              9. -
              10. Set client's active worker to registration's active worker.
              11. +
              12. If request's destination is not "report", set reservedClient's active service worker to registration's active worker.
              -

              From this point, the service worker client starts to use its active worker's containing service worker registration.

              +

              From this point, the service worker client starts to use its active service worker's containing service worker registration.

            2. Else if request is a subresource request, then:
                -
              1. If client's active worker is non-null, set registration to client's active worker's containing service worker registration.
              2. +
              3. If client's active service worker is non-null, set registration to client's active service worker's containing service worker registration.
              4. Else, return null.
            3. @@ -3202,7 +3229,9 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
              1. Create a trusted event e that uses the {{FetchEvent}} interface, with the event type fetch, which does not bubble.
              2. Let the request attribute of e be initialized to r.
              3. -
              4. Let the clientId attribute of e be initialized to client's id if request is not a non-subresource request, and to null otherwise.
              5. +
              6. Initialize e's {{FetchEvent/clientId}} attribute to client's id.
              7. +
              8. If request is a non-subresource request and request's destination is not "report", initialize e's {{FetchEvent/reservedClientId}} attribute to reservedClient's id, and to the empty string otherwise.
              9. +
              10. If request is a navigation request, initialize e's {{FetchEvent/targetClientId}} attribute to request's target client id, and to the empty string otherwise.
              11. 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.
              12. Dispatch e at activeWorker's environment settings object's global object.
              13. If e's respond-with entered flag is set, set respondWithEntered to true.
              14. diff --git a/docs/v1/index.html b/docs/v1/index.html index 7dbd75eb..18b9e857 100644 --- a/docs/v1/index.html +++ b/docs/v1/index.html @@ -1577,8 +1577,10 @@

                Table of Contents

                1. 4.5.1 event.request
                2. 4.5.2 event.clientId -
                3. 4.5.3 event.isReload -
                4. 4.5.4 event.respondWith(r) +
                5. 4.5.3 event.reservedClientId +
                6. 4.5.4 event.targetClientId +
                7. 4.5.5 event.isReload +
                8. 4.5.6 event.respondWith(r)
              15. 4.6 ExtendableMessageEvent @@ -1765,21 +1767,19 @@

                2.3. Service Worker Client

                -

                A service worker client is a type of environment settings object.

                -

                A service worker client has an associated active worker (an active worker) which currently controls it. It is initially set to null.

                -

                A service worker client has an associated id (an opaque string), which uniquely identifies itself during its lifetime. It is initially set to a new unique value when the corresponding environment settings object that it represents is created.

                -

                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 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 service worker client is a type of environment or environment settings object.

                +

                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 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 worker client is either a dedicated worker client or a shared worker client.

          17. 2.4. Selection and Use

            -

            A service worker client independently selects and uses a service worker registration for its own loading and its subresources. The selection of a service worker registration, upon a non-subresource request, is a process of either matching a service worker registration from scope to registration map or inheriting an existing service worker registration from its parent or owner context depending on the request’s url.

            -

            When the request’s url is not local, a service worker client matches a service worker registration from scope to registration map. That is, the service worker client attempts to consult a service worker registration whose scope url matches its creation url.

            -

            When the request’s url is local, if the service worker client’s responsible browsing context is a nested browsing context or the service worker client is a worker client, the service worker client inherits the service worker registration from its parent browsing context’s environment or one of the worker’s Documents' environment, respectively, if it exists.

            -

            If the selection was successful, the selected service worker registration’s active worker starts to control the service worker client. Otherwise, the flow returns to fetch where it falls back to the default behavior. When a service worker client is controlled by an active worker, it is considered that the service worker client is using the active worker’s containing service worker registration.

            +

            A service worker client independently selects and uses a service worker registration for its own loading and its subresources. The selection of a service worker registration, upon a non-subresource request, is a process of either matching a service worker registration from scope to registration map or inheriting an existing service worker registration from its parent or owner context depending on the request’s url.

            +

            When the request’s url is not local, a service worker client matches a service worker registration from scope to registration map. That is, the service worker client attempts to consult a service worker registration whose scope url matches its creation url.

            +

            When the request’s url is local, if the service worker client’s responsible browsing context is a nested browsing context or the service worker client is a worker client, the service worker client inherits the service worker registration from its parent browsing context’s environment or one of the worker’s Documents' environment, respectively, if it exists.

            +

            If the selection was successful, the selected service worker registration’s active worker starts to control the service worker client. Otherwise, the flow returns to fetch where it falls back to the default behavior. When a service worker client is controlled by an active worker, it is considered that the service worker client is using the active worker’s containing service worker registration.

            2.5. Task Sources

            @@ -1798,7 +1798,7 @@

            A user agent must maintain the state of its stored service worker registrations across restarts with the following rules:

            To attain this, the user agent must invoke Handle User Agent Shutdown when it terminates.

            @@ -1959,7 +1959,7 @@

            -

            The unregister() method unregisters the service worker registration. It is important to note that the currently controlled service worker client’s active worker’s containing service worker registration is effective until all the service worker clients (including itself) using this service worker registration unload. That is, the unregister() method only affects subsequent navigations.

            +

            The unregister() method unregisters the service worker registration. It is important to note that the currently controlled service worker client’s active service worker’s containing service worker registration is effective until all the service worker clients (including itself) using this service worker registration unload. That is, the unregister() method only affects subsequent navigations.

            unregister() method must run these steps:

            1. Let p be a promise. @@ -2022,7 +2022,7 @@

              The user agent must create a ServiceWorkerContainer object when a Navigator object or a WorkerNavigator object is created and associate it with that object.

              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.

              A ServiceWorkerContainer object has a task source called the client message queue, initially empty. A client message queue can be enabled or disabled, and is initially disabled. When a ServiceWorkerContainer object’s client message queue is enabled, the event loop must use it as one of its task sources. When the ServiceWorkerContainer object’s relevant global object is a Window object, all tasks queued on its client message queue must be associated with its relevant settings object’s responsible document.

              @@ -2030,7 +2030,7 @@
              @@ -2057,13 +2057,13 @@

          18. Return context object’s ready promise.
          -

          When the ready attribute is accessed, the returned promise will never reject. Instead, it waits until the promise resolves with a service worker registration that has an active worker.

          +

          When the ready attribute is accessed, the returned promise will never reject. Instead, it waits until the promise resolves with a service worker registration that has an active worker.

  • @@ -2239,7 +2239,7 @@

    controllerchange Event - The service worker client’s active worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a service worker causes activation of the service worker registration to occur while service worker clients are using the service worker registration, navigator.serviceWorker.controller immediately reflects the active worker as the service worker that controls the service worker client.) + The service worker client’s active service worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a service worker causes activation of the service worker registration to occur while service worker clients are using the service worker registration, navigator.serviceWorker.controller immediately reflects the active worker as the service worker that controls the service worker client.) message ServiceWorkerMessageEvent @@ -2305,7 +2305,7 @@

    A ServiceWorkerGlobalScope object represents the global execution context of a service worker. A ServiceWorkerGlobalScope object has an associated service worker (a service worker).

    -

    ServiceWorkerGlobalScope object provides generic, event-driven, time-limited script execution contexts that run at an origin. Once successfully registered, a service worker is started, kept alive and killed by their relationship to events, not service worker clients. Any type of synchronous requests must not be initiated inside of a service worker.

    +

    ServiceWorkerGlobalScope object provides generic, event-driven, time-limited script execution contexts that run at an origin. Once successfully registered, a service worker is started, kept alive and killed by their relationship to events, not service worker clients. Any type of synchronous requests must not be initiated inside of a service worker.

    4.1.1. clients

    clients attribute must return the Clients object that is associated with the context object.

    @@ -2316,7 +2316,7 @@

    4.1.3. skipWaiting()

    -

    The skipWaiting() method allows this service worker to progress from the registration’s waiting position to active even while service worker clients are using the registration.

    +

    The skipWaiting() method allows this service worker to progress from the registration’s waiting position to active even while service worker clients are using the registration.

    skipWaiting() method must run these steps:

    1. Let promise be a new promise. @@ -2383,7 +2383,7 @@

      4.2 "none" }; -

      A Client object has an associated service worker client (a service worker client).

      +

      A Client object has an associated service worker client (a service worker client).

      A WindowClient object has an associated visibility state, which is one of visibilityState attribute value.

      A WindowClient object has an associated focus state, which is either true or false (initially false).

      @@ -2412,7 +2412,7 @@

      4.2.3. id

      -

      The id attribute must return its associated service worker client’s id.

      +

      The id attribute must return its associated service worker client’s id.

      4.2.4. postMessage(message, transfer)

      @@ -2479,7 +2479,7 @@

      Let url be the result of parsing url with the context object’s relevant settings object’s API base URL.
    2. If url is failure, return a promise rejected with a TypeError.
    3. If url is about:blank, return a promise rejected with a TypeError. -
    4. If the context object’s associated service worker client’s active worker is not the context object’s relevant global object’s service worker, return a promise rejected with a TypeError. +
    5. If the context object’s associated service worker client’s active service worker is not the context object’s relevant global object’s service worker, return a promise rejected with a TypeError.
    6. Let promise be a new promise.
    7. Run these substeps in parallel: @@ -2545,12 +2545,12 @@

      in parallel:
      1. - For each service worker client client whose origin is the same as the associated service worker’s origin: + For each service worker client client whose origin is the same as the associated service worker’s origin:
        1. - If client’s id is id, then: + If client’s id is id, then:
            -
          1. If client is not a secure context, reject promise with a "SecurityError" exception and abort these steps. +
          2. If client is not a secure context, reject promise with a "SecurityError" exception and abort these steps.
          3. If client is a window client, then:
              @@ -2590,13 +2590,13 @@

              service worker client client whose origin is the same as the associated service worker’s origin: + For each service worker client client whose origin is the same as the associated service worker’s origin:
                -
              1. If client is not a secure context, continue to the next iteration of the loop. +
              2. If client is not a secure context, continue to the next iteration of the loop.
              3. If options.includeUncontrolled is false, then:
                  -
                1. If client’s active worker is the associated service worker, add client to targetClients. +
                2. If client’s active service worker is the associated service worker, add client to targetClients.
              4. Else: @@ -2606,7 +2606,7 @@

                service worker client client in targetClients, in the most recently focused order for window clients: + For each service worker client client in targetClients, in the most recently focused order for window clients:
                1. If options.type is "window", and client is a window client, then: @@ -2728,22 +2728,22 @@

                  4.3.4. claim()

                  The claim() method must run these steps:

                    -
                  1. If the service worker is not an active worker, return a promise rejected with an "InvalidStateError" exception. +
                  2. If the service worker is not an active worker, return a promise rejected with an "InvalidStateError" exception.
                  3. Let promise be a new promise.
                  4. Run the following substeps in parallel:
                    1. - For each service worker client client whose origin is the same as the service worker’s origin: + For each service worker client client whose origin is the same as the service worker’s origin:
                        -
                      1. If client is not a secure context, continue to the next iteration of the loop. +
                      2. If client is not a secure context, continue to the next iteration of the loop.
                      3. Let registration be the result of running Match Service Worker Registration algorithm passing client’s creation url as the argument.
                      4. If registration is not the service worker’s containing service worker registration, continue to the next iteration of the loop.
                      5. - If client’s active worker is not the service worker, then: + If client’s active worker is not the service worker, then:
                        1. Invoke Handle Service Worker Client Unload with client as the argument. -
                        2. Set client’s active worker to service worker. +
                        3. Set client’s active worker to service worker.
                        4. Invoke Notify Controller Change algorithm with client as the argument.
                      @@ -2800,7 +2800,7 @@

                      Service workers define the following behaviors for install event and activate event, respectively:

    8. @@ -2808,7 +2808,9 @@

      [Constructor(DOMString type, FetchEventInit eventInitDict), Exposed=ServiceWorker] interface FetchEvent : ExtendableEvent { [SameObject] readonly attribute Request request; - readonly attribute DOMString? clientId; + readonly attribute DOMString clientId; + readonly attribute DOMString reservedClientId; + readonly attribute DOMString targetClientId; readonly attribute boolean isReload; void respondWith(Promise<Response> r); @@ -2816,7 +2818,9 @@

      dictionary FetchEventInit : ExtendableEventInit {
         required Request request;
      -  DOMString? clientId = null;
      +  DOMString clientId = null;
      +  DOMString reservedClientId = "";
      +  DOMString targetClientId = "";
         boolean isReload = false;
       };
       
      @@ -2834,15 +2838,23 @@

      4.5.2. event.clientId

      -

      clientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to null.

      +

      clientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

      -

      4.5.3. event.isReload

      +

      4.5.3. event.reservedClientId

      +

      reservedClientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

      +
      +
      +

      4.5.4. event.targetClientId

      +

      targetClientId attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.

      +
      +
      +

      4.5.5. event.isReload

      isReload attribute must return the value it was initialized to. When an event is created the attribute must be initialized to false.

      Pressing the refresh button should be considered a reload while clicking a link and pressing the back button should not. The behavior of the Ctrl+l enter is left to the implementations of the user agents.

      -

      4.5.4. event.respondWith(r)

      +

      4.5.6. event.respondWith(r)

      Developers can set the argument r with either a promise that resolves with a Response object or a Response object (which is automatically cast to a promise). Otherwise, a network error is returned to Fetch. Renderer-side security checks about tainting for cross-origin content are tied to the types of filtered responses defined in Fetch.

      respondWith(r) method must run these steps:

        @@ -2964,7 +2976,7 @@

        4.6.2. event.origin

        -

        The origin attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents the origin of the service worker client that sent the message.

        +

        The origin attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents the origin of the service worker client that sent the message.

        4.6.3. event.lastEventId

        @@ -2996,7 +3008,7 @@

        activate ExtendableEvent - [Lifecycle event] The service worker’s containing service worker registration’s active worker changes. (See step 12.2 of the Activate algorithm.) + [Lifecycle event] The service worker’s containing service worker registration’s active worker changes. (See step 12.2 of the Activate algorithm.) fetch FetchEvent @@ -3579,7 +3591,7 @@

        6. Security Considerations

        6.1. Secure Context

        -

        Service workers must execute in secure contexts. Service worker clients must also be secure contexts to register a service worker registration, to get access to the service worker registrations and the service workers, to do messaging with the service workers, and to be manipulated by the service workers. This effectively means that service workers and their service worker clients should be hosted over HTTPS. A user agent may allow localhost, 127.0.0.0/8, and ::1/128 for development purpose. (Note that they may still be secure contexts.) The primary reason for this restriction is to protect users from the risks associated with insecure contexts.

        +

        Service workers must execute in secure contexts. Service worker clients must also be secure contexts to register a service worker registration, to get access to the service worker registrations and the service workers, to do messaging with the service workers, and to be manipulated by the service workers. This effectively means that service workers and their service worker clients should be hosted over HTTPS. A user agent may allow localhost, 127.0.0.0/8, and ::1/128 for development purpose. (Note that they may still be secure contexts.) The primary reason for this restriction is to protect users from the risks associated with insecure contexts.

        6.2. Content Security Policy

        @@ -3596,7 +3608,7 @@

        6.3.1. Origin restriction

        This section is non-normative.

        -

        A Service worker executes in the registering service worker client’s origin. One of the advanced concerns that major applications would encounter is whether they can be hosted from a CDN. By definition, these are servers in other places, often on other origins. Therefore, service workers cannot be hosted on CDNs. But they can include resources via importScripts(). The reason for this restriction is that service workers create the opportunity for a bad actor to turn a bad day into a bad eternity.

        +

        A Service worker executes in the registering service worker client’s origin. One of the advanced concerns that major applications would encounter is whether they can be hosted from a CDN. By definition, these are servers in other places, often on other origins. Therefore, service workers cannot be hosted on CDNs. But they can include resources via importScripts(). The reason for this restriction is that service workers create the opportunity for a bad actor to turn a bad day into a bad eternity.

        6.3.2. importScripts(urls)

        @@ -3696,7 +3708,7 @@

        Appendix A: Al

        A job has a scope url (a URL).

        A job has a script url (a URL).

        A job has a worker type ("classic" or "module").

        -

        A job has a client (a service worker client). It is initially null.

        +

        A job has a client (a service worker client). It is initially null.

        A job has a promise (a promise). It is initially null.

        A job has a list of equivalent jobs (a list of jobs). It is initially the empty list.

        A job has a force bypass cache flag It is initially unset.

        @@ -3715,7 +3727,7 @@

        Crea
        scopeURL, a URL
        scriptURL, a URL
        promise, a promise -
        client, a service worker client +
        client, a service worker client
        Output
        job, a job @@ -3834,7 +3846,7 @@

        Regist
        1. - If the result of running Is origin potentially trustworthy with the origin of job’s script url as the argument is Not Trusted, then: + If the result of running Is origin potentially trustworthy with the origin of job’s script url as the argument is Not Trusted, then:
          1. Invoke Reject Job Promise with job and a "SecurityError" exception.
          2. Invoke Finish Job with job and abort these steps. @@ -3982,7 +3994,7 @@

            Update
          3. Let worker be a new service worker. -
          4. Generate a unique opaque string and set worker’s id to the value. +
          5. Generate a unique opaque string and set worker’s id to the value.
          6. 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.
          7. Set worker’s script resource’s HTTPS state to httpsState.
          8. Set worker’s script resource’s referrer policy to referrerPolicy. @@ -4036,7 +4048,7 @@

            In
          9. Run the Update Worker State algorithm passing registration’s installing worker and installing as the arguments.
          10. Assert: job’s promise is not null.
          11. Invoke Resolve Job Promise with job and the ServiceWorkerRegistration object which represents registration. -
          12. 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. +
          13. 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.
          14. Let installingWorker be registration’s installing worker.
          15. Invoke Run Service Worker algorithm with installingWorker as the argument.
          16. @@ -4083,7 +4095,7 @@

            In

        2. Invoke Finish Job with job.
        3. Wait for all the tasks queued by Update Worker State invoked in this algorithm have executed. -
        4. Wait until no service worker client is using registration or registration’s waiting worker’s skip waiting flag is set. +
        5. Wait until no service worker client is using registration or registration’s waiting worker’s skip waiting flag is set.
        6. If registration’s waiting worker waitingWorker is not null and waitingWorker’s skip waiting flag is not set, invoke Activate algorithm with registration as its argument.

        @@ -4099,32 +4111,32 @@

        Acti
      1. If registration’s waiting worker is null, abort these steps.
      2. Let redundantWorker be null.
      3. - If registration’s active worker is not null, then: + If registration’s active worker is not null, then:
          -
        1. Set redundantWorker to registration’s active worker. +
        2. Set redundantWorker to registration’s active worker.
        3. Wait for redundantWorker to finish handling any in-progress requests.
        4. Terminate redundantWorker.
      4. Run the Update Registration State algorithm passing registration, "active" and registration’s waiting worker as the arguments.
      5. Run the Update Registration State algorithm passing registration, "waiting" and null as the arguments.
      6. - Run the Update Worker State algorithm passing registration’s active worker and activating as the arguments. + Run the Update Worker State algorithm passing registration’s active worker and activating as the arguments.

        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.

      7. If redundantWorker is not null, run the Update Worker State algorithm passing redundantWorker and redundant as the arguments.
      8. - 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.
        2. 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.

      9. - For each service worker client client who is using registration: + For each service worker client client who is using registration:
          -
        1. Set client’s active worker to registration’s active worker. +
        2. Set client’s active worker to registration’s active worker.
        3. Invoke Notify Controller Change algorithm with client as the argument.
        -
      10. Let activeWorker be registration’s active worker. +
      11. Let activeWorker be registration’s active worker.
      12. Invoke Run Service Worker algorithm with activeWorker as the argument.
      13. Queue a task task to run the following substeps: @@ -4135,7 +4147,7 @@

        Acti

    9. Wait for task to have executed or been discarded, or the script to have been aborted by the termination of activeWorker.
    10. Wait for the step labeled WaitForAsynchronousExtensions to complete. -
    11. Run the Update Worker State algorithm passing registration’s active worker and activated as the arguments. +
    12. Run the Update Worker State algorithm passing registration’s active worker and activated as the arguments.
    @@ -4175,7 +4187,7 @@

    API base URL
    Return serviceWorker’s script url.
    The origin -
    Return its registering service worker client’s origin. +
    Return its registering service worker client’s origin.
    The creation URL
    Return workerGlobalScope’s url.
    The HTTPS state @@ -4186,7 +4198,7 @@

    referrer policy to serviceWorker’s script resource’s referrer policy.
  • Set workerGlobalScope’s type to serviceWorker’s type.
  • Create a new WorkerLocation object and associate it with workerGlobalScope. -
  • If serviceWorker is an active worker, and there are any tasks queued in serviceWorker’s containing service worker registration’s task queues, queue them to serviceWorker’s event loop’s task queues in the same order using their original task sources. +
  • If serviceWorker is an active worker, and there are any tasks queued in serviceWorker’s containing service worker registration’s task queues, queue them to serviceWorker’s event loop’s task queues in the same order using their original task sources.
  • If script is a classic script, then run the classic script script. Otherwise, it is a module script; run the module script script.

    In addition to the usual possibilities of returning a value or failing due to an exception, this could be prematurely aborted by the kill a worker or terminate a worker algorithms.

    @@ -4238,7 +4250,8 @@

    guard to immutable.
  • Let response be null.
  • Let registration be null. -
  • Let client be the service worker client that corresponds to request’s client. +
  • Let client be request’s client. +
  • Let reservedClient be request’s reserved client.
  • Assert: request’s destination is not "serviceworker".
  • If request is a potential-navigation-or-subresource request, then: @@ -4249,20 +4262,29 @@

    non-subresource request, then:

    If the non-subresource request is under the scope of a service worker registration, application cache is completely bypassed regardless of whether the non-subresource request uses the service worker registration.

      -
    1. If client is not a secure context, return null. +
    2. + If reservedClient is not null and is an environment settings object, then: +
        +
      1. If reservedClient is not a secure context, return null. +
      +
    3. + Else: +
        +
      1. If request’s url is not a potentially trustworthy URL, return null. +
    4. If request is a navigation request and the navigation triggering it was initiated with a shift+reload or equivalent, return null.
    5. Set registration to the result of running Match Service Worker Registration algorithm passing request’s url as the argument. -
    6. If registration is null or registration’s active worker is null, return null. -
    7. Set client’s active worker to registration’s active worker. +
    8. If registration is null or registration’s active worker is null, return null. +
    9. If request’s destination is not "report", set reservedClient’s active service worker to registration’s active worker.
    -

    From this point, the service worker client starts to use its active worker’s containing service worker registration.

    +

    From this point, the service worker client starts to use its active service worker’s containing service worker registration.

  • Else if request is a subresource request, then:
      -
    1. If client’s active worker is non-null, set registration to client’s active worker’s containing service worker registration. +
    2. If client’s active service worker is non-null, set registration to client’s active service worker’s containing service worker registration.
    3. Else, return null.
    -
  • Let activeWorker be registration’s active worker. +
  • Let activeWorker be registration’s active worker.
  • If activeWorker’s set of event types to handle does not contain fetch, return null.

    To avoid unnecessary delays, the Handle Fetch enforces early return when no event listeners have been deterministically added in the service worker’s global during the very first script execution.

    @@ -4273,7 +4295,9 @@

    FetchEvent interface, with the event type fetch, which does not bubble.
  • Let the request attribute of e be initialized to r. -
  • Let the clientId attribute of e be initialized to client’s id if request is not a non-subresource request, and to null otherwise. +
  • Initialize e’s clientId attribute to client’s id. +
  • If request is a non-subresource request and request’s destination is not "report", initialize e’s reservedClientId attribute to reservedClient’s id, and to the empty string otherwise. +
  • If request is a navigation request, initialize e’s targetClientId attribute to request’s target client id, and to the empty string otherwise.
  • 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.
  • Dispatch e at activeWorker’s environment settings object’s global object.
  • If e’s respond-with entered flag is set, set respondWithEntered to true. @@ -4322,8 +4346,8 @@

    Assert: a Record with the [[value]] equals to registration is contained in scope to registration map. -
  • Assert: registration’s active worker is not null. -
  • Let activeWorker be registration’s active worker. +
  • Assert: registration’s active worker is not null. +
  • Let activeWorker be registration’s active worker.
  • If activeWorker’s set of event types to handle does not contain the event type for this functional event, return.

    To avoid unnecessary delays, the Handle Functional Event enforces early return when no event listeners have been deterministically added in the service worker’s global during the very first script execution.

    @@ -4338,10 +4362,10 @@

    Handle Service Worker Client Unload

    -

    The user agent must run these steps when a service worker client unloads by unloading, being killed, or terminating.

    +

    The user agent must run these steps when a service worker client unloads by unloading, being killed, or terminating.

    Input -
    client, a service worker client +
    client, a service worker client
    Output
    None
    @@ -4349,7 +4373,7 @@

    service worker registration used by client.
  • If registration is null, abort these steps. -
  • If any other service worker client is using registration, abort these steps. +
  • If any other service worker client is using registration, abort these steps.
  • If registration’s uninstalling flag is set, invoke Clear Registration algorithm passing registration as its argument and abort these steps.
  • If registration’s waiting worker is not null, run Activate algorithm with registration as the argument. @@ -4406,7 +4430,7 @@

    Unre
  • Set registration’s uninstalling flag.
  • Invoke Resolve Job Promise with job and true.
  • - If no service worker client is using registration, invoke Clear Registration algorithm passing registration as its argument. + If no service worker client is using registration, invoke Clear Registration algorithm passing registration as its argument.

    When the registration is being used for a client, the deletion of the registration is handled by the Handle Service Worker Client Unload algorithm.

  • Invoke Finish Job with job. @@ -4457,9 +4481,9 @@

    Update Worker State algorithm passing redundantWorker and redundant as the arguments.
  • - If registration’s active worker is not null, then: + If registration’s active worker is not null, then:
      -
    1. Set redundantWorker to registration’s active worker. +
    2. Set redundantWorker to registration’s active worker.
    3. Terminate redundantWorker.
    4. The user agent may abort in-flight requests triggered by redundantWorker.
    5. Run the Update Registration State algorithm passing registration, "active" and null as the arguments. @@ -4503,11 +4527,11 @@

      Else if target is "active", then:
        -
      1. Set registration’s active worker to source. +
      2. Set registration’s active worker to source.
      3. For each registrationObject in registrationObjects:
          -
        1. Queue a task to set the active attribute of registrationObject to the ServiceWorker object that represents registration’s active worker, or null if registration’s active worker is null. +
        2. Queue a task to set the active attribute of registrationObject to the ServiceWorker object that represents registration’s active worker, or null if registration’s active worker is null.

      The task must use registrationObject’s relevant settings object’s responsible event loop and the DOM manipulation task source.

      @@ -4545,11 +4569,11 @@

      Up
      activating
      "activating" -

      The service worker in this state is considered an active worker. During this state, event.waitUntil(f) can be called inside the onactivate event handler to extend the life of the active worker until the passed promise resolves successfully. No functional events are dispatched until the state becomes activated.

      +

      The service worker in this state is considered an active worker. During this state, event.waitUntil(f) can be called inside the onactivate event handler to extend the life of the active worker until the passed promise resolves successfully. No functional events are dispatched until the state becomes activated.

      activated
      "activated" -

      The service worker in this state is considered an active worker ready to handle functional events.

      +

      The service worker in this state is considered an active worker ready to handle functional events.

      redundant
      "redundant" @@ -4565,7 +4589,7 @@

      Up

      Notify Controller Change

      Input -
      client, a service worker client +
      client, a service worker client
      Output
      None
      @@ -4631,7 +4655,7 @@

      installing worker is not null, set newestWorker to registration’s installing worker.
    6. Else if registration’s waiting worker is not null, set newestWorker to registration’s waiting worker. -
    7. Else if registration’s active worker is not null, set newestWorker to registration’s active worker. +
    8. Else if registration’s active worker is not null, set newestWorker to registration’s active worker.
    9. Return newestWorker.
  • @@ -4639,7 +4663,7 @@

    Create Client

    Input -
    client, a service worker client +
    client, a service worker client
    Output
    clientObject, a Client object
    @@ -4653,7 +4677,7 @@

    C

    Create Window Client

    Input -
    client, a service worker client +
    client, a service worker client
    visibilityState, a string
    focusState, a boolean
    Output @@ -4842,7 +4866,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.

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

    @@ -4944,12 +4968,7 @@

    activating, in §3.1
  • "activating", in §3.1
  • active, in §3.2.3 -
  • - active worker - +
  • active worker, in §2.2
  • addAll(requests), in §5.4.4
  • add(request), in §5.4.3
  • all, in §4.3 @@ -5030,7 +5049,6 @@

    dfn for service worker, in §2.1 -
  • dfn for service worker client, in §2.3
  • attribute for Client, in §4.2.3
  • ignoreMethod, in §5.4 @@ -5055,7 +5073,7 @@

    dict-member for FetchEventInit, in §4.5 -
  • attribute for FetchEvent, in §4.5.3 +
  • attribute for FetchEvent, in §4.5.5
  • job, in §Unnumbered section
  • job promise, in §Unnumbered section @@ -5172,9 +5190,15 @@

    dict-member for CacheBatchOperation, in §5.4
  • request to response map, in §5.1 +
  • + reservedClientId +
  • respond-with entered flag, in §4.5
  • respond-with error flag, in §4.5 -
  • respondWith(r), in §4.5.4 +
  • respondWith(r), in §4.5.6
  • response, in §5.4
  • scope @@ -5252,6 +5276,12 @@

    attribute for ServiceWorker, in §3.1.2
  • statechange, in §3.6 +
  • + targetClientId +
  • task queues, in §2.2
  • top-level, in §4.2
  • "top-level", in §4.2 @@ -5378,12 +5408,14 @@

    redirect mode
  • request (for fetch)
  • request (for request) +
  • reserved client
  • response (for fetch)
  • response (for response)
  • skip service worker flag
  • status
  • stream
  • subresource request +
  • target client id
  • terminate
  • termination reason
  • type @@ -5409,6 +5441,7 @@

    WorkerType
  • a browsing context is discarded
  • active document +
  • active service worker
  • api base url
  • api url character encoding
  • application cache @@ -5418,6 +5451,7 @@

    creation url
  • discard a document
  • dom manipulation task source +
  • environment
  • environment settings object
  • event handler
  • event handler event type @@ -5485,13 +5519,6 @@

    VisibilityState
  • visibilityState -
  • - [secure-contexts] defines the following terms: -
  • [promises-guide] defines the following terms:
      @@ -5514,6 +5541,18 @@

    • vary
    +
  • + [secure-contexts] defines the following terms: + +
  • + [secure-contexts] defines the following terms: +
  • [WHATWG-URL] defines the following terms: - - - @@ -6893,7 +6918,7 @@

    4.4. ExtendableEvent
  • 4.4.1. event.waitUntil(f) (2) -
  • 4.5.4. event.respondWith(r) +
  • 4.5.6. event.respondWith(r)
  • 4.6. ExtendableMessageEvent
  • Update Worker State (2) @@ -6915,28 +6940,28 @@

    #fetchevent-potential-responseReferenced in: @@ -6956,11 +6981,27 @@

    Handle Fetch + + @@ -6968,7 +7009,7 @@

    #fetch-event-respondwith-methodReferenced in: