Skip to content

Commit

Permalink
Add postMessage override that provides WindowPostMessageOptions.
Browse files Browse the repository at this point in the history
Fixes issue whatwg#3799
  • Loading branch information
dtapuska committed Jul 5, 2018
1 parent 5a6930a commit 1abbadf
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -78098,11 +78098,18 @@ interface <dfn data-export="" data-dfn-type="interface">Window</dfn> : <span>Eve
void <span data-x="dom-window-cancelAnimationFrame">cancelAnimationFrame</span>(unsigned long handle);

void <span data-x="dom-window-postMessage">postMessage</span>(any message, USVString targetOrigin, optional sequence&lt;<span data-x="idl-object">object</span>&gt; transfer = []);
void <span data-x="dom-window-postMessage">postMessage</span>(any message, optional sequence&lt;<span data-x="idl-object">object</span>&gt; transfer = [], optional <span>WindowPostMessageOptions</span> options);
};
<span>Window</span> includes <span>GlobalEventHandlers</span>;
<span>Window</span> includes <span>WindowEventHandlers</span>;

callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span> time);</pre>
callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span> time);

dictionary <dfn>WindowPostMessageOptions</dfn>
{
USVString targetOrigin = "/";
};
</pre>

<!-- for more features to add here, look here:
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_window.asp
Expand Down Expand Up @@ -95379,10 +95386,9 @@ function receiver(e) {

<dl class="domintro">

<dt><var>window</var> . <code subdfn data-x="dom-window-postMessage">postMessage</code>(<var>message</var>, <var>targetOrigin</var> [, <var>transfer</var> ] )</dt>
<dt><var>window</var> . <code subdfn data-x="dom-window-postMessage">postMessage</code>(<var>message</var>[, <var>transfer</var> ] [, options ])</dt>

<dd>

<p>Posts a message to the given window. Messages can be structured objects, e.g. nested objects
and arrays, can contain JavaScript values (strings, numbers, <code>Date</code>
objects, etc), and can contain certain data objects such as <code>File</code> <code>Blob</code>,
Expand All @@ -95391,6 +95397,9 @@ function receiver(e) {
<p>Objects listed in <var>transfer</var> are transferred, not just cloned, meaning that
they are no longer usable on the sending side.</p>

<p>Target origin is specified as a member of <var>options</var>. If options is not provided
targetOrigin of the dictionary is initialized to "<code data-x="">/</code>".</p>

<p>If the origin of the target window doesn't match the given origin, the message is discarded,
to avoid information leakage. To send the message to the target regardless of origin, set the
target origin to "<code data-x="">*</code>". To restrict the message to same-origin targets only,
Expand All @@ -95402,6 +95411,15 @@ function receiver(e) {
cloned.</p>

</dd>
<dt><var>window</var> . <code data-x="dom-window-postMessage">postMessage</code>(<var>message</var>, <var>targetOrigin</var> [, <var>transfer</var> ] )</dt>

<dd>

<p>This is an alternate version of postMessage where the target origin is specified as a parameter.
Calling <code data-x="">window.postMessage(message, target, transfer);</code> is equivalent
to <code data-x="">window.postMessage(message, transfer, {targetOrigin: target});</code>

</dd>

</dl>

Expand All @@ -95417,7 +95435,7 @@ function receiver(e) {
<div w-nodev>

<p>The <dfn><code data-x="dom-window-postMessage">postMessage(<var>message</var>,
<var>targetOrigin</var>, <var>transfer</var>)</code></dfn> method, when invoked on a
<var>transfer</var>, <var>options</var>)</code></dfn> method, when invoked on a
<code>Window</code> object must run the following steps:</p>

<ol> <!-- a lot of this is similar or identical to port.postMessage -->
Expand All @@ -95433,6 +95451,8 @@ function receiver(e) {
window, in same-origin cases. See discussion at
https://github.com/whatwg/html/issues/1542#issuecomment-233502636 -->

<li><p>Let <var>targetOrigin</var> be <var>options</var>'s targetOrigin.</p></li>

<li><p>If <var>targetOrigin</var> is a single U+002F SOLIDUS character (/), then set
<var>targetOrigin</var> to <var>incumbentSettings</var>'s <span
data-x="concept-settings-object-origin">origin</span>.</p>
Expand Down

0 comments on commit 1abbadf

Please sign in to comment.