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.

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

mercurial