diff --git a/index.html b/index.html index af2c952..0e1675d 100644 --- a/index.html +++ b/index.html @@ -185,8 +185,11 @@

handler, event handler event type, queue a task, and - fire a simple + "http://www.w3.org/TR/html5/webappapis.html#queue-a-task">queue a task, + trusted + event, and fire a simple event are defined in [[!HTML5]].

@@ -205,6 +208,7 @@

SecurityError, NetworkError, + event listener, and steps for constructing events are defined in [[!DOM]].

@@ -223,9 +227,12 @@

"http://www.w3.org/TR/service-workers/#service-worker-global-scope-interface">ServiceWorkerGlobalScope, ExtendableEvent, - and ExtendableEventInit - are defined in [[!SERVICE-WORKERS]]. + ExtendableEventInit, + extend + lifetime promises and the Handle + Functional Event algorithm are defined in [[!SERVICE-WORKERS]].

The algorithms utf-8 @@ -407,7 +414,8 @@

Example

-
// https://example.com/serviceworker.js
+        
+// https://example.com/serviceworker.js
 this.onpush = function(event) {
   console.log(event.data);
   // From here we can write the data to IndexedDB, send it to any open
@@ -851,21 +859,50 @@ 

this event, in order to continue receiving push messages.

- To fire a pushsubscriptionchange event, the user agent MUST run the - following steps: + When new push subscription information becomes available, the user agent + MUST run the following steps:

    -
  1. If the Service Worker associated with the webapp is not running, start - it. +
  2. Let registration be the service worker registration corresponding + to the push message.
  3. -
  4. Let scope be the ServiceWorkerGlobalScope of the Service - Worker associated with the webapp. +
  5. If registration is not found, abort these steps.
  6. -
  7. - Queue a task to fire a simple event named - pushsubscriptionchange at scope. +
  8. Invoke the Handle Functional Event algorithm with a service worker + registration of registration and callbackSteps set to the + following steps: +
      +
    1. Set global to the global object that was provided as an argument. +
    2. +
    3. Create a trusted event, e, that uses the + ExtendableEvent interface, with the event type + pushsubscriptionchange, which does not bubble, is not cancelable, and + has no default action. +
    4. +
    5. Dispatch e to global. +
    6. +
    7. If the previous push subscription is still active, perform the following + steps in parallel: +
        +
      1. Set oldSubscription to the previous push subscription. +
      2. +
      3. Wait for all of the promises in the extend lifetime promises of + e to either resolve or reject. +
      4. +
      5. Unsubscribe oldSubscription. +
      6. +
      +
    8. +
+

+ This algorithm ensures that the webapp is able to react to any non-destructive + change in a push subscription, such as an automatic refresh, without causing any + active push subscription to be terminated prematurely. A webapp can request + a new push subscription during this process and ensure that no push + messages are lost. +