Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More explicitly associate agents and event loops #5416

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 36 additions & 28 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -78561,8 +78561,8 @@ interface <dfn>BarProp</dfn> {
</dd>

<dt>The <span>responsible event loop</span></dt>
<dd><p>Return the <span>event loop</span> associated with <var>window</var>'s <span>relevant
agent</span>.</p></dd>
<dd><p>Return <var>window</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span>.</p></dd>

<dt>The <span>responsible document</span></dt>
<dd>
Expand Down Expand Up @@ -87972,8 +87972,8 @@ document.querySelector("button").addEventListener("click", bound);
</li>

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

<ol>
<li><p>If <var>job settings</var> is not null, then <span>check if we can run script</span>
Expand Down Expand Up @@ -88895,14 +88895,16 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {

<p>To coordinate events, user interaction, scripts, rendering, networking, and so forth, user
agents must use <dfn data-x="event loop" data-lt="event loop" data-export="">event loops</dfn> as
described in this section. Each <span>agent</span> has an associated <span>event loop</span>,
which is unique to that agent.</p>
described in this section. Each <span>agent</span> has an associated <dfn data-export=""
data-dfn-for="agent" data-x="concept-agent-event-loop">event loop</dfn>, which is unique to that
agent.</p>

<p>The <span>event loop</span> of a <span>similar-origin window agent</span> is known as a
<dfn>window event loop</dfn>. The <span>event loop</span> of a <span>dedicated worker
agent</span>, <span>shared worker agent</span>, or <span>service worker agent</span> is known as a
<dfn>worker event loop</dfn>. And the <span>event loop</span> of a <span>worklet agent</span> is
known as a <dfn>worklet event loop</dfn>.</p>
<p>The <span data-x="concept-agent-event-loop">event loop</span> of a <span>similar-origin window
agent</span> is known as a <dfn>window event loop</dfn>. The <span
data-x="concept-agent-event-loop">event loop</span> of a <span>dedicated worker agent</span>,
<span>shared worker agent</span>, or <span>service worker agent</span> is known as a <dfn>worker
event loop</dfn>. And the <span data-x="concept-agent-event-loop">event loop</span> of a
<span>worklet agent</span> is known as a <dfn>worklet event loop</dfn>.</p>

<div class="note">
<p><span data-x="event loop">Event loops</span> do not necessarily correspond to implementation
Expand Down Expand Up @@ -89061,7 +89063,7 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {

<li><p>Let <var>event loop</var> be <var>document</var>'s <span
data-x="concept-relevant-realm">relevant realm</span>'s corresponding <span>agent</span>'s
<span>event loop</span>.</p></li>
<span data-x="concept-agent-event-loop">event loop</span>.</p></li>

<li><p><span>Queue a task</span> given <var>source</var>, <var>event loop</var>,
<var>document</var>, and <var>steps</var>.</p></li>
Expand Down Expand Up @@ -89209,8 +89211,8 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
<ol>
<li>
<p>Let <var>docs</var> be all <code>Document</code> objects whose <span>relevant
agent</span>'s <span>event loop</span> is this event loop, sorted arbitrarily except that the
following conditions must be met:</p>
agent</span>'s <span data-x="concept-agent-event-loop">event loop</span> is this event loop,
sorted arbitrarily except that the following conditions must be met:</p>

<ul>
<li><p>Any <code>Document</code> <var>B</var> whose <span
Expand Down Expand Up @@ -89367,8 +89369,9 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
</ul>

<p>then for each <code>Window</code> object whose whose <span>relevant agent</span>'s
<span>event loop</span> is this event loop, run the <span>start an idle period
algorithm</span>, passing the <code>Window</code>. <ref spec="REQUESTIDLECALLBACK"></p>
<span data-x="concept-agent-event-loop">event loop</span> is this event loop, run the
<span>start an idle period algorithm</span>, passing the <code>Window</code>. <ref
spec="REQUESTIDLECALLBACK"></p>
</li>

<li>
Expand Down Expand Up @@ -96161,8 +96164,8 @@ function receiver(e) {

<li>
<p><span>Queue a task</span> on the <dfn>posted message task source</dfn> of
<var>targetWindow</var>'s <span>relevant agent</span>'s <span>event loop</span> to run the
following steps:</p>
<var>targetWindow</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span> to run the following steps:</p>

<ol>
<li><p>If the <var>targetOrigin</var> argument is not a single literal U+002A ASTERISK character
Expand Down Expand Up @@ -96981,11 +96984,11 @@ interface <dfn>BroadcastChannel</dfn> : <span>EventTarget</span> {
<li>
<p>For each <code>BroadcastChannel</code> object <var>destination</var> in
<var>destinations</var>, <span>queue a task</span> on the <span>DOM manipulation task
source</span> of <var>destination</var>'s <span>relevant agent</span>'s <span>event loop</span>
that runs the following steps. If that event loop is a <span>window event loop</span>, then the
<span data-x="concept-task">task</span>'s <span data-x="concept-task-document">document</span>
must be set to <var>destination</var>'s <span><code>BroadcastChannel</code> settings
object</span>'s <span>responsible document</span>.</p>
source</span> of <var>destination</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span> that runs the following steps. If that event
loop is a <span>window event loop</span>, then the <span data-x="concept-task">task</span>'s
<span data-x="concept-task-document">document</span> must be set to <var>destination</var>'s
<span><code>BroadcastChannel</code> settings object</span>'s <span>responsible document</span>.</p>

<ol>
<li><p>If <var>destination</var>'s <span data-x="concept-BroadcastChannel-closed">closed
Expand Down Expand Up @@ -97694,7 +97697,8 @@ interface <dfn>DedicatedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span>

<ol>
<li><p>Discard any <span data-x="concept-task">tasks</span> that have been added to
<var>workerGlobal</var>'s <span>event loop</span>'s <span data-x="task queue">task
<var>workerGlobal</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span>'s <span data-x="task queue">task
queues</span>.</p>

<li><p>Set <var>workerGlobal</var>'s <span data-x="dom-WorkerGlobalScope-closing">closing</span>
Expand Down Expand Up @@ -98132,7 +98136,8 @@ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
data-x="dom-WorkerGlobalScope-closing">closing</span> flag to true.</p></li>

<li><p>If there are any <span data-x="concept-task">tasks</span> queued in the
<code>WorkerGlobalScope</code> object's <span>event loop</span>'s <span data-x="task queue">task
<code>WorkerGlobalScope</code> object's <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span>'s <span data-x="task queue">task
queues</span>, discard them without processing them.</p></li>

<li><p><span data-x="abort a running script">Abort the script</span> currently running in the
Expand Down Expand Up @@ -98245,15 +98250,18 @@ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
<li><p>Let <var>inherited origin</var> be <var>outside settings</var>'s <span
data-x="concept-settings-object-origin">origin</span>.</p></li>

<li><p>Let <var>worker event loop</var> be a newly created <span>worker event
loop</span>.</p></li>

<li><p>Let <var>realm</var> be the value of <var>execution context</var>'s Realm
component.</p></li>

<li><p>Let <var>worker global scope</var> be <var>realm</var>'s <span
data-x="concept-realm-global">global object</span>.</p></li>

<li><p>Let <var>worker event loop</var> be a newly created <span>worker event
loop</span>.</p></li>

<li><p>Set <var>worker global scope</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span> to <var>worker event loop</var>.</p></li>

<li>
<p>Let <var>settings object</var> be a new <span>environment settings object</span> whose algorithms
are defined as follows:</p>
Expand Down