Skip to content

Commit

Permalink
Eliminate redundant CSS module script fetch in workers
Browse files Browse the repository at this point in the history
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 whatwg#7047.
  • Loading branch information
dandclark authored and mfreed7 committed Jun 3, 2022
1 parent 815e369 commit f8f5f99
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -90958,9 +90958,9 @@ document.querySelector("button").addEventListener("click", bound);
type</var> be <var>entry</var>.[[Value]]. Otherwise let <var>module type</var> be "<code
data-x="">javascript</code>".</p></li>

<li><p>If <var>module type</var> is not "<code data-x="">javascript</code>", "<code
data-x="">css</code>", or "<code data-x="">json</code>", then asynchronously complete this
algorithm with null, and return.</p></li>
<li><p>If the result of running the <span>module type allowed</span> steps given <var>module
type</var> and <var>settings object</var> is false, then asynchronously complete this algorithm
with null, and return.</p></li>

<li><p><span>Fetch a single module script</span> given <var>url</var>, <var>settings
object</var>, "<code data-x="">script</code>", <var>options</var>, <var>settings object</var>,
Expand Down Expand Up @@ -91437,8 +91437,8 @@ document.querySelector("button").addEventListener("click", bound);
</ol>
</li>

<li><p>Assert: <var>module type</var> is "<code data-x="">javascript</code>", "<code
data-x="">css</code>", or "<code data-x="">json</code>". Otherwise we would not have reached
<li><p>Assert: the result of running the <span>module type allowed</span> steps given <var>module
type</var> and <var>module map settings object</var> is true. Otherwise we would not have reached
this point because a failure would have been raised when inspecting
<var>moduleRequest</var>.[[Assertions]] in <a
href="#validate-requested-module-specifiers">create a JavaScript module script</a> or
Expand Down Expand Up @@ -91734,9 +91734,8 @@ document.querySelector("button").addEventListener("click", bound);
data-x="">javascript</code>".</p></li>

<li>
<p>If <var>url</var> is failure, or if <var>module type</var> is not "<code
data-x="">javascript</code>", "<code data-x="">css</code>", or "<code data-x="">json</code>",
then:</p>
<p>If <var>url</var> is failure, or if the result of running the <span>module type
allowed</span> steps given <var>module type</var> and <var>settings</var> is false, then:</p>
<ol>
<li><p>Let <var>error</var> be a new <code>TypeError</code> exception.</p></li>

Expand Down Expand Up @@ -91764,10 +91763,6 @@ document.querySelector("button").addEventListener("click", bound);
string <var>source</var> and an <span>environment settings object</span> <var>settings</var>:</p>

<ol>
<li><p>If the <code>CSSStyleSheet</code> interface is not <span
data-x="idl-exposed">exposed</span> in <var>setting</var>'s <span data-x="environment settings
object's Realm">Realm</span>, then return null.</p></li>

<li><p>Let <var>script</var> be a new <span>module script</span> that this algorithm will
subsequently initialize.</p></li>

Expand Down Expand Up @@ -91832,6 +91827,21 @@ document.querySelector("button").addEventListener("click", bound);
<li><p>Return <var>script</var>.</p></li>
</ol>

<p>The <dfn>module type allowed</dfn> steps, given a <span>string</span> <var>module type</var>
and an <span>environment settings object</span> <var>settings</var>, are as follows:</p>

<ol>
<li><p>If <var>module type</var> is not "<code data-x="">javascript</code>", "<code
data-x="">css</code>", or "<code data-x="">json</code>", then return false.</p></li>

<li><p>If <var>module type</var> is "<code data-x="">css</code>" and the
<code>CSSStyleSheet</code> interface is not <span data-x="idl-exposed">exposed</span> in
<var>setting</var>'s <span data-x="environment settings object's Realm">Realm</span>, then
return false.</p></li>

<li><p>Return true.</p></li>
</ol>

<h5 id="calling-scripts">Calling scripts</h5>

<p>To <dfn export>run a classic script</dfn> given a <span>classic script</span> <var>script</var>
Expand Down

0 comments on commit f8f5f99

Please sign in to comment.