From d777add90d36be7d64ed6ede551b961f27802c6a Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Fri, 13 Jan 2017 21:49:01 +0900 Subject: [PATCH] Use microtask for handling extension promise This changes to use a microtask to decrease the pending promises count of extendable events. Before this change, by queuing a normal task for this job, all the reactions to the given promise were allowed to extend the lifetime of the event. After this change, by queuing a microtask for this job, only the initial reactions to the given promise are allowed to extend the lifetime of the event. Any reactions to drived promises or promises used in the reaction microtasks won't get a chance to extend it. (See https://github.com/w3c/ServiceWorker/issues/1039#issuecomment-272215615) This is a follow-up patch for https://github.com/w3c/ServiceWorker/commit/6c1f3fe31a976652d1ac4c48d7f0764ff8d63b58. Fixes #1039. --- docs/index.bs | 14 +++++++------- docs/index.html | 36 +++++++++++++++++------------------- docs/v1/index.bs | 8 ++++---- docs/v1/index.html | 27 +++++++++++++-------------- 4 files changed, 41 insertions(+), 44 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 1c411b0e..bd0d2715 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -1311,9 +1311,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 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. + 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 microtask 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. + 1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |f|, [=queue a microtask=] 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. @@ -1460,9 +1460,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 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. + 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 microtask 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. + 1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |r|, [=queue a microtask=] 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. @@ -1576,9 +1576,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 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. + 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 microtask 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. + 1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |r|, [=queue a microtask=] 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. @@ -3555,4 +3555,4 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe The authors would also like to thank Dimitri Glazkov for his scripts and formatting tools which have been essential in the production of this specification. The authors are also grateful for his considerable guidance. Thanks also to Vivian Cromwell, Greg Simon, Alex Komoroske, Wonsuk Lee, and Seojin Kim for their considerable professional support. - + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 09a92423..620b9769 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1424,7 +1424,7 @@

Service Workers Nightly

-

Editor’s Draft,

+

Editor’s Draft,

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

Add f to the extend lifetime promises.

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

    +

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

  • -

    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.

    +

    Upon fulfillment or rejection of f, queue a microtask 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.

    @@ -3223,9 +3223,9 @@

    Add r to the extend lifetime promises.

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

    +

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

  • -

    Upon fulfillment or 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 pending promises count by one.

    +

    Upon fulfillment or rejection of r, queue a microtask to decrease the pending promises count by one.

    Note: event.respondWith(r) extends the lifetime of the event by default as if event.waitUntil(r) is called.

  • Set the stop propagation flag and stop immediate propagation flag.

    @@ -3399,9 +3399,9 @@