Index: test/mjsunit/json2.js |
diff --git a/test/mjsunit/json2.js b/test/mjsunit/json2.js |
index 33e0aecd1e2928994a1cc478b3b7a15f0a3d4cc9..82d48c0dcf76769c53f71f1442a3cd1c25547c8d 100644 |
--- a/test/mjsunit/json2.js |
+++ b/test/mjsunit/json2.js |
@@ -109,6 +109,11 @@ assertEquals('["00","11"]', JSON.stringify(tojson_with_key_2)); |
var tojson_ex = { toJSON: function(key) { throw "123" } }; |
assertThrows(function() { JSON.stringify(tojson_ex); }); |
+// Test toJSON with access to this. |
+var obj = { toJSON: function(key) { return this.a + key; }, |
+ a: "x" }; |
+assertEquals('{"y":"xy"}', JSON.stringify({y: obj})); |
+ |
// Test holes in arrays. |
var fast_smi = [1, 2, 3, 4]; |
fast_smi.__proto__ = [7, 7, 7, 7]; |