This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
In particular, https://html.spec.whatwg.org/multipage/infrastructure.html#internal-structured-cloning-algorithm step 8.4 says: "Add a new property to output having the name name, and having the value cloned value." "Add a new property" has been interpreted differently in implementations: Chrome uses [[Set]] (thus invoking setters on the prototype), while Firefox appears to use [[DefineOwnProperty]]. [[DefineOwnProperty]] seems like a better idea to me, for what it's worth.
how can the prototype have anything interesting going on at this point? To put it another way, how could you detect the difference?
Example: ```js onmessage = function(m) { console.log(m.data); }; Object.defineProperty(Object.prototype, 'foo', { set: function(v) { console.log('in setter') } }); postMessage({foo: 1, bar: 2}, '*'); ``` If [[Set]] is used, this would log 'in setter' then {bar: 2} If [[DefineOwnProperty]] is used, this would log {foo: 1, bar: 2} This assumes Object.prototype is used as the prototype for a "newly constructed empty Object object", which appears to be true of all implementations we had handy to test in, the same as e.g. var newEmptyObject = {}
It's suppose to just create the object without invoking any JS code at all. i.e. all you're supposed to do is add a new property. I suppose we can say that this uses [[DefineOwnProperty]] if there are implementations that are interpreting it as something more than that.
(In reply to Ian 'Hixie' Hickson from comment #3) > It's suppose to just create the object without invoking any JS code at all. > i.e. all you're supposed to do is add a new property. I suppose we can say > that this uses [[DefineOwnProperty]] if there are implementations that are > interpreting it as something more than that. SGTM. Given that the spec uses [[Get]] later on, precision here would be nice. ("Add a new property" certainly seems pretty clear that it should not trigger setters since that would not be adding a property, but Chrome got this wrong...)
Adam or Joshua, either of you interested in fixing this by providing a pull request? https://github.com/whatwg/html
(In reply to Anne from comment #5) > Adam or Joshua, either of you interested in fixing this by providing a pull > request? https://github.com/whatwg/html Sure, let's try this out: https://github.com/whatwg/html/pull/36