W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2008

[whatwg] reply() extension to postMessage()

From: Henry Mason <hmason@mac.com>
Date: Thu, 14 Feb 2008 11:43:03 -0500
Message-ID: <2F3786B8-AC35-431F-8939-56873DAD3F54@mac.com>
On Feb 14, 2008, at 11:18 AM, Anne van Kesteren wrote:

> Given that everyone is now updating their postMessage() code  
> anyway, I wonder if it's possible to quickly make another minor  
> tweak. The proposal is to remove the source attribute from  
> MessageEvent and replace it with a reply() method. The semantics of  
> the reply() are probably best described in terms of equivalence.  
> That is,
>
>   e.reply(message)
>
> is equivalent to
>
>   e.source.postMessage(message, e.origin)
>

Ooo, I like that idea. I have one concern, however. Presumably, the  
message event that is sent as a reply could itself be replied. Since  
postMessage's spec currently says:

"The postMessage() method must only return once the event dispatch  
has been completely processed by the target document (i.e. all three  
of the capture, target, and bubble phases have been done, and event  
listeners have been executed as appropriate)."

...this behavior could cause some somewhat nasty infinite recursion.  
So what if we made reply() asynchronous so that the the reply message  
event doesn't need to be dispatched on the original message posting  
document until after the original postMessage from the sender is  
finished processing?

-Henry
Received on Thursday, 14 February 2008 08:43:03 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:39 UTC