From 8304676120a0df213afa07cf04eb1c3d26edfdc8 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Wed, 31 Jan 2024 13:20:55 +0900 Subject: [PATCH] Add "cache" source support. (#4) * Add "cache" source support. * Use |client| as settingsObject to evaluate COEP. When the ServiceWorker static routing API is used and source other than "fetch-event" is used, results are directly returned without running ServiceWorker. In that case, we use the request's COEP instead of ServiceWorker's COEP. --- docs/index.bs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 21b308c1..50718095 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -1572,7 +1572,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ }; enum RunningStatus { "running", "not-running" }; - enum RouterSource { "fetch-event", "network" }; + enum RouterSource { "cache", "fetch-event", "network" };
@@ -3117,7 +3117,16 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. If |request|'s [=request/destination=] is either "embed" or "object", then: 1. Return null. 1. Else if |registration|'s active worker's [=service worker/list of router rules=] is [=list/is not empty=]: - 1. If running [=Get Router Source=] algorithm with |registration|'s active worker and |request| returns "network", return null. + 1. Let |source| be the result of running [=Get Router Source=] algorithm with |registration|'s active worker and |request|. + 1. If |source| is {{RouterSource/"network"}}, return null. + 1. Else if |source| is {{RouterSource/"cache"}}, then: + 1. Let |requestResponses| be the result of running [=Query Cache=] with |request|. + 1. If |requestResponses| is an empty [=list=], return null. + 1. Else: + 1. Let |requestResponse| be the first element of |requestResponses|. + 1. Let |response| be |requestResponse|'s response. + 1. If |client| is not null, |response|'s [=response/type=] is "`opaque`", and [=cross-origin resource policy check=] with |request|'s [=request/origin=], |client|, "", and |response|'s [=filtered response/internal response=] returns blocked, then return null. + 1. Return |response|. 1. Else if |request| is a non-subresource request, then: 1. If |reservedClient| is not null and is an environment settings object, then: 1. If |reservedClient| is not a secure context, return null.