Yes, it sends a clone, but the source port becomes unentangled (inactive) - step 5 of the "clone a port" specification reads:<div><br></div><div><span class="Apple-style-span" style="font-family: -webkit-sans-serif; font-size: 16px; line-height: 21px; "><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#entangle" style="color: rgb(0, 0, 204); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; ">Entangle</a> the <var title="">remote port</var> and <var title="">new port</var> objects. The <var title="">original port</var> object will be unentangled by this process.</span><div>
<br></div><div>So, cloning a port has the effect of killing the original port - the intent, I think, is for the sender to permanently hand off ownership of the port to the recipient, not to duplicate the port itself.</div>
<div><br></div><div>I think this is a side issue, though - I agree that since you can effectively pass a message consisting of multiple objects, you probably ought to be able to pass multiple MessagePorts along with them. As you point out, it's primarily a matter of convenience/efficiency - you could still get the same functionality by individually serializing each object/port pair.</div>
<div><br></div><div>-atw<br><br><div class="gmail_quote">On Fri, Mar 13, 2009 at 2:06 PM, Mark S. Miller <span dir="ltr"><<a href="mailto:erights@google.com">erights@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Wed, Mar 11, 2009 at 2:30 PM, Drew Wilson <<a href="mailto:atwilson@google.com">atwilson@google.com</a>> wrote:<br>
> Mark, I won't pretend to completely understand the use cases you're<br>
> describing as I'm not familiar with the prior work you've cited. But my<br>
> understanding of the postMessage() API is that they are primarily useful for<br>
> handing off ports to new owners - your idea of a pass-by-copy serialization<br>
> of a proxy object implies that there's some way to copy the message port,<br>
> and pass that along with the proxy to the new owner, which I don't think is<br>
> possible in general (you can create a new port as part of a MessageChannel,<br>
> but you can't really duplicate an existing port).<br>
><br>
> I may be misunderstanding the use case that's driving your proposal, though.<br>
<br>
<br>
</div>And I may be misunderstanding the postMessage draft spec. But step 4<br>
of 7.4.4 at<br>
<<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#posting-messages-with-message-ports" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#posting-messages-with-message-ports</a>><br>
reads:<br>
<br>
> Try to obtain a new port by cloning the messagePort argument<br>
> with the Window object on which the method was invoked as<br>
> the owner of the clone. If this returns an exception, then throw<br>
> that exception and abort these steps.<br>
<br>
Doesn't this mean that sending a MessagePort actually sends a clone?<br>
<font color="#888888"><br>
--<br>
Cheers,<br>
--MarkM<br>
</font></blockquote></div><br></div></div>