js/src/jit-test/tests/proxy/testDirectProxyValidateProperty5.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/testDirectProxyValidateProperty5.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,26 @@
     1.4 +load(libdir + "asserts.js");
     1.5 +
     1.6 +/*
     1.7 + * Throw a TypeError if both the current descriptor and the descriptor returned
     1.8 + * by the trap are data descriptors, the current descriptor is non-configurable
     1.9 + * and non-writable, and the descriptor returned by the trap does not have the
    1.10 + * same value.
    1.11 + */
    1.12 +var target = {};
    1.13 +Object.defineProperty(target, 'foo', {
    1.14 +    value: 'bar',
    1.15 +    writable: false,
    1.16 +    configurable: false
    1.17 +});
    1.18 +var caught = false;
    1.19 +assertThrowsInstanceOf(function () { 
    1.20 +    Object.getOwnPropertyDescriptor(new Proxy(target, {
    1.21 +        getOwnPropertyDescriptor: function (target, name) {
    1.22 +            return {
    1.23 +                value: 'baz',
    1.24 +                writable: false,
    1.25 +                configurable: false
    1.26 +            };
    1.27 +        }
    1.28 +    }), 'foo');
    1.29 +}, TypeError);

mercurial