Skip to content

Commit

Permalink
Kill resurrection (fixes #1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakearchibald committed Jun 3, 2019
1 parent c3f8eca commit b622281
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 60 deletions.
38 changes: 19 additions & 19 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

A [=/service worker registration=] has an associated <dfn export id="dfn-update-via-cache">update via cache mode</dfn>, which is "`imports`", "`all`", or "`none`". It is initially set to "`imports`".

A [=/service worker registration=] has an associated <dfn export id="dfn-uninstalling-flag">uninstalling flag</dfn>. It is initially unset.

A [=/service worker registration=] has one or more <dfn export id="dfn-service-worker-registration-task-queue">task queues</dfn> that back up the <a>tasks</a> from its <a>active worker</a>'s <a>event loop</a>'s corresponding [=/task queues=]. (The target task sources for this back up operation are the <a>handle fetch task source</a> and the <a>handle functional event task source</a>.) The user agent dumps the <a>active worker</a>'s <a>tasks</a> to the [=/service worker registration=]'s [=service worker registration/task queues=] when the <a>active worker</a> is <a lt="terminate service worker">terminated</a> and <a lt="queue a task">re-queues those tasks</a> to the <a>active worker</a>'s <a>event loop</a>'s corresponding [=/task queues=] when the <a>active worker</a> spins off. Unlike the [=/task queues=] owned by <a>event loops</a>, the [=/service worker registration=]'s [=service worker registration/task queues=] are not processed by any <a>event loops</a> in and of itself.

A [=/service worker registration=] has an associated <dfn export>{{NavigationPreloadManager}}</dfn> object.
Expand All @@ -220,6 +218,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

A [=/service worker registration=] has an associated <dfn export>navigation preload header value</dfn>, which is a [=byte sequence=]. It is initially set to \`<code>true</code>\`.

A [=/service worker registration=] is said to be <dfn export id="dfn-service-worker-registration-uninstalled">unregistered</dfn> if [=scope to registration map=][[=service worker registration/scope url=]] is not this [=/service worker registration=].

<section>
<h4 id="service-worker-registration-lifetime">Lifetime</h4>

Expand Down Expand Up @@ -678,7 +678,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Run the following steps [=in parallel=]:
1. Let |registrations| be a new [=list=].
1. [=map/For each=] |scope| → |registration| of [=scope to registration map=]:
1. If the [=url/origin=] of the result of [=URL parser|parsing=] |scope| is the [=same origin|same=] as |client|'s [=environment settings object/origin=], and |registration|'s [=uninstalling flag=] is unset, then [=append=] |registration| to |registrations|.
1. If the [=url/origin=] of the result of [=URL parser|parsing=] |scope| is the [=same origin|same=] as |client|'s [=environment settings object/origin=], then [=append=] |registration| to |registrations|.
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 |registrationObjects| be a new [=list=].
1. [=list/For each=] |registration| of |registrations|, [=append=] the {{ServiceWorkerRegistration}} object associated with |registration| to |registrationObjects|.
Expand Down Expand Up @@ -1297,6 +1297,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. If |client| is not a [=secure context=], [=continue=].
1. Let |registration| be the result of running <a>Match Service Worker Registration</a> algorithm passing |client|'s <a>creation URL</a> as the argument.
1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s <a>containing service worker registration</a>, [=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 <a>active service worker</a> is not the [=ServiceWorkerGlobalScope/service worker=], then:
1. Invoke <a>Handle Service Worker Client Unload</a> with |client| as the argument.
1. Set |client|'s <a>active service worker</a> to [=ServiceWorkerGlobalScope/service worker=].
Expand Down Expand Up @@ -1360,8 +1363,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Upon [=upon fulfillment|fulfillment=] or [=upon rejection|rejection=] of |promise|, [=queue a microtask=] to run these substeps:
1. Decrement |event|'s [=ExtendableEvent/pending promises count=] by one.
1. If |event|'s [=ExtendableEvent/pending promises count=] is 0, then:
1. Let |registration| be the [=context object=]'s [=relevant global object=]'s associated [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=].
1. If |registration|'s [=uninstalling flag=] is set, invoke [=Try Clear Registration=] with |registration|.
1. Let |registration| be the [=current global object=]'s associated [=ServiceWorkerGlobalScope/service worker=]'s [=containing service worker registration=].
1. If |registration| is [=service worker registration/unregistered=], invoke [=Try Clear Registration=] with |registration|.
1. If |registration| is not null, invoke [=Try Activate=] with |registration|.

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=].
Expand Down Expand Up @@ -2434,7 +2437,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
1. Let |registration| be the result of running the <a>Get Registration</a> algorithm passing |job|'s [=job/scope url=] as the argument.
1. If |registration| is not null, then:
1. If |registration|'s <a>uninstalling flag</a> is set, unset it.
1. Let |newestWorker| be the result of running the <a>Get Newest Worker</a> algorithm passing |registration| as the argument.
1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=], and |job|'s [=job/update via cache mode=]'s value equals |registration|'s [=service worker registration/update via cache mode=], then:
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
Expand All @@ -2453,7 +2455,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
:: none

1. Let |registration| be the result of running the <a>Get Registration</a> algorithm passing |job|'s [=job/scope url=] as the argument.
1. If |registration| is null or |registration|'s <a>uninstalling flag</a> is set, then:
1. If |registration| is null or |registration| is [=service worker registration/unregistered=], then:
1. Invoke [=Reject Job Promise=] with |job| and `TypeError`.
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as the argument.
Expand Down Expand Up @@ -2604,7 +2606,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Run the <a>Update Worker State</a> algorithm passing |registration|'s <a>installing worker</a> and *installing* as the arguments.
1. Assert: |job|'s [=job/job promise=] is not null.
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
1. <a>Queue a task</a> to <a>fire an event</a> named <code>updatefound</code> at all the {{ServiceWorkerRegistration}} objects for all the [=/service worker clients=] whose <a>creation URL</a> <a lt="Match Service Worker Registration">matches</a> |registration|'s [=service worker registration/scope url=] and all the [=/service workers=] whose <a>containing service worker registration</a> is |registration|.
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |registration|'s [=service worker registration/scope url=]'s origin.
1. For each |settingsObject| of |settingsObjects|, [=queue a task=] on |settingsObject| to run the following steps:
1. Let |registrationObjects| be every {{ServiceWorkerRegistration}} object in |settingsObject|'s [=environment settings object/realm execution context=], whose [=ServiceWorkerRegistration/service worker registration=] is |registration|.
1. For each |registrationObject| of |registrationObjects|, [=fire an event=] on |registrationObject| named `updatefound`.
1. Let |installingWorker| be |registration|'s <a>installing worker</a>.
1. Invoke <a>Run Service Worker</a> algorithm given |installingWorker|, and with the *force bypass cache for importscripts flag* set if |job|'s [=job/force bypass cache flag=] is set.
1. <a>Queue a task</a> |task| to run the following substeps:
Expand Down Expand Up @@ -2900,7 +2905,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
: Output
:: None

1. Assert: [=scope to registration map=] contains a value equal to |registration|.
1. Assert: |registration|'s [=active worker=] is not null.
1. Let |activeWorker| be |registration|'s [=active worker=].
1. If |activeWorker|'s [=set of event types to handle=] does not [=set/contain=] |eventName|, then return and run the following steps [=in parallel=]:
Expand Down Expand Up @@ -2956,8 +2960,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Let |registration| be the [=/service worker registration=] <a>used</a> by |client|.
1. If |registration| is null, abort these steps.
1. If any other [=/service worker client=] is <a>using</a> |registration|, abort these steps.
1. If |registration|'s [=uninstalling flag=] is set, invoke [=Try Clear Registration=] with |registration|.
1. If |registration| is not null, invoke [=Try Activate=] with |registration|.
1. If |registration| is [=service worker registration/unregistered=], invoke [=Try Clear Registration=] with |registration|.
1. Invoke [=Try Activate=] with |registration|.
</section>

<section algorithm>
Expand Down Expand Up @@ -3006,7 +3010,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. If |registration| is null, then:
1. Invoke <a>Resolve Job Promise</a> with |job| and false.
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
1. Set |registration|'s <a>uninstalling flag</a>.
1. [=map/Remove=] [=scope to registration map=][|job|'s [=job/scope url=]].
1. Invoke <a>Resolve Job Promise</a> with |job| and true.
1. Invoke [=Try Clear Registration=] with |registration|.

Expand Down Expand Up @@ -3052,8 +3056,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. [=Terminate Service Worker|Terminate=] |registration|'s [=active worker=].
1. Run the <a>Update Worker State</a> algorithm passing |registration|'s [=active worker=] and *redundant* as the arguments.
1. Run the <a>Update Registration State</a> algorithm passing |registration|, "<code>active</code>" and null as the arguments.
1. Let |scopeString| be |registration|'s [=URL serializer|serialized=] [=service worker registration/scope url=].
1. [=map/Remove=] <a>scope to registration map</a>[|scopeString|].
</section>

<section algorithm>
Expand Down Expand Up @@ -3176,7 +3178,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Set |matchingScope| to the result of <a lt="URL parser">parsing</a> |matchingScopeString|.
1. Assert: |matchingScope|'s [=url/origin=] and |clientURL|'s [=url/origin=] are [=same origin=].
1. Let |registration| be the result of running <a>Get Registration</a> algorithm passing |matchingScope| as the argument.
1. If |registration| is not null and |registration|'s <a>uninstalling flag</a> is set, return null.
1. Return |registration|.
</section>

Expand All @@ -3186,15 +3187,14 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
: Input
:: |scope|, a [=/URL=]
: Output
:: |registration|, a [=/service worker registration=]
:: A [=/service worker registration=]

1. Run the following steps atomically.
1. Let |scopeString| be the empty string.
1. If |scope| is not null, set |scopeString| to [=URL serializer|serialized=] |scope| with the *exclude fragment flag* set.
1. Let |registration| be null.
1. [=map/For each=] |key| → |value| of <a>scope to registration map</a>:
1. If |scopeString| matches |key|, set |registration| to |value|.
1. Return |registration|.
1. If |scopeString| matches |key|, then return |value|.
1. Return null.
</section>

<section algorithm>
Expand Down
Loading

0 comments on commit b622281

Please sign in to comment.