diff --git a/docs/index.bs b/docs/index.bs index 15ee725b..1c411b0e 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -1289,14 +1289,12 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe An {{ExtendableEvent}} object has an associated extend lifetime promises (an array of promises). It is initially an empty array. - An {{ExtendableEvent}} object has an associated extensions allowed flag. It is initially set. + An {{ExtendableEvent}} object has an associated pending promises count (the number of pending promises in the [=ExtendableEvent/extend lifetime promises=]). It is initially set to zero. [=/Service workers=] have two lifecycle events, {{install!!event}} and {{activate!!event}}. [=/Service workers=] use the {{ExtendableEvent}} interface for {{activate!!event}} event and {{install!!event}} event. Service worker extensions that define event handlers *may* also use or extend the {{ExtendableEvent}} interface. - Note: To extend the lifetime of a [=/service worker=], algorithms that dispatch events using the {{ExtendableEvent}} interface run [=Extend Service Worker Lifetime=] algorithm after dispatching the event. See Handle Fetch, Handle Foreign Fetch, and Handle Functional Event. -

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

@@ -1304,10 +1302,20 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe waitUntil(|f|) method *must* run these steps: - 1. If the extensions allowed flag is unset, then: + 1. If the [=ExtendableEvent/pending promises count=] is zero and the [=dispatch flag=] is unset, then: 1. Throw an "{{InvalidStateError}}" exception. 1. Abort these steps. + + Note: If no lifetime extension promise has been added in the task that called the event handlers), calling {{ExtendableEvent/waitUntil()}} in subsequent asynchronous tasks will throw. + 1. Add |f| to the [=ExtendableEvent/extend lifetime promises=]. + 1. Increase the [=ExtendableEvent/pending promises count=] by one. + + Note: The [=ExtendableEvent/pending promises count=] is increased even if the given promise has already been settled. The corresponding count decrease is done in the task queued by the reaction to the promise. + + 1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |f|, [=queue a task=], on |f|’s [=relevant settings object=]'s [=responsible event loop=] using the [=handle functional event task source=], to decrease the [=ExtendableEvent/pending promises count=] by one. + + The user agent *should not* terminate the [=/service worker=] associated with |event|'s relevant settings object's [=environment settings object/global object=] when |event|'s [=dispatch flag=] is set or |event|'s [=ExtendableEvent/pending promises count=] is not zero. However, the user agent *may* impose a time limit to this lifetime extension.
[=/Service workers=] and extensions that define event handlers *may* define their own behaviors, allowing the [=ExtendableEvent/extend lifetime promises=] to suggest operation length, and the rejected state of any of the promise in [=ExtendableEvent/extend lifetime promises=] to suggest operation failure. @@ -1450,6 +1458,11 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Throw an "{{InvalidStateError}}" exception. 1. Abort these steps. 1. Add |r| to the extend lifetime promises. + 1. Increase the [=ExtendableEvent/pending promises count=] by one. + + Note: The [=ExtendableEvent/pending promises count=] is increased even if the given promise has already been settled. The corresponding count decrease is done in the task queued by the reaction to the promise. + + 1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |r|, [=queue a task=], on |r|’s [=relevant settings object=]'s [=responsible event loop=] using the [=handle fetch task source=], to decrease the [=ExtendableEvent/pending promises count=] by one. Note: {{FetchEvent/respondWith(r)|event.respondWith(r)}} extends the lifetime of the event by default as if {{ExtendableEvent/waitUntil()|event.waitUntil(r)}} is called. @@ -1561,6 +1574,14 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Throw an "{{InvalidStateError}}" exception. 1. Abort these steps. 1. Add |r| to the extend lifetime promises. + 1. Increase the [=ExtendableEvent/pending promises count=] by one. + + Note: The [=ExtendableEvent/pending promises count=] is increased even if the given promise has already been settled. The corresponding count decrease is done in the task queued by the reaction to the promise. + + 1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |r|, [=queue a task=], on |r|’s [=relevant settings object=]'s [=responsible event loop=] using the [=handle fetch task source=], to decrease the [=ExtendableEvent/pending promises count=] by one. + + Note: {{ForeignFetchEvent/respondWith(r)|event.respondWith(r)}} extends the lifetime of the event by default as if {{ExtendableEvent/waitUntil()|event.waitUntil(r)}} is called. + 1. Set the stop propagation flag and stop immediate propagation flag. 1. Set the [=ForeignFetchEvent/respond-with entered flag=]. 1. Set the [=ForeignFetchEvent/wait to respond flag=]. @@ -2678,9 +2699,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |e| be the result of creating an event with {{InstallEvent}}. 1. Initialize |e|’s {{Event/type}} attribute to {{install!!event}}. 1. Dispatch |e| at |installingWorker|'s [=service worker/global object=]. - 1. Invoke [=Extend Service Worker Lifetime=] with |e|. 1. *WaitForAsynchronousExtensions*: Run the following substeps in parallel: - 1. Wait until |e|'s extensions allowed flag is unset. + 1. Wait until |e|'s [=ExtendableEvent/pending promises count=] is zero. 1. If the result of waiting for all of |e|'s extend lifetime promises rejected, set |installFailed| to true. If |task| is discarded or the script has been aborted by the termination of |installingWorker|, set |installFailed| to true. @@ -2744,8 +2764,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |e| be the result of creating an event with {{ExtendableEvent}}. 1. Initialize |e|’s {{Event/type}} attribute to {{activate!!event}}. 1. Dispatch |e| at |activeWorker|'s [=service worker/global object=]. - 1. Invoke [=Extend Service Worker Lifetime=] with |e|. - 1. *WaitForAsynchronousExtensions*: Wait, in parallel, until |e|'s extensions allowed flag is unset. + 1. *WaitForAsynchronousExtensions*: Wait, in parallel, until |e|'s [=ExtendableEvent/pending promises count=] is zero. 1. Wait for |task| to have executed or been discarded, or the script to have been aborted by the termination of |activeWorker|. 1. Wait for the step labeled *WaitForAsynchronousExtensions* to complete. 1. Run the Update Worker State algorithm passing |registration|'s active worker and *activated* as the arguments. @@ -2829,25 +2848,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Abort the script currently running in |serviceWorker|. -
-

Extend Service Worker Lifetime

- - : Input - :: |event|, an {{ExtendableEvent}} object - : Output - :: None - - 1. If |event|'s extend lifetime promises is empty, unset |event|'s extensions allowed flag and abort these steps. - 1. Let |extendLifetimePromises| be an empty array. - 1. Run the following substeps in parallel: - 1. *SetupPromiseArray*: Set |extendLifetimePromises| to a copy of |event|'s extend lifetime promises. - 1. Wait until all the promises in |extendLifetimePromises| settle. - 1. If the length of |extendLifetimePromises| does not equal the length of |event|'s extend lifetime promises, jump to the step labeled *SetupPromiseArray*. - 1. Unset |event|'s extensions allowed flag. - - The user agent *should not* terminate the [=/service worker=] associated with |event|'s relevant settings object's [=environment settings object/global object=] until |event|'s extensions allowed flag is unset. However, the user agent *may* impose a time limit to this lifetime extension. -
-

Handle Fetch

@@ -2926,7 +2926,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |request| is a navigation request, initialize |e|'s {{FetchEvent/targetClientId}} attribute to |request|'s [=request/target client id=], and to the empty string otherwise. 1. Let the {{FetchEvent/isReload}} attribute of |e| be initialized to true if |request|'s [=request/client=] is a window client and the event was dispatched with the user's intention for the page reload, and false otherwise. 1. Dispatch |e| at |activeWorker|'s [=service worker/global object=]. - 1. Invoke [=Extend Service Worker Lifetime=] with |e|. 1. If |e|'s [=FetchEvent/respond-with entered flag=] is set, set |respondWithEntered| to true. 1. If |e|'s [=FetchEvent/wait to respond flag=] is set, then: 1. Wait until |e|'s [=FetchEvent/wait to respond flag=] is unset. @@ -2990,7 +2989,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Initialize |e|’s {{ForeignFetchEvent/request}} attribute to |r|. 1. Initialize |e|’s {{ForeignFetchEvent/origin}} attribute to the Unicode serialization of |request|'s [=request/origin=]. 1. Dispatch |e| at |activeWorker|'s [=service worker/global object=]. - 1. Invoke [=Extend Service Worker Lifetime=] with |e|. 1. If |e|'s [=ForeignFetchEvent/respond-with entered flag=] is set, set |respondWithEntered| to true. 1. If |e|'s wait to respond flag is set, wait until |e|'s wait to respond flag is unset. 1. Let |internalResponse| be |e|'s [=ForeignFetchEvent/potential response=]. @@ -3052,7 +3050,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Invoke Run Service Worker algorithm with |activeWorker| as the argument. 1. Queue a task |task| to run these substeps: 1. Invoke |callbackSteps| with |activeWorker|'s [=service worker/global object=] as its argument. - 1. Invoke [=Extend Service Worker Lifetime=] with |event|. The |task| *must* use |activeWorker|'s event loop and the handle functional event task source. diff --git a/docs/index.html b/docs/index.html index 8dde2e70..09a92423 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1424,7 +1424,7 @@

Service Workers Nightly

-

Editor’s Draft,

+

Editor’s Draft,

This version: @@ -1689,7 +1689,6 @@

Table of Contents

  • Activate
  • Run Service Worker
  • Terminate Service Worker -
  • Extend Service Worker Lifetime
  • Handle Fetch
  • Handle Foreign Fetch
  • Handle Functional Event @@ -3037,40 +3036,46 @@

    An ExtendableEvent object has an associated extend lifetime promises (an array of promises). It is initially an empty array.

    -

    An ExtendableEvent object has an associated extensions allowed flag. It is initially set.

    +

    An ExtendableEvent object has an associated pending promises count (the number of pending promises in the extend lifetime promises). It is initially set to zero.

    Service workers have two lifecycle events, install and activate. Service workers use the ExtendableEvent interface for activate event and install event.

    Service worker extensions that define event handlers may also use or extend the ExtendableEvent interface.

    -

    Note: To extend the lifetime of a service worker, algorithms that dispatch events using the ExtendableEvent interface run Extend Service Worker Lifetime algorithm after dispatching the event. See Handle Fetch, Handle Foreign Fetch, and Handle Functional Event.

    4.4.1. event.waitUntil(f)

    waitUntil() method extends the lifetime of the event.

    waitUntil(f) method must run these steps:

    1. -

      If the extensions allowed flag is unset, then:

      +

      If the pending promises count is zero and the dispatch flag is unset, then:

      1. Throw an "InvalidStateError" exception.

      2. Abort these steps.

      +

      Note: If no lifetime extension promise has been added in the task that called the event handlers), calling waitUntil() in subsequent asynchronous tasks will throw.

    2. -

      Add f to the extend lifetime promises.

      +

      Add f to the extend lifetime promises.

      +
    3. +

      Increase the pending promises count by one.

      +

      Note: The pending promises count is increased even if the given promise has already been settled. The corresponding count decrease is done in the task queued by the reaction to the promise.

      +
    4. +

      Upon fulfillment or rejection of f, queue a task, on f’s relevant settings object's responsible event loop using the handle functional event task source, to decrease the pending promises count by one.

    +

    The user agent should not terminate the service worker associated with event’s relevant settings object’s global object when event’s dispatch flag is set or event’s pending promises count is not zero. However, the user agent may impose a time limit to this lifetime extension.

    -

    Service workers and extensions that define event handlers may define their own behaviors, allowing the extend lifetime promises to suggest operation length, and the rejected state of any of the promise in extend lifetime promises to suggest operation failure.

    -

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

    +

    Service workers and extensions that define event handlers may define their own behaviors, allowing the extend lifetime promises to suggest operation length, and the rejected state of any of the promise in extend lifetime promises to suggest operation failure.

    +

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

  • 4.5. InstallEvent

    [Constructor(DOMString type, optional ExtendableEventInit eventInitDict), Exposed=ServiceWorker]
    -interface InstallEvent : ExtendableEvent {
    +interface InstallEvent : ExtendableEvent {
       void registerForeignFetch(ForeignFetchOptions options);
     };
     
    @@ -3138,7 +3143,7 @@ 

    4.6. FetchEvent

    [Constructor(DOMString type, FetchEventInit eventInitDict), Exposed=ServiceWorker]
    -interface FetchEvent : ExtendableEvent {
    +interface FetchEvent : ExtendableEvent {
       [SameObject] readonly attribute Request request;
       readonly attribute Promise<any> preloadResponse;
       readonly attribute DOMString clientId;
    @@ -3158,7 +3163,7 @@ 

    boolean isReload = false; };

    -

    Service workers have an essential functional event fetch. For fetch event, service workers use the FetchEvent interface which extends the ExtendableEvent interface.

    +

    Service workers have an essential functional event fetch. For fetch event, service workers use the FetchEvent interface which extends the ExtendableEvent interface.

    Each event using FetchEvent interface has an associated potential response (a response), initially set to null, and the following associated flags that are initially unset:

    @@ -5067,18 +5083,16 @@

    Initialize e’s type attribute to install.

  • Dispatch e at installingWorker’s global object.

    -
  • -

    Invoke Extend Service Worker Lifetime with e.

  • WaitForAsynchronousExtensions: Run the following substeps in parallel:

    1. -

      Wait until e’s extensions allowed flag is unset.

      +

      Wait until e’s pending promises count is zero.

    2. -

      If the result of waiting for all of e’s extend lifetime promises rejected, set installFailed to true.

      +

      If the result of waiting for all of e’s extend lifetime promises rejected, set installFailed to true.

    -

    If task is discarded or the script has been aborted by the termination of installingWorker, set installFailed to true.

    +

    If task is discarded or the script has been aborted by the termination of installingWorker, set installFailed to true.

  • Wait for task to have executed or been discarded.

  • @@ -5105,7 +5119,7 @@

    Set redundantWorker to registration’s waiting worker.

  • -

    Terminate redundantWorker.

    +

    Terminate redundantWorker.

  • The user agent may abort in-flight requests triggered by redundantWorker.

    @@ -5152,7 +5166,7 @@

    Wait for redundantWorker to finish handling any in-progress requests.

  • -

    Terminate redundantWorker.

    +

    Terminate redundantWorker.

  • Run the Update Registration State algorithm passing registration, "active" and registration’s waiting worker as the arguments.

    @@ -5188,18 +5202,16 @@

    Queue a task task to run the following substeps:

    1. -

      Let e be the result of creating an event with ExtendableEvent.

      +

      Let e be the result of creating an event with ExtendableEvent.

    2. Initialize e’s type attribute to activate.

    3. Dispatch e at activeWorker’s global object.

    4. -

      Invoke Extend Service Worker Lifetime with e.

      -
    5. -

      WaitForAsynchronousExtensions: Wait, in parallel, until e’s extensions allowed flag is unset.

      +

      WaitForAsynchronousExtensions: Wait, in parallel, until e’s pending promises count is zero.

  • -

    Wait for task to have executed or been discarded, or the script to have been aborted by the termination of activeWorker.

    +

    Wait for task to have executed or been discarded, or the script to have been aborted by the termination of activeWorker.

  • Wait for the step labeled WaitForAsynchronousExtensions to complete.

  • @@ -5333,47 +5345,15 @@

    Set serviceWorkerGlobalScope’s closing flag to true.

  • -

    If there are any tasks, whose task source is either the handle fetch task source or the handle functional event task source, queued in serviceWorkerGlobalScope’s event loop’s task queues, queue them to serviceWorker’s containing service worker registration’s corresponding task queues in the same order using their original task sources, and discard all the tasks (including tasks whose task source is neither the handle fetch task source nor the handle functional event task source) from serviceWorkerGlobalScope’s event loop’s task queues without processing them.

    +

    If there are any tasks, whose task source is either the handle fetch task source or the handle functional event task source, queued in serviceWorkerGlobalScope’s event loop’s task queues, queue them to serviceWorker’s containing service worker registration’s corresponding task queues in the same order using their original task sources, and discard all the tasks (including tasks whose task source is neither the handle fetch task source nor the handle functional event task source) from serviceWorkerGlobalScope’s event loop’s task queues without processing them.

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

  • Abort the script currently running in serviceWorker.

    -
    -

    Extend Service Worker Lifetime

    -
    -
    -

    Input

    -
    -

    event, an ExtendableEvent object

    -
    -

    Output

    -
    -

    None

    -
    -
      -
    1. -

      If event’s extend lifetime promises is empty, unset event’s extensions allowed flag and abort these steps.

      -
    2. -

      Let extendLifetimePromises be an empty array.

      -
    3. -

      Run the following substeps in parallel:

      -
        -
      1. -

        SetupPromiseArray: Set extendLifetimePromises to a copy of event’s extend lifetime promises.

        -
      2. -

        Wait until all the promises in extendLifetimePromises settle.

        -
      3. -

        If the length of extendLifetimePromises does not equal the length of event’s extend lifetime promises, jump to the step labeled SetupPromiseArray.

        -
      4. -

        Unset event’s extensions allowed flag.

        -
      -
    -

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

    -

    Handle Fetch

    -

    The Handle Fetch algorithm is the entry point for the fetch handling handed to the service worker context.

    +

    The Handle Fetch algorithm is the entry point for the fetch handling handed to the service worker context.

    Input

    @@ -5520,8 +5500,6 @@

    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 global object.

    -
  • -

    Invoke Extend Service Worker Lifetime with e.

  • If e’s respond-with entered flag is set, set respondWithEntered to true.

  • @@ -5538,7 +5516,7 @@

    canceled flag is set, set eventCanceled to true.

    If task is discarded or the script has been aborted by the termination of activeWorker, set handleFetchFailed to true.

    -

    The task must use activeWorker’s event loop and the handle fetch task source.

    +

    The task must use activeWorker’s event loop and the handle fetch task source.

  • Wait for task to have executed or been discarded.

  • @@ -5573,7 +5551,7 @@

    Handle Foreign Fetch

    -

    The Handle Foreign Fetch algorithm is the entry point for the fetch handling handed to the service worker context to handle foreign fetch requests.

    +

    The Handle Foreign Fetch algorithm is the entry point for the fetch handling handed to the service worker context to handle foreign fetch requests.

    Input

    @@ -5640,8 +5618,6 @@

    Initialize e’s origin attribute to the Unicode serialization of request’s origin.

  • Dispatch e at activeWorker’s global object.

    -
  • -

    Invoke Extend Service Worker Lifetime with e.

  • If e’s respond-with entered flag is set, set respondWithEntered to true.

  • @@ -5684,7 +5660,7 @@

    If e’s canceled flag is set, set eventCanceled to true.

    If task is discarded or the script has been aborted by the termination of activeWorker, set handleFetchFailed to true.

    -

    The task must use activeWorker’s event loop and the handle fetch task source.

    +

    The task must use activeWorker’s event loop and the handle fetch task source.

  • Wait for task to have executed or been discarded.

  • @@ -5724,7 +5700,7 @@

    Input

    -

    event, an ExtendableEvent object

    +

    event, an ExtendableEvent object

    registration, a service worker registration

    @@ -5761,10 +5737,8 @@

    Invoke callbackSteps with activeWorker’s global object as its argument.

    -
  • -

    Invoke Extend Service Worker Lifetime with event.

    -

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

    +

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

  • Wait for task to have executed or been discarded.

  • @@ -5976,7 +5950,7 @@

    target, a string (one of "installing", "waiting", and "active")

    -

    source, a service worker or null

    +

    source, a service worker or null

    Output

    @@ -6030,9 +6004,9 @@

    Input

    -

    worker, a service worker

    +

    worker, a service worker

    -

    state, a service worker's state

    +

    state, a service worker's state

    Output

    @@ -6056,27 +6030,27 @@

    installing

    "installing"

    -

    Note: The service worker in this state is considered an installing worker. During this state, waitUntil() can be called inside the oninstall event handler to extend the life of the installing worker until the passed promise resolves successfully. This is primarily used to ensure that the service worker is not active until all of the core caches are populated.

    +

    Note: The service worker in this state is considered an installing worker. During this state, waitUntil() can be called inside the oninstall event handler to extend the life of the installing worker until the passed promise resolves successfully. This is primarily used to ensure that the service worker is not active until all of the core caches are populated.

    installed

    "installed"

    -

    Note: The service worker in this state is considered a waiting worker.

    +

    Note: The service worker in this state is considered a waiting worker.

    activating

    "activating"

    -

    Note: The service worker in this state is considered an active worker. During this state, waitUntil() 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.

    +

    Note: The service worker in this state is considered an active worker. During this state, waitUntil() 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"

    -

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

    +

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

    redundant

    "redundant"

    -

    Note: A new service worker is replacing the current service worker, or the current service worker is being discarded due to an install failure.

    +

    Note: A new service worker is replacing the current service worker, or the current service worker is being discarded due to an install failure.

  • Fire an event named statechange at workerObject.

    @@ -6151,7 +6125,7 @@

    Output

    -

    worker, a service worker

    +

    worker, a service worker

    1. @@ -6219,7 +6193,7 @@

      Output

      -

      newestWorker, a service worker

      +

      newestWorker, a service worker

      1. @@ -6514,18 +6488,18 @@

        Appendix B: Extended HTTP headers

        Service Worker Script Request

        -

        An HTTP request to fetch a service worker's script resource will include the following header:

        +

        An HTTP request to fetch a service worker's script resource will include the following header:

        `Service-Worker`

        -

        Indicates this request is a service worker's script resource request.

        +

        Indicates this request is a service worker's script resource request.

        Note: This header helps administrators log the requests and detect threats.

        Service Worker Script Response

        -

        An HTTP response to a service worker's script resource request can include the following header:

        +

        An HTTP response to a service worker's script resource request can include the following header:

        `Service-Worker-Allowed`

        @@ -6572,7 +6546,7 @@

        Syntax

        -

        ABNF for the values of the headers used by the service worker's script resource requests and responses:

        +

        ABNF for the values of the headers used by the service worker's script resource requests and responses:

        Service-Worker = %x73.63.72.69.70.74 ; "script", case-sensitive
         

        Note: The validation of the Service-Worker-Allowed header’s values is done by URL parsing algorithm (in Update algorithm) instead of using ABNF.

        @@ -6691,8 +6665,6 @@

        ExtendableMessageEvent(type), in §4.8
      2. ExtendableMessageEvent(type, eventInitDict), in §4.8
      3. extend lifetime promises, in §4.4 -
      4. Extend Service Worker Lifetime, in §Unnumbered section -
      5. extensions allowed flag, in §4.4
      6. fetch, in §4.9
      7. FetchEvent, in §4.6
      8. FetchEventInit, in §4.6 @@ -6860,6 +6832,7 @@

        attribute for ExtendableMessageEvent, in §4.8.2
      9. origins, in §4.5 +
      10. pending promises count, in §4.4
      11. ports

        Terms defined by reference

        @@ -7353,6 +7326,8 @@

        reject
      12. resolve
      13. transforming +
      14. upon fulfillment +
      15. upon rejection
      16. waiting for all
      17. @@ -7758,7 +7733,8 @@

        3.5. Events (2)
      18. 4.1. ServiceWorkerGlobalScope (2) (3) (4)
      19. 4.1.3. skipWaiting() (2) -
      20. 4.4. ExtendableEvent (2) (3) (4) (5) (6) (7) +
      21. 4.4. ExtendableEvent (2) (3) (4) (5) (6) +
      22. 4.4.1. event.waitUntil(f)
      23. 4.5.1. event.registerForeignFetch(options) (2)
      24. 4.6. FetchEvent (2)
      25. 4.7. ForeignFetchEvent (2) @@ -7776,16 +7752,15 @@

        Install (2)
      26. Run Service Worker
      27. Terminate Service Worker -
      28. Extend Service Worker Lifetime -
      29. Handle Fetch -
      30. Handle Foreign Fetch -
      31. Update Registration State -
      32. Update Worker State (2) (3) (4) (5) (6) (7) (8) (9) (10) -
      33. Match Service Worker for Foreign Fetch -
      34. Get Newest Worker -
      35. Service Worker Script Request (2) -
      36. Service Worker Script Response -
      37. Syntax +
      38. Handle Fetch +
      39. Handle Foreign Fetch +
      40. Update Registration State +
      41. Update Worker State (2) (3) (4) (5) (6) (7) (8) (9) (10) +
      42. Match Service Worker for Foreign Fetch +
      43. Get Newest Worker +
      44. Service Worker Script Request (2) +
      45. Service Worker Script Response +
      46. Syntax -
      47. -
        -

        Extend Service Worker Lifetime

        - - : Input - :: |event|, an {{ExtendableEvent}} object - : Output - :: None - - 1. If |event|'s extend lifetime promises is empty, unset |event|'s extensions allowed flag and abort these steps. - 1. Let |extendLifetimePromises| be an empty array. - 1. Run the following substeps in parallel: - 1. *SetupPromiseArray*: Set |extendLifetimePromises| to a copy of |event|'s extend lifetime promises. - 1. Wait until all the promises in |extendLifetimePromises| settle. - 1. If the length of |extendLifetimePromises| does not equal the length of |event|'s extend lifetime promises, jump to the step labeled *SetupPromiseArray*. - 1. Unset |event|'s extensions allowed flag. - - The user agent *should not* terminate the [=/service worker=] associated with |event|'s relevant settings object's [=environment settings object/global object=] until |event|'s extensions allowed flag is unset. However, the user agent *may* impose a time limit to this lifetime extension. -
        -

        Handle Fetch

        @@ -2543,7 +2535,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |request| is a navigation request, initialize |e|'s {{FetchEvent/targetClientId}} attribute to |request|'s [=request/target client id=], and to the empty string otherwise. 1. Let the {{FetchEvent/isReload}} attribute of |e| be initialized to true if |request|'s [=request/client=] is a window client and the event was dispatched with the user's intention for the page reload, and false otherwise. 1. Dispatch |e| at |activeWorker|'s [=service worker/global object=]. - 1. Invoke [=Extend Service Worker Lifetime=] with |e|. 1. If |e|'s [=FetchEvent/respond-with entered flag=] is set, set |respondWithEntered| to true. 1. If |e|'s [=FetchEvent/wait to respond flag=] is set, then: 1. Wait until |e|'s [=FetchEvent/wait to respond flag=] is unset. @@ -2593,7 +2584,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Invoke Run Service Worker algorithm with |activeWorker| as the argument. 1. Queue a task |task| to run these substeps: 1. Invoke |callbackSteps| with |activeWorker|'s [=service worker/global object=] as its argument. - 1. Invoke [=Extend Service Worker Lifetime=] with |event|. The |task| *must* use |activeWorker|'s event loop and the handle functional event task source. diff --git a/docs/v1/index.html b/docs/v1/index.html index 1df42064..e7fce104 100644 --- a/docs/v1/index.html +++ b/docs/v1/index.html @@ -1177,7 +1177,7 @@ } } - +