Skip to content

Commit

Permalink
Throw for cross-origin [[Delete]] and use "SecurityError" as needed
Browse files Browse the repository at this point in the history
Returning false for [[Delete]] (on Window and Location objects) would
only cause its callers to throw in strict mode. Implementations
however always throw.

We also decided to throw "SecurityError" for [[DefineOwnProperty]]
and [[Set]] (the latter through CrossOriginSet). We did not do this
for all internal methods: only those where throwing was unique to
their cross-origin behavior.

Fixes whatwg#1726.
  • Loading branch information
annevk authored and Alice Boxhall committed Jan 7, 2019
1 parent af494a2 commit 9ab2789
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -78380,21 +78380,17 @@ console.assert(iframeWindow.frameElement === null);
<li><p>Assert: <var>desc</var> is not undefined.</p></li>

<li>
<p>If <span>IsAccessorDescriptor</span>(<var>desc</var>) is true, then:</p>
<p>If <var>desc</var>.[[Set]] is present and its value is not undefined, then:

<ol>
<li><p>Let <var>setter</var> be <var>desc</var>.[[Set]].</p></li>

<li><p>If <var>setter</var> is undefined, return false.</p></li>

<li><p>Perform ? <span>Call</span>(<var>setter</var>, <var>Receiver</var>,
«<var>V</var>»).</p></li>

<li><p>Return true.</p></li>
</ol>
</li>

<li><p>Return false.</p></li>
<li><p>Throw a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
</ol>

<h5><dfn>CrossOriginOwnPropertyKeys</dfn> ( <var>O</var> )</h5>
Expand Down Expand Up @@ -79344,22 +79340,28 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
)</h4>

<ol>
<li><p>If <var>P</var> is an <span>array index property name</span>, return false.</p></li>

<li><p>Let <var>W</var> be the value of the
[[<span data-x="concept-windowproxy-window">Window</span>]] internal slot of
<b>this</b>.</p></li>

<li>
<p>If <span>IsPlatformObjectSameOrigin</span>(<var>W</var>) is true, then return ?
<span>OrdinaryDefineOwnProperty</span>(<var>W</var>, <var>P</var>, <var>Desc</var>).</p>
<p>If <span>IsPlatformObjectSameOrigin</span>(<var>W</var>) is true, then:

<p class="note">This is a <span>willful violation</span> of the JavaScript specification's
<span>invariants of the essential internal methods</span> to maintain compatibility with
existing Web content. See <a href="https:/tc39/ecma262/issues/672">tc39/ecma262
issue #672</a> for more information. <ref spec=JAVASCRIPT></p>
<ol>
<li><p>If <var>P</var> is an <span>array index property name</span>, return false.</p></li>

<li><p>Return false.</p></li>
<li>
<p>Return ? <span>OrdinaryDefineOwnProperty</span>(<var>W</var>, <var>P</var>,
<var>Desc</var>).</p>

<p class="note">This is a <span>willful violation</span> of the JavaScript specification's
<span>invariants of the essential internal methods</span> to maintain compatibility with
existing Web content. See <a href="https:/tc39/ecma262/issues/672">tc39/ecma262
issue #672</a> for more information. <ref spec=JAVASCRIPT></p>
</li>
</ol>

<li><p>Throw a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
</ol>

<h4 id="windowproxy-get">[[Get]] ( <var>P</var>, <var>Receiver</var> )</h4>
Expand Down Expand Up @@ -79395,16 +79397,21 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
<h4 id="windowproxy-delete">[[Delete]] ( <var>P</var> )</h4>

<ol>
<li><p>If <var>P</var> is an <span>array index property name</span>, return false.</p></li>

<li><p>Let <var>W</var> be the value of the
[[<span data-x="concept-windowproxy-window">Window</span>]] internal slot of
<b>this</b>.</p></li>

<li><p>If <span>IsPlatformObjectSameOrigin</span>(<var>W</var>) is true, then return ?
<span>OrdinaryDelete</span>(<var>W</var>, <var>P</var>).</p></li>
<li>
<p>If <span>IsPlatformObjectSameOrigin</span>(<var>W</var>) is true, then:

<li><p>Return false.</p></li>
<ol>
<li><p>If <var>P</var> is an <span>array index property name</span>, then return
false.</p></li>

<li><p>Return ? <span>OrdinaryDelete</span>(<var>W</var>, <var>P</var>).</p></li>
</ol>

<li><p>Throw a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
</ol>

<h4 id="windowproxy-ownpropertykeys">[[OwnPropertyKeys]] ( )</h4>
Expand Down Expand Up @@ -81755,7 +81762,7 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
</ol>
</li>

<li><p>Return false.</p></li>
<li><p>Throw a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
</ol>

<h5 id="location-get">[[Get]] ( <var>P</var>, <var>Receiver</var> )</h5>
Expand Down Expand Up @@ -81784,7 +81791,7 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
<li><p>If <span>IsPlatformObjectSameOrigin</span>(<b>this</b>) is true, then return ?
<span>OrdinaryDelete</span>(<b>this</b>, <var>P</var>).</p></li>

<li><p>Return false.</p></li>
<li><p>Throw a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
</ol>

<h5 id="location-ownpropertykeys">[[OwnPropertyKeys]] ( )</h5>
Expand Down

0 comments on commit 9ab2789

Please sign in to comment.