Skip to content

Commit 8ebf2fd

Browse files
authored
<link rel=preload> integration
Before any particular fetch steps are performed, see if there is a matching request already in the preload store and consume it. This is called from the main fetch to avoid race conditions. Depends on whatwg/html#7260, and together they fix #590. Tests: web-platform-tests/wpt#31539.
1 parent 84c726a commit 8ebf2fd

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

fetch.bs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,6 +3830,46 @@ the request.
38303830
<var>request</var>'s <a for=request>origin</a> to <var>request</var>'s <a for=request>client</a>'s
38313831
<a for="environment settings object">origin</a>.
38323832

3833+
<li>
3834+
<p>If all of the following conditions are true:
3835+
3836+
<ul class=brief>
3837+
<li><p><var>request</var>'s <a for=request>URL</a>'s <a for=url>scheme</a> is an
3838+
<a>HTTP(S) scheme</a>
3839+
3840+
<li><p><var>request</var>'s <a for=request>mode</a> is "<code>same-origin</code>",
3841+
"<code>cors</code>", or "<code>no-cors</code>"
3842+
3843+
<li><p><var>request</var>'s <a for=request>window</a> is not null
3844+
3845+
<li><p><var>request</var>'s <a for=request>method</a> is `<code>GET</code>`
3846+
3847+
<li><p><var>request</var>'s <a for=request>unsafe-request flag</a> is not set or
3848+
<var>request</var>'s <a for=request>header list</a> <a for="list">is empty</a>
3849+
</ul>
3850+
3851+
<p>then:
3852+
3853+
<ol>
3854+
<li><p><a for=/>Assert</a>: <var>request</var>'s <a for=request>origin</a> is <a>same origin</a>
3855+
with <var>request</var>'s <a for=request>client</a>'s
3856+
<a for="environment settings object">origin</a>.
3857+
3858+
<li><p>Let <var>onPreloadedResponseAvailable</var> be an algorithm that runs the following
3859+
step <a>in parallel</a> given a <a for=/>response</a> <var>response</var>: run
3860+
<a>fetch finale</a> given <var>response</var> and <var>fetchParams</var>.
3861+
3862+
<li><p>Let <var>foundPreloadedResource</var> be the result of invoking
3863+
<a>consume a preloaded resource</a> for <var>req</var>'s <a for=request>window</a>,
3864+
given <var>req</var>'s <a for=request>URL</a>, <var>req</var>'s <a for=request>destination</a>,
3865+
<var>req</var>'s <a for=request>mode</a>, <var>req</var>'s <a for=request>credentials mode</a>,
3866+
<var>req</var>'s <a for=request>integrity metadata</a>, and
3867+
<var>onPreloadedResponseAvailable</var>.
3868+
3869+
<li><p>If <var>foundPreloadedResource</var> is true, then return.
3870+
</ol>
3871+
</li>
3872+
38333873
<li>
38343874
<p>If <var>request</var>'s <a for=request>policy container</a> is "<code>client</code>", then:
38353875

0 commit comments

Comments
 (0)