Comment #5 on issue 1310 by [email protected]:
Object.getOwnPropertyDescriptor/defineProperty should work on __proto__
http://code.google.com/p/v8/issues/detail?id=1310
Interestingly, FF4 also allows setting __proto__ to be an accessor rather
than a property:
var a = {};
//var d = Object.getOwnPropertyDescriptor(a, "__proto__");
//d.writable = false;
d = { get: function() { return { m: 42 }; } };
Object.defineProperty(a, "__proto__", d);
JSON.stringify(Object.getOwnPropertyDescriptor(a, "__proto__"));
a.m; // undefined
a.__proto__.m; // 42
Object.getPrototypeOf(a).m; // undefined
The first __proto__ implementation, SpiderMonkey's (predates Firefox but it
remains the same and is pretty much what ES6 will standardize) defines
__proto__ only on Object.prototype, as an internal accessor that
masquerades as a data property.
So your Object.defineProperty call above shadows the Object.prototype one,
while Object.getPrototypeOf (per spec) uses the SpiderMonkey
implementation-internal equivalent of ECMA-262's [[Prototype]] internal
property.
/be
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev