Skip to content

Commit b67c445

Browse files
committed
Rewrite the definition of service worker client and its references
This changes the definition of the service worker client from type of an environment or an environment settings object to just an environment. As an environment settings object *is-a* environment, this rewrites the references to those objects without using the explicit *type of* language. Instead, this changes to use if-else statments that check types from most-specialized to most-general order. Fixes #1045 #1046
1 parent 685b79f commit b67c445

File tree

4 files changed

+229
-197
lines changed

4 files changed

+229
-197
lines changed

docs/index.bs

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
223223
<section dfn-for="service worker client">
224224
<h3 id="service-worker-client-concept">Service Worker Client</h3>
225225

226-
A <dfn export id="dfn-service-worker-client" for="">service worker client</dfn> is a type of <a>environment</a> or <a>environment settings object</a>.
226+
A <dfn export id="dfn-service-worker-client" for="">service worker client</dfn> is an [=environment=].
227227

228-
A [=/service worker client=] has an algorithm defined as the <dfn export for="service worker client">origin</dfn> that returns the [=/service worker client=]'s <a>creation URL</a>'s [=url/origin=] if the [=/service worker client=] is a type of <a>environment</a>, and the [=/service worker client=]'s [=environment settings object/origin=] otherwise.
228+
A [=/service worker client=] has an algorithm defined as the <dfn export for="service worker client">origin</dfn> that returns the [=/service worker client=]'s [=environment settings object/origin=] if the [=/service worker client=] is an [=environment settings object=], and the [=/service worker client=]'s <a>creation URL</a>'s [=url/origin=] otherwise.
229229

230230
A <dfn export id="dfn-window-client">window client</dfn> is a [=/service worker client=] whose [=environment settings object/global object=] is a {{Window}} object.
231231

@@ -998,9 +998,13 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
998998

999999
The <dfn attribute for="Client"><code>type</code></dfn> attribute *must* run these steps:
10001000

1001-
1. If the [=context object=]'s [=Client/service worker client=] is a type of [=environment=] or is a [=window client=], return {{ClientType/"window"}}.
1002-
1. Else if the [=context object=]'s [=Client/service worker client=] is a [=dedicated worker client=], return {{ClientType/"worker"}}.
1003-
1. Else if the [=context object=]'s [=Client/service worker client=] is a [=shared worker client=], return {{ClientType/"sharedworker"}}.
1001+
1. Let |client| be [=context object=]'s [=Client/service worker client=].
1002+
1. If |client| is an [=environment settings object=], then:
1003+
1. If |client| is a [=window client=], return {{ClientType/"window"}}.
1004+
1. Else if |client| is a [=dedicated worker client=], return {{ClientType/"worker"}}.
1005+
1. Else if |client| is a [=shared worker client=], return {{ClientType/"sharedworker"}}.
1006+
1. Else:
1007+
1. Return {{ClientType/"window"}}.
10041008
</section>
10051009

10061010
<section>
@@ -1146,27 +1150,27 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
11461150
1. Run these substeps <a>in parallel</a>:
11471151
1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the <a lt="same origin">same</a> as the associated [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]:
11481152
1. If |client|'s [=environment/id=] is not |id|, continue to the next iteration of the loop.
1149-
1. If |client| is a type of <a>environment</a>, then:
1153+
1. If |client| is an [=environment settings object=], then:
1154+
1. If |client| is not a <a>secure context</a>, reject |promise| with a "{{SecurityError}}" exception and abort these steps.
1155+
1. Else:
11501156
1. If |client|’s <a>creation URL</a> is not a <a>potentially trustworthy URL</a>, reject |promise| with a "{{SecurityError}}" exception and abort these steps.
1157+
1. If |client| is an [=environment settings object=] and is not a [=window client=], then:
1158+
1. Let |clientObject| be the result of running <a>Create Client</a> algorithm with |client| as the argument.
1159+
1. Resolve |promise| with |clientObject| and abort these steps.
11511160
1. Else:
1152-
1. If |client| is not a <a>secure context</a>, reject |promise| with a "{{SecurityError}}" exception and abort these steps.
1153-
1. If |client| is a type of <a>environment</a> or is a <a>window client</a>, then:
11541161
1. Let |browsingContext| be null.
11551162
1. Let |visibilityState| be null.
11561163
1. Let |focusState| be false.
11571164
1. Let |ancestorOriginsList| be the empty list.
1158-
1. If |client| is a type of <a>environment</a>, set |browsingContext| to |client|s [=environment/target browsing context=].
1159-
1. Else, set |browsingContext| to |client|'s [=environment settings object/global object=]'s [=/browsing context=].
1165+
1. If |client| is an [=environment settings object=], set |browsingContext| to |client|'s [=environment settings object/global object=]'s [=/browsing context=].
1166+
1. Else, set |browsingContext| to |client|s [=environment/target browsing context=].
11601167
1. <a>Queue a task</a> |task| to run the following substeps on |browsingContext|'s <a>event loop</a> using the <a>user interaction task source</a>:
11611168
1. Set |visibilityState| to |browsingContext|'s <a>active document</a>'s {{Document/visibilityState}} attribute value.
11621169
1. Set |focusState| to the result of running the <a>has focus steps</a> with |browsingContext|'s <a>active document</a> as the argument.
11631170
1. If |client| is a <a>window client</a>, set |ancestorOriginsList| to |browsingContext|'s <a>active document</a>'s <a>relevant global object</a>'s {{Location}} object's [=Location/ancestor origins list=]'s associated list.
11641171
1. Wait for |task| to have executed.
11651172
1. Let |windowClient| be the result of running <a>Create Window Client</a> algorithm with |client|, |visibilityState|, |focusState|, and |ancestorOriginsList| as the arguments.
11661173
1. Resolve |promise| with |windowClient| and abort these steps.
1167-
1. Else:
1168-
1. Let |clientObject| be the result of running <a>Create Client</a> algorithm with |client| as the argument.
1169-
1. Resolve |promise| with |clientObject| and abort these steps.
11701174
1. Resolve |promise| with undefined.
11711175
1. Return |promise|.
11721176
</section>
@@ -1180,25 +1184,25 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
11801184
1. Run these substeps <a>in parallel</a>:
11811185
1. Let |targetClients| be an empty array.
11821186
1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the <a lt="same origin">same</a> as the associated [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]:
1183-
1. If |client| is a type of <a>environment</a>, then:
1184-
1. If |client|’s <a>creation URL</a> is not a <a>potentially trustworthy URL</a>, continue to the next iteration of the loop.
1185-
1. Else:
1187+
1. If |client| is an [=environment settings object=], then:
11861188
1. If |client| is not a <a>secure context</a>, continue to the next iteration of the loop.
1189+
1. Else:
1190+
1. If |client|’s <a>creation URL</a> is not a <a>potentially trustworthy URL</a>, continue to the next iteration of the loop.
11871191
1. If |options|.{{ClientQueryOptions/includeUncontrolled}} is false, then:
11881192
1. If |client|'s <a>active service worker</a> is not the associated [=ServiceWorkerGlobalScope/service worker=], continue to the next iteration of the loop.
11891193
1. If |options|.{{ClientQueryOptions/includeReserved}} is false, then:
11901194
1. If |client|'s [=environment/execution ready flag=] is unset, continue to the next iteration of the loop.
11911195
1. Add |client| to |targetClients|.
11921196
1. Let |matchedClients| be an empty array.
11931197
1. For each [=/service worker client=] |client| in |targetClients|:
1194-
1. If |options|.{{ClientQueryOptions/type}} is {{ClientType/"window"}} or {{ClientType/"all"}}, and |client| is a type of <a>environment</a> or is a <a>window client</a>, then:
1198+
1. If |options|.{{ClientQueryOptions/type}} is {{ClientType/"window"}} or {{ClientType/"all"}}, and |client| is not an [=environment settings object=] or is a [=window client=], then:
11951199
1. Let |browsingContext| be null.
11961200
1. Let |isClientEnumerable| be true.
11971201
1. Let |visibilityState| be the empty string.
11981202
1. Let |focusState| be false.
11991203
1. Let |ancestorOriginsList| be the empty list.
1200-
1. If |client| is a type of <a>environment</a>, set |browsingContext| to |client|s [=environment/target browsing context=].
1201-
1. Else, set |browsingContext| to |client|'s [=environment settings object/global object=]'s [=/browsing context=].
1204+
1. If |client| is an [=environment settings object=], set |browsingContext| to |client|'s [=environment settings object/global object=]'s [=/browsing context=].
1205+
1. Else, set |browsingContext| to |client|s [=environment/target browsing context=].
12021206
1. <a>Queue a task</a> |task| to run the following substeps on |browsingContext|'s <a>event loop</a> using the <a>user interaction task source</a>:
12031207
1. If |browsingContext| has been <a lt="a browsing context is discarded">discarded</a>, set |isClientEnumerable| to false and abort these steps.
12041208
1. If |client| is a window client and |client|'s <a>responsible document</a> is not |browsingContext|'s <a>active document</a>, set |isClientEnumerable| to false and abort these steps.
@@ -1212,7 +1216,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
12121216
1. If |isClientEnumerable| is true, then:
12131217
1. Let |windowClient| be the result of running <a>Create Window Client</a> algorithm with |client|, |visibilityState|, |focusState|, and |ancestorOriginsList| as the arguments.
12141218
1. Add |windowClient| to |matchedClients|.
1215-
1. Else if |options|.{{ClientQueryOptions/type}} is {{ClientType/"worker"}} or {{ClientType/"all"}} and |client| is a <a>dedicated worker client</a>, or |options|.{{ClientQueryOptions/type}} is {{ClientType/"sharedworker"}} or {{ClientType/"all"}} and |client| is a <a>shared worker client</a>, then:
1219+
1. Else if |options|.{{ClientQueryOptions/type}} is {{ClientType/"worker"}} or {{ClientType/"all"}} and |client| is a [=dedicated worker client=], or |options|.{{ClientQueryOptions/type}} is {{ClientType/"sharedworker"}} or {{ClientType/"all"}} and |client| is a [=shared worker client=], then:
12161220
1. Let |clientObject| be the result of running <a>Create Client</a> algorithm with |client| as the argument.
12171221
1. Add |clientObject| to |matchedClients|.
12181222
1. Sort |matchedClients| such that:
@@ -1263,10 +1267,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
12631267
1. Let |promise| be a new <a>promise</a>.
12641268
1. Run the following substeps <a>in parallel</a>:
12651269
1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the <a lt="same origin">same</a> as the [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]:
1266-
1. If |client| is a type of <a>environment</a>, then:
1267-
1. If |client|’s <a>creation URL</a> is not a <a>potentially trustworthy URL</a>, continue to the next iteration of the loop.
1268-
1. Else:
1270+
1. If |client| is an [=environment settings object=], then:
12691271
1. If |client| is not a <a>secure context</a>, continue to the next iteration of the loop.
1272+
1. Else:
1273+
1. If |client|’s <a>creation URL</a> is not a <a>potentially trustworthy URL</a>, continue to the next iteration of the loop.
12701274
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.
12711275
1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s <a>containing service worker registration</a>, continue to the next iteration of the loop.
12721276
1. If |client|'s <a>active service worker</a> is not the [=ServiceWorkerGlobalScope/service worker=], then:
@@ -3126,7 +3130,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
31263130
1. [=map/For each=] <var ignore>scope</var> → |registration| of <a>scope to registration map</a>:
31273131
1. If |registration|'s <a>installing worker</a> |installingWorker| is not null, then:
31283132
1. If |registration|'s [=waiting worker=] is null and |registration|'s [=active worker=] is null, invoke <a>Clear Registration</a> with |registration| and continue to the next iteration of the loop.
3129-
1. Else, set |registration|'s <a>installing worker</a> to null.
3133+
1. Else, set |installingWorker| to null.
31303134
1. If |registration|'s <a>waiting worker</a> is not null, run the following substep <a>in parallel</a>:
31313135
1. Invoke <a>Activate</a> with |registration|.
31323136
</section>
@@ -3305,7 +3309,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
33053309
:: None
33063310

33073311
1. Assert: |client| is not null.
3308-
1. If |client| is a type of <a>environment settings object</a>, <a>queue a task</a> to <a>fire an event</a> named <code>controllerchange</code> at the {{ServiceWorkerContainer}} object |client| is [=ServiceWorkerContainer/service worker client|associated=] with.
3312+
1. If |client| is an [=environment settings object=], <a>queue a task</a> to [=fire an event=] named <code>controllerchange</code> at the {{ServiceWorkerContainer}} object that |client| is [=ServiceWorkerContainer/service worker client|associated=] with.
33093313

33103314
The <a>task</a> *must* use |client|'s <a>responsible event loop</a> and the <a>DOM manipulation task source</a>.
33113315
</section>

0 commit comments

Comments
 (0)