Skip to content

Commit e92bab8

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 e63d98e commit e92bab8

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
@@ -8282,13 +8282,26 @@ interface <dfn>DOMStringList</dfn> {
82828282
<p>If ! <span>IsSharedArrayBuffer</span>(<var>value</var>) is true, then:
82838283

82848284
<ol>
8285+
<li><p>Let <var>agentCluster</var> be the <span>surrounding agent</span>'s
8286+
<span>agent cluster</span>.</p></li>
8287+
8288+
<li>
8289+
<p>If <var>agentCluster</var>'s <dfn>cross-origin isolated</dfn> is false, then throw a
8290+
<!-- TODO: this is not the place to <dfn> this, but doing this for now so the build does not
8291+
fail -->
8292+
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p>
8293+
8294+
<p class="note">This check is only needed when serializing (and not when deserializing) as
8295+
<span>cross-origin isolated</span> cannot change over time and a
8296+
<code>SharedArrayBuffer</code> cannot leave an <span>agent cluster</span>.</p>
8297+
</li>
8298+
82858299
<li><p>If <var>forStorage</var> is true, then throw a
82868300
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li>
82878301

82888302
<li><p>Set <var>serialized</var> to { [[Type]]: "SharedArrayBuffer", [[ArrayBufferData]]:
82898303
<var>value</var>.[[ArrayBufferData]], [[ArrayBufferByteLength]]: <var>size</var>,
8290-
[[AgentCluster]]: the <span>current Realm Record</span>'s corresponding <span>agent
8291-
cluster</span> }.</p></li>
8304+
[[AgentCluster]]: <var>agentCluster</var> }.</p></li>
82928305
</ol>
82938306
</li>
82948307

@@ -94371,6 +94384,7 @@ interface mixin <dfn>DocumentAndElementEventHandlers</dfn> {
9437194384

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

9437594389
// base64 utility methods
9437694390
DOMString <span data-x="dom-btoa">btoa</span>(DOMString data);
@@ -94394,8 +94408,17 @@ interface mixin <dfn>WindowOrWorkerGlobalScope</dfn> {
9439494408

9439594409
<dl class="domintro">
9439694410
<dt><var>origin</var> = self . <code subdfn data-x="dom-origin">origin</code></dt>
94397-
9439894411
<dd><p>Returns the global object's <span>origin</span>, serialized as string.</p></dd>
94412+
94413+
<dt><var>origin</var> = self . <code subdfn data-x="dom-crossOriginIsolated">crossOriginIsolated</code></dt>
94414+
<dd>
94415+
<p>Returns the <span>surrounding agent</span>'s <span>agent cluster</span>'s
94416+
<span>cross-origin isolated</span>.</p>
94417+
94418+
<p>(This value depends on the <code data-x="">Cross-Origin-Opener-Policy</code> and <code
94419+
data-x="">Cross-Origin-Embedder-Policy</code> HTTP response headers and determines whether
94420+
<code>SharedArrayBuffer</code> can be used with <code data-x="">postMessage()</code> APIs.)</p>
94421+
</dd>
9439994422
</dl>
9440094423

9440194424
<div class="example">
@@ -94420,6 +94443,10 @@ document.body.appendChild(frame)</code></pre>
9442094443
data-x="concept-settings-object-origin">origin</span>, <span data-x="serialization of an
9442194444
origin">serialized</span>.</p>
9442294445

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

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

0 commit comments

Comments
 (0)