Skip to content

Commit

Permalink
Top-level await integration
Browse files Browse the repository at this point in the history
Integrates HTML with the JavaScript top-level await feature:
https://github.com/tc39/proposal-top-level-await

Co-authored-by: Domenic Denicola <d@domenic.me>
Co-authored-by: Ms2ger <Ms2ger@igalia.com>
  • Loading branch information
3 people authored Dec 10, 2020
1 parent 009a731 commit fee73fa
Showing 1 changed file with 30 additions and 49 deletions.
79 changes: 30 additions & 49 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2654,6 +2654,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
sequence of Unicode scalar values</dfn></li>
<li><dfn data-x-href="https://heycam.github.io/webidl/#dfn-overload-resolution-algorithm">overload resolution algorithm</dfn></li>
<li><dfn data-x="idl-exposed" data-x-href="https://heycam.github.io/webidl/#dfn-exposed">exposed</dfn></li>
<li><dfn data-x-href="https://heycam.github.io/webidl/#a-promise-rejected-with">a promise rejected with</dfn></li>
<li><dfn data-x-href="https://heycam.github.io/webidl/#upon-rejection">upon rejection</dfn></li>
<li><dfn data-x="LegacyFactoryFunction" data-x-href="https://heycam.github.io/webidl/#LegacyFactoryFunction"><code>[LegacyFactoryFunction]</code></dfn></li>
<li><dfn data-x="LegacyLenientThis" data-x-href="https://heycam.github.io/webidl/#LegacyLenientThis"><code>[LegacyLenientThis]</code></dfn></li>
<li><dfn data-x="LegacyNullToEmptyString" data-x-href="https://heycam.github.io/webidl/#LegacyNullToEmptyString"><code>[LegacyNullToEmptyString]</code></dfn></li>
Expand Down Expand Up @@ -2867,6 +2869,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

<p>Users agents that support JavaScript must also implement <cite>ECMAScript
Internationalization API</cite>. <ref spec=JSINTL></p>

<p>User agents that support JavaScript must also implement the <cite>Top-Level Await</cite>
proposal. <ref spec=JSTLA></p>
</dd>


Expand Down Expand Up @@ -89007,11 +89012,9 @@ document.querySelector("button").addEventListener("click", bound);
<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>
and an optional <var>rethrow errors</var> boolean:</p>
and an optional boolean <var>rethrow errors</var> (default false):</p>

<ol>
<li><p>If <var>rethrow errors</var> is not given, let it be false.</p></li>

<li><p>Let <var>settings</var> be the <span>settings object</span> of <var>script</var>.</p></li>

<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do
Expand Down Expand Up @@ -89088,25 +89091,23 @@ document.querySelector("button").addEventListener("click", bound);
</p></li>
</ol>

<p>To <dfn export>run a module script</dfn> given a <span>module script</span> <var>script</var>,
with an optional <var>rethrow errors</var> boolean:</p>
<p>To <dfn export>run a module script</dfn> given a <span>module script</span> <var>script</var>
and an optional boolean <var>preventErrorReporting</var> (default false):</p>

<ol>
<li><p>If <var>rethrow errors</var> is not given, let it be false.</p></li>

<li><p>Let <var>settings</var> be the <span>settings object</span> of <var>script</var>.</p></li>

<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do
not run" then return <span>NormalCompletion</span>(empty).</p></li>
not run", then return a promise resolved with undefined.</p></li>

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

<li><p>Let <var>evaluationStatus</var> be null.</p></li>
<li><p>Let <var>evaluationPromise</var> be null.</p></li>

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

<li>
<p>Otherwise:</p>
Expand All @@ -89116,35 +89117,26 @@ document.querySelector("button").addEventListener("click", bound);
data-x="concept-script-record">record</span>.</p>

<li>
<p>Set <var>evaluationStatus</var> to <var>record</var>.<span
<p>Set <var>evaluationPromise</var> to <var>record</var>.<span
data-x="js-Evaluate">Evaluate</span>().</p>

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

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

<li>
<p>If <var>evaluationStatus</var> is an <span>abrupt completion</span>, then:</p>

<ol>
<li><p>If <var>rethrow errors</var> is true, rethrow the exception given by
<var>evaluationStatus</var>.[[Value]].</p></li>

<li><p>Otherwise, <span>report the exception</span> given by
<var>evaluationStatus</var>.[[Value]] for <var>script</var>.</p></li>
</ol>
</li>
<li><p>If <var>preventErrorReporting</var> is false, then <span>upon rejection</span> of
<var>evaluationPromise</var> with <var>reason</var>, <span>report the exception</span> given by
<var>reason</var> for <var>script</var>.</p></li>

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

<li><p>Return <var>evaluationStatus</var>.</p></li>
<li><p>Return <var>evaluationPromise</var>.</p></li>
</ol>

<p>The steps to <dfn>check if we can run script</dfn> with an <span>environment settings
Expand Down Expand Up @@ -89912,30 +89904,16 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
URL</var>, <var>settings object</var>, and <var>fetch options</var>. Wait until the algorithm
asynchronously completes with <var>result</var>.</p></li>

<li>
<p>If <var>result</var> is null, then:</p>

<ol>
<li><p>Let <var>completion</var> be Completion { [[Type]]: throw, [[Value]]: a new
<code>TypeError</code>, [[Target]]: empty }.</p></li>

<li><p>Perform <span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>,
<var>specifier</var>, <var>promiseCapability</var>, <var>completion</var>).</p></li>
<li><p>Let <var>promise</var> be null.

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

<li><p><span data-x="run a module script">Run the module script</span> <var>result</var>, with
the rethrow errors boolean set to true.</p></li>
<li><p>If <var>result</var> is null, then set <var>promise</var> to <span>a promise rejected
with</span> a new <code>TypeError</code>.</p></li>

<li><p>If running the module script throws an exception, then perform
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
<var>promiseCapability</var>, the thrown exception completion).</p></li>
<li><p>Otherwise, set <var>promise</var> to the result of <span data-x="run a module
script">running a module script</span> given <var>result</var> and true.</p></li>

<li><p>Otherwise, perform
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
<var>promiseCapability</var>, <span>NormalCompletion</span>(undefined)).</p></li>
<li><p>Perform <span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>,
<var>specifier</var>, <var>promiseCapability</var>, <var>promise</var>).</p></li>

<li><p>Return undefined.</p></li>
</ol>
Expand Down Expand Up @@ -122588,6 +122566,9 @@ INSERT INTERFACES HERE
<dt id="refsJSINTL">[JSINTL]</dt>
<dd><cite><a href="https://tc39.es/ecma402/">ECMAScript Internationalization API Specification</a></cite>. Ecma International.</dd>

<dt id="refsJSTLA">[JSTLA]</dt>
<dd><cite><a href="https://tc39.es/proposal-top-level-await/">Top-Level Await</a></cite>. Ecma International.</dd>

<dt id="refsJSON">[JSON]</dt>
<dd><cite><a href="https://tools.ietf.org/html/rfc7159">The JavaScript Object Notation (JSON) Data Interchange Format</a></cite>, T. Bray. IETF.</dd>

Expand Down

0 comments on commit fee73fa

Please sign in to comment.