From b95c755f0138f39e94dfa88b49398e9bcfcb24db Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Mon, 30 Mar 2020 13:12:59 -0400 Subject: [PATCH] More explicitly associate agents and event loops This adds a specific definition for "an agent's event loop", as opposed to "event loop" generally, and uses it where appropriate. In a few cases, this involves moving from "object's event loop" to "object's relevant agent's event loop". Note that for worker agents, event loop creation and association with the agent is explicit. For window agents there is no corresponding text. This can be settled as part of #5411. --- source | 64 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/source b/source index 508333b06a6..cdbf831465c 100644 --- a/source +++ b/source @@ -78561,8 +78561,8 @@ interface BarProp {
The responsible event loop
-

Return the event loop associated with window's relevant - agent.

+

Return window's relevant agent's event loop.

The responsible document
@@ -87972,8 +87972,8 @@ document.querySelector("button").addEventListener("click", bound);
  • -

    Queue a microtask on the surrounding agent's event - loop to perform the following steps:

    +

    Queue a microtask on the surrounding agent's event loop to perform the following steps:

    1. If job settings is not null, then check if we can run script @@ -88895,14 +88895,16 @@ dictionary PromiseRejectionEventInit : EventInit {

      To coordinate events, user interaction, scripts, rendering, networking, and so forth, user agents must use event loops as - described in this section. Each agent has an associated event loop, - which is unique to that agent.

      + described in this section. Each agent has an associated event loop, which is unique to that + agent.

      -

      The event loop of a similar-origin window agent is known as a - window event loop. The event loop of a dedicated worker - agent, shared worker agent, or service worker agent is known as a - worker event loop. And the event loop of a worklet agent is - known as a worklet event loop.

      +

      The event loop of a similar-origin window + agent is known as a window event loop. The event loop of a dedicated worker agent, + shared worker agent, or service worker agent is known as a worker + event loop. And the event loop of a + worklet agent is known as a worklet event loop.

      Event loops do not necessarily correspond to implementation @@ -89061,7 +89063,7 @@ dictionary PromiseRejectionEventInit : EventInit {

    2. Let event loop be document's relevant realm's corresponding agent's - event loop.

    3. + event loop.

    4. Queue a task given source, event loop, document, and steps.

    5. @@ -89209,8 +89211,8 @@ dictionary PromiseRejectionEventInit : EventInit {
      1. Let docs be all Document objects whose relevant - agent's event loop is this event loop, sorted arbitrarily except that the - following conditions must be met:

        + agent's event loop is this event loop, + sorted arbitrarily except that the following conditions must be met:

        • Any Document B whose PromiseRejectionEventInit : EventInit {

        then for each Window object whose whose relevant agent's - event loop is this event loop, run the start an idle period - algorithm, passing the Window.

        + event loop is this event loop, run the + start an idle period algorithm, passing the Window.

      2. @@ -96161,8 +96164,8 @@ function receiver(e) {
      3. Queue a task on the posted message task source of - targetWindow's relevant agent's event loop to run the - following steps:

        + targetWindow's relevant agent's event loop to run the following steps:

        1. If the targetOrigin argument is not a single literal U+002A ASTERISK character @@ -96981,11 +96984,11 @@ interface BroadcastChannel : EventTarget {

        2. For each BroadcastChannel object destination in destinations, queue a task on the DOM manipulation task - source of destination's relevant agent's event loop - that runs the following steps. If that event loop is a window event loop, then the - task's document - must be set to destination's BroadcastChannel settings - object's responsible document.

          + source of destination's relevant agent's event loop that runs the following steps. If that event + loop is a window event loop, then the task's + document must be set to destination's + BroadcastChannel settings object's responsible document.

          1. If destination's closed @@ -97694,7 +97697,8 @@ interface DedicatedWorkerGlobalScope : WorkerGlobalScope

            1. Discard any tasks that have been added to - workerGlobal's event loop's task + workerGlobal's relevant agent's event loop's task queues.

            2. Set workerGlobal's closing @@ -98132,7 +98136,8 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope { data-x="dom-WorkerGlobalScope-closing">closing flag to true.

            3. If there are any tasks queued in the - WorkerGlobalScope object's event loop's task + WorkerGlobalScope object's relevant agent's event loop's task queues, discard them without processing them.

            4. Abort the script currently running in the @@ -98245,15 +98250,18 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope {

            5. Let inherited origin be outside settings's origin.

            6. -
            7. Let worker event loop be a newly created worker event - loop.

            8. -
            9. Let realm be the value of execution context's Realm component.

            10. Let worker global scope be realm's global object.

            11. +
            12. Let worker event loop be a newly created worker event + loop.

            13. + +
            14. Set worker global scope's relevant agent's event loop to worker event loop.

            15. +
            16. Let settings object be a new environment settings object whose algorithms are defined as follows: