Skip to content

Commit

Permalink
Add "cache" source support. (#4)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
yoshisatoyanagisawa authored Jan 31, 2024
1 parent 2d0d848 commit 8304676
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
</pre>

<section>
Expand Down Expand Up @@ -3117,7 +3117,16 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
1. If |request|'s [=request/destination=] is either "<code>embed</code>" or "<code>object</code>", then:
1. Return null.
1. Else if |registration|'s <a>active worker</a>'s [=service worker/list of router rules=] is [=list/is not empty=]:
1. If running [=Get Router Source=] algorithm with |registration|'s <a>active worker</a> and |request| returns "network", return null.
1. Let |source| be the result of running [=Get Router Source=] algorithm with |registration|'s <a>active worker</a> 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 <b>blocked</b>, then return null.
1. Return |response|.
1. Else if |request| is a <a>non-subresource request</a>, then:
1. If |reservedClient| is not null and is an <a>environment settings object</a>, then:
1. If |reservedClient| is not a <a>secure context</a>, return null.
Expand Down

0 comments on commit 8304676

Please sign in to comment.