testDirectProxyDefineProperty2.js (1009B)
1 /* 2 * Call the trap with the handler as the this value, the target as the first 3 * argument, the name of the property as the second argument, and the descriptor 4 * as the third argument. 5 */ 6 var target = {}; 7 var handler = { 8 defineProperty: function (target1, key, desc1) { 9 assertEq(this, handler); 10 assertEq(target1, target); 11 log.push(key); 12 assertEq(desc1 == desc, false); 13 assertEq(desc1.value, 'bar'); 14 assertEq(desc1.writable, true); 15 assertEq(desc1.enumerable, false); 16 assertEq(desc1.configurable, true); 17 return true; 18 } 19 }; 20 var desc = { 21 value: 'bar', 22 writable: true, 23 enumerable: false, 24 configurable: true 25 }; 26 27 for (let p of [new Proxy(target, handler), Proxy.revocable(target, handler).proxy]) { 28 var log = []; 29 Object.defineProperty(p, 'foo', desc); 30 Object.defineProperty(p, Symbol.for('quux'), desc); 31 assertEq(log.length, 2); 32 assertEq(log[0], 'foo'); 33 assertEq(log[1], Symbol.for('quux')); 34 }