Skip to content

Commit b3c2c6c

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 8620da3 commit b3c2c6c

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

source

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7992,13 +7992,24 @@ interface <dfn>DOMStringList</dfn> {
79927992
<p>If ! <span>IsSharedArrayBuffer</span>(<var>value</var>) is true, then:
79937993

79947994
<ol>
7995+
<li><p>Let <var>agentCluster</var> be the <span>surrounding agent</span>'s
7996+
<span>agent cluster</span>.</p></li>
7997+
7998+
<li>
7999+
<p>If <var>agentCluster</var>'s <span>cross-origin isolated</span> is false, then throw a
8000+
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p>
8001+
8002+
<p class="note">This check is only needed when serializing (and not when deserializing) as
8003+
<span>cross-origin isolated</span> cannot change over time and a
8004+
<code>SharedArrayBuffer</code> cannot leave an <span>agent cluster</span>.</p>
8005+
</li>
8006+
79958007
<li><p>If <var>forStorage</var> is true, then throw a
79968008
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li>
79978009

79988010
<li><p>Set <var>serialized</var> to { [[Type]]: "SharedArrayBuffer", [[ArrayBufferData]]:
79998011
<var>value</var>.[[ArrayBufferData]], [[ArrayBufferByteLength]]: <var>size</var>,
8000-
[[AgentCluster]]: the <span>current Realm Record</span>'s corresponding <span>agent
8001-
cluster</span> }.</p></li>
8012+
[[AgentCluster]]: <var>agentCluster</var> }.</p></li>
80028013
</ol>
80038014
</li>
80048015

@@ -92076,6 +92087,7 @@ interface mixin <dfn>DocumentAndElementEventHandlers</dfn> {
9207692087
interface mixin <dfn>WindowOrWorkerGlobalScope</dfn> {
9207792088
[Replaceable] readonly attribute USVString <span data-x="dom-origin">origin</span>;
9207892089
readonly attribute boolean <span data-x="dom-isSecureContext">isSecureContext</span>;
92090+
readonly attribute boolean <span data-x="dom-crossOriginIsolated">crossOriginIsolated</span>;
9207992091

9208092092
// base64 utility methods
9208192093
DOMString <span data-x="dom-btoa">btoa</span>(DOMString data);
@@ -92104,8 +92116,17 @@ interface mixin <dfn>WindowOrWorkerGlobalScope</dfn> {
9210492116
spec=SECURE-CONTEXTS></p></dd>
9210592117

9210692118
<dt>self . <code subdfn data-x="dom-origin">origin</code></dt>
92107-
9210892119
<dd><p>Returns the global object's <span>origin</span>, serialized as string.</p></dd>
92120+
92121+
<dt>self . <code subdfn data-x="dom-crossOriginIsolated">crossOriginIsolated</code></dt>
92122+
<dd>
92123+
<p>Returns the <span>surrounding agent</span>'s <span>agent cluster</span>'s <span>cross-origin
92124+
isolated</span>.</p>
92125+
92126+
<p>(This value depends on the <code data-x="">Cross-Origin-Opener-Policy</code> and <code
92127+
data-x="">Cross-Origin-Embedder-Policy</code> HTTP response headers and determines whether
92128+
<code>SharedArrayBuffer</code> can be used with <code data-x="">postMessage()</code> APIs.)</p>
92129+
</dd>
9210992130
</dl>
9211092131

9211192132
<div class="example">
@@ -92136,6 +92157,10 @@ document.body.appendChild(frame)</code></pre>
9213692157
data-x="concept-settings-object-origin">origin</span>, <span data-x="serialization of an
9213792158
origin">serialized</span>.</p>
9213892159

92160+
<p>The <dfn data-x="dom-crossOriginIsolated"><code>crossOriginIsolated</code></dfn> attribute's
92161+
getter must return the <span>surrounding agent</span>'s <span>agent cluster</span>'s
92162+
<span>cross-origin isolated</span>.</p>
92163+
9213992164
</div>
9214092165

9214192166

0 commit comments

Comments
 (0)