From f8f5f9993ad8572e57faec9156d37b3a0524d991 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Thu, 16 Sep 2021 13:08:00 -0700 Subject: [PATCH] Eliminate redundant CSS module script fetch in workers Currently the check that disallows creation of CSS module scripts in worker contexts only happens after the fetch for that import is performed. This change moves the check to where we check that the assertion type is a valid value. By doing so, failing that check prevents the fetch. Closes #7047. --- source | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/source b/source index 3096f596daf..2bcaa0cdab4 100644 --- a/source +++ b/source @@ -90958,9 +90958,9 @@ document.querySelector("button").addEventListener("click", bound); type be entry.[[Value]]. Otherwise let module type be "javascript".

-
  • If module type is not "javascript", "css", or "json", then asynchronously complete this - algorithm with null, and return.

  • +
  • If the result of running the module type allowed steps given module + type and settings object is false, then asynchronously complete this algorithm + with null, and return.

  • Fetch a single module script given url, settings object, "script", options, settings object, @@ -91437,8 +91437,8 @@ document.querySelector("button").addEventListener("click", bound);

  • -
  • Assert: module type is "javascript", "css", or "json". Otherwise we would not have reached +

  • Assert: the result of running the module type allowed steps given module + type and module map settings object is true. Otherwise we would not have reached this point because a failure would have been raised when inspecting moduleRequest.[[Assertions]] in create a JavaScript module script or @@ -91734,9 +91734,8 @@ document.querySelector("button").addEventListener("click", bound); data-x="">javascript".

  • -

    If url is failure, or if module type is not "javascript", "css", or "json", - then:

    +

    If url is failure, or if the result of running the module type + allowed steps given module type and settings is false, then:

    1. Let error be a new TypeError exception.

    2. @@ -91764,10 +91763,6 @@ document.querySelector("button").addEventListener("click", bound); string source and an environment settings object settings:

        -
      1. If the CSSStyleSheet interface is not exposed in setting's Realm, then return null.

      2. -
      3. Let script be a new module script that this algorithm will subsequently initialize.

      4. @@ -91832,6 +91827,21 @@ document.querySelector("button").addEventListener("click", bound);
      5. Return script.

      +

      The module type allowed steps, given a string module type + and an environment settings object settings, are as follows:

      + +
        +
      1. If module type is not "javascript", "css", or "json", then return false.

      2. + +
      3. If module type is "css" and the + CSSStyleSheet interface is not exposed in + setting's Realm, then + return false.

      4. + +
      5. Return true.

      6. +
      +
      Calling scripts

      To run a classic script given a classic script script