Skip to content

Commit 7c3ff88

Browse files
authored
Stop requiring an event loop for queue a microtask
A microtask cannot cross the event loop boundary and thus necessarily has a surrounding agent. As such the event loop is always clear (but the document might not be). Without this you would get weird results in at least two cases: * A microtask would never run if it were queued on an event loop without tasks. * A microtask queued on another event loop could interleave microtasks on the currently running task of that event loop.
1 parent c63f712 commit 7c3ff88

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

source

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105762,8 +105762,7 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
105762105762
</li>
105763105763

105764105764
<li>
105765-
<p><span>Queue a microtask</span> on the <span>surrounding agent</span>'s <span
105766-
data-x="concept-agent-event-loop">event loop</span> to perform the following steps:</p>
105765+
<p><span>Queue a microtask</span> to perform the following steps:</p>
105767105766

105768105767
<ol>
105769105768
<li><p>If <var>job settings</var> is not null, then <span>check if we can run script</span>
@@ -106444,11 +106443,14 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
106444106443
</ol>
106445106444

106446106445
<p>To <dfn export>queue a microtask</dfn> which performs a series of steps <var>steps</var>,
106447-
optionally given an event loop <var>event loop</var> and a document <var>document</var>:</p>
106446+
optionally given a document <var>document</var>:</p>
106448106447

106449106448
<ol>
106450-
<li><p>If <var>event loop</var> was not given, set <var>event loop</var> to the <span>implied
106451-
event loop</span>.</p></li>
106449+
<li><p><span>Assert</span>: there is a <span>surrounding agent</span>. I.e., this algorithm is
106450+
not called while <span>in parallel</span>.</p></li>
106451+
106452+
<li><p>Let <var>eventLoop</var> be the <span>surrounding agent</span>'s <span
106453+
data-x="concept-agent-event-loop">event loop</span>.</p></li>
106452106454

106453106455
<li><p>If <var>document</var> was not given, set <var>document</var> to the <span>implied
106454106456
document</span>.</p></li>
@@ -106467,7 +106469,7 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
106467106469
<li><p>Set <var>microtask</var>'s <span>script evaluation environment settings object set</span>
106468106470
to an empty <span>set</span>.</p></li>
106469106471

106470-
<li><p><span>Enqueue</span> <var>microtask</var> on <var>event loop</var>'s <span>microtask
106472+
<li><p><span>Enqueue</span> <var>microtask</var> on <var>eventLoop</var>'s <span>microtask
106471106473
queue</span>.</p></li>
106472106474
</ol>
106473106475

@@ -106484,8 +106486,7 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
106484106486
exception is algorithms involving or specifying cross-agent communication (e.g., between a window
106485106487
and a worker); for those cases, the <span>implied event loop</span> concept must not be relied
106486106488
upon and specifications must explicitly provide an <span>event loop</span> when <span
106487-
data-x="queue a task">queuing a task</span> or <span data-x="queue a
106488-
microtask">microtask</span>.</p>
106489+
data-x="queue a task">queuing a task</span>.</p>
106489106490

106490106491
<p>The <dfn>implied document</dfn> when queuing a task on an <span>event loop</span> <var>event
106491106492
loop</var> is determined as follows:</p>

0 commit comments

Comments
 (0)