-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This allows more complicated callers, like service workers, to customize script fetching as necessary. See [1], and in particular [2]. [1]: w3c/ServiceWorker#831 [2]: w3c/ServiceWorker#831 (comment)
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84174,6 +84174,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 | ||
callers:</p> | ||
|
||
<ul> | ||
|
||
<li><p><dfn data-x="fetching-scripts-set-up-request">set up the request</dfn>, which takes a | ||
This comment has been minimized.
Sorry, something went wrong. |
||
<span data-x="concept-request">request</span> object which it may modify before the algorithm | ||
continues</p></li> | ||
|
||
<li><p><dfn data-x="fetching-scripts-validate-response">validate the response</dfn>, which takes | ||
This comment has been minimized.
Sorry, something went wrong. |
||
a <span data-x="concept-response">response</span> object and must either accept or reject | ||
This comment has been minimized.
Sorry, something went wrong.
jungkees
Contributor
|
||
it.</p></li> | ||
|
||
</ul> | ||
This comment has been minimized.
Sorry, something went wrong.
annevk
Member
|
||
|
||
<p class="note"><cite>Service Workers</cite> is an example of a specification that runs these | ||
algorithms with its own options for the hooks. <ref spec=SW></p> | ||
|
||
<p>To <dfn>fetch a classic script</dfn> for a <code>script</code> element <var>element</var>, | ||
given a <var>url</var>, a <var>CORS setting</var>, a <var>settings object</var>, and a | ||
<var>character encoding</var>, run these steps. The algorithm will asynchronously complete with | ||
|
@@ -84189,6 +84207,9 @@ interface <dfn>NavigatorOnLine</dfn> { | |
data-x="">script</code>", and its <span data-x="concept-request-destination">destination</span> | ||
to "<code data-x="">script</code>".</p></li> | ||
|
||
<li><p>If the caller specified custom steps to <span data-x="fetching-scripts-set-up-request">set | ||
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> | ||
|
||
|
@@ -84206,6 +84227,11 @@ interface <dfn>NavigatorOnLine</dfn> { | |
data-x="concept-response-status">status</span> is not an <span>ok status</span>, asynchronously | ||
complete this algorithm with null, and abort these steps.</p></li> | ||
|
||
<li><p>If the caller specified custom steps to <span | ||
data-x="fetching-scripts-validate-response">validate the response</span>, perform them on | ||
<var>response</var>. If they reject the <var>response</var>, complete this algorithm with null, | ||
This comment has been minimized.
Sorry, something went wrong.
jungkees
Contributor
|
||
and abort these steps.</p></li> | ||
|
||
<li><p>If <var>response</var>'s <span data-x="Content-Type">Content Type metadata</span>, if | ||
any, specifies a character encoding, and the user agent supports that encoding, then set | ||
<var>character encoding</var> to that encoding (ignoring the passed-in value).</p></li> | ||
|
@@ -84247,6 +84273,9 @@ interface <dfn>NavigatorOnLine</dfn> { | |
data-x="concept-request-credentials-mode">credentials mode</span> is "<code | ||
data-x="">same-origin</code>", and whose <span>use-URL-credentials flag</span> is set.</p></li> | ||
|
||
<li><p>If the caller specified custom steps to <span data-x="fetching-scripts-set-up-request">set | ||
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> | ||
|
||
|
@@ -84259,6 +84288,11 @@ interface <dfn>NavigatorOnLine</dfn> { | |
data-x="concept-response-status">status</span> is not an <span>ok status</span>, asynchronously | ||
complete this algorithm with null, and abort these steps.</p></li> | ||
|
||
<li><p>If the caller specified custom steps to <span | ||
data-x="fetching-scripts-validate-response">validate the response</span>, perform them on | ||
<var>response</var>. If they reject the <var>response</var>, complete this algorithm with null, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
and abort these steps.</p></li> | ||
|
||
<li><p>Let <var>source text</var> be the result of <span data-x="UTF-8 decode">UTF-8 | ||
decoding</span> <var>response</var>'s <span data-x="concept-response-body">body</span>.</p></li> | ||
|
||
|
@@ -84277,7 +84311,11 @@ interface <dfn>NavigatorOnLine</dfn> { | |
<li><p>If <var>ancestor list</var> is not given, let it be an empty list.</p></li> | ||
|
||
<li><p><span>Fetch a single module script</span> given <var>url</var>, <var>credentials | ||
mode</var>, <var>destination</var>, and <var>settings object</var>.</p> | ||
mode</var>, <var>destination</var>, and <var>settings object</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-validate-response">validate the response</span> | ||
steps, pass those along while <span data-x="fetch a single module script">fetching a single | ||
module script</span>.</p> | ||
|
||
<li><p>Return from this algorithm and run the following steps when <span data-x="fetch a single | ||
module script">fetching a single module script</span> asynchronously completes with | ||
|
@@ -84341,6 +84379,11 @@ interface <dfn>NavigatorOnLine</dfn> { | |
data-x="concept-module-script-credentials-mode">credentials mode</span>, <var>destination</var>, | ||
<var>module script</var>'s <span>settings object</span>, and <var>ancestor list</var>.</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 | ||
data-x="fetching-scripts-validate-response">validate the response</span> steps are passed along | ||
here. Those hooks only apply to the top-level fetch at the root of the module script tree.</p> | ||
|
||
<p>If any of the <span>fetch a module script tree</span> invocations asynchronously complete | ||
with null, the user agent may <span data-x="concept-fetch-terminate">terminate</span> any or | ||
all of the other fetches, and must then asynchronously complete this algorithm with null.</p> | ||
|
@@ -84378,6 +84421,9 @@ interface <dfn>NavigatorOnLine</dfn> { | |
mode</var>, and <span data-x="concept-request-client">client</span> is | ||
<var>settings object</var>.</p></li> | ||
|
||
<li><p>If the caller specified custom steps to <span data-x="fetching-scripts-set-up-request">set | ||
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> | ||
|
||
|
@@ -84410,6 +84456,10 @@ interface <dfn>NavigatorOnLine</dfn> { | |
classic script</span> does not include MIME type checking. In contrast, module scripts will | ||
fail to load if they are not of a correct MIME type.</p> | ||
</li> | ||
|
||
<li><p>The caller specified custom steps to <span | ||
data-x="fetching-scripts-validate-response">validate the response</span>, which when performed | ||
on <var>response</var> reject it.</p></li> | ||
</ul> | ||
</li> | ||
|
||
|
It seems other ul-li elements in the document start with capital?