Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Unified Diff: test/mjsunit/es6/proxies-json.js

Issue 1994183002: [json] handle proxies in BasicJsonSerializer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698