@@ -84174,6 +84174,24 @@ interface <dfn>NavigatorOnLine</dfn> {
84174
84174
84175
84175
<h5 id="fetching-scripts">Fetching scripts</h5>
84176
84176
84177
+ <p>The various script-fetching algorithms below have two hooks that may be customized by their
84178
+ callers:</p>
84179
+
84180
+ <ul>
84181
+
84182
+ <li><p><dfn data-x="fetching-scripts-set-up-request">set up the request</dfn>, which takes a
84183
+ <span data-x="concept-request">request</span> object which it may modify before the algorithm
84184
+ continues</p></li>
84185
+
84186
+ <li><p><dfn data-x="fetching-scripts-validate-response">validate the response</dfn>, which takes
84187
+ a <span data-x="concept-response">response</span> object and must either accept or reject
84188
+ it.</p></li>
84189
+
84190
+ </ul>
84191
+
84192
+ <p class="note"><cite>Service Workers</cite> is an example of a specification that runs these
84193
+ algorithms with its own options for the hooks. <ref spec=SW></p>
84194
+
84177
84195
<p>To <dfn>fetch a classic script</dfn> for a <code>script</code> element <var>element</var>,
84178
84196
given a <var>url</var>, a <var>CORS setting</var>, a <var>settings object</var>, and a
84179
84197
<var>character encoding</var>, run these steps. The algorithm will asynchronously complete with
@@ -84189,6 +84207,9 @@ interface <dfn>NavigatorOnLine</dfn> {
84189
84207
data-x="">script</code>", and its <span data-x="concept-request-destination">destination</span>
84190
84208
to "<code data-x="">script</code>".</p></li>
84191
84209
84210
+ <li><p>If the caller specified custom steps to <span data-x="fetching-scripts-set-up-request">set
84211
+ up the request</span>, perform them on <var>request</var>.</p></li>
84212
+
84192
84213
<!--FETCH-->
84193
84214
<li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
84194
84215
@@ -84206,6 +84227,11 @@ interface <dfn>NavigatorOnLine</dfn> {
84206
84227
data-x="concept-response-status">status</span> is not an <span>ok status</span>, asynchronously
84207
84228
complete this algorithm with null, and abort these steps.</p></li>
84208
84229
84230
+ <li><p>If the caller specified custom steps to <span
84231
+ data-x="fetching-scripts-validate-response">validate the response</span>, perform them on
84232
+ <var>response</var>. If they reject the <var>response</var>, complete this algorithm with null,
84233
+ and abort these steps.</p></li>
84234
+
84209
84235
<li><p>If <var>response</var>'s <span data-x="Content-Type">Content Type metadata</span>, if
84210
84236
any, specifies a character encoding, and the user agent supports that encoding, then set
84211
84237
<var>character encoding</var> to that encoding (ignoring the passed-in value).</p></li>
@@ -84247,6 +84273,9 @@ interface <dfn>NavigatorOnLine</dfn> {
84247
84273
data-x="concept-request-credentials-mode">credentials mode</span> is "<code
84248
84274
data-x="">same-origin</code>", and whose <span>use-URL-credentials flag</span> is set.</p></li>
84249
84275
84276
+ <li><p>If the caller specified custom steps to <span data-x="fetching-scripts-set-up-request">set
84277
+ up the request</span>, perform them on <var>request</var>.</p></li>
84278
+
84250
84279
<!--FETCH-->
84251
84280
<li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
84252
84281
@@ -84259,6 +84288,11 @@ interface <dfn>NavigatorOnLine</dfn> {
84259
84288
data-x="concept-response-status">status</span> is not an <span>ok status</span>, asynchronously
84260
84289
complete this algorithm with null, and abort these steps.</p></li>
84261
84290
84291
+ <li><p>If the caller specified custom steps to <span
84292
+ data-x="fetching-scripts-validate-response">validate the response</span>, perform them on
84293
+ <var>response</var>. If they reject the <var>response</var>, complete this algorithm with null,
84294
+ and abort these steps.</p></li>
84295
+
84262
84296
<li><p>Let <var>source text</var> be the result of <span data-x="UTF-8 decode">UTF-8
84263
84297
decoding</span> <var>response</var>'s <span data-x="concept-response-body">body</span>.</p></li>
84264
84298
@@ -84277,7 +84311,11 @@ interface <dfn>NavigatorOnLine</dfn> {
84277
84311
<li><p>If <var>ancestor list</var> is not given, let it be an empty list.</p></li>
84278
84312
84279
84313
<li><p><span>Fetch a single module script</span> given <var>url</var>, <var>credentials
84280
- mode</var>, <var>destination</var>, and <var>settings object</var>.</p>
84314
+ mode</var>, <var>destination</var>, and <var>settings object</var>. If the caller of this
84315
+ algorithm specified custom <span data-x="fetching-scripts-set-up-request">set up the
84316
+ request</span> or <span data-x="fetching-scripts-validate-response">validate the response</span>
84317
+ steps, pass those along while <span data-x="fetch a single module script">fetching a single
84318
+ module script</span>.</p>
84281
84319
84282
84320
<li><p>Return from this algorithm and run the following steps when <span data-x="fetch a single
84283
84321
module script">fetching a single module script</span> asynchronously completes with
@@ -84341,6 +84379,11 @@ interface <dfn>NavigatorOnLine</dfn> {
84341
84379
data-x="concept-module-script-credentials-mode">credentials mode</span>, <var>destination</var>,
84342
84380
<var>module script</var>'s <span>settings object</span>, and <var>ancestor list</var>.</p>
84343
84381
84382
+ <p class="note">It is intentional that no custom <span
84383
+ data-x="fetching-scripts-set-up-request">set up the request</span> or <span
84384
+ data-x="fetching-scripts-validate-response">validate the response</span> steps are passed along
84385
+ here. Those hooks only apply to the top-level fetch at the root of the module script tree.</p>
84386
+
84344
84387
<p>If any of the <span>fetch a module script tree</span> invocations asynchronously complete
84345
84388
with null, the user agent may <span data-x="concept-fetch-terminate">terminate</span> any or
84346
84389
all of the other fetches, and must then asynchronously complete this algorithm with null.</p>
@@ -84378,6 +84421,9 @@ interface <dfn>NavigatorOnLine</dfn> {
84378
84421
mode</var>, and <span data-x="concept-request-client">client</span> is
84379
84422
<var>settings object</var>.</p></li>
84380
84423
84424
+ <li><p>If the caller specified custom steps to <span data-x="fetching-scripts-set-up-request">set
84425
+ up the request</span>, perform them on <var>request</var>.</p></li>
84426
+
84381
84427
<!--FETCH-->
84382
84428
<li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
84383
84429
@@ -84410,6 +84456,10 @@ interface <dfn>NavigatorOnLine</dfn> {
84410
84456
classic script</span> does not include MIME type checking. In contrast, module scripts will
84411
84457
fail to load if they are not of a correct MIME type.</p>
84412
84458
</li>
84459
+
84460
+ <li><p>The caller specified custom steps to <span
84461
+ data-x="fetching-scripts-validate-response">validate the response</span>, which when performed
84462
+ on <var>response</var> reject it.</p></li>
84413
84463
</ul>
84414
84464
</li>
84415
84465
0 commit comments