Skip to content

Commit c3f8eca

Browse files
committed
Remove repetition in respondWith
1 parent c1f3619 commit c3f8eca

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

docs/index.bs

+23-24
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,12 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
518518
<section algorithm="navigator-service-worker-unregister">
519519
<h4 id="navigator-service-worker-unregister">{{ServiceWorkerRegistration/unregister()}}</h4>
520520

521-
Note: The {{ServiceWorkerRegistration/unregister()}} method unregisters the [=/service worker registration=]. It is important to note that the currently <a>controlled</a> [=/service worker client=]'s <a>active service worker</a>'s <a>containing service worker registration</a> is effective until all the [=/service worker clients=] (including itself) using this [=/service worker registration=] unload. That is, the {{ServiceWorkerRegistration/unregister()}} method only affects subsequent <a lt="navigate">navigations</a>.
521+
Note: The {{ServiceWorkerRegistration/unregister()}} method unregisters the [=/service worker registration=]. It is important to note that the currently [=controlled=] [=/service worker client=]'s [=active service worker=]'s [=containing service worker registration=] is effective until all the [=/service worker clients=] (including itself) using this [=/service worker registration=] unload. That is, the {{ServiceWorkerRegistration/unregister()}} method only affects subsequent [=navigate|navigations=].
522522

523523
<dfn method for="ServiceWorkerRegistration"><code>unregister()</code></dfn> method *must* run these steps:
524524

525-
1. Let |promise| be a <a>promise</a>.
526-
1. Let |job| be the result of running <a>Create Job</a> with *unregister*, the [=service worker registration/scope url=] of the [=ServiceWorkerRegistration/service worker registration=], null, |promise|, and the <a>context object</a>'s <a>relevant settings object</a>.
525+
1. Let |promise| be [=a new promise=].
526+
1. Let |job| be the result of running [=Create Job=] with *unregister*, the [=service worker registration/scope url=] of the [=ServiceWorkerRegistration/service worker registration=], null, |promise|, and the <a>context object</a>'s <a>relevant settings object</a>.
527527
1. Invoke <a>Schedule Job</a> with |job|.
528528
1. Return |promise|.
529529
</section>
@@ -1336,28 +1336,35 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
13361336
<section algorithm="wait-until-method">
13371337
<h4 id="wait-until-method">{{ExtendableEvent/waitUntil()|event.waitUntil(f)}}</h4>
13381338

1339-
{{ExtendableEvent/waitUntil()}} method extends the lifetime of the event.
1339+
Note: {{ExtendableEvent/waitUntil()}} method extends the lifetime of the event.
13401340

13411341
<dfn method for="ExtendableEvent"><code>waitUntil(|f|)</code></dfn> method *must* run these steps:
13421342

1343-
1. If the {{Event/isTrusted}} attribute is false, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1343+
1. Let |event| be the [=context object=].
1344+
1. [=ExtendableEvent/Add lifetime promise=] |f| to |event|.
1345+
</section>
1346+
1347+
<section algorithm="add-lifetime-promise">
1348+
To <dfn for="ExtendableEvent" export>add lifetime promise</dfn> |promise| (a [=promise=]) to |event| (an {{ExtendableEvent}}), run these steps:
13441349

1345-
1. If not [=ExtendableEvent/active=], [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1350+
1. If |event|'s {{Event/isTrusted}} attribute is false, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1351+
1. If |event| is not [=ExtendableEvent/active=], [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
13461352

13471353
Note: If no lifetime extension promise has been added in the task that called the event handlers, calling {{ExtendableEvent/waitUntil()}} in subsequent asynchronous tasks will throw.
13481354

1349-
1. Add |f| to the [=ExtendableEvent/extend lifetime promises=].
1350-
1. Increment the [=ExtendableEvent/pending promises count=] by one.
1355+
1. Add |promise| to |event|'s [=ExtendableEvent/extend lifetime promises=].
1356+
1. Increment |event|'s [=ExtendableEvent/pending promises count=] by one.
13511357

13521358
Note: The [=ExtendableEvent/pending promises count=] is incremented even if the given promise has already been settled. The corresponding count decrement is done in the microtask queued by the reaction to the promise.
13531359

1354-
1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |f|, [=queue a microtask=] to run these substeps:
1355-
1. Decrement the [=ExtendableEvent/pending promises count=] by one.
1356-
1. Let |registration| be the [=context object=]'s [=relevant global object=]'s associated [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=].
1357-
1. If |registration|'s [=uninstalling flag=] is set, invoke [=Try Clear Registration=] with |registration|.
1358-
1. If |registration| is not null, invoke [=Try Activate=] with |registration|.
1360+
1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |promise|, [=queue a microtask=] to run these substeps:
1361+
1. Decrement |event|'s [=ExtendableEvent/pending promises count=] by one.
1362+
1. If |event|'s [=ExtendableEvent/pending promises count=] is 0, then:
1363+
1. Let |registration| be the [=context object=]'s [=relevant global object=]'s associated [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=].
1364+
1. If |registration|'s [=uninstalling flag=] is set, invoke [=Try Clear Registration=] with |registration|.
1365+
1. If |registration| is not null, invoke [=Try Activate=] with |registration|.
13591366

1360-
The user agent *should not* [=terminate service worker|terminate=] a [=/service worker=] if [=Service Worker Has No Pending Events=] returns false for that [=/service worker=].
1367+
The user agent *should not* [=terminate service worker|terminate=] a [=/service worker=] if [=Service Worker Has No Pending Events=] returns false for that [=/service worker=].
13611368
</section>
13621369

13631370
[=/Service workers=] and <a href="#extensibility">extensions</a> that <a href="#extension-to-service-worker-global-scope">define event handlers</a> *may* define their own behaviors, allowing the [=ExtendableEvent/extend lifetime promises=] to suggest operation length, and the rejected state of any of the <a>promise</a> in [=ExtendableEvent/extend lifetime promises=] to suggest operation failure.
@@ -1435,18 +1442,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
14351442

14361443
<dfn method for="FetchEvent"><code>respondWith(|r|)</code></dfn> method *must* run these steps:
14371444

1445+
1. Let |event| be the [=context object=].
14381446
1. If the <a>dispatch flag</a> is unset, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
14391447
1. If the [=FetchEvent/respond-with entered flag=] is set, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1440-
1. Add |r| to the <a>extend lifetime promises</a>.
1441-
1. Increment the [=ExtendableEvent/pending promises count=] by one.
1442-
1443-
Note: The [=ExtendableEvent/pending promises count=] is incremented even if the given promise has already been settled. The corresponding count decrement is done in the microtask queued by the reaction to the promise.
1444-
1445-
1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |r|, [=queue a microtask=] to run these substeps:
1446-
1. Decrement the [=ExtendableEvent/pending promises count=] by one.
1447-
1. Let |registration| be the [=context object=]'s [=relevant global object=]'s associated [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=].
1448-
1. If |registration|'s [=uninstalling flag=] is set, invoke [=Try Clear Registration=] with |registration|.
1449-
1. If |registration| is not null, invoke [=Try Activate=] with |registration|.
1448+
1. [=ExtendableEvent/Add lifetime promise=] |r| to |event|.
14501449

14511450
Note: {{FetchEvent/respondWith(r)|event.respondWith(r)}} extends the lifetime of the event by default as if {{ExtendableEvent/waitUntil()|event.waitUntil(r)}} is called.
14521451

0 commit comments

Comments
 (0)