Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12cdfef

Browse files
authored
Fix import() inside setTimeout()/setInterval() strings
Closes whatwg#3116. Before this change, the "new script"-ness of setTimeout() and setInterval()'s string compilation was making any import() calls inside the compiled source behave unexpectedly. After this, they behave like eval().
1 parent a093d3d commit 12cdfef

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

source

+34-6
Original file line numberDiff line numberDiff line change
@@ -91221,6 +91221,11 @@ document.body.appendChild(frame)</pre>
9122191221
<li><p>Let <var>callerRealm</var> be the <span>current Realm Record</span>, and
9122291222
<var>calleeRealm</var> be <var>method context</var>'s <span>JavaScript realm</span>.</p></li>
9122391223

91224+
<li><p>Let <var>initiating script</var> be the <span>active script</span>.</p></li>
91225+
91226+
<li><p>Assert: <var>initiating script</var> is not null, since this algorithm is always called
91227+
from some script.</p></li>
91228+
9122491229
<li>
9122591230

9122691231
<p>Let <var>task</var> be a <span data-x="concept-task">task</span> that runs the
@@ -91255,20 +91260,43 @@ document.body.appendChild(frame)</pre>
9125591260
<ol>
9125691261
<li><p>Perform <span
9125791262
data-x="the-hostensurecancompilestrings-implementation">HostEnsureCanCompileStrings</span>(<var>callerRealm</var>,
91258-
<var>calleeRealm</var>). If this throws an exception, catch it, and <span>report the
91259-
exception</span>.</p></li>
91263+
<var>calleeRealm</var>). If this throws an exception, catch it, <span>report the
91264+
exception</span>, and abort these steps.</p></li>
9126091265

9126191266
<li><p>Let <var>script source</var> be the first method argument.</p></li>
9126291267

9126391268
<li><p>Let <var>settings object</var> be <var>method context</var>'s <span>environment
9126491269
settings object</span>.</p></li>
9126591270

91266-
<li><p>Let <var>base URL</var> be <var>settings object</var>'s <span>API base
91267-
URL</span>.</p></li>
91271+
<li><p>Let <var>base URL</var> be <var>initiating script</var>'s <span
91272+
data-x="concept-script-base-url">base URL</span>.</p></li>
91273+
91274+
<li>
91275+
<p>Let <var>fetch options</var> be a <span>script fetch options</span> whose <span
91276+
data-x="concept-script-fetch-options-nonce">cryptographic nonce</span> is <var>initiating
91277+
script</var>'s <span data-x="concept-script-script-fetch-options">fetch options</span>'s
91278+
<span data-x="concept-script-fetch-options-nonce">cryptographic nonce</span>, <span
91279+
data-x="concept-script-fetch-options-integrity">integrity metadata</span> is the empty
91280+
string, <span data-x="concept-script-fetch-options-parser">parser metadata</span> is
91281+
"<code data-x="">not-parser-inserted</code>", <span
91282+
data-x="concept-script-fetch-options-credentials">credentials mode</span> is
91283+
<var>initiating script</var>'s <span data-x="concept-script-script-fetch-options">fetch
91284+
options</span>'s <span data-x="concept-script-fetch-options-credentials">credentials
91285+
mode</span>, and <span data-x="concept-script-fetch-options-referrer-policy">referrer
91286+
policy</span> is <var>initiating script</var>'s <span
91287+
data-x="concept-script-script-fetch-options">fetch options</span>'s <span
91288+
data-x="concept-script-fetch-options-referrer-policy">referrer policy</span>.</p>
91289+
91290+
<p class="note">The effect of these options ensures that the string compilation done by
91291+
<code data-x="dom-setTimeout">setTimeout()</code> and <code
91292+
data-x="dom-setInterval">setInterval()</code> behaves equivalently to that done by
91293+
<code>eval()</code>. That is, <span>module script</span> fetches via <code>import()</code>
91294+
will behave the same in both contexts.</p>
91295+
</li>
9126891296

9126991297
<li><p>Let <var>script</var> be the result of <span>creating a classic script</span> given
91270-
<var>script source</var>, <var>settings object</var>, <var>base URL</var>, and the
91271-
<span>default classic script fetch options</span>.</p></li>
91298+
<var>script source</var>, <var>settings object</var>, <var>base URL</var>, and <var>fetch
91299+
options</var>.</p></li>
9127291300

9127391301
<li><p><span data-x="run a classic script">Run the classic script</span>
9127491302
<var>script</var>.</p></li>

0 commit comments

Comments
 (0)