Skip to content

Commit 7c09292

Browse files
committed
remove a few registration scope url references
1 parent 1a185bc commit 7c09292

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

docs/index.bs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
122122
}
123123
</pre>
124124

125+
<!-- TODO: remove service worker registration/scope url completely -->
126+
125127
<section>
126128
<h2 id="motivations">Motivations</h2>
127129

@@ -605,7 +607,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
605607
1. If |newestWorker| is null, return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}} and abort these steps.
606608
1. If [=this=]'s [=relevant global object=] |globalObject| is a {{ServiceWorkerGlobalScope}} object, and |globalObject|'s associated [=ServiceWorkerGlobalScope/service worker=]'s <a>state</a> is "`installing`", return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}} and abort these steps.
607609
1. Let |promise| be a <a>promise</a>.
608-
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/scope url=], |newestWorker|'s [=service worker/script url=], |promise|, and [=this=]'s <a>relevant settings object</a>.
610+
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/id=], |newestWorkers|'s [=service worker/scope url=], |newestWorker|'s [=service worker/script url=], |promise|, and the [=this=]'s <a>relevant settings object</a>.
609611
1. Set |job|'s <a>worker type</a> to |newestWorker|'s [=service worker/type=].
610612
1. Invoke <a>Schedule Job</a> with |job|.
611613
1. Return |promise|.
@@ -619,7 +621,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
619621
The <dfn method for="ServiceWorkerRegistration"><code>unregister()</code></dfn> method steps are:
620622

621623
1. Let |promise| be [=a new promise=].
622-
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 [=this=]'s <a>relevant settings object</a>.
624+
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as its argument.
625+
1. If |newestWorker| is null, return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}} and abort these steps.
626+
1. Let |job| be the result of running [=Create Job=] with *unregister*, the [=service worker registration/id=] of the [=ServiceWorkerRegistration/service worker registration=], |newest worker|'s [=service worker/scope url=], null, |promise|, and the [=this=]'s <a>relevant settings object</a>.
623627
1. Invoke <a>Schedule Job</a> with |job|.
624628
1. Return |promise|.
625629
</section>
@@ -741,8 +745,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
741745
1. Let |client| be [=this=]'s [=ServiceWorkerContainer/service worker client=].
742746
1. Let |scriptURL| be the result of <a lt="URL parser">parsing</a> |scriptURL| with [=this=]'s <a>relevant settings object</a>'s <a>API base URL</a>.
743747
1. Let |scopeURL| be null.
744-
1. If |options|["{{RegistrationOptions/scope}}"] [=map/exists=], set |scopeURL| to the result of <a lt="URL parser">parsing</a> |options|["{{RegistrationOptions/scope}}"] with [=this=]'s <a>relevant settings object</a>'s <a>API base URL</a>.
745-
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |p|, |client|, |client|'s <a>creation URL</a>, |options|["{{RegistrationOptions/type}}"], and |options|["{{RegistrationOptions/updateViaCache}}"].
748+
1. If |options|.{{RegistrationOptions/scope}} is <a>present</a>, set |scopeURL| to the result of <a lt="URL parser">parsing</a> |options|.{{RegistrationOptions/scope}} with the [=this=]'s <a>relevant settings object</a>'s <a>API base URL</a>.
749+
1. Let |id| be null.
750+
1. If |options|.{{RegistrationOptions/id} is <a>present</a>, set |id| to |options|.{{RegistrationOptions/id}}.
751+
1. Invoke [=Start Register=] with |id|, |scopeURL|, |scriptURL|, |p|, |client|, |client|'s <a>creation URL</a>, |options|.{{RegistrationOptions/type}}, and |options|.{{RegistrationOptions/updateViaCache}}.
746752
1. Return |p|.
747753
</section>
748754

@@ -2345,8 +2351,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
23452351

23462352
An <dfn id="dfn-id-to-registration-map">id to registration map</dfn> is an <a>ordered map</a> where the keys are [=service worker registration/ids=] and the values are [=/service worker registrations=].
23472353

2348-
A <dfn id="dfn-scope-to-service-worker-map">scope to service worker map</dfn> is an <a>ordered map</a> where the keys are [=service worker/scope urls=], [=URL serializer|serialized=], and the values are [=/service workers=].
2349-
23502354
A <dfn id="dfn-job">job</dfn> is an abstraction of one of register, update, and unregister request for a [=/service worker registration=].
23512355

23522356
<div dfn-for="job">
@@ -2398,6 +2402,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
23982402

23992403
: Input
24002404
:: |jobType|, a <a>job type</a>
2405+
:: |id|, a [=service worker registration/id=]
24012406
:: |scopeURL|, a [=/URL=]
24022407
:: |scriptURL|, a [=/URL=]
24032408
:: |promise|, a <a>promise</a>
@@ -2407,6 +2412,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
24072412

24082413
1. Let |job| be a new <a>job</a>.
24092414
1. Set |job|'s [=job/job type=] to |jobType|.
2415+
1. Set |job|'s [=job/id=] to |id|.
24102416
1. Set |job|'s [=job/scope url=] to |scopeURL|.
24112417
1. Set |job|'s [=job/script url=] to |scriptURL|.
24122418
1. Set |job|'s [=job/job promise=] to |promise|.
@@ -2511,6 +2517,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
25112517
<h3 id="start-register-algorithm"><dfn>Start Register</dfn></h3>
25122518

25132519
: Input
2520+
:: |id|, a [=service worker registration/id=] or null
25142521
:: |scopeURL|, a [=/URL=] or failure or null
25152522
:: |scriptURL|, a [=/URL=] or failure
25162523
:: |promise|, a <a>promise</a>
@@ -2539,7 +2546,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
25392546

25402547
1. If |scopeURL|'s [=url/scheme=] is not one of "<code>http</code>" and "<code>https</code>", reject |promise| with a <code>TypeError</code> and abort these steps.
25412548
1. If any of the strings in |scopeURL|'s [=url/path=] contains either <a>ASCII case-insensitive</a> "<code>%2f</code>" or <a>ASCII case-insensitive</a> "<code>%5c</code>", reject |promise| with a <code>TypeError</code> and abort these steps.
2542-
1. Let |job| be the result of running [=Create Job=] with *register*, |scopeURL|, |scriptURL|, |promise|, and |client|.
2549+
1. If |id| is null, set |id| to |scopeURL|.
2550+
1. Let |job| be the result of running [=Create Job=] with *register*, |id|, |scopeURL|, |scriptURL|, |promise|, and |client|.
25432551
1. Set |job|'s [=job/worker type=] to |workerType|.
25442552
1. Set |job|'s [=job/update via cache mode=] to |updateViaCache|.
25452553
1. Set |job|'s [=job/referrer=] to |referrer|.
@@ -2570,7 +2578,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
25702578
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
25712579
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
25722580
1. Else:
2573-
1. Invoke <a>Set Registration</a> algorithm with |job|'s [=job/scope url=] and |job|'s [=job/update via cache mode=].
2581+
1. Invoke <a>Set Registration</a> algorithm with |job|'s [=job/id], |job|'s [=job/scope url=], and |job|'s [=job/update via cache mode=].
25742582
1. Invoke <a>Update</a> algorithm passing |job| as the argument.
25752583
</section>
25762584

@@ -2634,7 +2642,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
26342642
1. If |serviceWorkerAllowed| is failure, then:
26352643
1. Asynchronously complete these steps with a <a>network error</a>.
26362644
1. Let |id| be |registration|'s [=service worker registration/id=]
2637-
1. TODO: use newest worker scope? Let |scopeURL| be |registration|'s [=service worker registration/scope url=].
2645+
1. If |newest worker| is not null, then:
2646+
1. Let |scopeURL| be |newest worker|'s [=service worker/scope url=].
2647+
1. Else:
2648+
1. Let |scopeURL| be |job|'s [=job/scope url=].
26382649
1. Let |maxScopeString| be null.
26392650
1. If |serviceWorkerAllowed| is null, then:
26402651
1. Let |resolvedScope| be the result of [=URL parser|parsing=] "`./`" using |job|'s [=job/script url=] as the [=base URL=].
@@ -2726,7 +2737,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
27262737

27272738
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as its argument.
27282739
1. If |newestWorker| is null, abort these steps.
2729-
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/scope url=], |newestWorker|'s [=service worker/script url=], null, and null.
2740+
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/id=], |newestWorker|'s [=service worker/scope url=], |newestWorker|'s [=service worker/script url=], null, and null.
27302741
1. Set |job|'s <a>worker type</a> to |newestWorker|'s [=service worker/type=].
27312742
1. Set |job|'s [=force bypass cache flag=] if |forceBypassCache| is true.
27322743
1. Invoke <a>Schedule Job</a> with |job|.
@@ -2749,7 +2760,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
27492760
1. Run the <a>Update Worker State</a> algorithm passing |registration|'s <a>installing worker</a> and "`installing`" as the arguments.
27502761
1. Assert: |job|'s [=job/job promise=] is not null.
27512762
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
2752-
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |registration|'s [=service worker registration/scope url=]'s [=url/origin=].
2763+
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |job|'s [=job/scope url=]'s [=url/origin=].
27532764
1. For each |settingsObject| of |settingsObjects|, [=queue a task=] on |settingsObject|'s [=responsible event loop=] in the [=DOM manipulation task source=] to run the following steps:
27542765
1. Let |registrationObjects| be every {{ServiceWorkerRegistration}} object in |settingsObject|'s [=environment settings object/realm=], whose [=ServiceWorkerRegistration/service worker registration=] is |registration|.
27552766
1. For each |registrationObject| of |registrationObjects|, [=fire an event=] on |registrationObject| named `updatefound`.
@@ -2815,6 +2826,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
28152826

28162827
Note: Make sure to design activation handlers to do non-essential work (like cleanup). This is because activation handlers may not all run to completion, especially in the case of browser termination during activation. A Service Worker should be designed to function properly, even if the activation handlers do not all complete successfully.
28172828

2829+
<!-- remove this service worker registration/scope url reference -->
28182830
1. Let |matchedClients| be a [=list=] of [=/service worker clients=] whose <a>creation URL</a> <a lt="Match Service Worker Registration">matches</a> |registration|'s [=service worker registration/scope url=].
28192831
1. [=list/For each=] |client| of |matchedClients|, [=queue a task=] on |client|'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following substeps:
28202832
1. Let |readyPromise| be |client|'s [=environment settings object/global object=]'s {{ServiceWorkerContainer}} object's [=ServiceWorkerContainer/ready promise=].
@@ -3208,6 +3220,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
32083220

32093221
1. Run the following steps atomically.
32103222
1. Let |scopeString| be [=URL serializer|serialized=] |scope| with the *exclude fragment flag* set.
3223+
<!-- get rid of this service worker registration/scope url reference -->
32113224
1. Let |registration| be a new [=/service worker registration=] whose [=service worker registration/id=] is set to |id|, [=service worker registration/scope url=] is set to |scope|, and [=service worker registration/update via cache mode=] is set to |updateViaCache|.
32123225
1. [=map/Set=] <a>id to registration map</a>[|id|] to |registration|.
32133226
1. Return |registration|.
@@ -3327,8 +3340,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
33273340
1. Let |matchingScopeString| be the empty string.
33283341
1. Let |scopeMap| be the empty map.
33293342
1. [=map/For each=] |key| → |value| of <a>id to registration map</a>:
3330-
1. If |value|'s [=service worker registration/active worker=/ is null, then [=continue=].
3331-
1. [=map/Set=] |scopeMap|[|value|'s [=service worker registration/scope url] to |value|.
3343+
1. Let |activeWorker| be |value|'s [=service worker registration/active worker=],
3344+
1. If |activeWorker| is null, then [=continue=].
3345+
1. [=map/Set=] |scopeMap|[|active worker|'s [=service worker/scope url] to |value|.
33323346
1. Let |scopeStringSet| be the result of [=map/get the keys|getting the keys=] from |scopeMap|.
33333347
1. Set |matchingScopeString| to the longest value in |scopeStringSet| which the value of |clientURLString| starts with, if it exists.
33343348

0 commit comments

Comments
 (0)