Skip to content

Commit

Permalink
[] (0) postMessage() methods that take MessagePort objects now take M…
Browse files Browse the repository at this point in the history
…essagePortArray objects.

git-svn-id: http://svn.whatwg.org/webapps@2885 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 20, 2009
1 parent 42c624b commit 64091bc
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 98 deletions.
131 changes: 89 additions & 42 deletions index
Expand Up @@ -38778,7 +38778,7 @@ interface <dfn id=window>Window</dfn> {

// <a href=#crossDocumentMessages>cross-document messaging</a>
void <a href=#dom-window-postmessage-2 title=dom-window-postMessage-2>postMessage</a>(in any message, in DOMString targetOrigin);
void <a href=#dom-window-postmessage-3 title=dom-window-postMessage-3>postMessage</a>(in any message, in <a href=#messageport>MessagePort</a> messagePort, in DOMString targetOrigin);
void <a href=#dom-window-postmessage-3 title=dom-window-postMessage-3>postMessage</a>(in any message, in <span>MessagePortArray</span> ports, in DOMString targetOrigin);

// <a href=#event-handler-dom-attributes>event handler DOM attributes</a>
attribute <a href=#function>Function</a> <a href=#handler-onabort title=handler-onabort>onabort</a>;
Expand Down Expand Up @@ -49708,9 +49708,9 @@ XXX Once we resolve the style="" issue, address these:
readonly attribute DOMString <a href=#dom-messageevent-origin title=dom-MessageEvent-origin>origin</a>;
readonly attribute DOMString <a href=#dom-messageevent-lasteventid title=dom-MessageEvent-lastEventId>lastEventId</a>;
readonly attribute <a href=#windowproxy>WindowProxy</a> <a href=#dom-messageevent-source title=dom-MessageEvent-source>source</a>;
readonly attribute <a href=#messageport>MessagePort</a> <a href=#dom-messageevent-messageport title=dom-MessageEvent-messagePort>messagePort</a>;
void <a href=#dom-messageevent-initmessageevent title=dom-MessageEvent-initMessageEvent>initMessageEvent</a>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any dataArg, in DOMString originArg, in DOMString lastEventIdArg, in <a href=#windowproxy>WindowProxy</a> sourceArg, in <a href=#messageport>MessagePort</a> messagePortArg);
void <a href=#dom-messageevent-initmessageeventns title=dom-MessageEvent-initMessageEventNS>initMessageEventNS</a>(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any dataArg, in DOMString originArg, in DOMString lastEventIdArg, in <a href=#windowproxy>WindowProxy</a> sourceArg, in <a href=#messageport>MessagePort</a> messagePortArg);
readonly attribute <span>MessagePortArray</span> <a href=#dom-messageevent-ports title=dom-MessageEvent-ports>ports</a>;
void <a href=#dom-messageevent-initmessageevent title=dom-MessageEvent-initMessageEvent>initMessageEvent</a>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any dataArg, in DOMString originArg, in DOMString lastEventIdArg, in <a href=#windowproxy>WindowProxy</a> sourceArg, in <span>MessagePortArray</span> portsArg);
void <a href=#dom-messageevent-initmessageeventns title=dom-MessageEvent-initMessageEventNS>initMessageEventNS</a>(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any dataArg, in DOMString originArg, in DOMString lastEventIdArg, in <a href=#windowproxy>WindowProxy</a> sourceArg, in <span>MessagePortArray</span> portsArg);
};</pre>

<dl class=domintro><dt><var title="">event</var> . <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code></dt>
Expand Down Expand Up @@ -49748,13 +49748,13 @@ XXX Once we resolve the style="" issue, address these:

</dd>

<dt><var title="">event</var> . <code title=dom-MessageEvent-messagePort><a href=#dom-messageevent-messageport>messagePort</a></code></dt>
<dt><var title="">event</var> . <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code></dt>

<dd>

<p>Returns the <code><a href=#messageport>MessagePort</a></code> sent with the message, for
<a href=#crossDocumentMessages>cross-document messaging</a> and <a href=#channel-messaging>channel
messaging</a>.</p>
<p>Returns the <code>MessagePortArray</code> sent with the
message, for <a href=#crossDocumentMessages>cross-document messaging</a> and
<a href=#channel-messaging>channel messaging</a>.</p>

</dd>

Expand Down Expand Up @@ -49784,18 +49784,18 @@ XXX Once we resolve the style="" issue, address these:
<code><a href=#windowproxy>WindowProxy</a></code> of the <a href=#browsing-context>browsing context</a> of the
<code><a href=#window>Window</a></code> object from which the message came.</p>

<p>The <dfn id=dom-messageevent-messageport title=dom-MessageEvent-messagePort><code>messagePort</code></dfn>
<p>The <dfn id=dom-messageevent-ports title=dom-MessageEvent-ports><code>ports</code></dfn>
attribute represents, in <a href=#crossDocumentMessages>cross-document messaging</a> and
<a href=#channel-messaging>channel messaging</a> the <code><a href=#messageport>MessagePort</a></code> being
sent, if any.</p>
<a href=#channel-messaging>channel messaging</a> the <code>MessagePortArray</code>
being sent, if any.</p>

<p>Unless otherwise specified, when the user agent creates and
dispatches a <code title=event-message><a href=#event-message>message</a></code> event in the
algorithms described in the following sections, the <code title=dom-MessageEvent-lastEventId><a href=#dom-messageevent-lasteventid>lastEventId</a></code> attribute
must be the empty string, the <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> attribute must be the
empty string, the <code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute must be
null, and the <code title=dom-MessageEvent-messagePort><a href=#dom-messageevent-messageport>messagePort</a></code>
attribute must be null.</p>
null, and the <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute
must be null.</p>

</div>

Expand Down Expand Up @@ -49911,17 +49911,22 @@ function receiver(e) {

<h4 id=posting-messages><span class=secno>7.2.3 </span>Posting messages</h4>

<dl class=domintro><dt><var title="">window</var> . <code title=dom-window-postMessage-2><a href=#dom-window-postmessage-2>postMessage</a></code>(<var title="">message</var>, [ <var title="">port</var>, ] <var title="">targetOrigin</var>)</dt>
<dl class=domintro><dt><var title="">window</var> . <code title=dom-window-postMessage-2><a href=#dom-window-postmessage-2>postMessage</a></code>(<var title="">message</var>, [ <var title="">ports</var>, ] <var title="">targetOrigin</var>)</dt>

<dd>

<p>Posts a message, optionally with a port, to the given window.</p>
<p>Posts a message, optionally with an array of ports, to the
given window.</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 title="">*</code>".</p>

<p>Throws an <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> if the <var title="">ports</var> array is not null and it contains
either null entries, duplicate ports, or ports that are not
entangled.</p>

</dd>

</dl><div class=impl>
Expand Down Expand Up @@ -50000,7 +50005,7 @@ function receiver(e) {

<h4 id=posting-messages-with-message-ports><span class=secno>7.2.4 </span>Posting messages with message ports</h4>

<p>When a script invokes the <dfn id=dom-window-postmessage-3 title=dom-window-postMessage-3><code>postMessage(<var title="">message</var>, <var title="">messagePort</var>, <var title="">targetOrigin</var>)</code></dfn> method (with three
<p>When a script invokes the <dfn id=dom-window-postmessage-3 title=dom-window-postMessage-3><code>postMessage(<var title="">message</var>, <var title="">ports</var>, <var title="">targetOrigin</var>)</code></dfn> method (with three
arguments) on a <code><a href=#window>Window</a></code> object, the user agent must
follow these steps:

Expand All @@ -50027,18 +50032,35 @@ function receiver(e) {

<li> <!-- NEW STEP -->

<p>If the <var title="">messagePort</var> argument is null, then
<p>If the <var title="">ports</var> argument is null, then
act as if the method had just been <a href=#dom-window-postmessage-2 title=dom-window-postMessage-2>called with two arguments</a>,
<var title="">message</var> and <var title="">targetOrigin</var>.</p>

</li>

<li> <!-- NEW STEP -->

<p>Try to obtain a <var title="">new port</var> by <a href=#clone-a-port title="clone a port">cloning</a> the <var title="">messagePort</var> argument with the <code><a href=#window>Window</a></code>
object on which the method was invoked as the owner of the
clone. If this returns an exception, then throw that exception and
abort these steps.</p>
<p>If any of the entries in <var title="">ports</var> are
null, if any of the entries in <var title="">ports</var>
are not entangled <code><a href=#messageport>MessagePort</a></code> objects, or if any
<code><a href=#messageport>MessagePort</a></code> object is listed in <var title="">ports</var> more than once, then throw an
<code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception.</p>

</li>

<li> <!-- NEW STEP -->

<p>Let <var title="">new ports</var> be an empty array.</p>

<p>For each port in <var title="">ports</var> in turn,
obtain a new port by <a href=#clone-a-port title="clone a port">cloning</a> the
port with the <code><a href=#window>Window</a></code> object on which the method was
invoked as the owner of the clone, and append the clone to the
<var title="">new ports</var> array.</p>

<p class=note>If the original <var title="">ports</var>
array was empty, then the <var title="">new ports</var> array will
also be empty.</p>

</li>

Expand Down Expand Up @@ -50077,8 +50099,8 @@ function receiver(e) {

<li> <!-- NEW STEP -->

<p>Let the <code title=dom-MessageEvent-messagePort><a href=#dom-messageevent-messageport>messagePort</a></code> attribute
of the event be the <var title="">new port</var>.</p>
<p>Let the <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute
of the event be the <var title="">new ports</var> array.</p>

</li>

Expand Down Expand Up @@ -50185,9 +50207,11 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
<p>Each channel has two message ports. Data sent through one port is
received by the other port, and vice versa.</p>

<pre class=idl>interface <dfn id=messageport>MessagePort</dfn> {
<pre class=idl>typedef sequence&lt;MessagePort&gt; MessagePortArray;

interface <dfn id=messageport>MessagePort</dfn> {
readonly attribute boolean <a href=#dom-messageport-active title=dom-MessagePort-active>active</a>;
void <a href=#dom-messageport-postmessage title=dom-MessagePort-postMessage>postMessage</a>(in any message, [Optional] in <a href=#messageport>MessagePort</a> messagePort);<!--
void <a href=#dom-messageport-postmessage title=dom-MessagePort-postMessage>postMessage</a>(in any message, [Optional] in <span>MessagePortArray</span> ports);<!--
<span>MessagePort</span> <span title="dom-MessagePort-startConversation">startConversation</span>(in any message);-->
void <a href=#dom-messageport-start title=dom-MessagePort-start>start</a>();
void <a href=#dom-messageport-close title=dom-MessagePort-close>close</a>();
Expand All @@ -50204,14 +50228,16 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {

</dd>

<dt><var title="">port</var> . <code title=dom-MessagePort-poseMessage>postMessage</code>(<var title="">message</var> [, <var title="">port</var>] )</dt>
<dt><var title="">port</var> . <code title=dom-MessagePort-poseMessage>postMessage</code>(<var title="">message</var> [, <var title="">ports</var>] )</dt>

<dd>

<p>Posts a message through the channel, optionally with the given port.</p>
<p>Posts a message through the channel, optionally with the given
ports.</p>

<p>Throws an <code><a href=#invalid_access_err>INVALID_ACCESS_ERR</a></code> if the port to be
sent is one of the ports involved in the communication.</p>
<p>Throws an <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> if the <var title="">ports</var> array is not null and it contains
either null entries, duplicate ports, ports that are not
entangled, or the source or target port.</p>

</dd>

Expand Down Expand Up @@ -50332,20 +50358,37 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
attribute of the event have the value of <var title="">message
clone</var>.</li>

<li><p>If the method was called with a second argument <var title="">data port</var> and that argument isn't null, then run the
following substeps:</p>
<li><p>If the method was called with a second argument <var title="">ports</var> and that argument isn't null, then run
the following substeps:</p>

<ol><li>

<p>If any of the entries in <var title="">ports</var> are
null, if any of the entries in <var title="">ports</var>
are not entangled <code><a href=#messageport>MessagePort</a></code> objects, or if any
<code><a href=#messageport>MessagePort</a></code> object is listed in <var title="">ports</var> more than once, then throw an
<code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception.</p>

<ol><li><p>If the <var title="">data port</var> is the <var title="">source port</var> or the <var title="">target
port</var>, then throw an <code><a href=#invalid_access_err>INVALID_ACCESS_ERR</a></code>
exception and abort all these steps.</li>
</li>

<li>

<li><p>Try to obtain a <var title="">new data port</var> by <a href=#clone-a-port title="clone a port">cloning</a> the <var title="">data
port</var> with the owner of the <var title="">target port</var>
as the owner of the clone. If this returns an exception, then
throw that exception and abort these steps.</li>
<p>Let <var title="">new ports</var> be an empty array.</p>

<p>For each port in <var title="">ports</var> in turn,
obtain a new port by <a href=#clone-a-port title="clone a port">cloning</a>
the port with the owner of the <var title="">target port</var>
as the owner of the clone, and append the clone to the <var title="">new ports</var> array.</p>

<p class=note>If the original <var title="">ports</var>
array was empty, then the <var title="">new ports</var> array will
also be empty.</p>

</li>

<li><p>Let the <code title=dom-MessageEvent-messagePort><a href=#dom-messageevent-messageport>messagePort</a></code> attribute
of the event be the <var title="">new data port</var>.</li>
<li><p>Let the <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code>
attribute of the event be the <var title="">new ports</var>
array.</li>

</ol></li>

Expand Down Expand Up @@ -50403,8 +50446,9 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
title="">message</var>, the method's first argument.</p></li>

<li><p>Let the <code
title="dom-MessageEvent-messagePort">messagePort</code> attribute
of the event be <var title="">port2</var>.</p></li>
title="dom-MessageEvent-ports">ports</code> attribute
of the event be an array containing only <var
title="">port2</var>.</p></li>

<li><p>Return <var title="">port1</var> from the method, but
continue with these steps.</p></li>
Expand Down Expand Up @@ -50484,6 +50528,9 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
<!-- we might not need to explicitly say the first part of DOM
Events is fixed to say that events on a task queue prevent GC -->

<!-- XXX what about ports in the ports attribute of a MessageEvent
that isn't dispatched yet? -->

</div>


Expand Down

0 comments on commit 64091bc

Please sign in to comment.