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

Unified Diff: test/mjsunit/json.js

Issue 14200035: Rollback of r13728 in 3.17 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.17
Patch Set: Created 7 years, 8 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 | « test/mjsunit/harmony/proxies.js ('k') | test/mjsunit/regress/regress-2441.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/json.js
diff --git a/test/mjsunit/json.js b/test/mjsunit/json.js
index 79826dbef181dc6f7b467443a04080bfd5db8bce..6e91725c7d85f3c2dc18034d5d524060ba10a709 100644
--- a/test/mjsunit/json.js
+++ b/test/mjsunit/json.js
@@ -453,23 +453,16 @@ falseNum.__proto__ = Number.prototype;
falseNum.toString = function() { return 42; };
assertEquals('"42"', JSON.stringify(falseNum));
-// Parse an object value as __proto__.
-var o1 = JSON.parse('{"__proto__":[]}');
-assertEquals([], o1.__proto__);
-assertEquals(["__proto__"], Object.keys(o1));
-assertEquals([], Object.getOwnPropertyDescriptor(o1, "__proto__").value);
-assertEquals(["__proto__"], Object.getOwnPropertyNames(o1));
-assertTrue(o1.hasOwnProperty("__proto__"));
-assertTrue(Object.prototype.isPrototypeOf(o1));
-
-// Parse a non-object value as __proto__.
-var o2 = JSON.parse('{"__proto__":5}');
-assertEquals(5, o2.__proto__);
-assertEquals(["__proto__"], Object.keys(o2));
-assertEquals(5, Object.getOwnPropertyDescriptor(o2, "__proto__").value);
-assertEquals(["__proto__"], Object.getOwnPropertyNames(o2));
-assertTrue(o2.hasOwnProperty("__proto__"));
-assertTrue(Object.prototype.isPrototypeOf(o2));
+// We don't currently allow plain properties called __proto__ in JSON
+// objects in JSON.parse. Instead we read them as we would JS object
+// literals. If we change that, this test should change with it.
+//
+// Parse a non-object value as __proto__. This must not create a
+// __proto__ property different from the original, and should not
+// change the original.
+var o = JSON.parse('{"__proto__":5}');
+assertEquals(Object.prototype, o.__proto__); // __proto__ isn't changed.
+assertEquals(0, Object.keys(o).length); // __proto__ isn't added as enumerable.
var json = '{"stuff before slash\\\\stuff after slash":"whatever"}';
assertEquals(json, JSON.stringify(JSON.parse(json)));
« no previous file with comments | « test/mjsunit/harmony/proxies.js ('k') | test/mjsunit/regress/regress-2441.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698