Skip to content

Commit 07e9487

Browse files
authored
Clean up Client API to not expose reserved clients (#1259)
To reflect the decision to not expose reserved clients (#1216) and to spec .resultingClientId and .targetClientId in Nightly only, this: * Removes - Client.reserved and its associated reserved state (V1, Nightly) - ClientQueryOptions.includeReserved (V1, Nightly) - FetchEvent.reservedClientId (V1) - FetchEvent.targetClientId (V1) - FetchEventInit.reservedClientId (V1) - FetchEventInit.targetClientId (V1) * Changes - FetchEvent.reservedClientId to FetchEvent.resultingClientId (Nightly) - FetchEventInit.reservedClientId to FetchEventInit.resultingClientId (Nightly) - Handle Fetch to set FetchEvent.clientId for a navigation request to the empty string (V1) * Corrects - matchedClients with clientObjects in Clients.matchAll() (V1, Nightly) Related issue: #1245. This also cleans up sort condition steps in Clients.matchAll() that fixes #1080 (V1, Nightly) (Changes for the Clients interface's methods will be addressed as separate PRs.)
1 parent 8db81d8 commit 07e9487

File tree

2 files changed

+28
-56
lines changed

2 files changed

+28
-56
lines changed

docs/index.bs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ spec: fetch;
3737
text: ReadableStream
3838
spec: infra;
3939
type: dfn;
40+
text: list;
4041
for: set; text: append
4142
for: list; text: append
4243
</pre>
@@ -972,7 +973,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
972973
readonly attribute USVString url;
973974
readonly attribute DOMString id;
974975
readonly attribute ClientType type;
975-
readonly attribute boolean reserved;
976976
void postMessage(any message, optional sequence&lt;object&gt; transfer = []);
977977
};
978978

@@ -988,7 +988,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
988988

989989
A {{Client}} object has an associated <dfn for="Client">service worker client</dfn> (a [=/service worker client=]).
990990

991-
A {{Client}} object has an associated <dfn for="Client">reserved state</dfn>, which is either true or false.
991+
A {{WindowClient}} object has an associated <dfn id="dfn-service-worker-client-browsing-context" for="WindowClient">browsing context</dfn>, which is its [=Client/service worker client=]'s [=environment settings object/global object=]'s [=/browsing context=].
992992

993993
A {{WindowClient}} object has an associated <dfn id="dfn-service-worker-client-visibilitystate">visibility state</dfn>, which is one of {{Document/visibilityState}} attribute value.
994994

@@ -1022,12 +1022,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
10221022
1. Return {{ClientType/"window"}}.
10231023
</section>
10241024

1025-
<section>
1026-
<h4 id="client-reserved">{{Client/reserved}}</h4>
1027-
1028-
The <dfn attribute for="Client"><code>reserved</code></dfn> attribute *must* return the <a>context object</a>'s associated [=Client/reserved state=].
1029-
</section>
1030-
10311025
<section algorithm="client-postmessage">
10321026
<h4 id="client-postmessage">{{Client/postMessage(message, transfer)}}</h4>
10331027

@@ -1140,7 +1134,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
11401134
<pre class="idl" id="serviceworker-client-query-options-dictionary">
11411135
dictionary ClientQueryOptions {
11421136
boolean includeUncontrolled = false;
1143-
boolean includeReserved = false;
11441137
ClientType type = "window";
11451138
};
11461139
</pre>
@@ -1203,7 +1196,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
12031196
1. Else:
12041197
1. If |client|’s [=creation URL=] is not a [=potentially trustworthy URL=], [=continue=].
12051198
1. If |options|["{{ClientQueryOptions/includeUncontrolled}}"] is false, and if |client|'s [=active service worker=] is not the associated [=ServiceWorkerGlobalScope/service worker=], [=continue=].
1206-
1. If |options|["{{ClientQueryOptions/includeReserved}}"] is false, and if |client|'s [=environment/execution ready flag=] is unset, [=continue=].
1199+
1. If |client|'s [=environment/execution ready flag=] is unset, [=continue=].
12071200
1. Add |client| to |targetClients|.
12081201
1. Let |matchedWindowData| be a new [=list=].
12091202
1. Let |matchedClients| be a new [=list=].
@@ -1236,10 +1229,13 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
12361229
1. [=list/For each=] |client| in |matchedClients|:
12371230
1. Let |clientObject| be the result of running [=Create Client=] algorithm with |client| as the argument.
12381231
1. [=Append=] |clientObject| to |clientObjects|.
1239-
1. Sort |matchedClients| such that:
1240-
* {{WindowClient}} objects are always placed before {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=].
1241-
* {{WindowClient}} objects that have been [=focusing steps|focused=] are placed first sorted in the most recently [=focusing steps|focused=] order, and {{WindowClient}} objects that have never been [=focusing steps|focused=] are placed next sorted in their [=Client/service worker clients=]' creation order.
1242-
* {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=] are placed next sorted in their [=Client/service worker clients=]' creation order.
1232+
1. Sort |clientObjects| such that:
1233+
* {{WindowClient}} objects whose [=WindowClient/browsing context=] has been [=focusing steps|focused=] are placed first, sorted in the most recently [=focusing steps|focused=] order.
1234+
* {{WindowClient}} objects whose [=WindowClient/browsing context=] has never been [=focusing steps|focused=] are placed next, sorted in their [=Client/service worker client=]'s creation order.
1235+
* {{Client}} objects whose associated [=Client/service worker client=] is a [=worker client=] are placed next, sorted in their [=Client/service worker client=]'s creation order.
1236+
1237+
Note: [=Window clients=] are always placed before [=worker clients=].
1238+
12431239
1. [=Resolve=] |promise| with [=create a frozen array|a new frozen array of=] |clientObjects| in |promise|'s [=relevant Realm=].
12441240
1. Return |promise|.
12451241
</section>
@@ -1363,7 +1359,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
13631359
[SameObject] readonly attribute Request request;
13641360
readonly attribute Promise&lt;any&gt; preloadResponse;
13651361
readonly attribute DOMString clientId;
1366-
readonly attribute DOMString reservedClientId;
1362+
readonly attribute DOMString resultingClientId;
13671363
readonly attribute DOMString targetClientId;
13681364

13691365
void respondWith(Promise&lt;Response&gt; r);
@@ -1374,7 +1370,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
13741370
required Request request;
13751371
required Promise&lt;any&gt; preloadResponse;
13761372
DOMString clientId = "";
1377-
DOMString reservedClientId = "";
1373+
DOMString resultingClientId = "";
13781374
DOMString targetClientId = "";
13791375
};
13801376
</pre>
@@ -1406,9 +1402,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
14061402
</section>
14071403

14081404
<section>
1409-
<h4 id="fetch-event-reservedclientid">{{FetchEvent/reservedClientId|event.reservedClientId}}</h4>
1405+
<h4 id="fetch-event-resultingclientid">{{FetchEvent/resultingClientId|event.resultingClientId}}</h4>
14101406

1411-
<dfn attribute for="FetchEvent"><code>reservedClientId</code></dfn> attribute *must* return the value it was initialized to. When an <a>event</a> is created the attribute *must* be initialized to the empty string.
1407+
<dfn attribute for="FetchEvent"><code>resultingClientId</code></dfn> attribute *must* return the value it was initialized to. When an <a>event</a> is created the attribute *must* be initialized to the empty string.
14121408
</section>
14131409

14141410
<section>
@@ -2741,7 +2737,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
27412737
1. Initialize |e|’s {{FetchEvent/request}} attribute to |requestObject|.
27422738
1. Initialize |e|’s {{FetchEvent/preloadResponse}} to |preloadResponse|.
27432739
1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=].
2744-
1. If |request| is a <a>non-subresource request</a> and |request|'s [=request/destination=] is not {{RequestDestination/"report"}}, initialize |e|'s {{FetchEvent/reservedClientId}} attribute to |reservedClient|'s [=environment/id=], and to the empty string otherwise.
2740+
1. If |request| is a <a>non-subresource request</a> and |request|'s [=request/destination=] is not {{RequestDestination/"report"}}, initialize |e|'s {{FetchEvent/resultingClientId}} attribute to |reservedClient|'s [=environment/id=], and to the empty string otherwise.
27452741
1. If |request| is a <a>navigation request</a>, initialize |e|'s {{FetchEvent/targetClientId}} attribute to |request|'s [=request/target client id=], and to the empty string otherwise.
27462742
1. <a>Dispatch</a> |e| at |activeWorker|'s [=service worker/global object=].
27472743
1. Invoke [=Update Service Worker Extended Events Set=] with |activeWorker| and |e|.
@@ -3099,7 +3095,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
30993095

31003096
1. Let |clientObject| be a new {{Client}} object.
31013097
1. Set |clientObject|'s [=Client/service worker client=] to |client|.
3102-
1. Set |clientObject|'s [=Client/reserved state=] to true if |client|'s [=environment/execution ready flag=] is unset, and false otherwise.
31033098
1. Return |clientObject|.
31043099
</section>
31053100

docs/v1/index.bs

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ spec: fetch;
3939
text: ReadableStream
4040
spec: infra;
4141
type: dfn;
42+
text: list;
4243
for: set; text: append
4344
for: list; text: append
4445
</pre>
@@ -910,7 +911,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
910911
readonly attribute USVString url;
911912
readonly attribute DOMString id;
912913
readonly attribute ClientType type;
913-
readonly attribute boolean reserved;
914914
void postMessage(any message, optional sequence&lt;object&gt; transfer = []);
915915
};
916916

@@ -926,7 +926,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
926926

927927
A {{Client}} object has an associated <dfn for="Client">service worker client</dfn> (a [=/service worker client=]).
928928

929-
A {{Client}} object has an associated <dfn for="Client">reserved state</dfn>, which is either true or false.
929+
A {{WindowClient}} object has an associated <dfn id="dfn-service-worker-client-browsing-context" for="WindowClient">browsing context</dfn>, which is its [=Client/service worker client=]'s [=environment settings object/global object=]'s [=/browsing context=].
930930

931931
A {{WindowClient}} object has an associated <dfn id="dfn-service-worker-client-visibilitystate">visibility state</dfn>, which is one of {{Document/visibilityState}} attribute value.
932932

@@ -960,12 +960,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
960960
1. Return {{ClientType/"window"}}.
961961
</section>
962962

963-
<section>
964-
<h4 id="client-reserved">{{Client/reserved}}</h4>
965-
966-
The <dfn attribute for="Client"><code>reserved</code></dfn> attribute *must* return the <a>context object</a>'s associated [=Client/reserved state=].
967-
</section>
968-
969963
<section algorithm="client-postmessage">
970964
<h4 id="client-postmessage">{{Client/postMessage(message, transfer)}}</h4>
971965

@@ -1078,7 +1072,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
10781072
<pre class="idl" id="serviceworker-client-query-options-dictionary">
10791073
dictionary ClientQueryOptions {
10801074
boolean includeUncontrolled = false;
1081-
boolean includeReserved = false;
10821075
ClientType type = "window";
10831076
};
10841077
</pre>
@@ -1127,8 +1120,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
11271120
1. Return |promise|.
11281121
</section>
11291122

1130-
<section algorithm="clients-getall">
1131-
<h4 id="clients-getall">{{Clients/matchAll(options)}}</h4>
1123+
<section algorithm="clients-matchall">
1124+
<h4 id="clients-matchall">{{Clients/matchAll(options)}}</h4>
11321125

11331126
The <dfn method for="Clients"><code>matchAll(|options|)</code></dfn> method *must* run these steps:
11341127

@@ -1141,7 +1134,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
11411134
1. Else:
11421135
1. If |client|’s [=creation URL=] is not a [=potentially trustworthy URL=], [=continue=].
11431136
1. If |options|["{{ClientQueryOptions/includeUncontrolled}}"] is false, and if |client|'s [=active service worker=] is not the associated [=ServiceWorkerGlobalScope/service worker=], [=continue=].
1144-
1. If |options|["{{ClientQueryOptions/includeReserved}}"] is false, and if |client|'s [=environment/execution ready flag=] is unset, [=continue=].
1137+
1. If |client|'s [=environment/execution ready flag=] is unset, [=continue=].
11451138
1. Add |client| to |targetClients|.
11461139
1. Let |matchedWindowData| be a new [=list=].
11471140
1. Let |matchedClients| be a new [=list=].
@@ -1174,10 +1167,13 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
11741167
1. [=list/For each=] |client| in |matchedClients|:
11751168
1. Let |clientObject| be the result of running [=Create Client=] algorithm with |client| as the argument.
11761169
1. [=Append=] |clientObject| to |clientObjects|.
1177-
1. Sort |matchedClients| such that:
1178-
* {{WindowClient}} objects are always placed before {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=].
1179-
* {{WindowClient}} objects that have been [=focusing steps|focused=] are placed first sorted in the most recently [=focusing steps|focused=] order, and {{WindowClient}} objects that have never been [=focusing steps|focused=] are placed next sorted in their [=Client/service worker clients=]' creation order.
1180-
* {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=] are placed next sorted in their [=Client/service worker clients=]' creation order.
1170+
1. Sort |clientObjects| such that:
1171+
* {{WindowClient}} objects whose [=WindowClient/browsing context=] has been [=focusing steps|focused=] are placed first, sorted in the most recently [=focusing steps|focused=] order.
1172+
* {{WindowClient}} objects whose [=WindowClient/browsing context=] has never been [=focusing steps|focused=] are placed next, sorted in their [=Client/service worker client=]'s creation order.
1173+
* {{Client}} objects whose associated [=Client/service worker client=] is a [=worker client=] are placed next, sorted in their [=Client/service worker client=]'s creation order.
1174+
1175+
Note: [=Window clients=] are always placed before [=worker clients=].
1176+
11811177
1. [=Resolve=] |promise| with [=create a frozen array|a new frozen array of=] |clientObjects| in |promise|'s [=relevant Realm=].
11821178
1. Return |promise|.
11831179
</section>
@@ -1300,8 +1296,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
13001296
interface FetchEvent : ExtendableEvent {
13011297
[SameObject] readonly attribute Request request;
13021298
readonly attribute DOMString clientId;
1303-
readonly attribute DOMString reservedClientId;
1304-
readonly attribute DOMString targetClientId;
13051299

13061300
void respondWith(Promise&lt;Response&gt; r);
13071301
};
@@ -1310,8 +1304,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
13101304
dictionary FetchEventInit : ExtendableEventInit {
13111305
required Request request;
13121306
DOMString clientId = "";
1313-
DOMString reservedClientId = "";
1314-
DOMString targetClientId = "";
13151307
};
13161308
</pre>
13171309

@@ -1335,18 +1327,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
13351327
<dfn attribute for="FetchEvent"><code>clientId</code></dfn> attribute *must* return the value it was initialized to. When an <a>event</a> is created the attribute *must* be initialized to the empty string.
13361328
</section>
13371329

1338-
<section>
1339-
<h4 id="fetch-event-reservedclientid">{{FetchEvent/reservedClientId|event.reservedClientId}}</h4>
1340-
1341-
<dfn attribute for="FetchEvent"><code>reservedClientId</code></dfn> attribute *must* return the value it was initialized to. When an <a>event</a> is created the attribute *must* be initialized to the empty string.
1342-
</section>
1343-
1344-
<section>
1345-
<h4 id="fetch-event-targetclientid">{{FetchEvent/targetClientId|event.targetClientId}}</h4>
1346-
1347-
<dfn attribute for="FetchEvent"><code>targetClientId</code></dfn> attribute *must* return the value it was initialized to. When an <a>event</a> is created the attribute *must* be initialized to the empty string.
1348-
</section>
1349-
13501330
<section algorithm="fetch-event-respondwith">
13511331
<h4 id="fetch-event-respondwith">{{FetchEvent/respondWith(r)|event.respondWith(r)}}</h4>
13521332

@@ -2606,9 +2586,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
26062586
1. Initialize |e|’s {{Event/type}} attribute to {{fetch!!event}}.
26072587
1. Initialize |e|’s {{Event/cancelable}} attribute to true.
26082588
1. Initialize |e|’s {{FetchEvent/request}} attribute to a new {{Request}} object associated with |request| and a new associated {{Headers}} object whose [=guard=] is "`immutable`".
2609-
1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=].
2610-
1. If |request| is a <a>non-subresource request</a> and |request|'s [=request/destination=] is not {{RequestDestination/"report"}}, initialize |e|'s {{FetchEvent/reservedClientId}} attribute to |reservedClient|'s [=environment/id=], and to the empty string otherwise.
2611-
1. If |request| is a <a>navigation request</a>, initialize |e|'s {{FetchEvent/targetClientId}} attribute to |request|'s [=request/target client id=], and to the empty string otherwise.
2589+
1. If |request| is a <a>non-subresource request</a> and |request|'s [=request/destination=] is not {{RequestDestination/"report"}}, initialize |e|'s {{FetchEvent/clientId}} attribute to the empty string, and to |client|'s [=environment/id=] otherwise.
26122590
1. <a>Dispatch</a> |e| at |activeWorker|'s [=service worker/global object=].
26132591
1. Invoke [=Update Service Worker Extended Events Set=] with |activeWorker| and |e|.
26142592
1. If |e|'s [=FetchEvent/respond-with entered flag=] is set, set |respondWithEntered| to true.
@@ -2964,7 +2942,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
29642942

29652943
1. Let |clientObject| be a new {{Client}} object.
29662944
1. Set |clientObject|'s [=Client/service worker client=] to |client|.
2967-
1. Set |clientObject|'s [=Client/reserved state=] to true if |client|'s [=environment/execution ready flag=] is unset, and false otherwise.
29682945
1. Return |clientObject|.
29692946
</section>
29702947

0 commit comments

Comments
 (0)