From 669e78694934050632761120cdebbeb4897b3f0c Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Fri, 2 Dec 2016 15:40:35 +0900 Subject: [PATCH] Change behavior of skipWaiting() Before this, skipWaiting() promises when called multiple times on a waiting worker had different behaviors among each other where the winner waits unitl the Activate is complete while others don't. This makes the behavior consistent by making the Activate be called only once. To achieve that, this removes the steps in skipWaiting() that call the Activate on a waiting worker (so promise resolves right away after setting the skip waiting flag) and simplifies the call sites of the Activate in the Install algorithm. Related issue: #1015. --- docs/index.bs | 7 +- docs/index.html | 278 +++++++++++++++++++++------------------------ docs/v1/index.bs | 7 +- docs/v1/index.html | 250 +++++++++++++++++++--------------------- 4 files changed, 250 insertions(+), 292 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index f033f7a4..aadc2ee3 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -814,8 +814,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |promise| be a new promise. 1. Run the following substeps in parallel: 1. Set [=/service worker=]'s skip waiting flag. - 1. If [=/service worker=]'s state is *installed*, then: - 1. Run Activate algorithm passing [=/service worker=]'s [=service worker/registration=] as the argument. 1. Resolve |promise| with undefined. 1. Return |promise|. @@ -2578,13 +2576,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Run the Update Registration State algorithm passing |registration|, "installing" and null as the arguments. 1. Run the Update Worker State algorithm passing |registration|'s waiting worker and *installed* as the arguments. 1. If |redundantWorker| is not null, run the Update Worker State algorithm passing |redundantWorker| and *redundant* as the arguments. - 1. If |registration|'s waiting worker's skip waiting flag is set, then: - 1. Run Activate algorithm passing |registration| as the argument. - 1. Invoke Finish Job with |job| and abort these steps. 1. Invoke Finish Job with |job|. 1. Wait for all the tasks queued by Update Worker State invoked in this algorithm have executed. 1. Wait until no [=/service worker client=] is using |registration| or |registration|'s waiting worker's skip waiting flag is set. - 1. 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. + 1. If |registration|'s waiting worker is not null, invoke Activate algorithm with |registration| as its argument.
diff --git a/docs/index.html b/docs/index.html index 6da3221c..71338413 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1424,7 +1424,7 @@

Service Workers Nightly

-

Editor’s Draft,

+

Editor’s Draft,

This version: @@ -2360,12 +2360,6 @@

Set service worker's skip waiting flag.

-
  • -

    If service worker's state is installed, then:

    -
      -
    1. -

      Run Activate algorithm passing service worker's registration as the argument.

      -
  • Resolve promise with undefined.

    @@ -2898,7 +2892,7 @@

    Let registration be the result of running Match Service Worker Registration algorithm passing client’s creation URL as the argument.

  • -

    If registration is not the service worker's containing service worker registration, continue to the next iteration of the loop.

    +

    If registration is not the service worker's containing service worker registration, continue to the next iteration of the loop.

  • If client’s active service worker is not the service worker, then:

      @@ -2931,9 +2925,9 @@

      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.

      -

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

      +

      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.

      +

      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.

      @@ -2951,13 +2945,13 @@

      Add f to the extend lifetime promises.

  • -

    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:

    @@ -3004,7 +2998,7 @@

    If options.scopes is empty throw a TypeError and abort these steps.

  • -

    Let scopeString be the context object’s relevant global object’s service worker's containing service worker registration’s scope url, serialized.

    +

    Let scopeString be the context object’s relevant global object’s service worker's containing service worker registration’s scope url, serialized.

  • Let subScopeURLs be an empty list of URLs.

  • @@ -3022,9 +3016,9 @@

    -

    Set this service worker's list of foreign fetch scopes to subScopeURLs.

    +

    Set this service worker's list of foreign fetch scopes to subScopeURLs.

  • -

    Set this service worker's list of foreign fetch origins to originURLs.

    +

    Set this service worker's list of foreign fetch origins to originURLs.

  • @@ -3049,7 +3043,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: