Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 // obj.hasOwnProperty(id), Object.getOwnPropertyDescriptor(obj, id), and
2 // Object.defineProperty(obj, id, desc) do not look at obj's prototype.
4 var angryHandler = new Proxy({}, {
5 has: () => true,
6 get: (t, id) => {
7 throw new Error("angryHandler should not be queried (" + id + ")");
8 }
9 });
10 var angryProto = new Proxy({}, angryHandler);
12 var obj = Object.create(angryProto, {
13 // Define hasOwnProperty directly on obj since we are poisoning its
14 // prototype chain.
15 hasOwnProperty: {
16 value: Object.prototype.hasOwnProperty
17 }
18 });
20 assertEq(Object.getOwnPropertyDescriptor(obj, "foo"), undefined);
21 assertEq(obj.hasOwnProperty("foo"), false);
22 Object.defineProperty(obj, "foo", {value: 5});
23 assertEq(obj.hasOwnProperty("foo"), true);
24 assertEq(obj.foo, 5);