Skip to content

Commit

Permalink
Raise the bar for SharedArrayBuffer via postMessage()
Browse files Browse the repository at this point in the history
This depends on the work to add Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy. It specifies how postMessage() is affected when both those headers are set for the agent clusters they impact.

Additionally, it exposes this state through self.crossOriginIsolated.

Tests: see links in #4732.

Closes #4732.
  • Loading branch information
annevk committed Jan 2, 2020
1 parent 5b42943 commit 89bf65b
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -8302,13 +8302,26 @@ interface <dfn>DOMStringList</dfn> {
<p>If ! <span>IsSharedArrayBuffer</span>(<var>value</var>) is true, then:

<ol>
<li><p>Let <var>agentCluster</var> be <span>surrounding agent</span>'s
<span>agent cluster</span>.</p></li>

<li>
<p>If <var>agentCluster</var>'s <dfn>cross-origin isolated</dfn> is false, then throw a
<!-- TODO: this is not the place to <dfn> this, but doing this for now so the build does not
fail -->
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p>

<p class="note">This check is only needed when serializing (and not when deserializing) as
<span>cross-origin isolated</span> cannot change over time and a
<code>SharedArrayBuffer</code> cannot leave an <span>agent cluster</span>.</p>
</li>

<li><p>If <var>forStorage</var> is true, then throw a
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Set <var>serialized</var> to { [[Type]]: "SharedArrayBuffer", [[ArrayBufferData]]:
<var>value</var>.[[ArrayBufferData]], [[ArrayBufferByteLength]]: <var>size</var>,
[[AgentCluster]]: the <span>current Realm Record</span>'s corresponding <span>agent
cluster</span> }.</p></li>
[[AgentCluster]]: <var>agentCluster</var> }.</p></li>
</ol>
</li>

Expand Down Expand Up @@ -94167,6 +94180,7 @@ interface mixin <dfn>DocumentAndElementEventHandlers</dfn> {

interface mixin <dfn>WindowOrWorkerGlobalScope</dfn> {
[Replaceable] readonly attribute USVString <span data-x="dom-origin">origin</span>;
readonly attribute boolean <span data-x="dom-crossOriginIsolated">crossOriginIsolated</span>;

// base64 utility methods
DOMString <span data-x="dom-btoa">btoa</span>(DOMString data);
Expand All @@ -94190,8 +94204,17 @@ interface mixin <dfn>WindowOrWorkerGlobalScope</dfn> {

<dl class="domintro">
<dt><var>origin</var> = self . <code subdfn data-x="dom-origin">origin</code></dt>

<dd><p>Returns the global object's <span>origin</span>, serialized as string.</p></dd>

<dt><var>origin</var> = self . <code subdfn data-x="dom-crossOriginIsolated">crossOriginIsolated</code></dt>
<dd>
<p>Returns the <span>surrounding agent</span>'s <span>agent cluster</span>'s
<span>cross-origin isolated</span>.</p>

<p>(This value depends on the <code data-x="">Cross-Origin-Opener-Policy</code> and <code
data-x="">Cross-Origin-Embedder-Policy</code> HTTP response headers and determines whether
<code>SharedArrayBuffer</code> can be used with <code data-x="">postMessage()</code> APIs.)</p>
</dd>
</dl>

<div class="example">
Expand All @@ -94216,6 +94239,10 @@ document.body.appendChild(frame)</code></pre>
data-x="concept-settings-object-origin">origin</span>, <span data-x="serialization of an
origin">serialized</span>.</p>

<p>The <dfn data-x="dom-crossOriginIsolated"><code>crossOriginIsolated</code></dfn> attribute's
getter must return the <span>surrounding agent</span>'s <span>agent cluster</span>'s
<span>cross-origin isolated</span>.</p>


<h3 id="atob">Base64 utility methods</h3>

Expand Down

0 comments on commit 89bf65b

Please sign in to comment.