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

Skip to content

Commit 5af258f

Browse files
committed
Sync with recent changes to the JS spec's job queue
In tc39/ecma262@7032383, JS made the first step toward a more usable job queue setup by removing the script/module evaluation from InitializeHostDefinedRealm, and removing the special NextJob algorithm step for terminating jobs. This allows us to stop saying "Do not obtain any source texts for scripts or modules", and to stop overriding NextJob, instead moving the reaction step to our definition of EnqueueJob. As a drive-by fix, consistified HostPromiseRejectionTracker's heading to match those of the other host-defined abstract operations.
1 parent baa8e34 commit 5af258f

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

source

+15-32
Original file line numberDiff line numberDiff line change
@@ -3028,13 +3028,13 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
30283028
<li>The <dfn data-noexport="" data-x-href="https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys">OrdinaryOwnPropertyKeys</dfn> abstract operation</li>
30293029
<li>The <dfn data-noexport="" data-x="js-ParseModule" data-x-href="https://tc39.github.io/ecma262/#sec-parsemodule">ParseModule</dfn> abstract operation</li>
30303030
<li>The <dfn data-noexport="" data-x="js-ParseScript" data-x-href="https://tc39.github.io/ecma262/#sec-parse-script">ParseScript</dfn> abstract operation</li>
3031+
<li>The <dfn data-noexport="" data-x-href="https://tc39.github.io/ecma262/#sec-runjobs">RunJobs</dfn> abstract operation</li>
30313032
<li>The <dfn data-noexport="" data-x-href="https://tc39.github.io/ecma262/#sec-samevalue">SameValue</dfn> abstract operation</li>
30323033
<li>The <dfn data-noexport="" data-x="js-ScriptEvaluation" data-x-href="https://tc39.github.io/ecma262/#sec-runtime-semantics-scriptevaluation">ScriptEvaluation</dfn> abstract operation</li>
30333034
<li>The <dfn data-noexport="" data-x="js-ToBoolean" data-x-href="https://tc39.github.io/ecma262/#sec-toboolean">ToBoolean</dfn> abstract operation</li>
30343035
<li>The <dfn data-noexport="" data-x-href="https://tc39.github.io/ecma262/#sec-tostring">ToString</dfn> abstract operation</li>
30353036
<li>The <dfn data-noexport="" data-x-href="https://tc39.github.io/ecma262/#sec-touint32">ToUint32</dfn> abstract operation</li>
30363037
<li>The <dfn data-noexport="" data-x-href="https://tc39.github.io/ecma262/#typedarray-create">TypedArrayCreate</dfn> abstract operation</li>
3037-
<li>The <dfn data-noexport="" data-x="js-NextJob" data-x-href="https://tc39.github.io/ecma262/#sec-nextjob-result">NextJob</dfn> algorithm step
30383038
<li>The <dfn data-noexport="" data-x="js-abstract-equality" data-x-href="https://tc39.github.io/ecma262/#sec-abstract-equality-comparison">Abstract Equality Comparison</dfn> algorithm
30393039
<li>The <dfn data-noexport="" data-x="js-strict-equality" data-x-href="https://tc39.github.io/ecma262/#sec-strict-equality-comparison">Strict Equality Comparison</dfn> algorithm
30403040
<li>The <dfn data-noexport="" data-x-href="https://tc39.github.io/ecma262/#sec-date-objects"><code>Date</code></dfn> class
@@ -75977,8 +75977,6 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
7597775977

7597875978
<li><p>Let <var>realm execution context</var> be the created <span>JavaScript execution
7597975979
context</span>.</p></li>
75980-
75981-
<li><p>Do not obtain any source texts for scripts or modules.</p></li>
7598275980
</ul>
7598375981
</li>
7598475982

@@ -85693,22 +85691,24 @@ interface <dfn>NavigatorOnLine</dfn> {
8569385691
<p>The JavaScript specification defines the JavaScript job and job queue abstractions in order to
8569485692
specify certain invariants about how promise operations execute with a clean <span>JavaScript
8569585693
execution context stack</span> and in a certain order. However, as of the time of this writing
85696-
the definitions of <span data-x="js-EnqueueJob">EnqueueJob</span> and <span
85697-
data-x="js-NextJob">NextJob</span> in that specification are not sufficiently flexible to
85698-
integrate with HTML as a host environment. <ref spec="ECMA262"></p>
85694+
the definition of <span data-x="js-EnqueueJob">EnqueueJob</span> in that specification is not
85695+
sufficiently flexible to integrate with HTML as a host environment. <ref spec="ECMA262"></p>
8569985696

8570085697
<p class="note">This is not strictly true. It is in fact possible, by taking liberal advantage of
85701-
the many "implementation defined" sections of those algorithms, to contort them to our purposes.
85698+
the many "implementation defined" sections of the algorithm, to contort it to our purposes.
8570285699
However, the end result is a mass of messy indirection and workarounds that essentially bypasses
8570385700
the job queue infrastructure entirely, albeit in a way that is technically sanctioned within the
8570485701
bounds of implementation-defined behavior. We do not take this path, and instead introduce the
85705-
following <span data-x="willful violation">willful violations</span>.</p>
85702+
following <span>willful violation</span>.</p>
8570685703

85707-
<p>As such, user agents must instead use the following definitions in place of those in the
85704+
<p>As such, user agents must instead use the following definition in place of that in the
8570885705
JavaScript specification. These ensure that the promise jobs enqueued by the JavaScript
8570985706
specification are properly integrated into the user agent's <span data-x="event loop">event
8571085707
loops</span>.</p>
8571185708

85709+
<p>The <span>RunJobs</span> abstract operation from the JavaScript specification must
85710+
not be used by user agents.</p>
85711+
8571285712
<h6><dfn>EnqueueJob</dfn>(<var>queueName</var>, <var>job</var>, <var>arguments</var>)</h6>
8571385713

8571485714
<p>When the JavaScript specification says to call the EnqueueJob abstract operation, the
@@ -85728,28 +85728,15 @@ interface <dfn>NavigatorOnLine</dfn> {
8572885728
<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do
8572985729
not run" then abort these steps.</p></li>
8573085730
<li><p><span>Prepare to run script</span> with <var>settings</var>.</p></li>
85731-
<li><p>Perform the abstract operation specified by <var>job</var>, using the elements of
85732-
<var>arguments</var> as its arguments.</p></li>
85731+
<li><p>Let <var>result</var> be the result of performing the abstract operation specified by
85732+
<var>job</var>, using the elements of <var>arguments</var> as its arguments.</p></li>
8573385733
<li><p><span>Clean up after running script</span> with <var>settings</var>.</p></li>
85734+
<li><p>If <var>result</var> is an abrupt completion, <span>report the exception</span> given by
85735+
<var>result</var>.[[Value]].</p></li>
8573485736
</ol>
8573585737
</li>
8573685738
</ol>
8573785739

85738-
<h6><dfn>NextJob</dfn> <var>result</var></h6>
85739-
85740-
<p>When the JavaScript specification uses the algorithm step NextJob, the following steps must be
85741-
used in place of those specified by JavaScript's <span data-x="js-NextJob">NextJob</span>:</p>
85742-
85743-
<ol>
85744-
<li><p>If <var>result</var> is an abrupt completion, <span>report the exception</span> given by
85745-
<var>result</var>.[[Value]].</p></li>
85746-
</ol>
85747-
85748-
<p class="note">A more accurate name for our overridden version of NextJob would be along the
85749-
lines of "yield to host environment" or "allow host environment to react to job results". The
85750-
process of actually initiating the next job will be taken care of by the <span>event
85751-
loop</span>.</p>
85752-
8575385740
<h5>Integration with the JavaScript module system</h5>
8575485741

8575585742
<p>The JavaScript specification defines a syntax for modules, as well as some host-agnostic parts
@@ -85792,7 +85779,7 @@ interface <dfn>NavigatorOnLine</dfn> {
8579285779

8579385780
<p>JavaScript contains an implementation-defined <span
8579485781
data-x="js-HostResolveImportedModule">HostResolveImportedModule</span> abstract operation. User
85795-
agents must use the following implementation. <ref spec="ECMA262"></p>
85782+
agents must use the following implementation: <ref spec="ECMA262"></p>
8579685783

8579785784
<ol>
8579885785
<li><p>Let <var>referencing module script</var> be
@@ -86027,7 +86014,7 @@ dictionary <dfn>ErrorEventInit</dfn> : <span>EventInit</span> {
8602786014
be reported to a developer console.</p>
8602886015

8602986016

86030-
<h6>The HostPromiseRejectionTracker implementation</h6>
86017+
<h6 id="the-hostpromiserejectiontracker-implementation"><dfn>HostPromiseRejectionTracker</dfn>(<var>promise</var>, <var>operation</var>)</h6>
8603186018

8603286019
<p>JavaScript contains an implementation-defined <span
8603386020
data-x="js-HostPromiseRejectionTracker">HostPromiseRejectionTracker</span>(<var>promise</var>,
@@ -87789,8 +87776,6 @@ interface <dfn>WindowBase64</dfn> {
8778987776

8779087777
<li><p>Let <var>realm execution context</var> be the created <span>JavaScript execution
8779187778
context</span>.</p></li>
87792-
87793-
<li><p>Do not obtain any source texts for scripts or modules.</p></li>
8779487779
</ul>
8779587780
</li>
8779687781

@@ -94552,8 +94537,6 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> {
9455294537

9455394538
<li><p>Let <var>realm execution context</var> be the created <span>JavaScript execution
9455494539
context</span>.</p></li>
94555-
94556-
<li><p>Do not obtain any source texts for scripts or modules.</p></li>
9455794540
</ul>
9455894541
</li>
9455994542

0 commit comments

Comments
 (0)