Skip to content

Commit 697b506

Browse files
quasi-modannevk
andauthored
Align with changes to Service Worker's handle fetch
Update the HTTP fetch algorithm, particularly the handling of the response to Service Worker's handle fetch. Currently, handle fetch is assumed to return null or a response. However, handle fetch can now return service worker timing info when the Service Worker static routing API is used, so that the corresponding timing information are correctly exposed when the ServiceWorker could not handle the fetch (i.e., would previously return null). To support this new return type, we need to update the handling of the response of handle fetch. To expose the Service Worker timing Info to the resource timing API, we also associate them to the fetch timing info. Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
1 parent 60e9ff5 commit 697b506

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

fetch.bs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ following <a for=struct>items</a>: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
367367
<dt><dfn export for="fetch timing info">final connection timing info</dfn> (default null)
368368
<dd>Null or a <a for=/>connection timing info</a>.
369369

370+
<dt><dfn export for="fetch timing info">service worker timing info</dfn> (default null)
371+
<dd>Null or a <a for=/>service worker timing info</a>.
372+
370373
<dt><dfn export for="fetch timing info">server-timing headers</dfn> (default « »)
371374
<dd>A <a for=/>list</a> of strings.
372375
<dt><dfn export for="fetch timing info">render-blocking</dfn> (default false)
@@ -5602,20 +5605,26 @@ these steps:
56025605
<li><p>Let <var>serviceWorkerStartTime</var> be the <a for=/>coarsened shared current time</a>
56035606
given <var>fetchParams</var>'s <a for="fetch params">cross-origin isolated capability</a>.
56045607

5605-
<li><p>Set <var>response</var> to the result of invoking <a for=/>handle fetch</a> for
5608+
<li><p>Let <var>fetchResponse</var> be the result of invoking <a for=/>handle fetch</a> for
56065609
<var>requestForServiceWorker</var>, with <var>fetchParams</var>'s
56075610
<a for="fetch params">controller</a> and <var>fetchParams</var>'s
56085611
<a for="fetch params">cross-origin isolated capability</a>. [[!HTML]] [[!SW]]
56095612

56105613
<li>
5611-
<p>If <var>response</var> is non-null, then:
5614+
<p>If <var>fetchResponse</var> is a <a for=/>response</a>:
56125615

56135616
<ol>
5617+
<li><p>Set <var>response</var> to <var>fetchResponse</var>.
5618+
56145619
<li><p>Set <var>fetchParams</var>'s <a for="fetch params">timing info</a>'s
56155620
<a for="fetch timing info">final service worker start time</a> to
56165621
<var>serviceWorkerStartTime</var>.
56175622

5618-
<li>If <var>request</var>'s <a for=request>body</a> is non-null, then
5623+
<li><p>Set <var>fetchParams</var>'s <a for="fetch params">timing info</a>'s
5624+
<a for="fetch timing info">service worker timing info</a> to <var>response</var>'s
5625+
<a for="response">service worker timing info</a>.
5626+
5627+
<li><p>If <var>request</var>'s <a for=request>body</a> is non-null, then
56195628
<a for=ReadableStream>cancel</a> <var>request</var>'s <a for=request>body</a> with undefined.
56205629

56215630
<li><p>Set <var>internalResponse</var> to <var>response</var>, if <var>response</var> is not a
@@ -5638,11 +5647,15 @@ these steps:
56385647
<var>response</var>'s <a for=response>type</a> is "<code>opaqueredirect</code>"
56395648

56405649
<li><var>request</var>'s <a for=request>redirect mode</a> is not "<code>follow</code>" and
5641-
<var>response</var>'s <a for=response>URL list</a> has more than one item.
5650+
<var>response</var>'s <a for=response>URL list</a> has more than one item
56425651
</ul>
56435652

56445653
<p>then return a <a>network error</a>.
56455654
</ol>
5655+
5656+
<li><p>Otherwise, if <var>fetchResponse</var> is a <a for=/>service worker timing info</a>,
5657+
then set <var>fetchParams</var>'s <a for="fetch params">timing info</a>'s
5658+
<a for="fetch timing info">service worker timing info</a> to <var>fetchResponse</var>.
56465659
</ol>
56475660

56485661
<li>
@@ -10182,6 +10195,7 @@ Julian Reschke,
1018210195
Jussi Kalliokoski,
1018310196
Jxck,
1018410197
Kagami Sascha Rosylight,
10198+
Keita Suzuki,
1018510199
Keith Yeung,
1018610200
Kenji Baheux,
1018710201
Lachlan Hunt,

0 commit comments

Comments
 (0)