1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/proxy/testDirectProxyValidateProperty3.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +load(libdir + "asserts.js"); 1.5 + 1.6 +/* 1.7 + * Throw a TypeError if the current descriptor is a data descriptor and the 1.8 + * descriptor returned by the trap is not, or vice versa, and the current 1.9 + * descriptor is non-configurable 1.10 + */ 1.11 +var target = {}; 1.12 +Object.defineProperty(target, 'foo', { 1.13 + value: 'bar', 1.14 + configurable: false 1.15 +}); 1.16 +var caught = false; 1.17 +assertThrowsInstanceOf(function () { 1.18 + Object.getOwnPropertyDescriptor(new Proxy(target, { 1.19 + getOwnPropertyDescriptor: function (target, name) { 1.20 + return { 1.21 + get: function () { 1.22 + return 'bar'; 1.23 + }, 1.24 + configurable: false 1.25 + }; 1.26 + } 1.27 + }), 'foo'); 1.28 +}, TypeError); 1.29 + 1.30 +var target = {}; 1.31 +Object.defineProperty(target, 'foo', { 1.32 + value: function () { 1.33 + return 'bar'; 1.34 + }, 1.35 + configurable: false 1.36 +}); 1.37 +assertThrowsInstanceOf(function () { 1.38 + Object.getOwnPropertyDescriptor(new Proxy(target, { 1.39 + getOwnPropertyDescriptor: function (target, name) { 1.40 + return { 1.41 + value: 'bar', 1.42 + configurable: false 1.43 + }; 1.44 + } 1.45 + }), 'foo'); 1.46 +}, TypeError);