Skip to content

Commit 8415c83

Browse files
committed
Rebase on top of the current TLA draft
- Evaluate() may return undefined, an abrupt completion, or a Promise. Handle all of these cases. - Move logic for waiting on a returned Promise from the import() draft spec to HTML, for simplicitly.
1 parent 36e321b commit 8415c83

File tree

1 file changed

+61
-40
lines changed

1 file changed

+61
-40
lines changed

source

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,6 +3061,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
30613061
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-isconstructor">IsConstructor</dfn> abstract operation</li>
30623062
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-isdatadescriptor">IsDataDescriptor</dfn> abstract operation</li>
30633063
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-isdetachedbuffer">IsDetachedBuffer</dfn> abstract operation</li>
3064+
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-ispromise">IsPromise</dfn> abstract operation</li>
30643065
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-issharedarraybuffer">IsSharedArrayBuffer</dfn> abstract operation</li>
30653066
<li>The <dfn data-x="js-NewObjectEnvironment" data-x-href="https://tc39.github.io/ecma262/#sec-newobjectenvironment">NewObjectEnvironment</dfn> abstract operation</li>
30663067
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-normalcompletion">NormalCompletion</dfn> abstract operation</li>
@@ -3120,12 +3121,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
31203121
<p>User agents that support JavaScript must also implement the <cite>BigInt</cite> proposal. <ref
31213122
spec=JSBIGINT></p>
31223123

3123-
<p>User agents that support JavaScript must also implement the <cite>top-level await</cite> proposal.
3124-
The following terms are defined there, and used in this specification: <ref spec=JSTLA></p>
3124+
<p>User agents that support JavaScript must also implement the <cite>top-level await</cite>
3125+
proposal: <ref spec=JSTLA></p>
31253126

3126-
<ul class="brief">
3127-
<li><dfn data-x="js-FlushJobs" data-x-href="https://tc39.github.io/proposal-top-level-await/#sec-flushjobs"><code>FlushJobs</code></dfn></li>
3128-
</ul>
31293127
</dd>
31303128

31313129

@@ -87768,9 +87766,12 @@ interface <dfn>ApplicationCache</dfn> : <span>EventTarget</span> {
8776887766

8776987767
<li><p><span>Prepare to run script</span> given <var>settings</var>.</p></li>
8777087768

87769+
<li><p>Let <var>evaluationStatus</var> be null.</p></li>
87770+
8777187771
<li><p>If <var>script</var>'s <span data-x="concept-script-error-to-rethrow">error to
87772-
rethrow</span> is not null, then let <var>evaluationPromise</var> be a promise rejected with <var>script</var>'s <span data-x="concept-script-error-to-rethrow">error to
87773-
rethrow</span>.</p></li>
87772+
rethrow</span> is not null, then set <var>evaluationStatus</var> to Completion { [[Type]]: throw,
87773+
[[Value]]: <var>script</var>'s <span data-x="concept-script-error-to-rethrow">error to
87774+
rethrow</span>, [[Target]]: empty }.</p></li>
8777487775

8777587776
<li>
8777687777
<p>Otherwise:</p>
@@ -87780,26 +87781,44 @@ interface <dfn>ApplicationCache</dfn> : <span>EventTarget</span> {
8778087781
data-x="concept-script-record">record</span>.</p>
8778187782

8778287783
<li>
87783-
<p>Let <var>evaluationPromise</var> be <var>record</var>.<span
87784+
<p>Set <var>evaluationStatus</var> to <var>record</var>.<span
8778487785
data-x="js-Evaluate">Evaluate</span>().</p>
8778587786

8778687787
<p class="note">This step will recursively evaluate all of the module's dependencies.</p>
8778787788

8778887789
<p>If <span data-x="js-Evaluate">Evaluate</span> fails to complete as a result of the user agent
87789-
<span data-x="abort a running script">aborting the running script</span>, then let
87790-
<var>evaluationPromise</var> be a promise rejected with a new
87791-
<span>"<code>QuotaExceededError</code>"</span> <code>DOMException</code>.</p>
87790+
<span data-x="abort a running script">aborting the running script</span>, then set
87791+
<var>evaluationStatus</var> to Completion { [[Type]]: throw, [[Value]]: a new
87792+
<span>"<code>QuotaExceededError</code>"</span> <code>DOMException</code>, [[Target]]: empty
87793+
}.</p>
8779287794
</li>
8779387795
</ol>
8779487796
</li>
8779587797

87796-
<li><p>If <var>rethrow errors</var> is false, then upon rejection of
87797-
<var>evaluationPromise</var>, <span>report the exception</span> given by
87798+
<li>
87799+
<p>If <var>evaluationStatus</var> is an <span>abrupt completion</span>, then:</p>
87800+
87801+
<ol>
87802+
<li><p>If <var>rethrow errors</var> is true, rethrow the exception given by
87803+
<var>evaluationStatus</var>.[[Value]].</p></li>
87804+
87805+
<li><p>Otherwise, <span>report the exception</span> given by
8779887806
<var>evaluationStatus</var>.[[Value]] for <var>script</var>.</p></li>
87807+
</ol>
87808+
</li>
87809+
87810+
<li>
87811+
<p>If <span>IsPromise</span>(<var>evaluationStatus</var>) is true, then:</p>
87812+
87813+
<ol>
87814+
<li><p>Upon rejection of <var>evaluationStatus</var> with <var>reason</var>,
87815+
<span>report the exception</span> given by <var>reason</var> for <var>script</var>.</p></li>
87816+
</ol>
87817+
</li>
8779987818

8780087819
<li><p><span>Clean up after running script</span> with <var>settings</var>.</p></li>
8780187820

87802-
<li><p>Return <var>evaluationPromise</var>.</p></li>
87821+
<li><p>Return <var>evaluationStatus</var>.</p></li>
8780387822
</ol>
8780487823

8780587824
<p>The steps to <dfn>check if we can run script</dfn> with an <span>environment settings
@@ -88601,24 +88620,6 @@ document.querySelector("button").addEventListener("click", bound);
8860188620
</li>
8860288621
</ol>
8860388622

88604-
<h6><dfn>FlushJobs</dfn>()</h6>
88605-
88606-
<p>When the JavaScript specification says to call the FlushJobs abstract operation, the
88607-
following algorithm must be used in place of JavaScript's <span
88608-
data-x="js-FlushJobs">FlushJobs</span>:</p>
88609-
88610-
<ol>
88611-
<li><p>Assert: the <span>JavaScript execution context stack</span> is empty</p></li>
88612-
88613-
<li>
88614-
<p><span>Perform a microtask checkpoint</span>.</p>
88615-
88616-
<p class="&#x0058;&#x0058;&#x0058;">Rather than simply a microtask checkpoint,
88617-
this algorithm may yield to the event loop before continuing; see discussion in <a
88618-
href="https://github.com/whatwg/html/issues/4400">issue #4400</a>.</p>
88619-
</li>
88620-
88621-
</ol>
8862288623
</div>
8862388624

8862488625
<h5>Integration with the JavaScript module system</h5>
@@ -88895,10 +88896,11 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
8889588896
<p>If <var>url</var> is failure, then:</p>
8889688897

8889788898
<ol>
88898-
<li><p>Let <var>promise</var> be a promise rejected with a new <code>TypeError</code>.</p></li>
88899+
<li><p>Let <var>completion</var> be Completion { [[Type]]: throw, [[Value]]: a new
88900+
<code>TypeError</code>, [[Target]]: empty }.</p></li>
8889988901

8890088902
<li><p>Perform <span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>,
88901-
<var>specifier</var>, <var>promiseCapability</var>, <var>promise</var>).</p></li>
88903+
<var>specifier</var>, <var>promiseCapability</var>, <var>completion</var>).</p></li>
8890288904

8890388905
<li><p>Return.</p></li>
8890488906
</ol>
@@ -88912,23 +88914,42 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
8891288914
<p>If <var>result</var> is null, then:</p>
8891388915

8891488916
<ol>
88915-
<li><p>Let <var>promise</var> be a promise rejected with a new <code>TypeError</code>.</p></li>
88917+
<li><p>Let <var>completion</var> be Completion { [[Type]]: throw, [[Value]]: a new
88918+
<code>TypeError</code>, [[Target]]: empty }.</p></li>
8891688919

8891788920
<li><p>Perform <span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>,
88918-
<var>specifier</var>, <var>promiseCapability</var>, <var>promise</var>).</p></li>
88921+
<var>specifier</var>, <var>promiseCapability</var>, <var>completion</var>).</p></li>
8891988922

8892088923
<li><p>Return.</p></li>
8892188924
</ol>
8892288925
</li>
8892388926

8892488927
<li><p><span data-x="run a module script">Run the module script</span> <var>result</var>, with
88925-
the rethrow errors boolean set to true, and let the result be <var>promise</var>.</p></li>
88928+
the rethrow errors boolean set to true, and let the result be <var>status</var>.</p></li>
8892688929

88927-
<li><p>Perform
88930+
<li><p>If running the module script throws an exception, then perform
8892888931
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
88929-
<var>promiseCapability</var>, <var>promise</var>).</p></li>
88932+
<var>promiseCapability</var>, the thrown exception completion).</p></li>
8893088933

88931-
<li><p>Return.</p></li>
88934+
<li>
88935+
<p>If <span>IsPromise</span>(<var>status</var>) is true, then:</p>
88936+
88937+
<ol>
88938+
<li>Upon fulfillment of <var>status</var> with <var>value</var>, perform
88939+
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
88940+
<var>promiseCapability</var>, <var>value</var>).</li>
88941+
88942+
<li>Upon rejection of <var>status</var> with <var>reason</var>, perform
88943+
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
88944+
<var>promiseCapability</var>, Completion{ [[Type]]: throw, [[Value]]: <var>reason</var> }).</li>
88945+
</ol>
88946+
</li>
88947+
88948+
<li><p>Otherwise, perform
88949+
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
88950+
<var>promiseCapability</var>, <span>NormalCompletion</span>(undefined)).</p></li>
88951+
88952+
<li><p>Return undefined.</p></li>
8893288953
</ol>
8893388954

8893488955
<h6

0 commit comments

Comments
 (0)