Skip to content

Imperative allocation of agent clusters #4361

Closed
@annevk

Description

@annevk

This is a follow-up to #4198. The browsing context group concept is added by #4350, but to properly clarify the lifetime of objects, we'll need to imperatively allocate them. In particular, objects might lose their direct connection to a browsing context (e.g., when you remove an <iframe>), but that doesn't mean they're outside the scope of the agent they were created in (e.g., when you keep a reference to a WindowProxy object while you remove that <iframe>).

(Alternatively we could perhaps give everything a pointer to the browsing context group, but that doesn't seem like a good architecture, in particular because nothing in ECMAScript really supports that kind of notion.)

This is the setup I have for this thus far:


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

An agent cluster key is an origin or a scheme-and-site. A scheme-and-site is a tuple of a scheme and a domain.

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

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

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

  3. Return (origin's host's scheme, origin's host's registrable domain).

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

  1. Let agentCluster be the result of obtaining a browsing context agent cluster with group and key.

  2. If agentCluster does not contain an agent, then add a new similar-origin window agent to it. (ECMAScript does not define the layout of agent clusters unfortunately.)

  3. Return agentCluster's similar-origin window agent.

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 agent clusters[key] does not exist, then set group's agent clusters[key] to a new agent cluster. (ECMAScript does not define allocating agent clusters unfortunately.)

  2. Return group's agent clusters[key].


Feedback appreciated.

cc @mystor @farre @rniwa @creis @domenic

(This intentionally does not cover workers. They can use a simpler allocation setup that can be sorted as part of #4339.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: agentThe interaction with JavaScript's agent and agent cluster concepts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions