testDirectProxyGet13.js (564B)
1 load(libdir + "asserts.js"); 2 3 var target = {x: 5}; 4 var returnValue = 42; 5 var handler = { 6 get(t, p) { 7 if (returnValue != 42) { 8 bailout(); 9 } 10 return returnValue; 11 } 12 }; 13 var proxy = new Proxy(target, handler); 14 15 function testGet(p) { 16 return p.x; 17 } 18 19 for (i = 0; i < 200; i++) { 20 assertEq(testGet(proxy), returnValue); 21 } 22 23 Object.defineProperty(target, 'x', { 24 value: 42, 25 writable: false, 26 configurable: false 27 }); 28 29 assertEq(testGet(proxy), returnValue); 30 returnValue = 41; 31 assertThrowsInstanceOf(function () { testGet(proxy) }, TypeError);