[whatwg] Proposal for enhancing postMessage

Drew Wilson atwilson at google.com
Fri Mar 13 15:02:13 PDT 2009


Yes, it sends a clone, but the source port becomes unentangled (inactive) -
step 5 of the "clone a port" specification reads:
Entangle<http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#entangle>
 the remote port and new port objects. The original port object will be
unentangled by this process.
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.

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.

-atw

On Fri, Mar 13, 2009 at 2:06 PM, Mark S. Miller <erights at google.com> wrote:

> On Wed, Mar 11, 2009 at 2:30 PM, Drew Wilson <atwilson at google.com> wrote:
> > Mark, I won't pretend to completely understand the use cases you're
> > describing as I'm not familiar with the prior work you've cited. But my
> > understanding of the postMessage() API is that they are primarily useful
> for
> > handing off ports to new owners - your idea of a pass-by-copy
> serialization
> > of a proxy object implies that there's some way to copy the message port,
> > and pass that along with the proxy to the new owner, which I don't think
> is
> > possible in general (you can create a new port as part of a
> MessageChannel,
> > but you can't really duplicate an existing port).
> >
> > I may be misunderstanding the use case that's driving your proposal,
> though.
>
>
> And I may be misunderstanding the postMessage draft spec. But step 4
> of 7.4.4 at
> <
> http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#posting-messages-with-message-ports
> >
> reads:
>
> > Try to obtain a new port by cloning the messagePort argument
> > with the Window 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.
>
> Doesn't this mean that sending a MessagePort actually sends a clone?
>
> --
>    Cheers,
>    --MarkM
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090313/8c7c7d68/attachment-0002.htm>


More information about the whatwg mailing list