From 6ae424e0c3ad62ec0dba38e2b640889285d266fe Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 25 Feb 2016 19:25:32 -0500 Subject: [PATCH] Add set up the request/validate the response hooks to script fetching This allows more complicated callers, like service workers, to customize script fetching as necessary. See [1], and in particular [2]. [1]: https://github.com/slightlyoff/ServiceWorker/issues/831 [2]: https://github.com/slightlyoff/ServiceWorker/issues/831#issuecomment-187139872 --- source | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/source b/source index 4f8186e4272..49d72f238f8 100644 --- a/source +++ b/source @@ -84174,6 +84174,24 @@ interface NavigatorOnLine {
Fetching scripts
+

The various script-fetching algorithms below have two hooks that may be customized by their + callers:

+ + + +

Service Workers is an example of a specification that runs these + algorithms with its own options for the hooks.

+

To fetch a classic script for a script element element, given a url, a CORS setting, a settings object, and a character encoding, run these steps. The algorithm will asynchronously complete with @@ -84189,6 +84207,9 @@ interface NavigatorOnLine { data-x="">script", and its destination to "script".

+
  • If the caller specified custom steps to set + up the request, perform them on request.

  • +
  • Fetch request.

  • @@ -84206,6 +84227,11 @@ interface NavigatorOnLine { data-x="concept-response-status">status is not an ok status, asynchronously complete this algorithm with null, and abort these steps.

    +
  • If the caller specified custom steps to validate the response, perform them on + response. If they reject the response, complete this algorithm with null, + and abort these steps.

  • +
  • If response's Content Type metadata, if any, specifies a character encoding, and the user agent supports that encoding, then set character encoding to that encoding (ignoring the passed-in value).

  • @@ -84247,6 +84273,9 @@ interface NavigatorOnLine { data-x="concept-request-credentials-mode">credentials mode is "same-origin", and whose use-URL-credentials flag is set.

    +
  • If the caller specified custom steps to set + up the request, perform them on request.

  • +
  • Fetch request.

  • @@ -84259,6 +84288,11 @@ interface NavigatorOnLine { data-x="concept-response-status">status is not an ok status, asynchronously complete this algorithm with null, and abort these steps.

    +
  • If the caller specified custom steps to validate the response, perform them on + response. If they reject the response, complete this algorithm with null, + and abort these steps.

  • +
  • Let source text be the result of UTF-8 decoding response's body.

  • @@ -84277,7 +84311,11 @@ interface NavigatorOnLine {
  • If ancestor list is not given, let it be an empty list.

  • Fetch a single module script given url, credentials - mode, destination, and settings object.

    + mode, destination, and settings object. If the caller of this + algorithm specified custom set up the + request or validate the response + steps, pass those along while fetching a single + module script.

  • Return from this algorithm and run the following steps when fetching a single module script asynchronously completes with @@ -84341,6 +84379,11 @@ interface NavigatorOnLine { data-x="concept-module-script-credentials-mode">credentials mode, destination, module script's settings object, and ancestor list.

    +

    It is intentional that no custom set up the request or validate the response steps are passed along + here. Those hooks only apply to the top-level fetch at the root of the module script tree.

    +

    If any of the fetch a module script tree invocations asynchronously complete with null, the user agent may terminate any or all of the other fetches, and must then asynchronously complete this algorithm with null.

    @@ -84378,6 +84421,9 @@ interface NavigatorOnLine { mode, and client is settings object.

  • +
  • If the caller specified custom steps to set + up the request, perform them on request.

  • +
  • Fetch request.

  • @@ -84410,6 +84456,10 @@ interface NavigatorOnLine { classic script does not include MIME type checking. In contrast, module scripts will fail to load if they are not of a correct MIME type.

    + +
  • The caller specified custom steps to validate the response, which when performed + on response reject it.