- From: Oliver Hunt <oliver@apple.com>
- Date: Thu, 1 Jul 2010 23:21:20 -0700
All meesaging through postMessage uses the internal structured cloning algorithm detailed at http://www.w3.org/TR/2010/WD-html5-20100304/Overview.html#internal-structured-cloning-algorithm It's basically a deep copy, but has a few restrictions on the types cloned, and doesn't copy functions or the prototype property, etc. --Oliver On Jul 1, 2010, at 9:06 PM, Evan Ireland wrote: > 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. > >
Received on Thursday, 1 July 2010 23:21:20 UTC