[whatwg] postMessage object cloning

Oliver Hunt oliver at apple.com
Mon Mar 16 17:33:59 PDT 2009

So I've been looking at the object cloning rules for postMessage and  
have noticed a couple of things that seem less than ideal.  The first  
is that it fails to specify the behaviour of cloning for prototype  
chains.  While this is definitely an issue specific to JS rather than  
binding languages as a whole, JS is the language of the web, so if I  
have an object, a la:
myObject = {};
myObject.__proto__ = {foo: "bar"}

Do we clone the prototype object?  Do we flatten the prototype list?  
or do we drop the prototype?

The other issue i bumped into is behaviour of ImageData/ 
CanvasPixelArray -- currently (per spec) these will not be cloned, and  
instead have to be marshalled into and out of arrays by the  
developer.  This seems less than ideal -- could the internal  
structuring algorithm be extended to include these types.  The  
alternative is to allow CPA, etc to be automatically marshalled to  
arrays, which (while not ideal) would at least get processing correct  
in one direction.  Unfortunately the developer would still have to  
manually marshall data coming from the worker, hence my preference for  
allowing ImageData and CPA to be cloned.


More information about the whatwg mailing list