Skip to content

Commit db370e7

Browse files
committed
Fix HostResolveImportedModule's current realm handling
If this is called as part of module script loading of a dependency, there is no current realm. But we don't actually need the current realm, except in the case of a top-level import() inside an event handler, in which case there *will* be a current realm. Rearrange the logic of the algorithm to only look at the current realm (or rather, current settings object) in that later case. Also removes some vestigial base URL stuff, and camel-cases all the variable names. Closes #8410.
1 parent 478e131 commit db370e7

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

source

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94860,9 +94860,7 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
9486094860
<var>referringScript</var> and a <span>string</span> <var>specifier</var>:</p>
9486194861

9486294862
<ol>
94863-
<li><p>Let <var>settingsObject</var> be the <span>current settings object</span>.</p></li>
94864-
94865-
<li><p>Let <var>baseURL</var> be <var>settingsObject</var>'s <span>API base URL</span>.</p></li>
94863+
<li><p>Let <var>settingsObject</var> and <var>baseURL</var> be null.</p></li>
9486694864

9486794865
<li>
9486894866
<p>If <var>referringScript</var> is not null, then:</p>
@@ -94876,6 +94874,19 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
9487694874
</ol>
9487794875
</li>
9487894876

94877+
<li>
94878+
<p>Otherwise:</p>
94879+
94880+
<ol>
94881+
<li><p><span>Assert</span>: there is a <span>current settings object</span>.</p></li>
94882+
94883+
<li><p>Set <var>settingsObject</var> to the <span>current settings object</span>.</p></li>
94884+
94885+
<li><p>Set <var>baseURL</var> to <var>settingsObject</var>'s <span>API base
94886+
URL</span>.</p></li>
94887+
</ol>
94888+
</li>
94889+
9487994890
<li><p>Let <var>importMap</var> be an <span>empty import map</span>.</p></li>
9488094891

9488194892
<li><p>If <var>settingsObject</var>'s <span data-x="concept-settings-object-global">global
@@ -96187,25 +96198,28 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
9618796198
agents must use the following implementation: <ref spec=JAVASCRIPT></p>
9618896199

9618996200
<ol>
96190-
<li><p>Let <var>settings object</var> be the <span>current settings object</span>.</p></li>
96191-
96192-
<li><p>Let <var>referencing script</var> be null.</p></li>
96201+
<li><p>Let <var>moduleMap</var> and <var>referencingScript</var> be null.</p></li>
9619396202

9619496203
<li>
9619596204
<p>If <var>referencingScriptOrModule</var> is not null, then:</p>
9619696205

9619796206
<ol>
96198-
<li><p>Set <var>referencing script</var> to
96207+
<li><p>Set <var>referencingScript</var> to
9619996208
<var>referencingScriptOrModule</var>.[[HostDefined]].</p></li>
9620096209

96201-
<li><p>Set <var>settings object</var> to <var>referencing script</var>'s <span>settings
96202-
object</span>.</p></li>
96210+
<li><p>Set <var>moduleMap</var> to <var>referencingScript</var>'s <span>settings
96211+
object</span>'s <span data-x="concept-settings-object-module-map">module map</span>.</p></li>
96212+
</ol>
96213+
</li>
9620396214

96204-
<li><p>Set <var>base URL</var> to <var>referencing script</var>'s <span
96205-
data-x="concept-script-base-url">base URL</span>.</p></li>
96215+
<li>
96216+
<p>Otherwise:</p>
96217+
96218+
<ol>
96219+
<li><p><span>Assert</span>: there is a <span>current settings object</span>.</p></li>
9620696220

96207-
<li><p><span>Assert</span>: <var>base URL</var> is not null, as <var>referencing script</var>
96208-
is a <span>classic script</span> or a <span>JavaScript module script</span>.</p></li>
96221+
<li><p>Set <var>moduleMap</var> to the <span>current settings object</span>'s <span
96222+
data-x="concept-settings-object-module-map">module map</span>.</p></li>
9620996223
</ol>
9621096224

9621196225
<div class="example">
@@ -96223,33 +96237,30 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
9622396237
</div>
9622496238
</li>
9622596239

96226-
<li><p>Let <var>moduleMap</var> be <var>settings object</var>'s <span
96227-
data-x="concept-settings-object-module-map">module map</span>.</p></li>
96228-
9622996240
<li><p>Let <var>url</var> be the result of <span data-x="resolve a module specifier">resolving a
96230-
module specifier</span> given <var>referencing script</var> and
96241+
module specifier</span> given <var>referencingScript</var> and
9623196242
<var>moduleRequest</var>.[[Specifier]].</p></li>
9623296243

9623396244
<li><p><span>Assert</span>: the previous step never throws an exception, because <span
96234-
data-x="resolve a module specifier">resolving a module specifier</span> must have been previously
96235-
successful with these same two arguments (either <a
96245+
data-x="resolve a module specifier">resolving a module specifier</span> must have been
96246+
previously successful with these same two arguments (either <a
9623696247
href="#validate-requested-module-specifiers">while creating the corresponding module script</a>,
9623796248
or in <span>fetch an import() module script graph</span>).</p></li>
9623896249

9623996250
<li><p>Let <var>moduleType</var> be the result of running the <span>module type from module
9624096251
request</span> steps given <var>moduleRequest</var>.</p></li>
9624196252

96242-
<li><p>Let <var>resolved module script</var> be <var>moduleMap</var>[(<var>url</var>,
96253+
<li><p>Let <var>resolvedModuleScript</var> be <var>moduleMap</var>[(<var>url</var>,
9624396254
<var>moduleType</var>)]. (This entry must <span data-x="map exists">exist</span> for us to have
9624496255
gotten to this point.)</p></li>
9624596256

96246-
<li><p><span>Assert</span>: <var>resolved module script</var> is a <span>module script</span>
96257+
<li><p><span>Assert</span>: <var>resolvedModuleScript</var> is a <span>module script</span>
9624796258
(i.e., is not null or "<code data-x="">fetching</code>").</p></li>
9624896259

96249-
<li><p><span>Assert</span>: <var>resolved module script</var>'s <span
96260+
<li><p><span>Assert</span>: <var>resolvedModuleScript</var>'s <span
9625096261
data-x="concept-script-record">record</span> is not null.</p>
9625196262

96252-
<li><p>Return <var>resolved module script</var>'s <span
96263+
<li><p>Return <var>resolvedModuleScript</var>'s <span
9625396264
data-x="concept-script-record">record</span>.</p></li>
9625496265
</ol>
9625596266

@@ -129531,6 +129542,7 @@ INSERT INTERFACES HERE
129531129542
Neil Rashbrook,
129532129543
Neil Soiffer,
129533129544
Nereida Rondon,
129545+
networkException,
129534129546
Nicholas Shanks,
129535129547
Nicholas Stimpson,
129536129548
Nicholas Zakas,

0 commit comments

Comments
 (0)