From 173475e4faaacf49ac6220b0aa595e765772a3cc Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Tue, 4 Apr 2017 15:21:57 +0900 Subject: [PATCH] Update StructuredCloneWithTransfer() usage Fixes #1089. --- docs/index.bs | 8 ++++---- docs/index.html | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index e5415431..c2a29019 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -355,8 +355,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |targetRealm| be |destination|'s [=global object/Realm=]. 1. Let |incumbentSettings| be the incumbent settings object, and |incumbentGlobal| its [=environment settings object/global object=]. 1. Let |cloneRecord| be StructuredCloneWithTransfer(|message|, |transfer|, |targetRealm|). If this throws an exception, rethrow that exception and abort these steps. - 1. Let |clonedMessage| be |cloneRecord|.\[[Clone]]. - 1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |cloneRecord|.\[[TransferList]], if any, maintaining their relative order. + 1. Let |clonedMessage| be |cloneRecord|.\[[Deserialized]]. + 1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |cloneRecord|.\[[TransferredValues]], if any, maintaining their relative order. 1. Queue a task that runs the following steps: 1. Create an event |e| that uses the {{ExtendableMessageEvent}} interface, with the event type {{message!!event}}, which does not bubble and is not cancelable. 1. Let the {{ExtendableMessageEvent/data}} attribute of |e| be initialized to |clonedMessage|. @@ -1019,8 +1019,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |destination| is null, throw an "{{InvalidStateError}}" exception. 1. Let |targetRealm| be |destination|'s relevant Realm. 1. Let |cloneRecord| be StructuredCloneWithTransfer(|message|, |transfer|, |targetRealm|). If this throws an exception, rethrow that exception and abort these steps. - 1. Let |clonedMessage| be |cloneRecord|.\[[Clone]]. - 1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |cloneRecord|.\[[TransferList]], if any, maintaining their relative order. + 1. Let |clonedMessage| be |cloneRecord|.\[[Deserialized]]. + 1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |cloneRecord|.\[[TransferredValues]], if any, maintaining their relative order. 1. Add a task that runs the following steps to |destination|'s [=ServiceWorkerContainer/client message queue=]: 1. Create an event |e| that uses the {{MessageEvent}} interface, with the event type {{Window/message!!event}}, which does not bubble and is not cancelable. 1. Let the data attribute of |e| be initialized to |clonedMessage|. diff --git a/docs/index.html b/docs/index.html index fa5aa772..9416ef7e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1425,7 +1425,7 @@

Service Workers Nightly

-

Editor’s Draft,

+

Editor’s Draft,

This version: @@ -1856,12 +1856,12 @@

Bootstrapping with a service worker:
// scope defaults to the path the script sits in
 // "/" in this example
-navigator.serviceWorker.register("/serviceworker.js").then(registration => {
+navigator.serviceWorker.register("/serviceworker.js").then(registration => {
   console.log("success!");
   if (registration.installing) {
     registration.installing.postMessage("Howdy from your installing page.");
   }
-}, err => {
+}, err => {
   console.error("Installing the worker failed!", err);
 });
 
@@ -1923,9 +1923,9 @@

<
  • Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). If this throws an exception, rethrow that exception and abort these steps.

  • -

    Let clonedMessage be cloneRecord.[[Clone]].

    +

    Let clonedMessage be cloneRecord.[[Deserialized]].

  • -

    Let newPorts be a new frozen array consisting of all MessagePort objects in cloneRecord.[[TransferList]], if any, maintaining their relative order.

    +

    Let newPorts be a new frozen array consisting of all MessagePort objects in cloneRecord.[[TransferredValues]], if any, maintaining their relative order.

  • Queue a task that runs the following steps:

      @@ -2390,10 +2390,10 @@

      Serving Cached Resources:
      // caching.js
      -self.addEventListener("install", event => {
      +self.addEventListener("install", event => {
         event.waitUntil(
           // Open a cache of resources.
      -    caches.open("shell-v1").then(cache => {
      +    caches.open("shell-v1").then(cache => {
             // Begins the process of fetching them.
             // The coast is only clear when all the resources are ready.
             return cache.addAll([
      @@ -2407,16 +2407,16 @@ 

      ); }); -self.addEventListener("fetch", event => { +self.addEventListener("fetch", event => { // No "fetch" events are dispatched to the service worker until it // successfully installs and activates. // All operations on caches are async, including matching URLs, so we use // promises heavily. e.respondWith() even takes promises to enable this: event.respondWith( - caches.match(e.request).then(response => { + caches.match(e.request).then(response => { return response || fetch(e.request); - }).catch(() => { + }).catch(() => { return caches.match("/fallback.html"); }) ); @@ -2563,9 +2563,9 @@

      Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). If this throws an exception, rethrow that exception and abort these steps.

    1. -

      Let clonedMessage be cloneRecord.[[Clone]].

      +

      Let clonedMessage be cloneRecord.[[Deserialized]].

    2. -

      Let newPorts be a new frozen array consisting of all MessagePort objects in cloneRecord.[[TransferList]], if any, maintaining their relative order.

      +

      Let newPorts be a new frozen array consisting of all MessagePort objects in cloneRecord.[[TransferredValues]], if any, maintaining their relative order.

    3. Add a task that runs the following steps to destination’s client message queue:

        @@ -6550,7 +6550,7 @@

        Default scope:
        // Maximum allowed scope defaults to the path the script sits in
         // "/js" in this example
        -navigator.serviceWorker.register("/js/sw.js").then(() => {
        +navigator.serviceWorker.register("/js/sw.js").then(() => {
           console.log("Install succeeded with the default scope '/js'.");
         });
         
        @@ -6559,7 +6559,7 @@

        Upper path without Service-Worker-Allowed header:
        // Set the scope to an upper path of the script location
         // Response has no Service-Worker-Allowed header
        -navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).catch(() => {
        +navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).catch(() => {
           console.error("Install failed due to the path restriction violation.");
         });
         
        @@ -6568,7 +6568,7 @@

        Upper path with Service-Worker-Allowed header:
        // Set the scope to an upper path of the script location
         // Response included "Service-Worker-Allowed : /"
        -navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).then(() => {
        +navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).then(() => {
           console.log("Install succeeded as the max allowed scope was overriden to '/'.");
         });
         
        @@ -6577,7 +6577,7 @@

        A path restriction voliation even with Service-Worker-Allowed header:
        // Set the scope to an upper path of the script location
         // Response included "Service-Worker-Allowed : /foo"
        -navigator.serviceWorker.register("/foo/bar/sw.js", { scope: "/" }).catch(() => {
        +navigator.serviceWorker.register("/foo/bar/sw.js", { scope: "/" }).catch(() => {
           console.error("Install failed as the scope is still out of the overriden maximum allowed scope.");
         });