[whatwg] Web Workers API

Evan Ireland eireland at sybase.com
Thu Jul 1 21:06:28 PDT 2010


Hi,

The IDL for Worker in the Web Workers API specification shows:

    void postMessage(in any message, in optional MessagePortArray ports);

I have a question regarding the 'any' type for message.

If a caller of postMessage passes an object to a worker that is not a
string, is it converted to a string or can non-string objects be propagated
through to the onmessage(event) in the worker.

So if I write:

var w = new MyWorker('MyWorker.js');
w.postMessage(new MyObject());

--------------
// MyWorker.js

onmessage = function(event)
{
    var d = event.data;
    // what type is 'd'?
}

If 'd' is not a string, then is it a MyObject, and if so, how is it supposed
to be marshalled by the inter-worker(thread) communication?

I suggest that whatever the answer, that this be covered when the spec
document is next updated.

Thanks.





More information about the whatwg mailing list