[whatwg] Workers and addEventListener

Drew Wilson atwilson at google.com
Thu Oct 15 10:54:23 PDT 2009


To be absolutely clear (since there's some confusion about whether we are
talking about explicit MessagePorts, or about implicit ports for dedicated
workers).
Are you saying that this:

var channel = new MessageChannel();
channel.port1.postMessage("hi mom");
channel.port2.addEventListener("message", function(event)
{alert(event.data); }, false);

Should result in an alert dialog being fired? Because that does not match my
reading of the spec at all - the spec explicitly states that a port's
message queue is only enabled via start() or via setting the onmessage IDL
attribute.

I would not be opposed to changing the spec to include enabling a port's
message queue when addEventListener("message") is invoked.

-atw

On Wed, Oct 14, 2009 at 3:32 AM, Ian Hickson <ian at hixie.ch> wrote:

> On Tue, 29 Sep 2009, Zoltan Herczeg wrote:
> >
> > In WebKit implementation of MessagePort the addEventListener("message",
> > ...) does not enable the transmitting of messages. All messages are
> > actually discarded until a dummy function is assigned to onmessage.
>
> That is a bug. The port message queue is explicitly enabled during the
> creation of the dedicated worker (step 12).
>
>
> > And in the normative text, it is not mentioned that addEventListener
> > should also enable message transmitting.
>
> The normative text just says to fire an event; the DOM Events spec makes
> it clear that events can be handled using addEventListener()-added
> handlers.
>
>
> > Anyway, my qestion is:
> >   - should addEventListener enable message transmitting?
>
> Yes.
>
> >   - Should it do it in all cases, or only when "message" is passed as the
> > first argument
>
> It should only receive 'message' events if you say 'message' as the first
> argument.
>
> --
> Ian Hickson               U+1047E                )\._.,--....,'``.    fL
> http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
> Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20091015/c082f5bb/attachment-0001.htm>


More information about the whatwg mailing list