From ae8815ec36eaa41978d3a0f64a05210fcd00c4cf Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 15 Jun 2026 20:03:58 +0200 Subject: [PATCH 1/5] Integrate with MakeRealm Initial attempt at integrating with https://github.com/tc39/ecma262/pull/3728. --- source | 491 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 270 insertions(+), 221 deletions(-) diff --git a/source b/source index 7790765471f..5968ef31a73 100644 --- a/source +++ b/source @@ -2955,6 +2955,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute constructing callback functions
  • overload resolution algorithm
  • exposed
  • +
  • global names of an interface
  • a promise resolved with
  • a promise rejected with
  • wait for all
  • @@ -3137,7 +3138,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The HostLoadImportedModule abstract operation
  • The HostMakeJobCallback abstract operation
  • The HostPromiseRejectionTracker abstract operation
  • -
  • The InitializeHostDefinedRealm abstract operation
  • +
  • The MakeRealm abstract operation
  • The IsArrayBufferViewOutOfBounds abstract operation
  • The IsAccessorDescriptor abstract operation
  • The IsCallable abstract operation
  • @@ -96290,8 +96291,8 @@ interface Origin { is not "blob":

      -
    1. Assert: workerGlobalScope's owner set's size is 1.

    2. +
    3. Assert: workerGlobalScope's relevant settings + object's owner set's size is 1.

    4. Set workerGlobalScope's policy container to a BarProp {

      To set up a window environment settings object, given a URL - creationURL, a JavaScript execution context execution context, - null or an environment reservedEnvironment, a URL + creationURL, a realm realm, null or an + environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin, run these steps:

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

      2. - -
      3. Let window be realm's global - object.

      4. +

        This algorithm is invoked before realm's global object is allocated. The closures defined below read + the global object lazily when they are invoked, by which time realm has been fully + wired.

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

          The realm execution context
          -
          -

          Return execution context.

          -
          +

          Return the JavaScript execution context whose Realm component is + realm.

          The module map
          -
          -

          Return the module map of - window's associated - Document.

          -
          +

          Return realm's global object's + associated Document's module map.

          The API base URL
          -
          -

          Return the current base URL of window's - associated Document.

          -
          +

          Return realm's global object's + associated Document's base URL.

          The origin
          -
          -

          Return the origin of window's - associated Document.

          -
          +

          Return realm's global object's + associated Document's origin.

          The has cross-site ancestor
            +
          1. Let window be realm's global object.

          2. +
          3. If window's navigable's parent is null, then return false.

          4. @@ -97866,11 +97864,9 @@ interface BarProp {
          The policy container
          -
          -

          Return the policy container of - window's associated - Document.

          -
          +

          Return the policy container of + realm's global object's associated Document.

          The cross-origin isolated capability
          @@ -97881,18 +97877,20 @@ interface BarProp { data-x="agent-cluster-cross-origin-isolation">cross-origin-isolation mode is "concrete", and

        2. -
        3. window's associated - Document is allowed to use the "

          realm's global object's associated Document is + allowed to use the "cross-origin-isolated" feature.

        4. The time origin
          -
          -

          Return window's associated - Document's load timing info's navigation start - time.

          -
          +

          Return realm's global object's + associated Document's load + timing info's navigation start time.

          + +
          The global names
          +

          Return Window's global names.

          @@ -104386,7 +104384,7 @@ interface NotRestoredReasons {
          "sharedworker"
          This Document was in the owner set of a - SharedWorkerGlobalScope. + SharedWorkerGlobalScope's relevant settings object.

          User agents that support the back/forward cache for documents using shared workers can use more specific reasons such as NotRestoredReasons {

          "sharedworker-message"
          While the page was stored in back/forward cache, a message was - received from a SharedWorkerGlobalScope whose owner set contains this Document.
          + received from a SharedWorkerGlobalScope whose relevant settings + object's owner set contains this + Document.
          "sharedworker-with-no-active-client"
          This Document was in the owner set of a - SharedWorkerGlobalScope that is not actively - needed.
          + SharedWorkerGlobalScope's relevant settings object that is not + actively needed.
          "smartcardconnection"
          The Document had an active SmartCardConnection while NotRestoredReasons { data-x="obtain-similar-origin-window-agent">obtaining a similar-origin window agent given origin, group, and false.

          -
        5. -

          Let realm execution context be the result of creating a new realm - given agent and the following customizations:

          - -
            -
          • For the global object, create a new Window object.

          • - -
          • For the global this binding, use browsingContext's - WindowProxy object.

          • -
          -
        6. -
        7. Let topLevelCreationURL be about:blank if embedder is null; otherwise embedder's relevant settings object's top-level creation URL.

        8. @@ -106075,9 +106062,25 @@ interface NotRestoredReasons { otherwise embedder's relevant settings object's top-level origin.

          -
        9. Set up a window environment settings object with about:blank, - realm execution context, null, topLevelCreationURL, and - topLevelOrigin.

        10. +
        11. +

          Let customizations be the following abstract closure given a + realm realm:

          + +
            +
          1. Set up a window environment settings object with + about:blank, realm, null, topLevelCreationURL, and + topLevelOrigin.

          2. + +
          3. Let window be a new Window object created in + realm.

          4. + +
          5. Return (window, browsingContext's WindowProxy + object).

          6. +
          +
        12. + +
        13. Let realm execution context be the result of creating a new realm + given agent and customizations.

        14. Let loadTimingInfo be a new document load timing info with its navigation start time set to the result of calling coarsen time @@ -112947,21 +112950,6 @@ location.href = '#foo'; browsingContext's group, and requestsOAC.

        15. -
        16. -

          Let realmExecutionContext be the result of creating a new realm - given agent and the following customizations:

          - -
            -
          • For the global object, create a new Window object.

          • - -
          • For the global this binding, use browsingContext's - WindowProxy object.

          • -
          -
        17. - -
        18. Set window to the global - object of realmExecutionContext's Realm component.

        19. -
        20. Let topLevelCreationURL be creationURL.

        21. Let topLevelOrigin be navigationParams's

        -
      5. Set up a window environment settings object with creationURL, - realmExecutionContext, navigationParams's reserved environment, - topLevelCreationURL, and topLevelOrigin.

      6. +
      7. +

        Let customizations be the following abstract closure given a + realm realm:

        + +
          +
        1. Set up a window environment settings object with creationURL, + realm, navigationParams's reserved environment, + topLevelCreationURL, and topLevelOrigin.

        2. + +
        3. Let newWindow be a new Window object created in + realm.

        4. + +
        5. Return (newWindow, browsingContext's WindowProxy + object).

        6. +
        +
      8. + +
      9. Let realmExecutionContext be the result of creating a new + realm given agent and customizations.

      10. + +
      11. Set window to the global + object of realmExecutionContext's Realm component.

      This is the usual case, where the new Document we're about to @@ -113991,9 +113998,9 @@ new PaymentRequest(…); // Allowed to use data-x="she-document-state">document state's document to null.

    5. -
    6. Remove document from the - owner set of each WorkerGlobalScope object whose set contains document.

    7. +
    8. Remove document from the owner + set of each WorkerGlobalScope object's relevant settings object + whose set contains document.

    9. For each workletGlobalScope in document's worklet global @@ -117026,6 +117033,15 @@ new PaymentRequest(…); // Allowed to use for="environment settings object">time origin

      A number used as the baseline for performance-related timestamps. HRT
      + +
      A global names
      +

      A set of identifiers (strings), corresponding to the global + names of the global object's + interface. Used by Web IDL to determine which constructs are exposed in the realm, including during the realm's creation.

      @@ -117130,24 +117146,25 @@ new PaymentRequest(…); // Allowed to use

      To create a new - realm in an agent agent, optionally with instructions to create a - global object or a global this binding (or both), the following steps are taken:

      + realm in an agent agent, given an abstract closure + customizations taking a realm and returning a tuple of an object (the + global object) and an object or null (the global this binding), the following steps are + taken:

      + +

      customizations runs at the point during realm initialization when the + realm record exists (with its intrinsics) but its [[GlobalObject]] is not yet set. The closure is + expected to set up the realm's environment settings object (writing the realm's + [[HostDefined]] field) and then construct the global object and global this binding, + returning them. Doing the environment settings object setup before global + allocation is necessary so that Web IDL's is exposed check + can be answered during global allocation: the exposure check reads the environment + settings object's global names, + secure-context status, and cross-origin isolated + capability, none of which require the global object to exist yet.

        -
      1. Perform InitializeHostDefinedRealm() - with the provided customizations for creating the global object and the global this - binding.

      2. - -
      3. -

        Let realm execution context be the running JavaScript execution - context.

        - -

        This is the JavaScript execution context created in the previous - step.

        -
      4. - -
      5. Remove realm execution context from the JavaScript execution context - stack.

      6. +
      7. Let realm execution context be MakeRealm(customizations).

      8. Let realm be realm execution context's Realm component.

      9. @@ -117757,16 +117774,17 @@ document.querySelector("button").addEventListener("click", bound);

        If environment is an environment settings object:

          -
        1. Let global be environment's global object.

        2. +
        3. Let globalNames be environment's global names.

        4. -

          If global is a WorkerGlobalScope: +

          If globalNames contains + "Worker":

          1. -

            If global's owner set[0]'s relevant settings object - is a secure context, then return true.

            +

            If environment's owner set[0]'s relevant settings + object is a secure context, then return true.

            We only need to check the 0th item since they will necessarily all be consistent.

            @@ -117777,7 +117795,8 @@ document.querySelector("button").addEventListener("click", bound);
          2. -

            If global is a WorkletGlobalScope, then return true.

            +

            If globalNames contains + "Worklet", then return true.

            Worklets can only be created in secure contexts.

          3. @@ -132071,11 +132090,11 @@ interface mixin AnimationFrameProvider {
            • provider is a Window.

            • -
            • provider's owner set contains - a Document object.

            • +
            • provider's relevant settings object's owner set contains a Document object.

            • Any of the DedicatedWorkerGlobalScope objects in provider's - owner set are relevant settings object's owner set are supported.

      @@ -134863,13 +134882,15 @@ interface WorkerGlobalScope : EventTarget {
      -

      A WorkerGlobalScope object has an associated owner set (a - set of Document and WorkerGlobalScope objects). It is - initially empty and populated when the worker is created or obtained.

      +

      A worker environment settings object has an + associated owner set (a set of Document + and WorkerGlobalScope items). It is set when the worker + environment settings object is set up.

      -

      It is a set, instead of a single owner, to accommodate - SharedWorkerGlobalScope objects.

      +

      It is a set, instead of a single owner, to accommodate shared + workers (SharedWorkerGlobalScope).

      A WorkerGlobalScope object has an associated type ("classic" or "WorkerGlobalScope : EventTarget { data-x="concept-WorkerGlobalScope-module-map">module map. It is a module map, initially empty.

      -

      A WorkerGlobalScope object has an associated cross-origin isolated - capability boolean. It is initially false.

      -
      @@ -135214,13 +135231,13 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope data-x="concept-SharedWorkerGlobalScope-extended-lifetime">extended lifetime is false, then return false.

    10. -
    11. If global's owner set is - empty, but has been empty for less than the user agent's extended lifetime shared - worker timeout, then return true.

    12. +
    13. If global's relevant settings object's owner set + is empty, but has been empty for less than the user agent's + extended lifetime shared worker timeout, then return true.

    14. For each owner of global's - owner set:

      + relevant settings object's owner set:

      1. @@ -135235,7 +135252,7 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
      2. For each owner of global's - owner set:

        + relevant settings object's owner set:

        1. If owner is a Document and the amount of time that @@ -135261,7 +135278,7 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope

        2. For each owner of global's - owner set:

          + relevant settings object's owner set:

          1. If owner is a Document, and owner is fully @@ -135305,7 +135322,7 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope worker">permissible if the following algorithm returns true:

              -
            1. If global's owner set is not empty, then return true.

            2. If global is in extended @@ -135317,9 +135334,9 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope

              • global is a SharedWorkerGlobalScope;

              • -
              • global's owner set has been empty for no more than the user agent's between-loads shared worker - timeout; and

                +
              • global's relevant settings object's owner set has + been empty for no more than the user agent's + between-loads shared worker timeout; and

              • the user agent has a navigable whose active document is not completely loaded,

              • @@ -135441,16 +135458,32 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope is shared. Run the rest of these steps in that agent.

              • -

                Let realm execution context be the result of creating a new realm - given agent and the following customizations:

                +

                Let globalScopeType be SharedWorkerGlobalScope if is + shared is true; otherwise DedicatedWorkerGlobalScope.

                +
              • -
                  -
                • For the global object, if is shared is true, create a new - SharedWorkerGlobalScope object. Otherwise, create a new - DedicatedWorkerGlobalScope object.

                • -
                +
              • Let ownerSet be « owner ».

              • + +
              • +

                Let customizations be the following abstract closure given a + realm realm:

                + +
                  +
                1. Let inside settings be the result of setting up a worker environment settings object with + realm, globalScopeType, url, outside settings, + ownerSet, and unsafeWorkerCreationTime.

                2. + +
                3. Let workerScope be a new object of type globalScopeType + created in realm.

                4. + +
                5. Return (workerScope, null).

                6. +
              • +
              • Let realm execution context be the result of creating a new realm + given agent and customizations.

              • +
              • Let worker global scope be the global object of realm execution context's Realm component. @@ -135459,17 +135492,10 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope SharedWorkerGlobalScope object created in the previous step.

              • -
              • Set up a worker environment settings object with realm execution - context, outside settings, and unsafeWorkerCreationTime, and let - inside settings be the result.

              • -
              • Set worker global scope's name to options["name"].

              • -
              • Append owner to worker global - scope's owner set.

              • -
              • If is shared is true:

                @@ -135573,34 +135599,6 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope settings, and response is false, then set response to a network error.

              • -
              • Set worker global scope's cross-origin isolated - capability to true if agent's agent cluster's cross-origin isolation mode is "concrete".

              • - -
              • If is shared is false and owner's cross-origin isolated - capability is false, then set worker global scope's cross-origin isolated - capability to false.

              • - -
              • -

                If is shared is false and response's - url's scheme is "data", then set - worker global scope's cross-origin isolated - capability to false.

                - -

                This is a conservative default for now, while we figure out how workers in - general, and data: URL workers in particular (which are - cross-origin from their owner), will be treated in the context of permissions policies. See - w3c/webappsec-permissions-policy - issue #207 for more details.

                -
              • -
              • Run processCustomFetchResponse with response and bodyBytes.

            @@ -135720,7 +135718,8 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
          2. Empty - worker global scope's owner set.

          3. + worker global scope's relevant settings object's owner + set.

        @@ -135797,20 +135796,23 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
        Script settings for workers
        -

        To set up a worker environment settings object, given a JavaScript execution - context execution context, an environment settings object - outside settings, and a number unsafeWorkerCreationTime:

        +

        To set up a worker environment settings object, given a realm + realm, an interface globalScopeType, a URL + workerURL, an environment settings object outside settings, a + set ownerSet of Document and WorkerGlobalScope + items, and a number unsafeWorkerCreationTime:

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

        2. +

          This algorithm is invoked before realm's global object is allocated. The closures defined below + read the global object lazily when they are invoked, by which time realm has been + fully wired.

          -
        3. Let worker global scope be realm's global object.

        4. +
            +
          1. Let globalNames be globalScopeType's global + names.

          2. Let origin be a unique opaque origin if worker global scope's - url's opaque origin if workerURL's scheme is "data"; otherwise outside settings's origin.

          3. @@ -135822,19 +135824,20 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
            The realm execution context
            -

            Return execution context. +

            Return the JavaScript execution context whose Realm component is + realm.

            The module map
            -

            Return worker global scope's module map.

            +

            Return realm's global object's + module map.

            The API base URL
            -

            Return worker global scope's url.

            +

            Return realm's global object's + url.

            The origin
            @@ -135848,8 +135851,7 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope data-x="concept-settings-object-has-cross-site-ancestor">has cross-site ancestor is true, then return true.

            -
          4. If worker global scope's url's

            If workerURL's scheme is "data", then return true.

          5. @@ -135858,35 +135860,67 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
            The policy container
            -
            -

            Return worker global scope's policy container.

            -
            +

            Return realm's global object's + policy container.

            The cross-origin isolated capability
            -

            Return worker global scope's cross-origin isolated - capability.

            +
            +
              +
            1. If realm's agent cluster's cross-origin-isolation mode is not + "concrete", then return + false.

            2. + +
            3. +

              If globalNames contains + "DedicatedWorker":

              + +
                +
              1. If outside settings's cross-origin isolated + capability is false, then return false.

              2. + +
              3. If workerURL's scheme is + "data", then return false.

              4. +
              +
            4. + +
            5. Return true.

            6. +
            + +

            The data-URL downgrade preserves the existing conservative default for + data: URL workers. See w3c/webappsec-permissions-policy + issue #207. Using the request URL here (rather than the post-fetch response URL) is safe + because fetch errors on redirects to data: URLs.

            +
            The time origin

            Return the result of coarsening - unsafeWorkerCreationTime with worker global scope's cross-origin isolated + unsafeWorkerCreationTime with settings object's cross-origin isolated capability.

            + +
            The global names
            +

            Return globalNames.

          6. Set settings object's id to a new unique opaque string, creation URL to - worker global scope's url, top-level creation URL to null, + workerURL, top-level creation URL to null, target browsing context to null, and active service worker to null.

          7. -
          8. If worker global scope is a DedicatedWorkerGlobalScope object, - then set settings object's top-level origin to outside - settings's top-level origin.

          9. +
          10. Set settings object's owner set to ownerSet.

          11. + +
          12. If globalNames contains + "DedicatedWorker", then set settings object's + top-level origin to outside settings's + top-level origin.

          13. Otherwise, set settings object's top-level origin to an @@ -136324,7 +136358,8 @@ dictionary SharedWorkerOptions : WorkerOptionsinsidePort.

          14. Append the relevant owner to add given - outsideSettings to workerGlobalScope's owner set.

          15. + outsideSettings to workerGlobalScope's relevant settings + object's owner set.

          @@ -137035,23 +137070,32 @@ interface WorkletGlobalScope {};
          worklet agent given outsideSettings. Run the rest of these steps in that agent.

          +
        5. Let workletGlobalScopeType be worklet's worklet global + scope type.

        6. +
        7. -

          Let realmExecutionContext be the result of creating a new realm given - agent and the following customizations:

          +

          Let customizations be the following abstract closure given a + realm realm:

          -
            -
          • For the global object, create a new object of the type given by worklet's - worklet global scope type.

          • -
          +
            +
          1. Let insideSettings be the result of setting up a worklet environment settings object + given realm, workletGlobalScopeType, and + outsideSettings.

          2. + +
          3. Let workletScope be a new object of type workletGlobalScopeType + created in realm.

          4. + +
          5. Return (workletScope, null).

          6. +
        8. +
        9. Let realmExecutionContext be the result of creating a new realm + given agent and customizations.

        10. +
        11. Let workletGlobalScope be the global object of realmExecutionContext's Realm component.

        12. -
        13. Let insideSettings be the result of setting up a worklet environment settings object given - realmExecutionContext and outsideSettings.

        14. -
        15. Let pendingAddedModules be a clone of worklet's added modules list.

        16. @@ -137150,9 +137194,13 @@ interface WorkletGlobalScope {};
          Script settings for worklets
          -

          To set up a worklet environment settings object, given a JavaScript - execution context executionContext and an environment settings - object outsideSettings:

          +

          To set up a worklet environment settings object, given a realm + realm, an interface workletGlobalScopeType, and an environment + settings object outsideSettings:

          + +

          This algorithm is invoked before realm's global object is allocated. The closures defined below + read the global object lazily when they are invoked.

          1. Let origin be a unique opaque @@ -137165,11 +137213,8 @@ interface WorkletGlobalScope {}; container">clone of outsideSettings's policy container.

          2. -
          3. Let realm be the value of executionContext's Realm - component.

          4. - -
          5. Let workletGlobalScope be realm's global object.

          6. +
          7. Let globalNames be workletGlobalScopeType's global + names.

          8. Let settingsObject be a new environment settings object whose @@ -137178,13 +137223,14 @@ interface WorkletGlobalScope {};

            The realm execution context
            -

            Return executionContext.

            +

            Return the JavaScript execution context whose Realm component is + realm.

            The module map
            -

            Return workletGlobalScope's module map.

            +

            Return realm's global object's + module map.

            The API base URL
            @@ -137221,6 +137267,9 @@ interface WorkletGlobalScope {};

            Assert: this algorithm is never called, because the time origin is not available in a worklet context.

            + +
            The global names
            +

            Return globalNames.

          9. From 6304cd51ad19edaf40483788b21f5a7e72b2e777 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 22 Jun 2026 13:49:26 +0200 Subject: [PATCH 2/5] MakeRealm was updated to return an execution context --- source | 152 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 77 insertions(+), 75 deletions(-) diff --git a/source b/source index 5968ef31a73..bada6bcfdea 100644 --- a/source +++ b/source @@ -96296,9 +96296,9 @@ interface Origin {
          10. Set workerGlobalScope's policy container to a clone of workerGlobalScope's owner - set[0]'s relevant settings object's policy container.

          11. + data-x="clone a policy container">clone of workerGlobalScope's relevant + settings object's owner set[0]'s relevant settings object's + policy container.

          @@ -97801,25 +97801,26 @@ interface BarProp {

          To set up a window environment settings object, given a URL - creationURL, a realm realm, null or an - environment reservedEnvironment, a URL + creationURL, a JavaScript execution context executionContext, + null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin, run these steps:

          -

          This algorithm is invoked before realm's global object is allocated. The closures defined below read - the global object lazily when they are invoked, by which time realm has been fully - wired.

          +

          This algorithm is invoked before executionContext's Realm + component's global object is allocated. The closures + defined below read the global object lazily when they are invoked, by which time the realm has + been fully wired.

            +
          1. Let realm be executionContext's Realm component.

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

            The realm execution context
            -

            Return the JavaScript execution context whose Realm component is - realm.

            +

            Return executionContext.

            The module map

            Return realm's global object's @@ -97874,7 +97875,7 @@ interface BarProp {

            Return true if both of the following hold, and false otherwise:

            • realm's agent cluster's cross-origin-isolation mode is "cross-origin isolation mode is "concrete", and

            • realm's global object's NotRestoredReasons {

            • Let customizations be the following abstract closure given a - realm realm:

              + JavaScript execution context executionContext:

              1. Set up a window environment settings object with - about:blank, realm, null, topLevelCreationURL, and - topLevelOrigin.

              2. + about:blank, executionContext, null, + topLevelCreationURL, and topLevelOrigin.

              3. Let window be a new Window object created in - realm.

              4. + executionContext's Realm component.

              5. Return (window, browsingContext's WindowProxy object).

            • -
            • Let realm execution context be the result of creating a new realm +

            • Let executionContext be the result of creating a new realm given agent and customizations.

            • Let loadTimingInfo be a new document load timing info with @@ -112972,27 +112973,27 @@ location.href = '#foo';

            • Let customizations be the following abstract closure given a - realm realm:

              + JavaScript execution context executionContext:

              1. Set up a window environment settings object with creationURL, - realm, navigationParams's executionContext, navigationParams's reserved environment, topLevelCreationURL, and topLevelOrigin.

              2. Let newWindow be a new Window object created in - realm.

              3. + executionContext's Realm component.

              4. Return (newWindow, browsingContext's WindowProxy object).

            • -
            • Let realmExecutionContext be the result of creating a new +

            • Let executionContext be the result of creating a new realm given agent and customizations.

            • Set window to the global - object of realmExecutionContext's Realm component.

            • + object of executionContext's Realm component.

          This is the usual case, where the new Document we're about to @@ -117147,26 +117148,28 @@ new PaymentRequest(…); // Allowed to use

          To create a new realm in an agent agent, given an abstract closure - customizations taking a realm and returning a tuple of an object (the - global object) and an object or null (the global this binding), the following steps are - taken:

          - -

          customizations runs at the point during realm initialization when the - realm record exists (with its intrinsics) but its [[GlobalObject]] is not yet set. The closure is - expected to set up the realm's environment settings object (writing the realm's - [[HostDefined]] field) and then construct the global object and global this binding, - returning them. Doing the environment settings object setup before global - allocation is necessary so that Web IDL's is exposed check - can be answered during global allocation: the exposure check reads the environment - settings object's global names, - secure-context status, and cross-origin isolated - capability, none of which require the global object to exist yet.

          + customizations taking a JavaScript execution context and returning a + tuple of an object (the global object) and an object or null (the global this binding):

            -
          1. Let realm execution context be MakeRealm(customizations).

          2. +
          3. +

            Let executionContext be MakeRealm(customizations).

            -
          4. Let realm be realm execution context's Realm component.

          5. +

            customizations runs at the point during realm initialization when the + realm record exists (with its intrinsics), but its [[GlobalObject]] is not yet set. The closure + is expected to set up the realm's environment settings object (writing the realm's + [[HostDefined]] field) and then construct the global object and global this binding, + returning them. Doing the environment settings object setup before global + allocation is necessary so that Web IDL's is exposed check + can be answered during global allocation: the exposure check reads the environment + settings object's global + names, secure context status, and cross-origin isolated + capability, none of which require the global object to exist yet.

            + + +
          6. Let realm be executionContext's Realm component.

          7. If agent's agent cluster's .

          8. -
          9. Return realm execution context.

          10. +
          11. Return executionContext.

          @@ -135466,27 +135469,27 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
        17. Let customizations be the following abstract closure given a - realm realm:

          + JavaScript execution context executionContext:

          1. Let inside settings be the result of setting up a worker environment settings object with - realm, globalScopeType, url, outside settings, - ownerSet, and unsafeWorkerCreationTime.

          2. + executionContext, globalScopeType, url, outside + settings, ownerSet, and unsafeWorkerCreationTime.

          3. Let workerScope be a new object of type globalScopeType - created in realm.

          4. + created in executionContext's Realm component.

          5. Return (workerScope, null).

        18. -
        19. Let realm execution context be the result of creating a new realm +

        20. Let executionContext be the result of creating a new realm given agent and customizations.

        21. Let worker global scope be the global - object of realm execution context's Realm component. + object of executionContext's Realm component.

          This is the DedicatedWorkerGlobalScope or SharedWorkerGlobalScope object created in the previous step.

          @@ -135796,18 +135799,20 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
          Script settings for workers
          -

          To set up a worker environment settings object, given a realm - realm, an interface globalScopeType, a URL - workerURL, an environment settings object outside settings, a - set ownerSet of Document and WorkerGlobalScope - items, and a number unsafeWorkerCreationTime:

          +

          To set up a worker environment settings object, given a JavaScript execution + context executionContext, an interface globalScopeType, a + URL workerURL, an environment settings object outside + settings, a set ownerSet of Document and + WorkerGlobalScope items, and a number unsafeWorkerCreationTime:

          -

          This algorithm is invoked before realm's global object is allocated. The closures defined below - read the global object lazily when they are invoked, by which time realm has been - fully wired.

          +

          This algorithm is invoked before executionContext's Realm + component's global object is allocated. The closures + defined below read the global object lazily when they are invoked, by which time the realm has + been fully wired.

            +
          1. Let realm be executionContext's Realm component.

          2. +
          3. Let globalNames be globalScopeType's global names.

          4. @@ -135823,10 +135828,7 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
            The realm execution context
            -
            -

            Return the JavaScript execution context whose Realm component is - realm. -

            +

            Return executionContext.

            The module map
            @@ -135868,7 +135870,7 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
            1. If realm's agent cluster's cross-origin-isolation mode is not + data-x="agent-cluster-cross-origin-isolation">cross-origin isolation mode is not "concrete", then return false.

            2. @@ -137075,26 +137077,26 @@ interface WorkletGlobalScope {};
            3. Let customizations be the following abstract closure given a - realm realm:

              + JavaScript execution context executionContext:

              1. Let insideSettings be the result of setting up a worklet environment settings object - given realm, workletGlobalScopeType, and + given executionContext, workletGlobalScopeType, and outsideSettings.

              2. Let workletScope be a new object of type workletGlobalScopeType - created in realm.

              3. + created in executionContext's Realm component.

              4. Return (workletScope, null).

            4. -
            5. Let realmExecutionContext be the result of creating a new realm +

            6. Let executionContext be the result of creating a new realm given agent and customizations.

            7. Let workletGlobalScope be the global - object of realmExecutionContext's Realm component.

            8. + object of executionContext's Realm component.

            9. Let pendingAddedModules be a clone of worklet's added modules @@ -137194,15 +137196,18 @@ interface WorkletGlobalScope {};

              Script settings for worklets
              -

              To set up a worklet environment settings object, given a realm - realm, an interface workletGlobalScopeType, and an environment - settings object outsideSettings:

              +

              To set up a worklet environment settings object, given a JavaScript + execution context executionContext, an interface + workletGlobalScopeType, and an environment settings object + outsideSettings:

              -

              This algorithm is invoked before realm's global object is allocated. The closures defined below - read the global object lazily when they are invoked.

              +

              This algorithm is invoked before executionContext's Realm component's + global object is allocated. The closures defined + below read the global object lazily when they are invoked.

                +
              1. Let realm be executionContext's Realm component.

              2. +
              3. Let origin be a unique opaque origin.

              4. @@ -137222,10 +137227,7 @@ interface WorkletGlobalScope {};
                The realm execution context
                -
                -

                Return the JavaScript execution context whose Realm component is - realm.

                -
                +

                Return executionContext.

                The module map
                From fb819cb4c4b970086b3ce168090729ef2c2f2052 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 22 Jun 2026 14:12:54 +0200 Subject: [PATCH 3/5] nits --- source | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/source b/source index bada6bcfdea..eefe3f51d15 100644 --- a/source +++ b/source @@ -97803,16 +97803,17 @@ interface BarProp {

                To set up a window environment settings object, given a URL creationURL, a JavaScript execution context executionContext, null or an environment reservedEnvironment, a URL - topLevelCreationURL, and an origin topLevelOrigin, run these - steps:

                - -

                This algorithm is invoked before executionContext's Realm - component's global object is allocated. The closures - defined below read the global object lazily when they are invoked, by which time the realm has - been fully wired.

                + topLevelCreationURL, and an origin topLevelOrigin:

                  -
                1. Let realm be executionContext's Realm component.

                2. +
                3. +

                  Let realm be executionContext's Realm component.

                  + +

                  This algorithm is invoked before realm's global object is allocated. The closures defined below read + the global object lazily when they are invoked, by which time the realm has been fully + wired.

                  +
                4. Let settings object be a new environment settings object whose @@ -135325,8 +135326,8 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope worker">permissible if the following algorithm returns true:

                    -
                  1. If global's relevant settings object's owner set is not empty, then return true.

                  2. +
                  3. If global's relevant settings object's owner set is + not empty, then return true.

                  4. If global is in extended lifetime, then return true.

                  5. @@ -135460,10 +135461,8 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope agent">obtaining a dedicated/shared worker agent given outside settings and is shared. Run the rest of these steps in that agent.

                    -
                  6. -

                    Let globalScopeType be SharedWorkerGlobalScope if is - shared is true; otherwise DedicatedWorkerGlobalScope.

                    -
                  7. +
                  8. Let globalScopeType be SharedWorkerGlobalScope if is + shared is true; otherwise DedicatedWorkerGlobalScope.

                  9. Let ownerSet be « owner ».

                  10. @@ -135805,13 +135804,15 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope settings, a set ownerSet of Document and WorkerGlobalScope items, and a number unsafeWorkerCreationTime:

                    -

                    This algorithm is invoked before executionContext's Realm - component's global object is allocated. The closures - defined below read the global object lazily when they are invoked, by which time the realm has - been fully wired.

                    -
                      -
                    1. Let realm be executionContext's Realm component.

                    2. +
                    3. +

                      Let realm be executionContext's Realm component.

                      + +

                      This algorithm is invoked before realm's global object is allocated. The closures defined below read + the global object lazily when they are invoked, by which time the realm has been fully + wired.

                      +
                    4. Let globalNames be globalScopeType's global names.

                    5. @@ -137201,12 +137202,15 @@ interface WorkletGlobalScope {}; workletGlobalScopeType, and an environment settings object outsideSettings:

                      -

                      This algorithm is invoked before executionContext's Realm component's - global object is allocated. The closures defined - below read the global object lazily when they are invoked.

                      -
                        -
                      1. Let realm be executionContext's Realm component.

                      2. +
                      3. +

                        Let realm be executionContext's Realm component.

                        + +

                        This algorithm is invoked before realm's global object is allocated. The closures defined below read + the global object lazily when they are invoked, by which time the realm has been fully + wired.

                        +
                      4. Let origin be a unique opaque origin.

                      5. From cd40a65a4f79231a5bc91b690f07f031c988ebdb Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 23 Jun 2026 08:56:38 +0200 Subject: [PATCH 4/5] return a list and use undefined for global this binding instead of null --- source | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source b/source index eefe3f51d15..027492a12ba 100644 --- a/source +++ b/source @@ -106076,8 +106076,8 @@ interface NotRestoredReasons {
                      6. Let window be a new Window object created in executionContext's Realm component.

                      7. -
                      8. Return (window, browsingContext's WindowProxy - object).

                      9. +
                      10. Return « window, browsingContext's WindowProxy + object ».

                      @@ -112985,8 +112985,8 @@ location.href = '#foo';
                    6. Let newWindow be a new Window object created in executionContext's Realm component.

                    7. -
                    8. Return (newWindow, browsingContext's WindowProxy - object).

                    9. +
                    10. Return « newWindow, browsingContext's WindowProxy + object ».

                    @@ -117150,7 +117150,8 @@ new PaymentRequest(…); // Allowed to use

                    To create a new realm in an agent agent, given an abstract closure customizations taking a JavaScript execution context and returning a - tuple of an object (the global object) and an object or null (the global this binding):

                    + list containing an object (the global object) and an object or undefined (the + global this binding):

                    1. @@ -135479,7 +135480,7 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
                    2. Let workerScope be a new object of type globalScopeType created in executionContext's Realm component.

                    3. -
                    4. Return (workerScope, null).

                    5. +
                    6. Return « workerScope, undefined ».

                    @@ -137089,7 +137090,7 @@ interface WorkletGlobalScope {};
                  11. Let workletScope be a new object of type workletGlobalScopeType created in executionContext's Realm component.

                  12. -
                  13. Return (workletScope, null).

                  14. +
                  15. Return « workletScope, undefined ».

                5. From 407ac89f0a8c8df61a1e3e24b2c1a99c7d4d62cb Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 24 Jun 2026 10:10:42 +0200 Subject: [PATCH 5/5] switch back to null --- source | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source b/source index 027492a12ba..420ccc60cb5 100644 --- a/source +++ b/source @@ -117150,8 +117150,8 @@ new PaymentRequest(…); // Allowed to use

                  To create a new realm in an agent agent, given an abstract closure customizations taking a JavaScript execution context and returning a - list containing an object (the global object) and an object or undefined (the - global this binding):

                  + list containing an object (the global object) and an object or null (the global + this binding):

                  1. @@ -135480,7 +135480,7 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
                  2. Let workerScope be a new object of type globalScopeType created in executionContext's Realm component.

                  3. -
                  4. Return « workerScope, undefined ».

                  5. +
                  6. Return « workerScope, null ».

                  @@ -137090,7 +137090,7 @@ interface WorkletGlobalScope {};
                6. Let workletScope be a new object of type workletGlobalScopeType created in executionContext's Realm component.

                7. -
                8. Return « workletScope, undefined ».

                9. +
                10. Return « workletScope, null ».