You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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=].
522
522
523
523
<dfn method for="ServiceWorkerRegistration"><code>unregister()</code></dfn> method *must* run these steps:
524
524
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>.
{{ExtendableEvent/waitUntil()}} method extends the lifetime of the event.
1339
+
Note: {{ExtendableEvent/waitUntil()}} method extends the lifetime of the event.
1340
1340
1341
1341
<dfn method for="ExtendableEvent"><code>waitUntil(|f|)</code></dfn> method *must* run these steps:
1342
1342
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:
1344
1349
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}}.
1346
1352
1347
1353
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.
1348
1354
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.
1351
1357
1352
1358
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.
1353
1359
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|.
1359
1366
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=].
1361
1368
</section>
1362
1369
1363
1370
[=/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.
<dfn method for="FetchEvent"><code>respondWith(|r|)</code></dfn> method *must* run these steps:
1437
1444
1445
+
1. Let |event| be the [=context object=].
1438
1446
1. If the <a>dispatch flag</a> is unset, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1439
1447
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|.
1450
1449
1451
1450
Note: {{FetchEvent/respondWith(r)|event.respondWith(r)}} extends the lifetime of the event by default as if {{ExtendableEvent/waitUntil()|event.waitUntil(r)}} is called.
0 commit comments