tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

testDirectProxyValidateProperty3.js (1134B)


      1 load(libdir + "asserts.js");
      2 
      3 /*
      4 * Throw a TypeError if the current descriptor is a data descriptor and the
      5 * descriptor returned by the trap is not, or vice versa, and the current
      6 * descriptor is non-configurable
      7 */
      8 var target = {};
      9 Object.defineProperty(target, 'foo', {
     10    value: 'bar',
     11    configurable: false
     12 });
     13 var caught = false;
     14 assertThrowsInstanceOf(function () { 
     15    Object.getOwnPropertyDescriptor(new Proxy(target, {
     16        getOwnPropertyDescriptor: function (target, name) {
     17            return {
     18                get: function () {
     19                    return 'bar';
     20                },
     21                configurable: false
     22            };
     23        }
     24    }), 'foo');
     25 }, TypeError);
     26 
     27 var target = {};
     28 Object.defineProperty(target, 'foo', {
     29    value: function () {
     30        return 'bar';
     31    },
     32    configurable: false
     33 });
     34 assertThrowsInstanceOf(function () { 
     35    Object.getOwnPropertyDescriptor(new Proxy(target, {
     36        getOwnPropertyDescriptor: function (target, name) {
     37            return {
     38                value: 'bar',
     39                configurable: false
     40            };
     41        }
     42    }), 'foo');
     43 }, TypeError);