From 9a86923fb64fe156c9b739cb60dddf0def549045 Mon Sep 17 00:00:00 2001 From: Monica Chintala Date: Thu, 13 Feb 2025 16:25:17 -0800 Subject: [PATCH 1/3] Editorial: Queue the task for parallel steps --- docs/index.bs | 124 +++++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 57 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 472b2cd4..ee9dcdd9 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -807,10 +807,11 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Set |clientURL|'s [=url/fragment=] to null. 1. If the [=environment settings object/origin=] of |clientURL| is not |client|'s [=environment settings object/origin=], return a |promise| rejected with a "{{SecurityError}}" {{DOMException}}. 1. Let |promise| be a new promise. - 1. Run the following substeps in parallel: + 1. Run the following sub steps in parallel: 1. Let |registration| be the result of running Match Service Worker Registration given |storage key| and |clientURL|. - 1. If |registration| is null, resolve |promise| with undefined and abort these steps. - 1. Resolve |promise| with the result of [=getting the service worker registration object=] that represents |registration| in |promise|'s [=relevant settings object=]. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. If |registration| is null, resolve |promise| with undefined and abort these steps. + 1. Resolve |promise| with the result of [=getting the service worker registration object=] that represents |registration| in |promise|'s [=relevant settings object=]. 1. Return |promise|. @@ -970,9 +971,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |promise| be [=a new promise=]. 1. Run the following steps [=in parallel=]: 1. Let |registration| be [=this=]'s associated [=/service worker registration=]. - 1. If |registration|'s [=active worker=] is null, [=reject=] |promise| with an "{{InvalidStateError}}" {{DOMException}}, and abort these steps. - 1. Set |registration|'s [=navigation preload enabled flag=]. - 1. Resolve |promise| with undefined. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. If |registration|'s [=active worker=] is null, [=reject=] |promise| with an "{{InvalidStateError}}" {{DOMException}}, and abort these steps. + 1. Set |registration|'s [=navigation preload enabled flag=]. + 1. Resolve |promise| with undefined. 1. Return |promise|. @@ -984,9 +986,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |promise| be [=a new promise=]. 1. Run the following steps [=in parallel=]: 1. Let |registration| be [=this=]'s associated [=/service worker registration=]. - 1. If |registration|'s [=active worker=] is null, [=reject=] |promise| with an "{{InvalidStateError}}" {{DOMException}}, and abort these steps. - 1. Unset |registration|'s [=navigation preload enabled flag=]. - 1. Resolve |promise| with undefined. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. If |registration|'s [=active worker=] is null, [=reject=] |promise| with an "{{InvalidStateError}}" {{DOMException}}, and abort these steps. + 1. Unset |registration|'s [=navigation preload enabled flag=]. + 1. Resolve |promise| with undefined. 1. Return |promise|. @@ -998,9 +1001,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |promise| be [=a new promise=]. 1. Run the following steps [=in parallel=]: 1. Let |registration| be [=this=]'s associated [=/service worker registration=]. - 1. If |registration|'s [=active worker=] is null, [=reject=] |promise| with an "{{InvalidStateError}}" {{DOMException}}, and abort these steps. - 1. Set |registration|'s [=navigation preload header value=] to |value|. - 1. Resolve |promise| with undefined. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. If |registration|'s [=active worker=] is null, [=reject=] |promise| with an "{{InvalidStateError}}" {{DOMException}}, and abort these steps. + 1. Set |registration|'s [=navigation preload header value=] to |value|. + 1. Resolve |promise| with undefined. 1. Return |promise|. @@ -1015,7 +1019,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |state| be a new {{NavigationPreloadState}} dictionary. 1. If |registration|'s [=navigation preload enabled flag=] is set, set |state|["{{NavigationPreloadState/enabled}}"] to true. 1. Set |state|["{{NavigationPreloadState/headerValue}}"] to |registration|'s [=navigation preload header value=]. - 1. Resolve |promise| with |state|. + 1. [=Queue a task=] to resolve |promise| with |state|. 1. Return |promise|. @@ -1126,7 +1130,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Run the following substeps in parallel: 1. Set [=ServiceWorkerGlobalScope/service worker=]'s skip waiting flag. 1. Invoke [=Try Activate=] with [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=]. - 1. Resolve |promise| with undefined. + 1. [=Queue a task=] to resolve |promise| with undefined. 1. Return |promise|. @@ -1271,10 +1275,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |source| be the result of [=getting the service worker object=] that represents |contextObject|'s [=relevant global object=]'s [=ServiceWorkerGlobalScope/service worker=] in |targetClient|. 1. Let |deserializeRecord| be StructuredDeserializeWithTransfer(|serializeWithTransferResult|, |destination|'s [=relevant Realm=]). - If this throws an exception, catch it, [=fire an event=] named {{ServiceWorkerContainer/messageerror!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin| and the {{MessageEvent/source}} attribute initialized to |source|, and then abort these steps. + If this throws an exception, catch it, [=queue a task=] to [=fire an event=] named {{ServiceWorkerContainer/messageerror!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin| and the {{MessageEvent/source}} attribute initialized to |source|, and then abort these steps. 1. Let |messageClone| be |deserializeRecord|.\[[Deserialized]]. 1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |deserializeRecord|.\[[TransferredValues]], if any. - 1. [=Dispatch|Dispatch an event=] named {{Window/message!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin|, the {{MessageEvent/source}} attribute initialized to |source|, the {{MessageEvent/data}} attribute initialized to |messageClone|, and the {{MessageEvent/ports}} attribute initialized to |newPorts|. + 1. [=Queue a task=] to [=Dispatch|Dispatch an event=] named {{Window/message!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin|, the {{MessageEvent/source}} attribute initialized to |source|, the {{MessageEvent/data}} attribute initialized to |messageClone|, and the {{MessageEvent/ports}} attribute initialized to |newPorts|.
@@ -1384,8 +1388,8 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. For each [=/service worker client=] |client| where the result of running [=obtain a storage key=] given |client| [=storage key/equals=] the associated [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=]'s [=service worker registration/storage key=]: 1. If |client|'s [=environment/id=] is not |id|, [=continue=]. 1. Wait for either |client|'s [=environment/execution ready flag=] to be set or for |client|'s [=discarded flag=] to be set. - 1. If |client|'s [=environment/execution ready flag=] is set, then invoke [=Resolve Get Client Promise=] with |client| and |promise|, and abort these steps. - 1. Resolve |promise| with undefined. + 1. If |client|'s [=environment/execution ready flag=] is set, [=queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to invoke [=Resolve Get Client Promise=] with |client| and |promise|, and abort these steps. + 1. [=Queue a task=] to resolve |promise| with undefined. 1. Return |promise|.
@@ -1479,20 +1483,21 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. If the [=ServiceWorkerGlobalScope/service worker=] is not an active worker, return a promise rejected with an "{{InvalidStateError}}" {{DOMException}}. 1. Let |promise| be a new promise. 1. Run the following substeps in parallel: - 1. For each [=/service worker client=] |client| where the result of running [=obtain a storage key=] given |client| [=storage key/equals=] the [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=]'s [=service worker registration/storage key=]: - 1. If |client|'s [=environment/execution ready flag=] is unset or |client|'s [=discarded flag=] is set, [=continue=]. - 1. If |client| is not a [=secure context=], [=continue=]. - 1. Let |storage key| be the result of running [=obtain a storage key=] given |client|. - 1. Let |registration| be the result of running Match Service Worker Registration given |storage key| and |client|'s creation URL. - 1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s containing service worker registration, [=continue=]. - - Note: |registration| will be null if the [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=] is [=service worker registration/unregistered=]. - - 1. If |client|'s active service worker is not the [=ServiceWorkerGlobalScope/service worker=], then: - 1. Invoke Handle Service Worker Client Unload with |client| as the argument. - 1. Set |client|'s active service worker to [=ServiceWorkerGlobalScope/service worker=]. - 1. Invoke Notify Controller Change algorithm with |client| as the argument. - 1. Resolve |promise| with undefined. + 1. [=Queue a task=] to run the following steps on the [=ServiceWorkerGlobalScope/service worker=]'s [=responsible event loop=] using the [=DOM manipulation task source=]: + 1. For each [=/service worker client=] |client| where the result of running [=obtain a storage key=] given |client| [=storage key/equals=] the [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=]'s [=service worker registration/storage key=]: + 1. If |client|'s [=environment/execution ready flag=] is unset or |client|'s [=discarded flag=] is set, [=continue=]. + 1. If |client| is not a [=secure context=], [=continue=]. + 1. Let |storage key| be the result of running [=obtain a storage key=] given |client|. + 1. Let |registration| be the result of running Match Service Worker Registration given |storage key| and |client|'s creation URL. + 1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s containing service worker registration, [=continue=]. + + Note: |registration| will be null if the [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=] is [=service worker registration/unregistered=]. + + 1. If |client|'s active service worker is not the [=ServiceWorkerGlobalScope/service worker=], then: + 1. Invoke Handle Service Worker Client Unload with |client| as the argument. + 1. Set |client|'s active service worker to [=ServiceWorkerGlobalScope/service worker=]. + 1. Invoke Notify Controller Change algorithm with |client| as the argument. + 1. [=Queue a task=] to resolve |promise| with undefined. 1. Return |promise|. @@ -2008,15 +2013,16 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |promise| be [=a new promise=]. 1. Run these substeps [=in parallel=]: - 1. Let |p| be the result of running the algorithm specified in {{Cache/matchAll(request, options)}} method with |request| and |options|. - 1. Wait until |p| settles. - 1. If |p| rejects with an exception, then: - 1. Reject |promise| with that exception. - 1. Else if |p| resolves with an array, |responses|, then: - 1. If |responses| is an empty array, then: - 1. Resolve |promise| with undefined. - 1. Else: - 1. Resolve |promise| with the first element of |responses|. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. Let |p| be the result of running the algorithm specified in {{Cache/matchAll(request, options)}} method with |request| and |options|. + 1. Wait until |p| settles. + 1. If |p| rejects with an exception, then: + 1. Reject |promise| with that exception. + 1. Else if |p| resolves with an array, |responses|, then: + 1. If |responses| is an empty array, then: + 1. Resolve |promise| with undefined. + 1. Else: + 1. Resolve |promise| with the first element of |responses|. 1. Return |promise|. @@ -2044,7 +2050,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. [=list/For each=] |requestResponse| of |requestResponses|: 1. Add a copy of |requestResponse|'s response to |responses|. 1. [=list/For each=] |response| of |responses|: - 1. If |response|'s [=response/type=] is "`opaque`" and [=cross-origin resource policy check=] with |promise|'s [=relevant settings object=]'s [=environment settings object/origin=], |promise|'s [=relevant settings object=], "", and |response|'s [=filtered response/internal response=] returns blocked, then reject |promise| with a `TypeError` and abort these steps. + 1. If |response|'s [=response/type=] is "`opaque`" and [=cross-origin resource policy check=], [=queue a task=] on |promise|'s [=relevant settings object=]'s [=environment settings object/origin=], |promise|'s [=relevant settings object=], "", and |response|'s [=filtered response/internal response=] returns blocked, then reject |promise| with a `TypeError` and abort these steps. 1. [=Queue a task=], on |promise|'s [=relevant settings object=]'s [=responsible event loop=] using the [=DOM manipulation task source=], to perform the following steps: 1. Let |responseList| be a [=list=]. 1. [=list/For each=] |response| of |responses|: @@ -2261,10 +2267,11 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ The match(|request|, |options|) method steps are: 1. If |options|["{{MultiCacheQueryOptions/cacheName}}"] [=map/exists=], then: - 1. Return [=a new promise=] |promise| and run the following substeps [=in parallel=]: + 1. Let |promise| be [=a new promise=]. + 1. Run the following substeps [=in parallel=]: 1. [=map/For each=] |cacheName| → |cache| of the [=relevant name to cache map=]: 1. If |options|["{{MultiCacheQueryOptions/cacheName}}"] matches |cacheName|, then: - 1. Resolve |promise| with the result of running the algorithm specified in {{Cache/match(request, options)}} method of {{Cache}} interface with |request| and |options| (providing |cache| as thisArgument to the `\[[Call]]` internal method of {{Cache/match(request, options)}}.) + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |promise| with the result of running the algorithm specified in {{Cache/match(request, options)}} method of {{Cache}} interface with |request| and |options| (providing |cache| as thisArgument to the `\[[Call]]` internal method of {{Cache/match(request, options)}}). 1. Abort these steps. 1. Resolve |promise| with undefined. 1. Else: @@ -2284,8 +2291,9 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |promise| be [=a new promise=]. 1. Run the following substeps [=in parallel=]: 1. [=map/For each=] |key| → value of the [=relevant name to cache map=]: - 1. If |cacheName| matches |key|, resolve |promise| with true and abort these steps. - 1. Resolve |promise| with false. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. If |cacheName| matches |key|, resolve |promise| with true and abort these steps. + 1. Resolve |promise| with false. 1. Return |promise|. @@ -2298,11 +2306,12 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Run the following substeps [=in parallel=]: 1. [=map/For each=] |key| → |value| of the [=relevant name to cache map=]: 1. If |cacheName| matches |key|, then: - 1. Resolve |promise| with a new {{Cache}} object that represents |value|. - 1. Abort these steps. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. Resolve |promise| with a new {{Cache}} object that represents |value|. + 1. Abort these steps. 1. Let |cache| be a new [=request response list=]. - 1. [=map/Set=] the [=relevant name to cache map=][|cacheName|] to |cache|. If this cache write operation failed due to exceeding the granted quota limit, reject |promise| with a "{{QuotaExceededError}}" {{DOMException}} and abort these steps. - 1. Resolve |promise| with a new {{Cache}} object that represents |cache|. + 1. [=map/Set=] the [=relevant name to cache map=][|cacheName|] to |cache|. If this cache write operation failed due to exceeding the granted quota limit, [=queue a task=] to reject |promise| with a "{{QuotaExceededError}}" {{DOMException}} and abort these steps. + 1. [=Queue a task=] to resolve |promise| with a new {{Cache}} object that represents |cache|. 1. Return |promise|. @@ -2318,7 +2327,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |cacheJobPromise| be [=a new promise=]. 1. Run the following substeps [=in parallel=]: 1. [=map/Remove=] the [=relevant name to cache map=][|cacheName|]. - 1. Resolve |cacheJobPromise| with true. + 1. [=Queue a task=] on |cacheJobPromise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |cacheJobPromise| with true. Note: After this step, the existing DOM objects (i.e. the currently referenced Cache, Request, and Response objects) should remain functional. @@ -2336,7 +2345,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ Note: The [=list/items=] in the result [=ordered set=] are in the order that their corresponding entry was added to the [=name to cache map=]. - 1. Resolve |promise| with |cacheKeys|. + 1. [=Queue a task=] to resolve |promise| with |cacheKeys|. 1. Return |promise|. @@ -3270,13 +3279,14 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Set |preloadRequest|'s [=service-workers mode=] to "`none`". 1. Let |preloadFetchController| be null. 1. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "terminated" or "aborted": - 1. Set |preloadFetchController| to the result of [=Fetch|fetching=] |preloadRequest|. + 1. [=Queue a task=] on |preloadResponse|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. Set |preloadFetchController| to the result of [=Fetch|fetching=] |preloadRequest|. - To [=fetch/processResponse=] for |navigationPreloadResponse|, run these substeps: + To [=fetch/processResponse=] for |navigationPreloadResponse|, run these substeps: - 1. If |navigationPreloadResponse|'s [=response/type=] is "`error`", reject |preloadResponse| with a `TypeError` and terminate these substeps. - 1. Associate |preloadResponseObject| with |navigationPreloadResponse|. - 1. Resolve |preloadResponse| with |preloadResponseObject|. + 1. If |navigationPreloadResponse|'s [=response/type=] is "`error`", reject |preloadResponse| with a `TypeError` and terminate these substeps. + 1. Associate |preloadResponseObject| with |navigationPreloadResponse|. + 1. Resolve |preloadResponse| with |preloadResponseObject|. 1. [=If aborted=], then: 1. Let |deserializedError| be the result of [=deserialize a serialized abort reason=] given null and |workerRealm|. 1. [=fetch controller/Abort=] |preloadFetchController| with |deserializedError|. From 28459427d6dab311ca137c2c56d0da712d64cf59 Mon Sep 17 00:00:00 2001 From: Monica Chintala Date: Fri, 14 Feb 2025 16:20:22 -0800 Subject: [PATCH 2/3] fix typo --- docs/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index ee9dcdd9..20195f5d 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -807,7 +807,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Set |clientURL|'s [=url/fragment=] to null. 1. If the [=environment settings object/origin=] of |clientURL| is not |client|'s [=environment settings object/origin=], return a |promise| rejected with a "{{SecurityError}}" {{DOMException}}. 1. Let |promise| be a new promise. - 1. Run the following sub steps in parallel: + 1. Run the following substeps in parallel: 1. Let |registration| be the result of running Match Service Worker Registration given |storage key| and |clientURL|. 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: 1. If |registration| is null, resolve |promise| with undefined and abort these steps. From 828a0a116ab89da0ceca69f25b73b12f3d9a73f3 Mon Sep 17 00:00:00 2001 From: Monica Chintala Date: Fri, 21 Feb 2025 15:51:58 -0800 Subject: [PATCH 3/3] address feedback-1 --- docs/index.bs | 90 ++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 20195f5d..adc45f81 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -808,8 +808,8 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. If the [=environment settings object/origin=] of |clientURL| is not |client|'s [=environment settings object/origin=], return a |promise| rejected with a "{{SecurityError}}" {{DOMException}}. 1. Let |promise| be a new promise. 1. Run the following substeps in parallel: - 1. Let |registration| be the result of running Match Service Worker Registration given |storage key| and |clientURL|. 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. Let |registration| be the result of running Match Service Worker Registration given |storage key| and |clientURL|. 1. If |registration| is null, resolve |promise| with undefined and abort these steps. 1. Resolve |promise| with the result of [=getting the service worker registration object=] that represents |registration| in |promise|'s [=relevant settings object=]. 1. Return |promise|. @@ -1019,7 +1019,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |state| be a new {{NavigationPreloadState}} dictionary. 1. If |registration|'s [=navigation preload enabled flag=] is set, set |state|["{{NavigationPreloadState/enabled}}"] to true. 1. Set |state|["{{NavigationPreloadState/headerValue}}"] to |registration|'s [=navigation preload header value=]. - 1. [=Queue a task=] to resolve |promise| with |state|. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=] to resolve |promise| with |state|. 1. Return |promise|. @@ -1130,7 +1130,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Run the following substeps in parallel: 1. Set [=ServiceWorkerGlobalScope/service worker=]'s skip waiting flag. 1. Invoke [=Try Activate=] with [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=]. - 1. [=Queue a task=] to resolve |promise| with undefined. + 1. [=Queue a task=] on [=ServiceWorkerGlobalScope/service worker=]'s [=responsible event loop=], to resolve |promise| with undefined. 1. Return |promise|. @@ -1275,10 +1275,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |source| be the result of [=getting the service worker object=] that represents |contextObject|'s [=relevant global object=]'s [=ServiceWorkerGlobalScope/service worker=] in |targetClient|. 1. Let |deserializeRecord| be StructuredDeserializeWithTransfer(|serializeWithTransferResult|, |destination|'s [=relevant Realm=]). - If this throws an exception, catch it, [=queue a task=] to [=fire an event=] named {{ServiceWorkerContainer/messageerror!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin| and the {{MessageEvent/source}} attribute initialized to |source|, and then abort these steps. + If this throws an exception, catch it, [=queue a task=] on |targetClient|'s [=responsible event loop=], using the [=DOM manipulation task source=], to [=fire an event=] named {{ServiceWorkerContainer/messageerror!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin| and the {{MessageEvent/source}} attribute initialized to |source|, and then abort these steps. 1. Let |messageClone| be |deserializeRecord|.\[[Deserialized]]. 1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |deserializeRecord|.\[[TransferredValues]], if any. - 1. [=Queue a task=] to [=Dispatch|Dispatch an event=] named {{Window/message!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin|, the {{MessageEvent/source}} attribute initialized to |source|, the {{MessageEvent/data}} attribute initialized to |messageClone|, and the {{MessageEvent/ports}} attribute initialized to |newPorts|. + 1. [=Queue a task=] on |targetClient|'s [=responsible event loop=], using the [=DOM manipulation task source=], to [=Dispatch|Dispatch an event=] named {{Window/message!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin|, the {{MessageEvent/source}} attribute initialized to |source|, the {{MessageEvent/data}} attribute initialized to |messageClone|, and the {{MessageEvent/ports}} attribute initialized to |newPorts|.
@@ -1388,8 +1388,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. For each [=/service worker client=] |client| where the result of running [=obtain a storage key=] given |client| [=storage key/equals=] the associated [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=]'s [=service worker registration/storage key=]: 1. If |client|'s [=environment/id=] is not |id|, [=continue=]. 1. Wait for either |client|'s [=environment/execution ready flag=] to be set or for |client|'s [=discarded flag=] to be set. - 1. If |client|'s [=environment/execution ready flag=] is set, [=queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to invoke [=Resolve Get Client Promise=] with |client| and |promise|, and abort these steps. - 1. [=Queue a task=] to resolve |promise| with undefined. + 1. If |client|'s [=environment/execution ready flag=] is set, [=queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. Invoke [=Resolve Get Client Promise=] with |client| and |promise|. + 1. Abort these steps. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |promise| with undefined. 1. Return |promise|.
@@ -1483,21 +1485,20 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. If the [=ServiceWorkerGlobalScope/service worker=] is not an active worker, return a promise rejected with an "{{InvalidStateError}}" {{DOMException}}. 1. Let |promise| be a new promise. 1. Run the following substeps in parallel: - 1. [=Queue a task=] to run the following steps on the [=ServiceWorkerGlobalScope/service worker=]'s [=responsible event loop=] using the [=DOM manipulation task source=]: - 1. For each [=/service worker client=] |client| where the result of running [=obtain a storage key=] given |client| [=storage key/equals=] the [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=]'s [=service worker registration/storage key=]: - 1. If |client|'s [=environment/execution ready flag=] is unset or |client|'s [=discarded flag=] is set, [=continue=]. - 1. If |client| is not a [=secure context=], [=continue=]. - 1. Let |storage key| be the result of running [=obtain a storage key=] given |client|. - 1. Let |registration| be the result of running Match Service Worker Registration given |storage key| and |client|'s creation URL. - 1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s containing service worker registration, [=continue=]. - - Note: |registration| will be null if the [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=] is [=service worker registration/unregistered=]. - - 1. If |client|'s active service worker is not the [=ServiceWorkerGlobalScope/service worker=], then: - 1. Invoke Handle Service Worker Client Unload with |client| as the argument. - 1. Set |client|'s active service worker to [=ServiceWorkerGlobalScope/service worker=]. - 1. Invoke Notify Controller Change algorithm with |client| as the argument. - 1. [=Queue a task=] to resolve |promise| with undefined. + 1. For each [=/service worker client=] |client| where the result of running [=obtain a storage key=] given |client| [=storage key/equals=] the [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=]'s [=service worker registration/storage key=]: + 1. If |client|'s [=environment/execution ready flag=] is unset or |client|'s [=discarded flag=] is set, [=continue=]. + 1. If |client| is not a [=secure context=], [=continue=]. + 1. Let |storage key| be the result of running [=obtain a storage key=] given |client|. + 1. Let |registration| be the result of running Match Service Worker Registration given |storage key| and |client|'s creation URL. + 1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s containing service worker registration, [=continue=]. + + Note: |registration| will be null if the [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=] is [=service worker registration/unregistered=]. + + 1. If |client|'s active service worker is not the [=ServiceWorkerGlobalScope/service worker=], then: + 1. Invoke Handle Service Worker Client Unload with |client| as the argument. + 1. Set |client|'s active service worker to [=ServiceWorkerGlobalScope/service worker=]. + 1. Invoke Notify Controller Change algorithm with |client| as the argument. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=] using the [=DOM manipulation task source=] to resolve |promise| with undefined. 1. Return |promise|. @@ -2013,16 +2014,15 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |promise| be [=a new promise=]. 1. Run these substeps [=in parallel=]: - 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: - 1. Let |p| be the result of running the algorithm specified in {{Cache/matchAll(request, options)}} method with |request| and |options|. - 1. Wait until |p| settles. - 1. If |p| rejects with an exception, then: - 1. Reject |promise| with that exception. - 1. Else if |p| resolves with an array, |responses|, then: - 1. If |responses| is an empty array, then: - 1. Resolve |promise| with undefined. - 1. Else: - 1. Resolve |promise| with the first element of |responses|. + 1. Let |p| be the result of running the algorithm specified in {{Cache/matchAll(request, options)}} method with |request| and |options|. + 1. Wait until |p| settles. + 1. If |p| rejects with an exception, then: + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to reject |promise| with that exception. + 1. Else if |p| resolves with an array, |responses|, then: + 1. If |responses| is an empty array, then: + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |promise| with undefined. + 1. Else: + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |promise| with the first element of |responses|. 1. Return |promise|. @@ -2050,7 +2050,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. [=list/For each=] |requestResponse| of |requestResponses|: 1. Add a copy of |requestResponse|'s response to |responses|. 1. [=list/For each=] |response| of |responses|: - 1. If |response|'s [=response/type=] is "`opaque`" and [=cross-origin resource policy check=], [=queue a task=] on |promise|'s [=relevant settings object=]'s [=environment settings object/origin=], |promise|'s [=relevant settings object=], "", and |response|'s [=filtered response/internal response=] returns blocked, then reject |promise| with a `TypeError` and abort these steps. + 1. If |response|'s [=response/type=] is "`opaque`" and [=cross-origin resource policy check=] with |promise|'s [=relevant settings object=]'s [=environment settings object/origin=], |promise|'s [=relevant settings object=], "", and |response|'s [=filtered response/internal response=] returns blocked, then: + 1. [=Queue a task=], on |promise|'s [=relevant settings object=]'s [=responsible event loop=] using the [=DOM manipulation task source=], to perform the following steps: + 1. Reject |promise| with a `TypeError`. + 1. Abort these steps. 1. [=Queue a task=], on |promise|'s [=relevant settings object=]'s [=responsible event loop=] using the [=DOM manipulation task source=], to perform the following steps: 1. Let |responseList| be a [=list=]. 1. [=list/For each=] |response| of |responses|: @@ -2271,9 +2274,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Run the following substeps [=in parallel=]: 1. [=map/For each=] |cacheName| → |cache| of the [=relevant name to cache map=]: 1. If |options|["{{MultiCacheQueryOptions/cacheName}}"] matches |cacheName|, then: - 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |promise| with the result of running the algorithm specified in {{Cache/match(request, options)}} method of {{Cache}} interface with |request| and |options| (providing |cache| as thisArgument to the `\[[Call]]` internal method of {{Cache/match(request, options)}}). - 1. Abort these steps. - 1. Resolve |promise| with undefined. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. Resolve |promise| with the result of running the algorithm specified in {{Cache/match(request, options)}} method of {{Cache}} interface with |request| and |options| (providing |cache| as thisArgument to the `\[[Call]]` internal method of {{Cache/match(request, options)}}). + 1. Abort these steps. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |promise| with undefined. 1. Else: 1. Let |promise| be [=a promise resolved with=] undefined. 1. [=map/For each=] cacheName → |cache| of the [=relevant name to cache map=]: @@ -2292,8 +2296,9 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Run the following substeps [=in parallel=]: 1. [=map/For each=] |key| → value of the [=relevant name to cache map=]: 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: - 1. If |cacheName| matches |key|, resolve |promise| with true and abort these steps. - 1. Resolve |promise| with false. + 1. If |cacheName| matches |key|, resolve |promise| with true. + 1. Abort these steps. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |promise| with false. 1. Return |promise|. @@ -2310,8 +2315,11 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Resolve |promise| with a new {{Cache}} object that represents |value|. 1. Abort these steps. 1. Let |cache| be a new [=request response list=]. - 1. [=map/Set=] the [=relevant name to cache map=][|cacheName|] to |cache|. If this cache write operation failed due to exceeding the granted quota limit, [=queue a task=] to reject |promise| with a "{{QuotaExceededError}}" {{DOMException}} and abort these steps. - 1. [=Queue a task=] to resolve |promise| with a new {{Cache}} object that represents |cache|. + 1. [=map/Set=] the [=relevant name to cache map=][|cacheName|] to |cache|. If this cache write operation failed due to exceeding the granted quota limit, then: + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps: + 1. Reject |promise| with a "{{QuotaExceededError}}" {{DOMException}}. + 1. Abort these steps. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |promise| with a new {{Cache}} object that represents |cache|. 1. Return |promise|. @@ -2345,7 +2353,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ Note: The [=list/items=] in the result [=ordered set=] are in the order that their corresponding entry was added to the [=name to cache map=]. - 1. [=Queue a task=] to resolve |promise| with |cacheKeys|. + 1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to resolve |promise| with |cacheKeys|. 1. Return |promise|.