mark.lam@apple.com | 7682413 | 2017-11-24 10:58:16 +0000 | [diff] [blame] | 1 | var createProxy = $vm.createProxy; |
| 2 | |
keith_miller@apple.com | 17f4ae7 | 2016-06-28 00:42:26 +0000 | [diff] [blame] | 3 | let foo = {}; |
| 4 | let properties = []; |
| 5 | let p = new Proxy(foo, { get:(target, property) => { |
| 6 | properties.push(property.toString()); |
| 7 | if (property === Symbol.toStringTag) |
| 8 | return "bad things"; |
| 9 | return target[property]; |
| 10 | }}); |
| 11 | |
| 12 | for (i = 0; i < 5; i++) { |
| 13 | if (p != "[object bad things]") |
| 14 | throw new Error("bad toString result."); |
| 15 | |
| 16 | if (properties[0] !== "Symbol(Symbol.toPrimitive)" || properties[1] !== "valueOf" || properties[2] !== "toString" || properties[3] !== "Symbol(Symbol.toStringTag)") |
| 17 | throw new Error("bad property accesses."); |
| 18 | |
| 19 | properties = []; |
| 20 | } |
| 21 | |
| 22 | p = createProxy(foo); |
| 23 | |
| 24 | for (i = 0; i < 5; i++) { |
| 25 | let str = "bad things" + i; |
| 26 | foo[Symbol.toStringTag] = str; |
| 27 | if (p != "[object " + str + "]") |
| 28 | throw new Error("bad toString result."); |
| 29 | } |