Skip to content

Commit

Permalink
Introduce SameOrigin and SameAgentCluster for [Serializable]
Browse files Browse the repository at this point in the history
Useful for WebAssembly.Module and RTCCertificate. SharedArrayBuffer can reuse the underlying infrastructure.

Fixes #4939. Helps with #4920.
  • Loading branch information
annevk committed Sep 27, 2019
1 parent a59059b commit cf022e6
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -8101,12 +8101,17 @@ interface <dfn>DOMStringList</dfn> {
and deserialized by these steps. Typically the steps are very symmetric.</p>

<p>The <code data-x="Serializable">[Serializable]</code> extended attribute must take no
arguments, and must not appear on anything other than an interface. It must appear only once on an
interface. It must not be used on a callback interface. If it appears on a partial interface or an
interface that is really a mixin, then it must also appear on the original or mixed-in-to
interface, and any supplied <span>serialization steps</span> and <span>deserialization
steps</span> for the partial interface or mixin should be understood as being appended to those of
the original or mixed-in-to interface.</p>
arguments, an identifier, or an identifier list, and must not appear on anything other than an
interface. It must appear only once on an interface. It must not be used on a callback interface.
If it appears on a partial interface or an interface that is really a mixin, then it must also
appear on the original or mixed-in-to interface, and any supplied <span>serialization steps</span>
and <span>deserialization steps</span> for the partial interface or mixin should be understood as
being appended to those of the original or mixed-in-to interface.</p>

<p>The identifiers for the <code data-x="Serializable">[Serializable]</code> extended
attribute are <dfn data-x="Serializable SameOrigin"><code>SameOrigin</code></dfn> and <dfn
data-x="Serializable SameAgentCluster"><code>SameAgentCluster</code></dfn>. These can be used to
restrict where a <span>serializable object</span> can be deserialized.</p>

<div class="example">
<p>Let's say we were defining a platform object <code data-x="">Person</code>, which had
Expand Down Expand Up @@ -8296,8 +8301,7 @@ interface <dfn>DOMStringList</dfn> {

<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>
[[EnforceAgentCluster]]: null }.</p></li>
</ol>
</li>

Expand Down Expand Up @@ -8460,6 +8464,15 @@ interface <dfn>DOMStringList</dfn> {

<li><p>Set <var>serialized</var> to { [[Type]]: <var>typeString</var> }.</p></li>

<li><p>If <var>value</var>'s interface <code data-x="Serializable">[Serializable]</code>
extended attribute contains the <code data-x="Serializable SameOrigin">SameOrigin</code>
identifier, then set <var>serialized</var>.[[EnforceOrigin]] to null.</p></li>

<li><p>If <var>value</var>'s interface <code data-x="Serializable">[Serializable]</code>
extended attribute contains the <code data-x="Serializable
SameAgentCluster">SameAgentCluster</code> identifier, then set
<var>serialized</var>.[[EnforceAgentCluster]] to null.</p></li>

<li><p>Set <var>deep</var> to true.</p></li>
</ol>
</li>
Expand Down Expand Up @@ -8642,6 +8655,14 @@ interface <dfn>DOMStringList</dfn> {
</ol>
</li>

<li><p>If <var>serialized</var> has an [[EnforceOrigin]] internal slot, then set
<var>serialized</var>.[[EnforceOrigin]] to the <span>current settings object</span>'s <span
data-x="concept-settings-object-origin">origin</span>.</p></li>

<li><p>If <var>serialized</var> has an [[EnforceAgentCluster]] internal slot, then set
<var>serialized</var>.[[EnforceAgentCluster]] to the <span>surrounding agent</span>'s <span>agent
cluster</span>.</p></li>

<li><p>Return <var>serialized</var>.</p></li>
</ol>

Expand Down Expand Up @@ -8712,6 +8733,16 @@ o.myself = o;</code></pre>

<li><p>Let <var>value</var> be an uninitialized value.</p></li>

<li><p>If <var>serialized</var> has an [[EnforceOrigin]] internal slot and its value is not
<span>same origin</span> with <var>targetRealm</var>'s <span
data-x="concept-realm-settings-object">settings object</span>'s <span
data-x="concept-settings-object-origin">origin</span>, then throw a
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If <var>serialized</var> has an [[EnforceAgentCluster]] internal slot and its value is not
<var>targetRealm</var>'s corresponding <span>agent cluster</span>, then throw a
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If <var>serialized</var>.[[Type]] is "primitive", then set <var>value</var> to
<var>serialized</var>.[[Value]].</p>

Expand Down Expand Up @@ -8741,20 +8772,11 @@ o.myself = o;</code></pre>
<var>serialized</var>.[[OriginalSource]], and whose [[OriginalFlags]] internal slot value is
<var>serialized</var>.[[OriginalFlags]].</p></li>

<li>
<p>Otherwise, if <var>serialized</var>.[[Type]] is "SharedArrayBuffer", then:</p>

<ol>
<li><p>If <var>targetRealm</var>'s corresponding <span>agent cluster</span> is not
<var>serialized</var>.[[AgentCluster]], then then throw a
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Otherwise, set <var>value</var> to a new SharedArrayBuffer object in
<var>targetRealm</var> whose [[ArrayBufferData]] internal slot value is
<var>serialized</var>.[[ArrayBufferData]] and whose [[ArrayBufferByteLength]] internal slot
value is <var>serialized</var>.[[ArrayBufferByteLength]].</p></li>
</ol>
</li>
<li><p>Otherwise, if <var>serialized</var>.[[Type]] is "SharedArrayBuffer", then set
<var>value</var> to a new SharedArrayBuffer object in <var>targetRealm</var> whose
[[ArrayBufferData]] internal slot value is <var>serialized</var>.[[ArrayBufferData]], and whose
[[ArrayBufferByteLength]] internal slot value is
<var>serialized</var>.[[ArrayBufferByteLength]].</p></li>

<li>
<p>Otherwise, if <var>serialized</var>.[[Type]] is "ArrayBuffer", then set <var>value</var> to a
Expand Down

0 comments on commit cf022e6

Please sign in to comment.