Skip to content

Commit 89bf65b

Browse files
committed
Raise the bar for SharedArrayBuffer via postMessage()
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.
1 parent 5b42943 commit 89bf65b

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

source

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8302,13 +8302,26 @@ interface <dfn>DOMStringList</dfn> {
83028302
<p>If ! <span>IsSharedArrayBuffer</span>(<var>value</var>) is true, then:
83038303

83048304
<ol>
8305+
<li><p>Let <var>agentCluster</var> be <span>surrounding agent</span>'s
8306+
<span>agent cluster</span>.</p></li>
8307+
8308+
<li>
8309+
<p>If <var>agentCluster</var>'s <dfn>cross-origin isolated</dfn> is false, then throw a
8310+
<!-- TODO: this is not the place to <dfn> this, but doing this for now so the build does not
8311+
fail -->
8312+
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p>
8313+
8314+
<p class="note">This check is only needed when serializing (and not when deserializing) as
8315+
<span>cross-origin isolated</span> cannot change over time and a
8316+
<code>SharedArrayBuffer</code> cannot leave an <span>agent cluster</span>.</p>
8317+
</li>
8318+
83058319
<li><p>If <var>forStorage</var> is true, then throw a
83068320
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li>
83078321

83088322
<li><p>Set <var>serialized</var> to { [[Type]]: "SharedArrayBuffer", [[ArrayBufferData]]:
83098323
<var>value</var>.[[ArrayBufferData]], [[ArrayBufferByteLength]]: <var>size</var>,
8310-
[[AgentCluster]]: the <span>current Realm Record</span>'s corresponding <span>agent
8311-
cluster</span> }.</p></li>
8324+
[[AgentCluster]]: <var>agentCluster</var> }.</p></li>
83128325
</ol>
83138326
</li>
83148327

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

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

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

9419194205
<dl class="domintro">
9419294206
<dt><var>origin</var> = self . <code subdfn data-x="dom-origin">origin</code></dt>
94193-
9419494207
<dd><p>Returns the global object's <span>origin</span>, serialized as string.</p></dd>
94208+
94209+
<dt><var>origin</var> = self . <code subdfn data-x="dom-crossOriginIsolated">crossOriginIsolated</code></dt>
94210+
<dd>
94211+
<p>Returns the <span>surrounding agent</span>'s <span>agent cluster</span>'s
94212+
<span>cross-origin isolated</span>.</p>
94213+
94214+
<p>(This value depends on the <code data-x="">Cross-Origin-Opener-Policy</code> and <code
94215+
data-x="">Cross-Origin-Embedder-Policy</code> HTTP response headers and determines whether
94216+
<code>SharedArrayBuffer</code> can be used with <code data-x="">postMessage()</code> APIs.)</p>
94217+
</dd>
9419594218
</dl>
9419694219

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

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

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

0 commit comments

Comments
 (0)