blob: d0b0e3b4d5f490ab93299db2227e1200d6586578 [file] [log] [blame]
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
{
var order = [];
let target = {x: 20, y:42};
let handler = {
getOwnPropertyDescriptor(theTarget, propName)
{
order.push(`getOwnPropertyDescriptor ${propName}`);
return {
enumerable: true,
configurable: true,
value: 42
};
},
get(theTarget, propName, receiver)
{
order.push(`get ${propName}`);
return 42;
}
};
let proxy = new Proxy(target, handler);
var result = Object.assign({}, proxy);
shouldBe(result.x, 42);
shouldBe(result.y, 42);
shouldBe(order.join(','), `getOwnPropertyDescriptor x,get x,getOwnPropertyDescriptor y,get y`);
}