Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce SameOrigin and SameAgentCluster for [Serializable] #4940

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 44 additions & 19 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -8104,9 +8104,23 @@ interface <dfn>DOMStringList</dfn> {
<p>It is up to the definition of individual platform objects to determine what data is serialized
annevk marked this conversation as resolved.
Show resolved Hide resolved
and deserialized by these steps. Typically the steps are very symmetric.</p>

domenic marked this conversation as resolved.
Show resolved Hide resolved
<p>The <code data-x="Serializable">[Serializable]</code> extended attribute must take no
arguments, and must only appear on an interface. It must not appear more than once on an
interface.</p>
<p>The <code data-x="Serializable">[Serializable]</code> extended attribute must take one of: no
arguments, the identifier <dfn data-x="Serializable SameOrigin"><code>SameOrigin</code></dfn>, the
annevk marked this conversation as resolved.
Show resolved Hide resolved
identifier <dfn data-x="Serializable SameAgentCluster"><code>SameAgentCluster</code></dfn>, or an
identifier list containing both <code data-x="Serializable SameOrigin">SameOrigin</code> and <code
data-x="Serializable SameAgentCluster">SameAgentCluster</code>. It must only appear on an
interface. It must not appear more than once on an interface.</p>

<p class="note">The <code data-x="Serializable SameOrigin">SameOrigin</code> identifier prevents
deserialization in cross-origin realms. Similarly, the <code data-x="Serializable
SameAgentCluster">SameAgentCluster</code> identifier prevents deserialization in realms belonging
to other agent clusters.</p>

<p class="XXX">As discussed in <a href="https://github.com/whatwg/html/issues/4920">issue
#4920</a>, new features are strongly encouraged to use either <code data-x="Serializable
SameOrigin">SameOrigin</code> or <code data-x="Serializable SameOrigin">SameOrigin</code> and
<code data-x="Serializable SameAgentCluster">SameAgentCluster</code> together. A future
refactoring will likely tightly couple the latter.</p>

<p>For a given <span>platform object</span>, only the object's <span>primary interface</span> is
considered during the (de)serialization process. Thus, if inheritance is involved in defining the
Expand Down Expand Up @@ -8306,8 +8320,8 @@ 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]]: the <span>surrounding agent</span>'s <span>agent cluster</span>
}.</p></li>
</ol>
</li>

Expand Down Expand Up @@ -8470,6 +8484,17 @@ 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's <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 the <span>current settings
object</span>'s <span data-x="concept-settings-object-origin">origin</span>.</p></li>

<li><p>If <var>value</var>'s interface's <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 the <span>surrounding agent</span>'s
<span>agent cluster</span>.</p></li>

<li><p>Set <var>deep</var> to true.</p></li>
</ol>
</li>
Expand Down Expand Up @@ -8722,6 +8747,15 @@ 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]] field 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]] field 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 @@ -8751,20 +8785,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