Skip to content

Commit 3e5abf2

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 22e2ebd commit 3e5abf2

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
@@ -7922,13 +7922,24 @@ interface <dfn>DOMStringList</dfn> {
79227922
<p>If ! <span>IsSharedArrayBuffer</span>(<var>value</var>) is true, then:
79237923

79247924
<ol>
7925+
<li><p>Let <var>agentCluster</var> be the <span>surrounding agent</span>'s
7926+
<span>agent cluster</span>.</p></li>
7927+
7928+
<li>
7929+
<p>If <var>agentCluster</var>'s <span>cross-origin isolated</span> is false, then throw a
7930+
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p>
7931+
7932+
<p class="note">This check is only needed when serializing (and not when deserializing) as
7933+
<span>cross-origin isolated</span> cannot change over time and a
7934+
<code>SharedArrayBuffer</code> cannot leave an <span>agent cluster</span>.</p>
7935+
</li>
7936+
79257937
<li><p>If <var>forStorage</var> is true, then throw a
79267938
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li>
79277939

79287940
<li><p>Set <var>serialized</var> to { [[Type]]: "SharedArrayBuffer", [[ArrayBufferData]]:
79297941
<var>value</var>.[[ArrayBufferData]], [[ArrayBufferByteLength]]: <var>size</var>,
7930-
[[AgentCluster]]: the <span>current Realm Record</span>'s corresponding <span>agent
7931-
cluster</span> }.</p></li>
7942+
[[AgentCluster]]: <var>agentCluster</var> }.</p></li>
79327943
</ol>
79337944
</li>
79347945

@@ -91068,6 +91079,7 @@ interface mixin <dfn>DocumentAndElementEventHandlers</dfn> {
9106891079

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

9107291084
// base64 utility methods
9107391085
DOMString <span data-x="dom-btoa">btoa</span>(DOMString data);
@@ -91091,8 +91103,17 @@ interface mixin <dfn>WindowOrWorkerGlobalScope</dfn> {
9109191103

9109291104
<dl class="domintro">
9109391105
<dt><var>origin</var> = self . <code subdfn data-x="dom-origin">origin</code></dt>
91094-
9109591106
<dd><p>Returns the global object's <span>origin</span>, serialized as string.</p></dd>
91107+
91108+
<dt><var>origin</var> = self . <code subdfn data-x="dom-crossOriginIsolated">crossOriginIsolated</code></dt>
91109+
<dd>
91110+
<p>Returns the <span>surrounding agent</span>'s <span>agent cluster</span>'s
91111+
<span>cross-origin isolated</span>.</p>
91112+
91113+
<p>(This value depends on the <code data-x="">Cross-Origin-Opener-Policy</code> and <code
91114+
data-x="">Cross-Origin-Embedder-Policy</code> HTTP response headers and determines whether
91115+
<code>SharedArrayBuffer</code> can be used with <code data-x="">postMessage()</code> APIs.)</p>
91116+
</dd>
9109691117
</dl>
9109791118

9109891119
<div class="example">
@@ -91117,6 +91138,10 @@ document.body.appendChild(frame)</code></pre>
9111791138
data-x="concept-settings-object-origin">origin</span>, <span data-x="serialization of an
9111891139
origin">serialized</span>.</p>
9111991140

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

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

0 commit comments

Comments
 (0)