Index: test/mjsunit/es6/proxies-json.js |
diff --git a/test/mjsunit/es6/proxies-json.js b/test/mjsunit/es6/proxies-json.js |
index 03dfabecea100ae71ad4d81b1b3a1e94dcd002ba..6b40e3ee7d8d68796be0e8a22f28a888004ac06e 100644 |
--- a/test/mjsunit/es6/proxies-json.js |
+++ b/test/mjsunit/es6/proxies-json.js |
@@ -507,3 +507,56 @@ for (var i in log) assertSame(target, log[i][1]); |
assertEquals(["get", target, "length", proxy], log[0]); |
assertEquals(["get", target, "0", proxy], log[1]); |
assertEquals(["deleteProperty", target, "0"], log[2]); |
+ |
+proxy = new Proxy([], { |
+ get: function(target, property) { |
+ if (property == "length") return 7; |
+ return 0; |
+ }, |
+}); |
+assertEquals('[[0,0,0,0,0,0,0]]', JSON.stringify([proxy])); |
+ |
+proxy = new Proxy([], { |
+ get: function(target, property) { |
+ if (property == "length") return 1E40; |
+ return 0; |
+ }, |
+}); |
+assertThrows(() => JSON.stringify([proxy]), RangeError); |
+ |
+log = []; |
+proxy = new Proxy({}, { |
+ ownKeys: function() { |
+ log.push("ownKeys"); |
+ return ["0", "a", "b"]; |
+ }, |
+ get: function(target, property) { |
+ log.push("get " + property); |
+ return property.toUpperCase(); |
+ }, |
+ getOwnPropertyDescriptor: function(target, property) { |
+ log.push("descriptor " + property); |
+ return {enumerable: true, configurable: true}; |
+ }, |
+ isExtensible: assertUnreachable, |
+ has: assertUnreachable, |
+ getPrototypeOf: assertUnreachable, |
+ setPrototypeOf: assertUnreachable, |
+ preventExtensions: assertUnreachable, |
+ setPrototypeOf: assertUnreachable, |
+ defineProperty: assertUnreachable, |
+ set: assertUnreachable, |
+ deleteProperty: assertUnreachable, |
+ apply: assertUnreachable, |
+ construct: assertUnreachable, |
+}); |
+ |
+assertEquals('[{"0":"0","a":"A","b":"B"}]', JSON.stringify([proxy])); |
+assertEquals(['get toJSON', |
+ 'ownKeys', |
+ 'descriptor 0', |
+ 'descriptor a', |
+ 'descriptor b', |
+ 'get 0', |
+ 'get a', |
+ 'get b'], log); |