Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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);