You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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=].
227
227
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.
229
229
230
230
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.
The <dfn attribute for="Client"><code>type</code></dfn> attribute *must* run these steps:
1000
1000
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"}}.
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=]:
1148
1152
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:
1150
1156
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.
1151
1160
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:
1154
1161
1. Let |browsingContext| be null.
1155
1162
1. Let |visibilityState| be null.
1156
1163
1. Let |focusState| be false.
1157
1164
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=].
1160
1167
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>:
1161
1168
1. Set |visibilityState| to |browsingContext|'s <a>active document</a>'s {{Document/visibilityState}} attribute value.
1162
1169
1. Set |focusState| to the result of running the <a>has focus steps</a> with |browsingContext|'s <a>active document</a> as the argument.
1163
1170
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.
1164
1171
1. Wait for |task| to have executed.
1165
1172
1. Let |windowClient| be the result of running <a>Create Window Client</a> algorithm with |client|, |visibilityState|, |focusState|, and |ancestorOriginsList| as the arguments.
1166
1173
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.
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:
1186
1188
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.
1187
1191
1. If |options|.{{ClientQueryOptions/includeUncontrolled}} is false, then:
1188
1192
1. If |client|'s <a>active service worker</a> is not the associated [=ServiceWorkerGlobalScope/service worker=], continue to the next iteration of the loop.
1189
1193
1. If |options|.{{ClientQueryOptions/includeReserved}} is false, then:
1190
1194
1. If |client|'s [=environment/execution ready flag=] is unset, continue to the next iteration of the loop.
1191
1195
1. Add |client| to |targetClients|.
1192
1196
1. Let |matchedClients| be an empty array.
1193
1197
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:
1195
1199
1. Let |browsingContext| be null.
1196
1200
1. Let |isClientEnumerable| be true.
1197
1201
1. Let |visibilityState| be the empty string.
1198
1202
1. Let |focusState| be false.
1199
1203
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=].
1202
1206
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>:
1203
1207
1. If |browsingContext| has been <a lt="a browsing context is discarded">discarded</a>, set |isClientEnumerable| to false and abort these steps.
1204
1208
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.
1. Let |windowClient| be the result of running <a>Create Window Client</a> algorithm with |client|, |visibilityState|, |focusState|, and |ancestorOriginsList| as the arguments.
1214
1218
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:
1216
1220
1. Let |clientObject| be the result of running <a>Create Client</a> algorithm with |client| as the argument.
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:
1269
1271
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.
1270
1274
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.
1271
1275
1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s <a>containing service worker registration</a>, continue to the next iteration of the loop.
1272
1276
1. If |client|'s <a>active service worker</a> is not the [=ServiceWorkerGlobalScope/service worker=], then:
1. [=map/For each=]<var ignore>scope</var> → |registration| of <a>scope to registration map</a>:
3127
3131
1. If |registration|'s <a>installing worker</a> |installingWorker| is not null, then:
3128
3132
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.
3130
3134
1. If |registration|'s <a>waiting worker</a> is not null, run the following substep <a>in parallel</a>:
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.
3309
3313
3310
3314
The <a>task</a> *must* use |client|'s <a>responsible event loop</a> and the <a>DOM manipulation task source</a>.
0 commit comments