Patched __proto__ (that uses Object.setPrototypeOf) fails and throws TypeError
lauritzthamsen opened this issue · 4 comments
There seems to be an issue with how proto is patched to use Object.setPrototypeOf.
Currently, setting the proto property of an object causes a TypeError:
TypeError: Generic use of proto accessor not allowed
The error occurs, for example, when using test/testProxies.html to run testProxies.js in the testSetPrototypeOf.
Is there another way to patch proto?
I used Chrome 29.0.1547.22 beta (with Experimental JavaScript for the old Harmony proxies and Harmony Weak Maps).
My current solution is to prevent the patch (not executing the function after _var _proto__setter), change Object.setPrototypeOf to directly set the proto property, and then consistently use
Object.setPrototypeOf(target, newProto)
instead of
target.proto = newProto
in the project... :-/
This seems to be an issue with Chrome itself rather than my patch: Chrome advertises Object.prototype.proto as an accessor property with a setter, but actually calling the setter produces an error:
var protoDesc = Object.getOwnPropertyDescriptor(Object.prototype,'__proto__');
protoDesc.set.call({}, {}); // TypeError: Generic use of __proto__ accessor not allowed
I updated reflect.js so that Object.setPrototypeOf
throws a 'not supported on this platform' exception on Chrome, as I have no way of implementing it without being able to call the setter. In the new patch, I also leave Object.prototype.__proto__
alone in this case, such that normal uses of object.__proto__ = v
should still work.
Update to reflect.js v0.0.7 to see the patch.
I also filed a bug with v8, asking for clarification:
https://code.google.com/p/v8/issues/detail?id=2804
Thanks for reporting.
Wow. Thanks for looking into this, the clarification, and the workaround. And for filing the issue with v8.
This seems fixed. The status of the issue you filed with v8 was set to fixed and worked for me in the most recent Chrome.
Thanks for your help again!
No problem!