Skip to content

Commit

Permalink
Add code to allocate agent clusters.
Browse files Browse the repository at this point in the history
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 whatwg#4361
  • Loading branch information
dtapuska committed May 23, 2019
1 parent 6773932 commit c8bb7d8
Showing 1 changed file with 134 additions and 40 deletions.
174 changes: 134 additions & 40 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-dfn-for="url" data-x="concept-url-origin" data-x-href="https://url.spec.whatwg.org/#concept-url-origin">Origin</dfn> of URLs</li>
<li><dfn data-x-href="https://url.spec.whatwg.org/#syntax-url-absolute">Absolute URL</dfn></li>
<li><dfn data-x-href="https://url.spec.whatwg.org/#syntax-url-relative">Relative URL</dfn></li>
<li><dfn data-x="host-registrable-domain" data-x-href="https://url.spec.whatwg.org/#host-registrable-domain">registrable domain</dfn></li>
<li>
The <dfn data-x-href="https://url.spec.whatwg.org/#concept-url-parser">URL parser</dfn> and
<dfn data-x-href="https://url.spec.whatwg.org/#concept-basic-url-parser">basic URL
Expand Down Expand Up @@ -77891,8 +77892,26 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {

<div w-nodev>

<p>To <dfn data-x="determining the origin">determine the origin</dfn>, given <span>browsing
context</span><var>browsingContext</var> and <span>sandboxing flag set</span>
<var>sandboxFlags</var>:</p>

<ol>
<li><p>Let <var>origin</var> be null.</p></li>

<li><p>If <var>sandboxFlags</var> has its <span>sandboxed origin browsing context flag</span>
unset, set <var>origin</var> to be <var>browsingContext</var>'s <span>creator
origin</span>.</p></li>

<li><p>If <var>origin</var> is null, set <var>origin</var> to be a unique <span
data-x="concept-origin-opaque">opaque origin</span>.</p></li>

<li><p>Return <var>origin</var>.</p></li>
</ol>

<p>To <dfn data-x="creating a new browsing context">create a new browsing context</dfn>, given
null or a <code>Document</code> object <var>creator</var>:</p>
null or a <code>Document</code> object <var>creator</var>, <span>browsing context group</span>
<var>group</var>:</p>

<ol>
<li><p>Let <var>browsingContext</var> be a new <span>browsing context</span>.</p></li>
Expand All @@ -77906,9 +77925,19 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
return <var>creator</var>'s <span data-x="concept-document-referrer-policy">referrer
policy</span>.</p></li>

<li><p>Let <var>sandboxFlags</var> be the result of <span>determining active sandboxing
flags</span> given <var>browsingContext</var>.</p></li>

<li><p>Let <var>origin</var> be the result of <span>determining the origin</span> given
<var>browsingContext</var> and <var>sandboxFlags</var>.

<li><p>Let <var>agent</var> be the result of obtaining a <span
data-x="obtain-similar-origin-window-agent">similar-origin window agent</span> given
<var>origin</var>, and <var>group</var>.</p></li>

<li>
<p>Let <var>realm execution context</var> be the result of <span>creating a new JavaScript
realm</span> with the following customizations:</p>
realm</span> provided <var>agent</var> with the following customizations:</p>

<ul>
<li><p>For the global object, create a new <code>Window</code> object.</p></li>
Expand All @@ -77924,21 +77953,16 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
<li><p>Let <var>document</var> be a new <code>Document</code>, marked as an <span data-x="HTML
documents">HTML document</span> in <span>quirks mode</span>, whose <span
data-x="concept-document-content-type">content type</span> is "<code data-x="">text/html</code>",
and which is both <span>ready for post-load tasks</span> and <span>completely loaded</span>
immediately.</p></li>
<span>origin</span> is <var>origin</var>, <span>active sandboxing flag set</span> is
<var>sandboxFlags</var>, and which is both <span>ready for post-load tasks</span> and
<span>completely loaded</span> immediately.</p></li>

<li><p>Ensure that <var>document</var> has a single child <code>html</code> node, which itself
has two empty child nodes: a <code>head</code> element, and a <code>body</code> element.</p></li>

<li><p><span>Set the active document</span> of <var>browsingContext</var> to
<var>document</var>.</p></li>

<li id="about-blank-origin"><p>If <var>browsingContext</var>'s <span>creator origin</span> is
non-null, then set <var>document</var>'s <span>origin</span> to it.</p></li>

<li><p>Otherwise, set <var>document</var>'s <span>origin</span> to a unique <span
data-x="concept-origin-opaque">opaque origin</span>.</p></li>

<li><p>If <var>browsingContext</var>'s <span>creator URL</span> is non-null, then set
<var>document</var>'s <span data-x="the document's referrer">referrer</span> to the <span
data-x="concept-url-serializer">serialization</span> of it.</p></li>
Expand All @@ -77947,8 +77971,6 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
<var>document</var>'s <span data-x="concept-document-referrer-policy">referrer policy</span> to
it.</p></li>

<li><p><span>Implement the sandboxing</span> for <var>document</var>.</p></li>

<li><p><span>Initialize a document's feature policy</span> given <var>document</var>. <ref
spec="FEATUREPOLICY"></p></li>

Expand All @@ -77974,15 +77996,17 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
context</dfn>, given a <span>browsing context</span> <var>opener</var>:</p>

<ol>
<li><p>Let <var>browsingContext</var> be the result of <span>creating a new browsing
context</span> with <var>opener</var>'s <span>active document</span>.</p></li>
<li><p>Let <var>group</var> be <var>opener</var>'s <span>top-level browsing context</span>'s
<span data-x="tlbc group">group</span></p></li>

<li><p>Assert: <var>opener</var>'s <span>top-level browsing context</span>'s <span data-x="tlbc
group">group</span> is non-null, as <span data-x="navigate">navigating</span> invokes this
directly.</p></li>
<li><p>Assert: <var>group</var> is non-null, as <span data-x="navigate">navigating</span> invokes
this directly.</p></li>

<li><p><span data-x="bcg append">Append</span> <var>browsingContext</var> to <var>opener</var>'s
<span>top-level browsing context</span>'s <span data-x="tlbc group">group</span>.</p></li>
<li><p>Let <var>browsingContext</var> be the result of <span>creating a new browsing
context</span> with <var>opener</var>'s <span>active document</span>, and <var>group</var>.</p></li>

<li><p><span data-x="bcg append">Append</span> <var>browsingContext</var> to
<var>group</var>.</p></li>

<li><p>Set <var>browsingContext</var>'s <span>opener browsing context</span> to
<var>opener</var>.</p></li>
Expand Down Expand Up @@ -78010,7 +78034,8 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {

<ol>
<li><p>Let <var>browsingContext</var> be the result of <span>creating a new browsing
context</span> with <var>element</var>'s <span>node document</span>.</p></li>
context</span> with <var>element</var>'s <span>node document</span>, and <var>element</var>'s
<span>top-level browsing context</span>'s <span data-x="tlbc group">group</span></p></li>

<li><p>Set <var>element</var>'s <span>nested browsing context</span> to
<var>browsingContext</var>.</p></li>
Expand Down Expand Up @@ -81241,31 +81266,26 @@ interface <dfn>BarProp</dfn> {

<hr>

<p>To <dfn>implement the sandboxing</dfn> for a <code>Document</code> object <var>document</var>,
populate <var>document</var>'s <span>active sandboxing flag set</span> with the union of the flags
that are present in the following <span data-x="sandboxing flag set">sandboxing flag
sets</span>:</p>
<p>To <dfn data-x="determining active sandboxing flags">determine active sandboxing flags</dfn>
for a <span data-x="concept-document-bc">browsing context</span> <var>browsing context</var> given
an optional <var>navigation resource</var>, union the flags that are present in the following
<span data-x="sandboxing flag set">sandboxing flag sets</span>:</p>

<ul>
<li><p>If <var>document</var>'s <span data-x="concept-document-bc">browsing context</span> is a
<span>top-level browsing context</span>, then: the flags set on the <span>browsing
context</span>'s <span>popup sandboxing flag set</span>.</p></li>
<li><p>If <var>browsing context</var> is a <span>top-level browsing context</span>, then: the
flags set on the <span>popup sandboxing flag set</span>.</p></li>

<li><p>If <var>document</var>'s <span data-x="concept-document-bc">browsing context</span> is a
<span>nested browsing context</span>, then: the flags set on the <span>browsing context</span>'s
<span><code>iframe</code> sandboxing flag set</span>.</p></li>
<li><p>If <var>browsing context</var>'s is a <span>nested browsing context</span>, then: the
flags set on the <span><code>iframe</code> sandboxing flag set</span>.</p></li>

<li><p>If <var>document</var>'s <span data-x="concept-document-bc">browsing context</span> is a
<span>nested browsing context</span>, then: the flags set on the <span>browsing context</span>'s
<span>parent browsing context</span>'s <span>active document</span>'s <span>active sandboxing
flag set</span>.</p></li>
<li><p>If <var>browsing context</var>'s is a <span>nested browsing context</span>, then: the
flags set on the <span>parent browsing context</span>'s <span>active document</span>'s
<span>active sandboxing flag set</span>.</p></li>

<li><p>The flags set on <var>document</var>'s resource's <span>forced sandboxing flag set</span>,
if it has one.</p></li>
<li><p>If <var>navigation resource</var> is not null, the flags set on <var>navigation
resource</var>'s <span>forced sandboxing flag set</span>.</p></li>
</ul>



<h3 split-filename="history" id="history">Session history and navigation</h3>

<h4>The session history of browsing contexts</h4>
Expand Down Expand Up @@ -83574,6 +83594,9 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
response</span> to here.</p>

<ol>
<li><p>Let <var>sandboxFlags</var> be the result of <span>determining active sandboxing
flags</span> given <var>browsingContext</var>, and <var>response</var>.</p></li>

<li><p>If <var>browsingContext</var>'s only entry in its <span>session history</span> is the
<code>about:blank</code> <code>Document</code> that was added when <var>browsingContext</var> was
<span data-x="creating a new browsing context">created</span>, and navigation is occurring with
Expand All @@ -83584,9 +83607,15 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
<p>Otherwise:</p>

<ol>

<li><p>Let <var>agent</var> be the result of obtaining a <span
data-x="obtain-similar-origin-window-agent">similar-origin window agent</span> given
<var>document</var>'s <span>origin</span>, and <var>browsingContext</var>'s <span data-x="tlbc
group">group</span>.</p></li>

<li>
<p>Let <var>realm execution context</var> be the result of <span>creating a new JavaScript
realm</span> with the following customizations:</p>
realm</span> provided <var>agent</var> with the following customizations:</p>

<ul>
<li><p>For the global object, create a new <code>Window</code> object.</p></li>
Expand Down Expand Up @@ -83633,7 +83662,8 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
"<code data-x="">no-referrer</code>" at this point.</p>
</li>

<li><p><span>Implement the sandboxing</span> for <var>document</var>.</p></li>
<li><p>Set <var>document</var>'s <span>active sandboxing flag set</span> to
<var>sandboxFlags</var>.</p></li>

<li>
<p><span>Initialize a document's feature policy from a response</span> given
Expand All @@ -83653,6 +83683,10 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
</div>
</li>

<li><p>Obtain a <span data-x="obtain-similar-origin-window-agent">similar-origin window agent
</span> given <var>document</var> and <var>browsingContext</var>'s <span>top-level browsing
context</span>'s <span data-x="tlbc group">group</span>.</p></li>

<li>
<p>If <var>response</var> has a `<code data-x="http-refresh">Refresh</code>` header, then:</p>

Expand Down Expand Up @@ -90072,6 +90106,66 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
in particular among which <span data-x="agent">agents</span> the backing data of
<code>SharedArrayBuffer</code> objects can be shared.</p>

<p>A <span>browsing context group</span> has associated <dfn data-export="">shared agent
clusters</dfn> (a <span data-x="ordered map">map</span> of <span>agent cluster key</span> to
<span>agent cluster</span>).</p>

<p>A <dfn data-export="">scheme-and-site</dfn> is a tuple of a <span
data-x="concept-url-scheme">scheme</span> and a <span data-x="concept-domain">domain</span>.</p>

<p>An <dfn data-export="">agent cluster key</dfn> is an <span>origin</span> or a
<span>scheme-and-site</span>.</p>

<p>To obtain an <span>agent cluster key</span>, given an origin <var>origin</var>, run these
steps:</p>

<ol>

<li><p>If <var>origin</var> is an <span data-x="concept-origin-opaque">opaque origin</span>, then
return <var>origin</var>.</p></li>

<li><p>If <var>origin</var>'s host's <span data-x="host-registrable-domain">registrable
domain</span> is null, then return <var>origin</var>.</p></li>

<li><p>Return (<var>origin</var>'s <span data-x="concept-url-scheme">scheme</span>,
<var>origin</var>'s <span data-x="host-registrable-domain">registrable
domain</span>).</p></li>

</ol>

<p>To obtain a <dfn data-export="" data-x="obtain-similar-origin-window-agent">similar-origin
window agent</dfn>, given an <span>origin</span> <var>origin</var>, and <span>browsing context
group</span> <var>group</var>, run these steps:</p>

<ol>

<li><p>Let <var>clusterKey</var> be the result of obtaining an <span>agent cluster key</span>
given <var>origin</var>.</p></li>

<li><p>Let <var>agentCluster</var> be the result of obtaining a <span>browsing context agent
cluster</span> with <var>group</var> and <var>clusterKey</var>.</p></li>

<li><p>If <var>agentCluster</var> does not contain an agent, then add a new <span>similar-origin
window agent</span> to it.</p></li>

<li><p>Return <var>agentCluster</var>'s <span>similar-origin window agent</span>.</p></li>

</ol>

<p>To obtain a <dfn data-export="">browsing context agent cluster</dfn>, given a <span>browsing
context group</span> <var>group</var> and <span>agent cluster key</span> <var>key</var>, run these
steps:</p>

<ol>

<li><p>If <var>group</var>'s <span>shared agent clusters</span>[<var>key</var>] does not exist,
then set <var>group</var>'s <span>shared agent clusters</span>[<var>key</var>] to a new agent
cluster.</p></li>

<li><p>Return <var>group</var>'s <span>shared agent clusters</span>[<var>key</var>].</p></li>

</ol>

<p class="note">Conceptually, the <span>agent cluster</span> concept is an
architecture-independent, idealized "process boundary" that groups together multiple "threads"
(<span data-x="agent">agents</span>). The <span data-x="agent cluster">agent clusters</span>
Expand Down

0 comments on commit c8bb7d8

Please sign in to comment.