Skip to content

Commit

Permalink
Add a custom "perform the fetch" hook for modules
Browse files Browse the repository at this point in the history
This allows worklets to use their own cache for module fetching, as
discussed in w3c/css-houdini-drafts#229 and
w3c/css-houdini-drafts#251.
  • Loading branch information
domenic committed Jul 1, 2016
1 parent 21d5b5c commit 8c43afc
Showing 1 changed file with 48 additions and 23 deletions.
71 changes: 48 additions & 23 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2798,6 +2798,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<li><dfn data-noexport="" data-x-href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type">extract a MIME type</dfn>
<li><dfn data-noexport="" data-x="concept-fetch" data-x-href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</dfn>
<li><dfn data-noexport="" data-x-href="https://fetch.spec.whatwg.org/#ok-status">ok status</dfn>
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#concept-network-error">network error</dfn>
<li>`<dfn data-noexport="" data-x="http-origin" data-x-href="https://fetch.spec.whatwg.org/#http-origin"><code>Origin</code></dfn>` header
<li><dfn data-noexport="" data-x-href="https://fetch.spec.whatwg.org/#process-response">process response</dfn>
<li><dfn data-noexport="" data-x="concept-header-list-set" data-x-href="https://fetch.spec.whatwg.org/#concept-header-list-set">set</dfn>
Expand Down Expand Up @@ -86347,18 +86348,24 @@ interface <dfn>NavigatorOnLine</dfn> {

<h5 id="fetching-scripts">Fetching scripts</h5>

<p>The various script-fetching algorithms below have two hooks that may be customized by their
<p>The various script-fetching algorithms below have three hooks that may be customized by their
callers:</p>

<ul>

<li><p><dfn data-x="fetching-scripts-set-up-request">Set up the request</dfn>, which takes a
<span data-x="concept-request">request</span> which it may modify before the algorithm
continues</p></li>
<li><p><dfn data-x="fetching-scripts-set-up-request" data-export="" data-dfn-for="fetching
scripts">Set up the request</dfn>, which takes a <span data-x="concept-request">request</span>
which it may modify before the algorithm continues</p></li>

<li><p><dfn data-x="fetching-scripts-process-response">Process the response</dfn>, which takes
a <span data-x="concept-response">response</span> and must either return true or false to
indicate success or failure, respectively</p></li>
<li><p><dfn data-x="fetching-scripts-perform-fetch" data-export="" data-dfn-for="fetching
scripts">Perform the fetch</dfn>, which takes a <span data-x="concept-request">request</span> and
must asynchronously complete with a <span data-x="concept-response">response</span> (which may be
a <span>network error</span>)</p></li>

<li><p><dfn data-x="fetching-scripts-process-response" data-export="" data-dfn-for="fetching
scripts">Process the response</dfn>, which takes a <span
data-x="concept-response">response</span> and must either return true or false to indicate
success or failure, respectively</p></li>

</ul>

Expand Down Expand Up @@ -86388,12 +86395,16 @@ interface <dfn>NavigatorOnLine</dfn> {
up the request</span>, perform them on <var>request</var>.</p></li>

<!--FETCH-->
<li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>

<li>
<p>Return from this algorithm, and run the remaining steps as part of the fetch's
<span>process response</span> for the <span data-x="concept-response">response</span>
<var>response</var>.</p>
<p>If the caller specified custom steps to <span data-x="fetching-scripts-perform-fetch">perform
the fetch</span>, perform them on <var>request</var>. Return from this algorithm, and when the
custom <span data-x="fetching-scripts-perform-fetch">perform the fetch</span> steps complete
with <span data-x="concept-response">response</span> <var>response</var>, run the remaining
steps.</p>

<p>Otherwise, <span data-x="concept-fetch">fetch</span> <var>request</var>. Return from this
algorithm, and run the remaining steps as part of the fetch's <span>process response</span> for
the <span data-x="concept-response">response</span> <var>response</var>.</p>

<p class="note"><var>response</var> can be either <span>CORS-same-origin</span> or
<span>CORS-cross-origin</span>. This only affects how error reporting happens.</p>
Expand Down Expand Up @@ -86454,11 +86465,17 @@ interface <dfn>NavigatorOnLine</dfn> {
up the request</span>, perform them on <var>request</var>.</p></li>

<!--FETCH-->
<li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
<li>
<p>If the caller specified custom steps to <span data-x="fetching-scripts-perform-fetch">perform
the fetch</span>, perform them on <var>request</var>. Return from this algorithm, and when the
custom <span data-x="fetching-scripts-perform-fetch">perform the fetch</span> steps complete
with <span data-x="concept-response">response</span> <var>response</var>, run the remaining
steps.</p>

<li><p>Return from this algorithm, and run the remaining steps as part of the fetch's
<span>process response</span> for the <span data-x="concept-response">response</span>
<var>response</var>.</p></li>
<p>Otherwise, <span data-x="concept-fetch">fetch</span> <var>request</var>. Return from this
algorithm, and run the remaining steps as part of the fetch's <span>process response</span> for
the <span data-x="concept-response">response</span> <var>response</var>.</p>
</li>

<li><p>If <var>response</var>'s <span data-x="concept-response-type">type</span> is "<code
data-x="">error</code>", or <var>response</var>'s <span
Expand Down Expand Up @@ -86498,7 +86515,8 @@ interface <dfn>NavigatorOnLine</dfn> {
mode</var>, <var>cryptographic nonce</var>, <var>parser state</var>, <var>destination</var>,
<var>fetch client settings object</var>, <var>module map settings object</var>, and
<var>referrer</var>. If the caller of this algorithm specified custom <span
data-x="fetching-scripts-set-up-request">set up the request</span> or <span
data-x="fetching-scripts-set-up-request">set up the request</span>, <span
data-x="fetching-scripts-perform-fetch">perform the fetch</span>, or <span
data-x="fetching-scripts-process-response">process the response</span> steps, pass those along
while <span data-x="fetch a single module script">fetching a single module script</span>.</p>

Expand Down Expand Up @@ -86566,7 +86584,10 @@ interface <dfn>NavigatorOnLine</dfn> {
<var>module script</var>'s <span data-x="concept-module-script-parser">parser state</span>,
<var>destination</var>, <var>module script</var>'s <span>settings object</span>, <var>module
script</var>'s <span>settings object</span>, <var>ancestor list</var>, and <var>module
script</var>'s <span data-x="concept-module-script-base-url">base URL</span>.</p>
script</var>'s <span data-x="concept-module-script-base-url">base URL</span>. If the caller of
this algorithm specified custom <span data-x="fetching-scripts-perform-fetch">perform the
fetch</span> steps, pass those along while <span data-x="fetch a module script tree">fetching a
module script tree</span>.</p>

<p class="note">It is intentional that no custom <span
data-x="fetching-scripts-set-up-request">set up the request</span> or <span
Expand Down Expand Up @@ -86620,12 +86641,16 @@ interface <dfn>NavigatorOnLine</dfn> {
up the request</span>, perform them on <var>request</var>.</p></li>

<!--FETCH-->
<li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>

<li>
<p>Return from this algorithm, and run the remaining steps as part of the fetch's
<span>process response</span> for the <span data-x="concept-response">response</span>
<var>response</var>.</p>
<p>If the caller specified custom steps to <span data-x="fetching-scripts-perform-fetch">perform
the fetch</span>, perform them on <var>request</var>. Return from this algorithm, and when the
custom <span data-x="fetching-scripts-perform-fetch">perform the fetch</span> steps complete
with <span data-x="concept-response">response</span> <var>response</var>, run the remaining
steps.</p>

<p>Otherwise, <span data-x="concept-fetch">fetch</span> <var>request</var>. Return from this
algorithm, and run the remaining steps as part of the fetch's <span>process response</span> for
the <span data-x="concept-response">response</span> <var>response</var>.</p>

<p class="note"><var>response</var> is always <span>CORS-same-origin</span>.</p>
</li>
Expand Down

0 comments on commit 8c43afc

Please sign in to comment.