Skip to content

Commit 3428c08

Browse files
committed
fail Register when there is a conflicting registration with the same scope
1 parent ffab8b1 commit 3428c08

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

docs/index.bs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
123123
</pre>
124124

125125
<!-- TODO: uncontrol old clients that no longer match in Activate -->
126-
<!-- TODO: look for conflicting scopes -->
127126

128127
<section>
129128
<h2 id="motivations">Motivations</h2>
@@ -2616,6 +2615,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
26162615
1. If |newestWorker| is not null, |job|'s [=job/scope url=] [=url/equals=] |newestWorker|'s [=service worker/scope url=], |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=], |job|'s [=job/worker type=] equals |newestWorker|'s [=service worker/type=], and |job|'s [=job/update via cache mode=]'s value equals |registration|'s [=service worker registration/update via cache mode=], then:
26172616
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
26182617
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
2618+
1. Let |scopeRegistration| be the result of running the <a>Get Registration By Scope</a> algorithm passing |job|'s [=job/scope url=] as the argument.
2619+
1. If |scopeRegistration| is not null, |scopeRegistration| is not |registration|, and |scopeRegistration|'s <a>active worker</a>'s [=service worker/scope url=] [=url/equals=] |job|'s [=job/scope url=], then:
2620+
1. Invoke [=Reject Job Promise=] with |job| and "{{InvalidStateError}}" {{DOMException}}.
2621+
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
26192622
1. Else:
26202623
1. Invoke <a>Set Registration</a> algorithm with |job|'s [=job/origin=], |job|'s [=job/id=], and |job|'s [=job/update via cache mode=].
26212624
1. Invoke <a>Update</a> algorithm passing |job| as the argument.
@@ -3404,12 +3407,30 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
34043407
:: |origin|, a [=environment settings object/origin=]
34053408
:: |id|, a [=service worker registration/id=]
34063409
: Output
3407-
:: A [=/service worker registration=]
3410+
:: A [=/service worker registration=] or null.
34083411

34093412
1. Run the following steps atomically.
34103413
1. [=map/Get=] (|origin|,|id|) from [=registration map=] and return the result.
34113414
</section>
34123415

3416+
<section algorithm>
3417+
<h3 id="get-registration-by-scope-algorithm"><dfn>Get Registration By Scope</dfn></h3>
3418+
3419+
: Input
3420+
:: |scope|, a [=URL=]
3421+
: Output
3422+
:: A [=/service worker registration=] or null.
3423+
3424+
1. Run the following steps atomically.
3425+
1. [=map/For each=] |key| → |value| of <a>registration map</a>:
3426+
1. If |value|'s <a>active worker</a>'s [=service worker/scope url=] [=url/equals=] |scope|, then return |value|.
3427+
1. If |value|'s <a>waiting worker</a>'s [=service worker/scope url=] [=url/equals=] |scope|, then return |value|.
3428+
1. If |value|'s <a>installing worker</a>'s [=service worker/scope url=] [=url/equals=] |scope|, then return |value|.
3429+
1. Return null.
3430+
3431+
Note: Only one registration should be associated with a given scope at a time since we fail <a>Register</a> when there is a conflicting registration with the same scope.
3432+
</section>
3433+
34133434
<section algorithm>
34143435
<h3 id="get-newest-worker-algorithm"><dfn>Get Newest Worker</dfn></h3>
34153436

0 commit comments

Comments
 (0)