js/src/jit-test/tests/proxy/testDirectProxyGet3.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 load(libdir + "asserts.js");
     3 /*
     4  * Throw a TypeError if the trap reports a different value for a non-writable,
     5  * non-configurable property
     6  */
     7 var target = {};
     8 Object.defineProperty(target, 'foo', {
     9     value: 'bar',
    10     writable: false,
    11     configurable: false
    12 });
    13 assertThrowsInstanceOf(function () {
    14     new Proxy(target, {
    15         get: function (target, name, receiver) {
    16             return 'baz';
    17         }
    18     })['foo'];
    19 }, TypeError);
    21 /*
    22  * Don't throw a TypeError if the trap reports the same value for a non-writable,
    23  * non-configurable property
    24  */
    25 assertEq(new Proxy(target, {
    26         get: function (target, name, receiver) {
    27             return 'bar';
    28         }
    29     })['foo'],
    30     'bar');
    33 /*
    34  * Don't throw a TypeError if the trap reports a different value for a writable,
    35  * non-configurable property
    36  */
    37 Object.defineProperty(target, 'prop', {
    38     value: 'bar',
    39     writable: true,
    40     configurable: false
    41 });
    42 assertEq(new Proxy(target, {
    43         get: function (target, name, receiver) {
    44             return 'baz';
    45         }
    46     })['prop'],
    47     'baz');
    50 /*
    51  * Don't throw a TypeError if the trap reports a different value for a non-writable,
    52  * configurable property
    53  */
    54 Object.defineProperty(target, 'prop2', {
    55     value: 'bar',
    56     writable: false,
    57     configurable: true
    58 });
    59 assertEq(new Proxy(target, {
    60         get: function (target, name, receiver) {
    61             return 'baz';
    62         }
    63     })['prop2'],
    64     'baz');

mercurial