From 5ab28e827081814e8febbdf731263ba2289afa05 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Fri, 12 Jan 2018 15:20:09 +0900 Subject: [PATCH] Clean up Client API to not expose reserved clients To reflect the decision to not expose reserved clients (https://github.com/w3c/ServiceWorker/issues/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: https://github.com/w3c/ServiceWorker/issues/1245. This also cleans up sort condition steps in Clients.matchAll() that fixes https://github.com/w3c/ServiceWorker/issues/1080 (V1, Nightly) (Changes for the Clients interface's methods will be addressed as separate PRs.) --- docs/index.bs | 35 +++++++++++++++------------------- docs/v1/index.bs | 49 +++++++++++++----------------------------------- 2 files changed, 28 insertions(+), 56 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index b5a31625..26acd272 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -37,6 +37,7 @@ spec: fetch; text: ReadableStream spec: infra; type: dfn; + text: list; for: set; text: append for: list; text: append @@ -972,7 +973,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe readonly attribute USVString url; readonly attribute DOMString id; readonly attribute ClientType type; - readonly attribute boolean reserved; void postMessage(any message, optional sequence<object> transfer = []); }; @@ -988,7 +988,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A {{Client}} object has an associated service worker client (a [=/service worker client=]). - A {{Client}} object has an associated reserved state, which is either true or false. + A {{WindowClient}} object has an associated browsing context, which is its [=Client/service worker client=]'s [=environment settings object/global object=]'s [=/browsing context=]. A {{WindowClient}} object has an associated visibility state, which is one of {{Document/visibilityState}} attribute value. @@ -1022,12 +1022,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Return {{ClientType/"window"}}. -
-

{{Client/reserved}}

- - The reserved attribute *must* return the context object's associated [=Client/reserved state=]. -
-

{{Client/postMessage(message, transfer)}}

@@ -1140,7 +1134,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
       dictionary ClientQueryOptions {
         boolean includeUncontrolled = false;
-        boolean includeReserved = false;
         ClientType type = "window";
       };
     
@@ -1203,7 +1196,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Else: 1. If |client|’s [=creation URL=] is not a [=potentially trustworthy URL=], [=continue=]. 1. If |options|["{{ClientQueryOptions/includeUncontrolled}}"] is false, and if |client|'s [=active service worker=] is not the associated [=ServiceWorkerGlobalScope/service worker=], [=continue=]. - 1. If |options|["{{ClientQueryOptions/includeReserved}}"] is false, and if |client|'s [=environment/execution ready flag=] is unset, [=continue=]. + 1. If |client|'s [=environment/execution ready flag=] is unset, [=continue=]. 1. Add |client| to |targetClients|. 1. Let |matchedWindowData| be a new [=list=]. 1. Let |matchedClients| be a new [=list=]. @@ -1236,10 +1229,13 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. [=list/For each=] |client| in |matchedClients|: 1. Let |clientObject| be the result of running [=Create Client=] algorithm with |client| as the argument. 1. [=Append=] |clientObject| to |clientObjects|. - 1. Sort |matchedClients| such that: - * {{WindowClient}} objects are always placed before {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=]. - * {{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. - * {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=] are placed next sorted in their [=Client/service worker clients=]' creation order. + 1. Sort |clientObjects| such that: + * {{WindowClient}} objects whose [=WindowClient/browsing context=] has been [=focusing steps|focused=] are placed first, sorted in the most recently [=focusing steps|focused=] order. + * {{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. + * {{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. + + Note: [=Window clients=] are always placed before [=worker clients=]. + 1. [=Resolve=] |promise| with [=create a frozen array|a new frozen array of=] |clientObjects| in |promise|'s [=relevant Realm=]. 1. Return |promise|.
@@ -1363,7 +1359,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe [SameObject] readonly attribute Request request; readonly attribute Promise<any> preloadResponse; readonly attribute DOMString clientId; - readonly attribute DOMString reservedClientId; + readonly attribute DOMString resultingClientId; readonly attribute DOMString targetClientId; void respondWith(Promise<Response> r); @@ -1374,7 +1370,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe required Request request; required Promise<any> preloadResponse; DOMString clientId = ""; - DOMString reservedClientId = ""; + DOMString resultingClientId = ""; DOMString targetClientId = ""; }; @@ -1406,9 +1402,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
-

{{FetchEvent/reservedClientId|event.reservedClientId}}

+

{{FetchEvent/resultingClientId|event.resultingClientId}}

- reservedClientId attribute *must* return the value it was initialized to. When an event is created the attribute *must* be initialized to the empty string. + resultingClientId attribute *must* return the value it was initialized to. When an event is created the attribute *must* be initialized to the empty string.
@@ -2741,7 +2737,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Initialize |e|’s {{FetchEvent/request}} attribute to |requestObject|. 1. Initialize |e|’s {{FetchEvent/preloadResponse}} to |preloadResponse|. 1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=]. - 1. If |request| is a non-subresource request 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. + 1. If |request| is a non-subresource request 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. 1. If |request| is a navigation request, initialize |e|'s {{FetchEvent/targetClientId}} attribute to |request|'s [=request/target client id=], and to the empty string otherwise. 1. Dispatch |e| at |activeWorker|'s [=service worker/global object=]. 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 1. Let |clientObject| be a new {{Client}} object. 1. Set |clientObject|'s [=Client/service worker client=] to |client|. - 1. Set |clientObject|'s [=Client/reserved state=] to true if |client|'s [=environment/execution ready flag=] is unset, and false otherwise. 1. Return |clientObject|.
diff --git a/docs/v1/index.bs b/docs/v1/index.bs index 1e3dfd2a..cd4e5407 100644 --- a/docs/v1/index.bs +++ b/docs/v1/index.bs @@ -39,6 +39,7 @@ spec: fetch; text: ReadableStream spec: infra; type: dfn; + text: list; for: set; text: append for: list; text: append @@ -910,7 +911,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe readonly attribute USVString url; readonly attribute DOMString id; readonly attribute ClientType type; - readonly attribute boolean reserved; void postMessage(any message, optional sequence<object> transfer = []); }; @@ -926,7 +926,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A {{Client}} object has an associated service worker client (a [=/service worker client=]). - A {{Client}} object has an associated reserved state, which is either true or false. + A {{WindowClient}} object has an associated browsing context, which is its [=Client/service worker client=]'s [=environment settings object/global object=]'s [=/browsing context=]. A {{WindowClient}} object has an associated visibility state, which is one of {{Document/visibilityState}} attribute value. @@ -960,12 +960,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Return {{ClientType/"window"}}. -
-

{{Client/reserved}}

- - The reserved attribute *must* return the context object's associated [=Client/reserved state=]. -
-

{{Client/postMessage(message, transfer)}}

@@ -1078,7 +1072,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
       dictionary ClientQueryOptions {
         boolean includeUncontrolled = false;
-        boolean includeReserved = false;
         ClientType type = "window";
       };
     
@@ -1127,8 +1120,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Return |promise|.
-
-

{{Clients/matchAll(options)}}

+
+

{{Clients/matchAll(options)}}

The matchAll(|options|) method *must* run these steps: @@ -1141,7 +1134,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Else: 1. If |client|’s [=creation URL=] is not a [=potentially trustworthy URL=], [=continue=]. 1. If |options|["{{ClientQueryOptions/includeUncontrolled}}"] is false, and if |client|'s [=active service worker=] is not the associated [=ServiceWorkerGlobalScope/service worker=], [=continue=]. - 1. If |options|["{{ClientQueryOptions/includeReserved}}"] is false, and if |client|'s [=environment/execution ready flag=] is unset, [=continue=]. + 1. If |client|'s [=environment/execution ready flag=] is unset, [=continue=]. 1. Add |client| to |targetClients|. 1. Let |matchedWindowData| be a new [=list=]. 1. Let |matchedClients| be a new [=list=]. @@ -1174,10 +1167,13 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. [=list/For each=] |client| in |matchedClients|: 1. Let |clientObject| be the result of running [=Create Client=] algorithm with |client| as the argument. 1. [=Append=] |clientObject| to |clientObjects|. - 1. Sort |matchedClients| such that: - * {{WindowClient}} objects are always placed before {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=]. - * {{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. - * {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=] are placed next sorted in their [=Client/service worker clients=]' creation order. + 1. Sort |clientObjects| such that: + * {{WindowClient}} objects whose [=WindowClient/browsing context=] has been [=focusing steps|focused=] are placed first, sorted in the most recently [=focusing steps|focused=] order. + * {{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. + * {{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. + + Note: [=Window clients=] are always placed before [=worker clients=]. + 1. [=Resolve=] |promise| with [=create a frozen array|a new frozen array of=] |clientObjects| in |promise|'s [=relevant Realm=]. 1. Return |promise|.
@@ -1300,8 +1296,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe interface FetchEvent : ExtendableEvent { [SameObject] readonly attribute Request request; readonly attribute DOMString clientId; - readonly attribute DOMString reservedClientId; - readonly attribute DOMString targetClientId; void respondWith(Promise<Response> r); }; @@ -1310,8 +1304,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe dictionary FetchEventInit : ExtendableEventInit { required Request request; DOMString clientId = ""; - DOMString reservedClientId = ""; - DOMString targetClientId = ""; }; @@ -1335,18 +1327,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe clientId attribute *must* return the value it was initialized to. When an event is created the attribute *must* be initialized to the empty string.
-
-

{{FetchEvent/reservedClientId|event.reservedClientId}}

- - reservedClientId attribute *must* return the value it was initialized to. When an event is created the attribute *must* be initialized to the empty string. -
- -
-

{{FetchEvent/targetClientId|event.targetClientId}}

- - targetClientId attribute *must* return the value it was initialized to. When an event is created the attribute *must* be initialized to the empty string. -
-

{{FetchEvent/respondWith(r)|event.respondWith(r)}}

@@ -2606,9 +2586,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Initialize |e|’s {{Event/type}} attribute to {{fetch!!event}}. 1. Initialize |e|’s {{Event/cancelable}} attribute to true. 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`". - 1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=]. - 1. If |request| is a non-subresource request 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. - 1. If |request| is a navigation request, initialize |e|'s {{FetchEvent/targetClientId}} attribute to |request|'s [=request/target client id=], and to the empty string otherwise. + 1. If |request| is a non-subresource request 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. 1. Dispatch |e| at |activeWorker|'s [=service worker/global object=]. 1. Invoke [=Update Service Worker Extended Events Set=] with |activeWorker| and |e|. 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 1. Let |clientObject| be a new {{Client}} object. 1. Set |clientObject|'s [=Client/service worker client=] to |client|. - 1. Set |clientObject|'s [=Client/reserved state=] to true if |client|'s [=environment/execution ready flag=] is unset, and false otherwise. 1. Return |clientObject|.