diff --git a/docs/index.bs b/docs/index.bs
index 472b2cd4..adc45f81 100644
--- a/docs/index.bs
+++ b/docs/index.bs
@@ -808,9 +808,10 @@ 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. 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. 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|.
@@ -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=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=] 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=] on [=ServiceWorkerGlobalScope/service worker=]'s [=responsible event loop=], 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=] 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. [=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|.
@@ -1384,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, 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 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|.
@@ -1492,7 +1498,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
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=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=] using the [=DOM manipulation task source=] to resolve |promise| with undefined.
1. Return |promise|.
@@ -2009,14 +2015,14 @@ 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. Wait until |p| settles.
1. If |p| rejects with an exception, then:
- 1. Reject |promise| with that exception.
+ 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. 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 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 resolve |promise| with the first element of |responses|.
1. Return |promise|.
@@ -2044,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=] 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=] 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|:
@@ -2261,12 +2270,14 @@ 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. 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=]:
@@ -2284,8 +2295,10 @@ 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.
+ 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|.
@@ -2298,11 +2311,15 @@ 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, 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|.
@@ -2318,7 +2335,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 +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. 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|.
@@ -3270,13 +3287,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|.