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 Jun 26, 2020
1 parent 8620da3 commit b3c2c6c
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -7992,13 +7992,24 @@ interface <dfn>DOMStringList</dfn> {
<p>If ! <span>IsSharedArrayBuffer</span>(<var>value</var>) is true, then:

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

<li>
<p>If <var>agentCluster</var>'s <span>cross-origin isolated</span> is false, then throw a
<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 @@ -92076,6 +92087,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-isSecureContext">isSecureContext</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 Down Expand Up @@ -92104,8 +92116,17 @@ interface mixin <dfn>WindowOrWorkerGlobalScope</dfn> {
spec=SECURE-CONTEXTS></p></dd>

<dt>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>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 Down Expand Up @@ -92136,6 +92157,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>

</div>


Expand Down

0 comments on commit b3c2c6c

Please sign in to comment.