blob: 2351d6ee0ae9c6ec31bf2aa2cfb004baf312b6b7 [file] [log] [blame]
mark.lam@apple.com76824132017-11-24 10:58:16 +00001var createProxy = $vm.createProxy;
2
keith_miller@apple.com17f4ae72016-06-28 00:42:26 +00003let foo = {};
4let properties = [];
5let 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
12for (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
22p = createProxy(foo);
23
24for (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}