Proposal to allow Transferables to be used in initMessageEvent

I came across this while implementing support for the new Transferable[1]
interface for Chromium. initMessageEvent is defined[2] as:

  void initMessageEvent(in DOMString typeArg, in boolean canBubbleArg, in
boolean cancelableArg, in any dataArg, in DOMString originArg, in DOMString
lastEventIdArg, in WindowProxy? sourceArg, in sequence<MessagePort>
portsArg);

However, postMessage is usually defined to take a sequence<Transferable>
[3]:

  void postMessage(in any message, in optional sequence<Transferable>
transfer);

I suggest changing initMessageEvent to permit arbitrary Transferables:

  void initMessageEvent(in DOMString typeArg, in boolean canBubbleArg, in
boolean cancelableArg, in any dataArg, in DOMString originArg, in DOMString
lastEventIdArg, in WindowProxy? sourceArg, in sequence<Transferable>
transferablesArg);

Without this change, it is not possible for a JavaScript author to directly
construct a MessageEvent with a dataArg that contains Transferable objects
(other than MessagePorts).

This does not imply that the ports property of MessageEvent should change.
It should behave just like the ports array for MessageEvents generated by
postMessage: the ports array contains all MessagePorts sent in the transfer
list in the same relative order.

Please let me know what you think!

  Luke

[1]
http://www.whatwg.org/specs/web-apps/current-work/complete/common-dom-interfaces.html#transferable-objects
[2]
http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#event-definitions-1
[3]
http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#message-ports

Received on Thursday, 11 August 2011 22:39:42 UTC