js/src/jit-test/tests/proxy/bug-862848-1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/proxy/bug-862848-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,24 @@
     1.4 +// obj.hasOwnProperty(id), Object.getOwnPropertyDescriptor(obj, id), and
     1.5 +// Object.defineProperty(obj, id, desc) do not look at obj's prototype.
     1.6 +
     1.7 +var angryHandler = new Proxy({}, {
     1.8 +    has: () => true,
     1.9 +    get: (t, id) => {
    1.10 +        throw new Error("angryHandler should not be queried (" + id + ")");
    1.11 +    }
    1.12 +});
    1.13 +var angryProto = new Proxy({}, angryHandler);
    1.14 +
    1.15 +var obj = Object.create(angryProto, {
    1.16 +    // Define hasOwnProperty directly on obj since we are poisoning its
    1.17 +    // prototype chain.
    1.18 +    hasOwnProperty: {
    1.19 +        value: Object.prototype.hasOwnProperty
    1.20 +    }
    1.21 +});
    1.22 +
    1.23 +assertEq(Object.getOwnPropertyDescriptor(obj, "foo"), undefined);
    1.24 +assertEq(obj.hasOwnProperty("foo"), false);
    1.25 +Object.defineProperty(obj, "foo", {value: 5});
    1.26 +assertEq(obj.hasOwnProperty("foo"), true);
    1.27 +assertEq(obj.foo, 5);

mercurial