From 2b052d4b8c3c704dc377753b3dc68e014ee1ece6 Mon Sep 17 00:00:00 2001 From: Dave Tapuska Date: Mon, 13 May 2019 15:48:48 -0400 Subject: [PATCH] Add code to allocate agent clusters. Store shared agent clusters in the browsing context group via a map of scheme & registrable domain. Hook the document initialization methods to obtain a similar-orgin window agent. Fixes #4361 --- source | 156 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 58 deletions(-) diff --git a/source b/source index e7c5d190517..6a5bd9c0f2f 100644 --- a/source +++ b/source @@ -2643,6 +2643,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • Origin of URLs
  • Absolute URL
  • Relative URL
  • +
  • registrable domain
  • The URL parser and basic URL @@ -78028,7 +78029,8 @@ dictionary DragEventInit : MouseEventInit {

    To create a new browsing context, given - null or a Document object creator:

    + null or a Document object creator, and browsing context group + group:

    1. Let browsingContext be a new browsing context.

    2. @@ -78047,9 +78049,13 @@ dictionary DragEventInit : MouseEventInit { origin given browsingContext, about:blank, sandboxFlags, browsingContext's creator origin, and null. +
    3. Let agent be the result ofobtaining a similar-origin window agent given + origin, and group.

    4. +
    5. Let realm execution context be the result of creating a new JavaScript - realm with the following customizations:

      + realm provided agent with the following customizations:

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

      • @@ -78108,15 +78114,17 @@ dictionary DragEventInit : MouseEventInit { context, given a browsing context opener:

          -
        1. Let browsingContext be the result of creating a new browsing - context with opener's active document.

        2. +
        3. Let group be opener's top-level browsing context's + group

        4. + +
        5. Assert: group is non-null, as navigating invokes + this directly.

        6. -
        7. Assert: opener's top-level browsing context's group is non-null, as navigating invokes this - directly.

        8. +
        9. Let browsingContext be the result of creating a new browsing + context with opener's active document, and group.

        10. -
        11. Append browsingContext to opener's - top-level browsing context's group.

        12. +
        13. Append browsingContext to + group.

        14. Set browsingContext's opener browsing context to opener.

        15. @@ -78144,7 +78152,8 @@ dictionary DragEventInit : MouseEventInit {
          1. Let browsingContext be the result of creating a new browsing - context with element's node document.

          2. + context with element's node document, and element's + top-level browsing context's group

          3. Set element's nested browsing context to browsingContext.

          4. @@ -78621,8 +78630,11 @@ console.assert(iframeWindow.frameElement === null);
          5. Append group to the user agent's browsing context group set.

          6. -
          7. Append the result of creating a new browsing - context with null to group.

          8. +
          9. Let browsingContext be the result of creating a new browsing + context with null, and group.

          10. + +
          11. Append browsingContext to + group.

          12. Return group.

          @@ -81327,8 +81339,6 @@ interface BarProp { navigationResource's forced sandboxing flag set.

      - -

      Session history and navigation

      The session history of browsing contexts

      @@ -83678,9 +83688,15 @@ interface Location { // but see also obtaining a similar-origin window agent given + origin, and browsingContext's group.

    6. +
    7. Let realm execution context be the result of creating a new JavaScript - realm with the following customizations:

      + realm provided agent with the following customizations:

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

      • @@ -90280,45 +90296,11 @@ import "https://example.com/foo/../module2.mjs"; data-x="concept-global-object-realm">realms that can synchronously access each other, and thus needs to run in a single execution thread.

        -

        To determine whether a Window object A and a Window object - B are considered same-agent Window objects, run - these steps:

        - -
          -
        1. -

          If A's relevant settings object's responsible browsing - context's top-level browsing context's group is not B's relevant settings object's - responsible browsing context's top-level browsing context's group, then return false.

          - -

          Unfortunately this model falls apart the moment a browsing context - is discarded. Issue #4361 sketches a setup that could - improve this situation.

          -
        2. - -
        3. Let originA be A's relevant settings object's origin and originB be B's - relevant settings object's origin.

        4. - -
        5. If originA is same origin with originB, then return - true.

        6. - -
        7. If originA or originB is not a tuple origin, then return false.

        8. - -
        9. If originA's scheme is not - originB's scheme, then return - false.

        10. - -
        11. If originA's host is same - site with originB's host, then return - true.

        12. - -
        13. Return false.

        14. -
        +

        Window object A and a Window object B are + considered same-agent Window objects if A's relevant + settings object's realm execution context's agent is the same object as + B's relevant settings object's realm execution context's + agent.

        All same-agent Window objects together represent a group of Window objects that can synchronously access each other, though sometimes only @@ -90328,10 +90310,6 @@ import "https://example.com/foo/../module2.mjs";

        Until such a time that this standard has a better handle on lifetimes, it defines five types of agents that user agents must allocate at the appropriate time.

        -

        In the future, this standard hopes to define exactly when agents and agent clusters are - created.

        -
        Similar-origin window agent
        @@ -90393,6 +90371,68 @@ import "https://example.com/foo/../module2.mjs"; in particular among which agents the backing data of SharedArrayBuffer objects can be shared.

        +

        A browsing context group has associated shared agent + clusters (a map of agent cluster key to + agent cluster).

        + +

        A scheme-and-site is a tuple of a scheme and a domain.

        + +

        An agent cluster key is an origin or a + scheme-and-site.

        + +

        An agent cluster has an associated window agent.

        + +

        To obtain an agent cluster key, given an origin origin, run these + steps:

        + +
          + +
        1. If origin is an opaque origin, then + return origin.

        2. + +
        3. If origin's host's registrable + domain is null, then return origin.

        4. + +
        5. Return (origin's scheme, + origin's registrable + domain).

        6. + +
        + +

        To obtain a similar-origin + window agent, given an origin origin, and browsing context + group group, run these steps:

        + +
          + +
        1. Let clusterKey be the result of obtaining an agent cluster key + given origin.

        2. + +
        3. Let agentCluster be the result of obtaining a browsing context agent + cluster with group and clusterKey.

        4. + +
        5. If agentCluster does not contain a window agent, then add a + new similar-origin window agent to it.

        6. + +
        7. Return agentCluster's window agent.

        8. + +
        + +

        To obtain a browsing context agent cluster, given a browsing + context group group and agent cluster key key, run these + steps:

        + +
          + +
        1. If group's shared agent clusters[key] does not exist, + then set group's shared agent clusters[key] to a new agent + cluster.

        2. + +
        3. Return group's shared agent clusters[key].

        4. + +
        +

        Conceptually, the agent cluster concept is an architecture-independent, idealized "process boundary" that groups together multiple "threads" (agents). The agent clusters