W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2009

[whatwg] Sending messages to just-created windows/workers

From: Drew Wilson <atwilson@google.com>
Date: Thu, 19 Mar 2009 11:10:09 -0700
Message-ID: <f965ae410903191110w30e372ddx3ef00d6702e1918f@mail.gmail.com>
The WebWorkers spec states:
"DedicatedWorkerGlobalScope objects act as if they had an implicit
MessagePort associated with them"

MessagePorts will queue up events until the owner either explicitly invokes
start() on them, or sets the onmessage attribute. Is the intent that
dedicated workers also implement this same functionality for their implicit
port (i.e. if I create a dedicated worker, and immediately post a message to
it, but the worker doesn't actually set an onmessage handler, should that
event be queued until such a time as the worker does set an onmessage
handler)?

There's a similar issue with cross-window postMessage(). I've been playing
around with the current implementation in Chrome/WebKit, and code like this:

function newWindow() {
  var childWin = window.open();
  childWin.document.location = "http://example.com/child.html";

  childWin.postMessage("hi new window", "*");

}

...does not result in the message handler in the new window being
called, because the window isn't loaded at the time the message is
posted (it works just fine after the new window has loaded/executed
its script). I'm curious whether this is just a bug in the early
implementation, or if this is indeed the expected behavior -- if so,
then it makes it difficult to do cross-domain messaging as you have
this race condition on startup.

The spec is fairly clear about how this should work when explicitly
working with MessagePorts, but the behavior for these other related
use cases seems ambiguous (maybe intentionally so?)

-atw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090319/2b96403e/attachment.htm>
Received on Thursday, 19 March 2009 11:10:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:47:49 GMT