Skip to content

Commit 8aafaac

Browse files
committed
remove a few registration scope url references
1 parent 1f28504 commit 8aafaac

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

docs/index.bs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
120120
}
121121
</pre>
122122

123+
<!-- TODO: remove service worker registration/scope url completely -->
124+
123125
<section>
124126
<h2 id="motivations">Motivations</h2>
125127

@@ -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 the <a>context object</a>'s <a>relevant settings object</a>'s [=environment settings object/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 the <a>context object</a>'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 <a>context object</a>'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
<dfn method for="ServiceWorkerRegistration"><code>unregister()</code></dfn> method *must* run these steps:
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 the <a>context object</a>'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 <a>context object</a>'s <a>relevant settings object</a>.
623627
1. Invoke <a>Schedule Job</a> with |job|.
624628
1. Return |promise|.
625629
</section>
@@ -742,7 +746,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
742746
1. Let |scriptURL| be the result of <a lt="URL parser">parsing</a> |scriptURL| with the <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.
743747
1. Let |scopeURL| be null.
744748
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 <a>context object</a>'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}}.
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

@@ -2336,8 +2342,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
23362342

23372343
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=].
23382344

2339-
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=].
2340-
23412345
A <dfn id="dfn-job">job</dfn> is an abstraction of one of register, update, and unregister request for a [=/service worker registration=].
23422346

23432347
<div dfn-for="job">
@@ -2389,6 +2393,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
23892393

23902394
: Input
23912395
:: |jobType|, a <a>job type</a>
2396+
:: |id|, a [=service worker registration/id=]
23922397
:: |scopeURL|, a [=/URL=]
23932398
:: |scriptURL|, a [=/URL=]
23942399
:: |promise|, a <a>promise</a>
@@ -2398,6 +2403,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
23982403

23992404
1. Let |job| be a new <a>job</a>.
24002405
1. Set |job|'s [=job/job type=] to |jobType|.
2406+
1. Set |job|'s [=job/id=] to |id|.
24012407
1. Set |job|'s [=job/scope url=] to |scopeURL|.
24022408
1. Set |job|'s [=job/script url=] to |scriptURL|.
24032409
1. Set |job|'s [=job/job promise=] to |promise|.
@@ -2502,6 +2508,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
25022508
<h3 id="start-register-algorithm"><dfn>Start Register</dfn></h3>
25032509

25042510
: Input
2511+
:: |id|, a [=service worker registration/id=] or null
25052512
:: |scopeURL|, a [=/URL=] or failure or null
25062513
:: |scriptURL|, a [=/URL=] or failure
25072514
:: |promise|, a <a>promise</a>
@@ -2530,7 +2537,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
25302537

25312538
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.
25322539
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.
2533-
1. Let |job| be the result of running [=Create Job=] with *register*, |scopeURL|, |scriptURL|, |promise|, and |client|.
2540+
1. If |id| is null, set |id| to |scopeURL|.
2541+
1. Let |job| be the result of running [=Create Job=] with *register*, |id|, |scopeURL|, |scriptURL|, |promise|, and |client|.
25342542
1. Set |job|'s [=job/worker type=] to |workerType|.
25352543
1. Set |job|'s [=job/update via cache mode=] to |updateViaCache|.
25362544
1. Set |job|'s [=job/referrer=] to |referrer|.
@@ -2561,7 +2569,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
25612569
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
25622570
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
25632571
1. Else:
2564-
1. Invoke <a>Set Registration</a> algorithm with |job|'s [=job/scope url=] and |job|'s [=job/update via cache mode=].
2572+
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=].
25652573
1. Invoke <a>Update</a> algorithm passing |job| as the argument.
25662574
</section>
25672575

@@ -2627,7 +2635,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
26272635
1. If |serviceWorkerAllowed| is failure, then:
26282636
1. Asynchronously complete these steps with a <a>network error</a>.
26292637
1. Let |id| be |registration|'s [=service worker registration/id=]
2630-
1. TODO: use newest worker scope? Let |scopeURL| be |registration|'s [=service worker registration/scope url=].
2638+
1. If |newest worker| is not null, then:
2639+
1. Let |scopeURL| be |newest worker|'s [=service worker/scope url=].
2640+
1. Else:
2641+
1. Let |scopeURL| be |job|'s [=job/scope url=].
26312642
1. Let |maxScopeString| be null.
26322643
1. If |serviceWorkerAllowed| is null, then:
26332644
1. Let |resolvedScope| be the result of [=URL parser|parsing=] "`./`" using |job|'s [=job/script url=] as the [=base URL=].
@@ -2720,7 +2731,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
27202731

27212732
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as its argument.
27222733
1. If |newestWorker| is null, abort these steps.
2723-
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.
2734+
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.
27242735
1. Set |job|'s <a>worker type</a> to |newestWorker|'s [=service worker/type=].
27252736
1. Set |job|'s [=force bypass cache flag=] if |forceBypassCache| is true.
27262737
1. Invoke <a>Schedule Job</a> with |job|.
@@ -2743,7 +2754,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
27432754
1. Run the <a>Update Worker State</a> algorithm passing |registration|'s <a>installing worker</a> and "`installing`" as the arguments.
27442755
1. Assert: |job|'s [=job/job promise=] is not null.
27452756
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
2746-
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |registration|'s [=service worker registration/scope url=]'s [=url/origin=].
2757+
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |job|'s [=job/scope url=]'s [=url/origin=].
27472758
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:
27482759
1. Let |registrationObjects| be every {{ServiceWorkerRegistration}} object in |settingsObject|'s [=environment settings object/realm=], whose [=ServiceWorkerRegistration/service worker registration=] is |registration|.
27492760
1. For each |registrationObject| of |registrationObjects|, [=fire an event=] on |registrationObject| named `updatefound`.
@@ -2809,6 +2820,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
28092820

28102821
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.
28112822

2823+
<!-- remove this service worker registration/scope url reference -->
28122824
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=].
28132825
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:
28142826
1. Let |readyPromise| be |client|'s [=environment settings object/global object=]'s {{ServiceWorkerContainer}} object's [=ServiceWorkerContainer/ready promise=].
@@ -3205,6 +3217,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
32053217

32063218
1. Run the following steps atomically.
32073219
1. Let |scopeString| be [=URL serializer|serialized=] |scope| with the *exclude fragment flag* set.
3220+
<!-- get rid of this service worker registration/scope url reference -->
32083221
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|.
32093222
1. [=map/Set=] <a>id to registration map</a>[|id|] to |registration|.
32103223
1. Return |registration|.
@@ -3324,8 +3337,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
33243337
1. Let |matchingScopeString| be the empty string.
33253338
1. Let |scopeMap| be the empty map.
33263339
1. [=map/For each=] |key| → |value| of <a>id to registration map</a>:
3327-
1. If |value|'s [=service worker registration/active worker=/ is null, then [=continue=].
3328-
1. [=map/Set=] |scopeMap|[|value|'s [=service worker registration/scope url] to |value|.
3340+
1. Let |activeWorker| be |value|'s [=service worker registration/active worker=],
3341+
1. If |activeWorker| is null, then [=continue=].
3342+
1. [=map/Set=] |scopeMap|[|active worker|'s [=service worker/scope url] to |value|.
33293343
1. Let |scopeStringSet| be the result of [=map/get the keys|getting the keys=] from |scopeMap|.
33303344
1. Set |matchingScopeString| to the longest value in |scopeStringSet| which the value of |clientURLString| starts with, if it exists.
33313345

0 commit comments

Comments
 (0)