summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/JSON/parse
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/JSON/parse')
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-1.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-2.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-3.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-4.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-5.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-6.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-8.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-9.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-1.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-2.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-3.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-4.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-1.js11
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-2.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-3.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-4.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-5.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-1.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-2.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-3.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-4.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-1.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-2.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-3.js15
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-1.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-2.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-3.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-4.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-5.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-6.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-7.js13
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-1.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-10.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-2.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-3.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-4.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-5.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-6.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-7.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-8.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-9.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/S15.12.2_A1.js20
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/builtin.js30
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/duplicate-proto.js19
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/invalid-whitespace.js76
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/length.js27
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/name.js29
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/prop-desc.js22
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/revived-proxy-revoked.js47
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/revived-proxy.js86
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-array-define-prop-err.js48
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-array-delete-err.js42
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-array-get-prop-from-prototype.js46
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-array-length-coerce-err.js45
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-array-length-get-err.js40
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-array-non-configurable-prop-create.js49
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-array-non-configurable-prop-delete.js49
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-call-err.js27
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-call-order.js22
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-get-name-err.js31
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-object-define-prop-err.js49
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-object-delete-err.js44
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-object-get-prop-from-prototype.js48
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-object-non-configurable-prop-create.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-object-non-configurable-prop-delete.js51
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-object-own-keys-err.js38
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/reviver-wrapper.js41
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/text-negative-zero.js23
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/text-non-string-primitive.js36
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/text-object-abrupt.js30
-rw-r--r--js/src/tests/test262/built-ins/JSON/parse/text-object.js27
74 files changed, 2193 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-1.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-1.js
new file mode 100644
index 0000000000..ae9059ed5b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-1.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-0-1
+description: The JSON lexical grammar treats whitespace as a token seperator
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('12\t\r\n 34'); // should produce a syntax error as whitespace results in two tokens
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-2.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-2.js
new file mode 100644
index 0000000000..7cb3e4fc2d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-2.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-0-2
+description: >
+ <VT> is not valid JSON whitespace as specified by the production
+ JSONWhitespace.
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u000b1234'); // should produce a syntax error
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-3.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-3.js
new file mode 100644
index 0000000000..b6436fa204
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-3.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-0-3
+description: >
+ <FF> is not valid JSON whitespace as specified by the production
+ JSONWhitespace.
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u000c1234'); // should produce a syntax error
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-4.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-4.js
new file mode 100644
index 0000000000..448066da70
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-4.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-0-4
+description: >
+ <NBSP> is not valid JSON whitespace as specified by the production
+ JSONWhitespace.
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u00a01234'); // should produce a syntax error
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-5.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-5.js
new file mode 100644
index 0000000000..0d0b9d0e1b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-5.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-0-5
+description: >
+ <ZWSPP> is not valid JSON whitespace as specified by the
+ production JSONWhitespace.
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u200b1234'); // should produce a syntax error
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-6.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-6.js
new file mode 100644
index 0000000000..07c7436077
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-6.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-0-6
+description: >
+ <BOM> is not valid JSON whitespace as specified by the production
+ JSONWhitespace.
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\ufeff1234'); // should produce a syntax error a
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-8.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-8.js
new file mode 100644
index 0000000000..c2a49dbb58
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-8.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-0-8
+description: >
+ U+2028 and U+2029 are not valid JSON whitespace as specified by
+ the production JSONWhitespace.
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u2028\u20291234'); // should produce a syntax error
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-9.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-9.js
new file mode 100644
index 0000000000..04a9d306a9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-0-9.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-0-9
+description: Whitespace characters can appear before/after any JSONtoken
+---*/
+
+JSON.parse('\t\r \n{\t\r \n' +
+ '"property"\t\r \n:\t\r \n{\t\r \n}\t\r \n,\t\r \n' +
+ '"prop2"\t\r \n:\t\r \n' +
+ '[\t\r \ntrue\t\r \n,\t\r \nnull\t\r \n,123.456\t\r \n]' +
+ '\t\r \n}\t\r \n'); // should JOSN parse without error
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-1.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-1.js
new file mode 100644
index 0000000000..64bddfb579
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-1.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g1-1
+description: The JSON lexical grammar treats <TAB> as a whitespace character
+---*/
+
+assert.sameValue(JSON.parse('\t1234'), 1234, '<TAB> should be ignored');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('12\t34');
+}, '<TAB> should produce a syntax error as whitespace results in two tokens');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-2.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-2.js
new file mode 100644
index 0000000000..53a0261914
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-2.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g1-2
+description: The JSON lexical grammar treats <CR> as a whitespace character
+---*/
+
+assert.sameValue(JSON.parse('\r1234'), 1234, '<cr> should be ignored');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('12\r34');
+}, '<CR> should produce a syntax error as whitespace results in two tokens');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-3.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-3.js
new file mode 100644
index 0000000000..b846ff548c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-3.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g1-3
+description: The JSON lexical grammar treats <LF> as a whitespace character
+---*/
+
+assert.sameValue(JSON.parse('\n1234'), 1234, '<LF> should be ignored');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('12\n34');
+}, '<LF> should produce a syntax error as whitespace results in two tokens');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-4.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-4.js
new file mode 100644
index 0000000000..ba29db50da
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g1-4.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g1-4
+description: The JSON lexical grammar treats <SP> as a whitespace character
+---*/
+
+assert.sameValue(JSON.parse(' 1234'), 1234, '<SP> should be ignored');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('12 34');
+}, '<SP> should produce a syntax error as whitespace results in two tokens');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-1.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-1.js
new file mode 100644
index 0000000000..f39bb364b6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-1.js
@@ -0,0 +1,11 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g2-1
+description: JSONStrings can be written using double quotes
+---*/
+
+assert.sameValue(JSON.parse('"abc"'), "abc", 'JSON.parse(\'"abc"\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-2.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-2.js
new file mode 100644
index 0000000000..28379cace7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-2.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g2-2
+description: A JSONString may not be delimited by single quotes
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse("'abc'");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-3.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-3.js
new file mode 100644
index 0000000000..4a0e5ad382
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-3.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g2-3
+description: A JSONString may not be delimited by Uncode escaped quotes
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse("\\u0022abc\\u0022");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-4.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-4.js
new file mode 100644
index 0000000000..0e366108bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-4.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g2-4
+description: A JSONString must both begin and end with double quotes
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('"ab'+"c'");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-5.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-5.js
new file mode 100644
index 0000000000..51fd1c8e77
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g2-5.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g2-5
+description: >
+ A JSONStrings can contain no JSONStringCharacters (Empty
+ JSONStrings)
+---*/
+
+assert.sameValue(JSON.parse('""'), "", 'JSON.parse(\'""\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-1.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-1.js
new file mode 100644
index 0000000000..fcbe29740a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-1.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g4-1
+description: >
+ The JSON lexical grammar does not allow a JSONStringCharacter to
+ be any of the Unicode characters U+0000 thru U+0007
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007"'); // invalid string characters should produce a syntax error
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-2.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-2.js
new file mode 100644
index 0000000000..7d29a50833
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-2.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g4-2
+description: >
+ The JSON lexical grammar does not allow a JSONStringCharacter to
+ be any of the Unicode characters U+0008 thru U+000F
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('"\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f"'); // invalid string characters should produce a syntax error
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-3.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-3.js
new file mode 100644
index 0000000000..94b1a4f02f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-3.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g4-3
+description: >
+ The JSON lexical grammar does not allow a JSONStringCharacter to
+ be any of the Unicode characters U+0010 thru U+0017
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017"'); // invalid string characters should produce a syntax error
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-4.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-4.js
new file mode 100644
index 0000000000..3df9c206f1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g4-4.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g4-4
+description: >
+ The JSON lexical grammar does not allow a JSONStringCharacter to
+ be any of the Unicode characters U+0018 thru U+001F
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('"\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f"'); // invalid string characters should produce a syntax error
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-1.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-1.js
new file mode 100644
index 0000000000..80f58f2b52
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-1.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g5-1
+description: >
+ The JSON lexical grammar allows Unicode escape sequences in a
+ JSONString
+---*/
+
+assert.sameValue(JSON.parse('"\\u0058"'), 'X', 'JSON.parse(\'"\\u0058"\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-2.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-2.js
new file mode 100644
index 0000000000..8111eae39d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-2.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g5-2
+description: >
+ A JSONStringCharacter UnicodeEscape may not have fewer than 4 hex
+ characters
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('"\\u005"')
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-3.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-3.js
new file mode 100644
index 0000000000..c302bc31ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g5-3.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g5-3
+description: >
+ A JSONStringCharacter UnicodeEscape may not include any non=hex
+ characters
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('"\\u0X50"')
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-1.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-1.js
new file mode 100644
index 0000000000..49ed1a4af1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-1.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g6-1
+description: >
+ The JSON lexical grammer allows '/' as a JSONEscapeCharacter after
+ '' in a JSONString
+---*/
+
+assert.sameValue(JSON.parse('"\\/"'), '/', 'JSON.parse(\'"\\/"\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-2.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-2.js
new file mode 100644
index 0000000000..a9951a0064
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-2.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g6-2
+description: >
+ The JSON lexical grammer allows '' as a JSONEscapeCharacter after
+ '' in a JSONString
+---*/
+
+assert.sameValue(JSON.parse('"\\\\"'), '\\', 'JSON.parse(\'"\\\\"\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-3.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-3.js
new file mode 100644
index 0000000000..d6b3f59919
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-3.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g6-3
+description: >
+ The JSON lexical grammer allows 'b' as a JSONEscapeCharacter after
+ '' in a JSONString
+---*/
+
+assert.sameValue(JSON.parse('"\\b"'), '\b', 'JSON.parse(\'"\\b"\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-4.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-4.js
new file mode 100644
index 0000000000..0788c5ce01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-4.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g6-4
+description: >
+ The JSON lexical grammer allows 'f' as a JSONEscapeCharacter after
+ '' in a JSONString
+---*/
+
+assert.sameValue(JSON.parse('"\\f"'), '\f', 'JSON.parse(\'"\\f"\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-5.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-5.js
new file mode 100644
index 0000000000..3c53499abd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-5.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g6-5
+description: >
+ The JSON lexical grammer allows 'n' as a JSONEscapeCharacter after
+ '' in a JSONString
+---*/
+
+assert.sameValue(JSON.parse('"\\n"'), '\n', 'JSON.parse(\'"\\n"\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-6.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-6.js
new file mode 100644
index 0000000000..871c6560e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-6.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g6-6
+description: >
+ The JSON lexical grammer allows 'r' as a JSONEscapeCharacter after
+ '' in a JSONString
+---*/
+
+assert.sameValue(JSON.parse('"\\r"'), '\r', 'JSON.parse(\'"\\r"\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-7.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-7.js
new file mode 100644
index 0000000000..3a44f9fc08
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.1.1-g6-7.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.1.1-g6-7
+description: >
+ The JSON lexical grammer allows 't' as a JSONEscapeCharacter after
+ '' in a JSONString
+---*/
+
+assert.sameValue(JSON.parse('"\\t"'), '\t', 'JSON.parse(\'"\\t"\')');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-1.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-1.js
new file mode 100644
index 0000000000..abb366914a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-1.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-1
+description: >
+ JSON.parse - parsing an object where property name is a null
+ character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{ ' + nullChars[index] + ' : "John" } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-10.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-10.js
new file mode 100644
index 0000000000..102c7bc53b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-10.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-10
+description: >
+ JSON.parse - parsing an object where property value middles with a
+ null character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{ "name" : ' + "Jo" + nullChars[index] + "hn" + ' } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-2.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-2.js
new file mode 100644
index 0000000000..6735e36f0e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-2.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-2
+description: >
+ JSON.parse - parsing an object where property name starts with a
+ null character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{ ' + nullChars[index] + "name" + ' : "John" } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-3.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-3.js
new file mode 100644
index 0000000000..4f1136bc48
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-3.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-3
+description: >
+ JSON.parse - parsing an object where property name ends with a
+ null character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{' + "name" + nullChars[index] + ' : "John" } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-4.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-4.js
new file mode 100644
index 0000000000..9a2c4f5d72
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-4.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-4
+description: >
+ JSON.parse - parsing an object where property name starts and ends
+ with a null character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{' + nullChars[index] + "name" + nullChars[index] + ' : "John" } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-5.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-5.js
new file mode 100644
index 0000000000..25a39033c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-5.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-5
+description: >
+ JSON.parse - parsing an object where property name middles with a
+ null character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{ ' + "na" + nullChars[index] + "me" + ' : "John" } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-6.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-6.js
new file mode 100644
index 0000000000..7d8d572f3d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-6.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-6
+description: >
+ JSON.parse - parsing an object where property value is a null
+ character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{ "name" : ' + nullChars[index] + ' } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-7.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-7.js
new file mode 100644
index 0000000000..312ee20a88
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-7.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-7
+description: >
+ JSON.parse - parsing an object where property value starts with a
+ null character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{ "name" : ' + nullChars[index] + "John" + ' } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-8.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-8.js
new file mode 100644
index 0000000000..9f25002a2f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-8.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-8
+description: >
+ JSON.parse - parsing an object where property value ends with a
+ null character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{ "name" : ' + "John" + nullChars[index] + ' } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-9.js b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-9.js
new file mode 100644
index 0000000000..df23a803dd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/15.12.2-2-9.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.12.2-2-9
+description: >
+ JSON.parse - parsing an object where property value starts and
+ ends with a null character
+---*/
+
+var nullChars = new Array();
+nullChars[0] = '\"\u0000\"';
+nullChars[1] = '\"\u0001\"';
+nullChars[2] = '\"\u0002\"';
+nullChars[3] = '\"\u0003\"';
+nullChars[4] = '\"\u0004\"';
+nullChars[5] = '\"\u0005\"';
+nullChars[6] = '\"\u0006\"';
+nullChars[7] = '\"\u0007\"';
+nullChars[8] = '\"\u0008\"';
+nullChars[9] = '\"\u0009\"';
+nullChars[10] = '\"\u000A\"';
+nullChars[11] = '\"\u000B\"';
+nullChars[12] = '\"\u000C\"';
+nullChars[13] = '\"\u000D\"';
+nullChars[14] = '\"\u000E\"';
+nullChars[15] = '\"\u000F\"';
+nullChars[16] = '\"\u0010\"';
+nullChars[17] = '\"\u0011\"';
+nullChars[18] = '\"\u0012\"';
+nullChars[19] = '\"\u0013\"';
+nullChars[20] = '\"\u0014\"';
+nullChars[21] = '\"\u0015\"';
+nullChars[22] = '\"\u0016\"';
+nullChars[23] = '\"\u0017\"';
+nullChars[24] = '\"\u0018\"';
+nullChars[25] = '\"\u0019\"';
+nullChars[26] = '\"\u001A\"';
+nullChars[27] = '\"\u001B\"';
+nullChars[28] = '\"\u001C\"';
+nullChars[29] = '\"\u001D\"';
+nullChars[30] = '\"\u001E\"';
+nullChars[31] = '\"\u001F\"';
+
+for (var index in nullChars) {
+ assert.throws(SyntaxError, function() {
+ var obj = JSON.parse('{ "name" : ' + nullChars[index] + "John" + nullChars[index] + ' } ');
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/S15.12.2_A1.js b/js/src/tests/test262/built-ins/JSON/parse/S15.12.2_A1.js
new file mode 100644
index 0000000000..2de3caa3c9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/S15.12.2_A1.js
@@ -0,0 +1,20 @@
+// Copyright 2011 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: JSON.parse must create a property with the given property name
+es5id: 15.12.2_A1
+description: Tests that JSON.parse treats "__proto__" as a regular property name
+---*/
+
+var x = JSON.parse('{"__proto__":[]}');
+
+assert.sameValue(
+ Object.getPrototypeOf(x),
+ Object.prototype,
+ 'Object.getPrototypeOf("JSON.parse(\'{"__proto__":[]}\')") returns Object.prototype'
+);
+
+assert(Array.isArray(x.__proto__), 'Array.isArray(x.__proto__) must return true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/browser.js b/js/src/tests/test262/built-ins/JSON/parse/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/browser.js
diff --git a/js/src/tests/test262/built-ins/JSON/parse/builtin.js b/js/src/tests/test262/built-ins/JSON/parse/builtin.js
new file mode 100644
index 0000000000..c9737b46c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/builtin.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: >
+ Requirements for built-in functions, defined in introduction of chapter 17,
+ are satisfied.
+features: [Reflect.construct]
+---*/
+
+var parse = JSON.parse;
+assert(Object.isExtensible(parse), 'Object.isExtensible(parse) must return true');
+assert.sameValue(typeof parse, 'function', 'The value of `typeof parse` is "function"');
+assert.sameValue(
+ Object.prototype.toString.call(parse),
+ '[object Function]',
+ 'Object.prototype.toString.call("JSON.parse") must return "[object Function]"'
+);
+assert.sameValue(
+ Object.getPrototypeOf(parse),
+ Function.prototype,
+ 'Object.getPrototypeOf("JSON.parse") must return the value of Function.prototype'
+);
+assert.sameValue(
+ parse.hasOwnProperty('prototype'),
+ false,
+ 'parse.hasOwnProperty("prototype") must return false'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/duplicate-proto.js b/js/src/tests/test262/built-ins/JSON/parse/duplicate-proto.js
new file mode 100644
index 0000000000..93becbbc45
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/duplicate-proto.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2020 devsnek. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object-initializer-static-semantics-early-errors
+description: >
+ It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains
+ any duplicate entries for "__proto__" and at least two of those entries were
+ obtained from productions of the form
+ PropertyDefinition : PropertyName `:` AssignmentExpression .
+ This rule is not applied if this PropertyDefinition is contained within a
+ Script which is being evaluated for JSON.parse (see step 4 of JSON.parse).
+---*/
+
+var result = JSON.parse('{ "__proto__": 1, "__proto__": 2 }');
+
+assert.sameValue(result.__proto__, 2);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/invalid-whitespace.js b/js/src/tests/test262/built-ins/JSON/parse/invalid-whitespace.js
new file mode 100644
index 0000000000..96693fb97e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/invalid-whitespace.js
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-json.parse
+es5id: 15.12.1.1-0-7
+description: >
+ other category z spaces are not valid JSON whitespace as specified
+ by the production JSONWhitespace.
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u16801');
+}, '\\u1680');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u180e1');
+}, '\\u180e');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20001');
+}, '\\u2000');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20011');
+}, '\\u2001');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20021');
+}, '\\u2002');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20031');
+}, '\\u2003');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20041');
+}, '\\u2004');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20051');
+}, '\\u2005');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20061');
+}, '\\u2006');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20071');
+}, '\\u2007');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20081');
+}, '\\u2008');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u20091');
+}, '\\u2009');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u200a1');
+}, '\\u200a');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u202f1');
+}, '\\u202f');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u205f1');
+}, '\\u205f');
+
+assert.throws(SyntaxError, function() {
+ JSON.parse('\u30001');
+}, '\\u3000');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/length.js b/js/src/tests/test262/built-ins/JSON/parse/length.js
new file mode 100644
index 0000000000..85c0515de0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/length.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: >
+ JSON.parse.length is 2.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ The "length" property of the parse function is 2.
+
+ ECMAScript Standard Built-in Objects
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+verifyProperty(JSON.parse, 'length', {
+ value: 2,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/name.js b/js/src/tests/test262/built-ins/JSON/parse/name.js
new file mode 100644
index 0000000000..b029b4f744
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-json.parse
+description: >
+ JSON.parse.name is "parse".
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+verifyProperty(JSON.parse, 'name', {
+ value: 'parse',
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/not-a-constructor.js b/js/src/tests/test262/built-ins/JSON/parse/not-a-constructor.js
new file mode 100644
index 0000000000..d46040d8a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/not-a-constructor.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ JSON.parse does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(JSON.parse), false, 'isConstructor(JSON.parse) must return false');
+
+assert.throws(TypeError, () => {
+ new JSON.parse('{}');
+}, '`new JSON.parse(\'{}\')` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/prop-desc.js b/js/src/tests/test262/built-ins/JSON/parse/prop-desc.js
new file mode 100644
index 0000000000..f3f2fc6b18
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/prop-desc.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: >
+ Property descriptor of JSON.parse.
+info: |
+ ECMAScript Standard Built-in Objects
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2
+ has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+---*/
+
+verifyProperty(JSON, 'parse', {
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/revived-proxy-revoked.js b/js/src/tests/test262/built-ins/JSON/parse/revived-proxy-revoked.js
new file mode 100644
index 0000000000..b0f82dcca5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/revived-proxy-revoked.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: Behavior when revived value is a revoked Proxy exotic object
+info: |
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ a. Let root be ObjectCreate(%ObjectPrototype%).
+ b. Let rootName be the empty String.
+ c. Let status be CreateDataProperty(root, rootName, unfiltered).
+ d. Assert: status is true.
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ 24.3.1.1 Runtime Semantics: InternalizeJSONProperty
+
+ [...]
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+
+ 7.2.2 IsArray
+
+ [...]
+ 3. If argument is a Proxy exotic object, then
+ a. If the value of the [[ProxyHandler]] internal slot of argument is null,
+ throw a TypeError exception.
+ b. Let target be the value of the [[ProxyTarget]] internal slot of
+ argument.
+ c. Return ? IsArray(target).
+features: [Proxy]
+---*/
+
+var handle = Proxy.revocable([], {});
+var returnCount = 0;
+
+handle.revoke();
+
+assert.throws(TypeError, function() {
+ JSON.parse('[null, null]', function() {
+ this[1] = handle.proxy;
+ returnCount += 1;
+ });
+});
+
+assert.sameValue(returnCount, 1, 'invocation returns normally');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/revived-proxy.js b/js/src/tests/test262/built-ins/JSON/parse/revived-proxy.js
new file mode 100644
index 0000000000..fd3c659907
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/revived-proxy.js
@@ -0,0 +1,86 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: Behavior when revived value is a Proxy exotic object
+info: |
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ a. Let root be ObjectCreate(%ObjectPrototype%).
+ b. Let rootName be the empty String.
+ c. Let status be CreateDataProperty(root, rootName, unfiltered).
+ d. Assert: status is true.
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ 24.3.1.1 Runtime Semantics: InternalizeJSONProperty
+
+ [...]
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ c. Else,
+ [...]
+
+ 7.2.2 IsArray
+
+ [...]
+ 3. If argument is a Proxy exotic object, then
+ a. If the value of the [[ProxyHandler]] internal slot of argument is null,
+ throw a TypeError exception.
+ b. Let target be the value of the [[ProxyTarget]] internal slot of
+ argument.
+ c. Return ? IsArray(target).
+features: [Proxy]
+---*/
+
+var objectProxy = new Proxy({
+ length: 0,
+ other: 0
+}, {});
+var arrayProxy = new Proxy([], {});
+var arrayProxyProxy = new Proxy(arrayProxy, {});
+var visitedOther, injectProxy;
+
+arrayProxy.other = 0;
+
+injectProxy = function(name, val) {
+ if (name === 'other') {
+ visitedOther = true;
+ }
+ this[1] = objectProxy;
+ return val;
+};
+visitedOther = false;
+
+JSON.parse('[null, null]', injectProxy);
+
+assert.sameValue(visitedOther, true, 'proxy for ordinary object');
+
+injectProxy = function(name, val) {
+ if (name === 'other') {
+ visitedOther = true;
+ }
+ this[1] = arrayProxy;
+ return val;
+};
+visitedOther = false;
+
+JSON.parse('[null, null]', injectProxy);
+
+assert.sameValue(visitedOther, false, 'proxy for array');
+
+injectProxy = function(name, val) {
+ if (name === 'other') {
+ visitedOther = true;
+ }
+ this[1] = arrayProxyProxy;
+ return val;
+};
+visitedOther = false;
+
+JSON.parse('[null, null]', injectProxy);
+
+assert.sameValue(visitedOther, false, 'proxy for array proxy');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-array-define-prop-err.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-define-prop-err.js
new file mode 100644
index 0000000000..1613fa6878
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-define-prop-err.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: Abrupt completion from defining array property while reviving
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ Runtime Semantics: InternalizeJSONProperty ( holder, name)
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ i. Set I to 0.
+ ii. Let len be ? ToLength(? Get(val, "length")).
+ iii. Repeat while I < len,
+ 1. Let newElement be ? InternalizeJSONProperty(val, !
+ ToString(I)).
+ 2. If newElement is undefined, then
+ [...]
+ 3. Else,
+ a. Perform ? CreateDataProperty(val, ! ToString(I),
+ newElement).
+features: [Proxy]
+---*/
+
+var badDefine = new Proxy([null], {
+ defineProperty: function(_, name) {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ JSON.parse('["first", null]', function(_, value) {
+ if (value === 'first') {
+ this[1] = badDefine;
+ }
+ return value;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-array-delete-err.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-delete-err.js
new file mode 100644
index 0000000000..92d37426ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-delete-err.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: Abrupt completion from array property deletion while reviving
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ Runtime Semantics: InternalizeJSONProperty ( holder, name)
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ i. Set I to 0.
+ ii. Let len be ? ToLength(? Get(val, "length")).
+ iii. Repeat while I < len,
+ 1. Let newElement be ? InternalizeJSONProperty(val, !
+ ToString(I)).
+ 2. If newElement is undefined, then
+ a. Perform ? val.[[Delete]](! ToString(I)).
+features: [Proxy]
+---*/
+
+var badDelete = new Proxy([0], {
+ deleteProperty: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ JSON.parse('[0,0]', function() {
+ this[1] = badDelete;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-array-get-prop-from-prototype.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-get-prop-from-prototype.js
new file mode 100644
index 0000000000..a148a6e55d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-get-prop-from-prototype.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: >
+ `name` property is obtained with [[Get]] from prototype chain.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ d. Return ? InternalizeJSONProperty(root, rootName).
+
+ InternalizeJSONProperty ( holder, name )
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ iii. Repeat, while I < len,
+ 1. Let newElement be ? InternalizeJSONProperty(val, ! ToString(I)).
+ 2. If newElement is undefined, then
+ [...]
+ 3. Else,
+ a. Perform ? CreateDataProperty(val, ! ToString(I), newElement).
+---*/
+
+Array.prototype[1] = 3;
+
+var json = '[1, 2]';
+var arr = JSON.parse(json, function(key, value) {
+ if (key === '0') {
+ assert(delete this[1]);
+ }
+
+ return value;
+});
+
+assert(delete Array.prototype[1]);
+assert.sameValue(arr[0], 1);
+assert(arr.hasOwnProperty('1'));
+assert.sameValue(arr[1], 3);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-array-length-coerce-err.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-length-coerce-err.js
new file mode 100644
index 0000000000..5a2f8be696
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-length-coerce-err.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: >
+ Abrupt completion from coercing array "length" property to a number value
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ Runtime Semantics: InternalizeJSONProperty ( holder, name)
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ i. Set I to 0.
+ ii. Let len be ? ToLength(? Get(val, "length")).
+features: [Proxy]
+---*/
+
+var uncoercible = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+var badLength = new Proxy([], {
+ get: function(_, name) {
+ if (name === 'length') {
+ return uncoercible;
+ }
+ }
+});
+
+assert.throws(Test262Error, function() {
+ JSON.parse('[0,0]', function() {
+ this[1] = badLength;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-array-length-get-err.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-length-get-err.js
new file mode 100644
index 0000000000..1004af33e0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-length-get-err.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: >
+ Abrupt completion from array "length" property access while reviving
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ Runtime Semantics: InternalizeJSONProperty ( holder, name)
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ i. Set I to 0.
+ ii. Let len be ? ToLength(? Get(val, "length")).
+features: [Proxy]
+---*/
+
+var badLength = new Proxy([], {
+ get: function(_, name) {
+ if (name === 'length') {
+ throw new Test262Error();
+ }
+ }
+});
+
+assert.throws(Test262Error, function() {
+ JSON.parse('[0,0]', function() {
+ this[1] = badLength;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-array-non-configurable-prop-create.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-non-configurable-prop-create.js
new file mode 100644
index 0000000000..848cf62b6b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-non-configurable-prop-create.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: >
+ [[DefineOwnProperty]] validates property descriptor before applying.
+ If [[DefineOwnProperty]] is unsuccessful, no exception is thrown.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ d. Return ? InternalizeJSONProperty(root, rootName).
+
+ InternalizeJSONProperty ( holder, name )
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ iii. Repeat, while I < len,
+ 1. Let newElement be ? InternalizeJSONProperty(val, ! ToString(I)).
+ 2. If newElement is undefined, then
+ [...]
+ 3. Else,
+ a. Perform ? CreateDataProperty(val, ! ToString(I), newElement).
+
+ CreateDataProperty ( O, P, V )
+
+ [...]
+ 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
+---*/
+
+var json = '[1, 2]';
+var arr = JSON.parse(json, function(key, value) {
+ if (key === '0') {
+ Object.defineProperty(this, '1', {configurable: false});
+ }
+ if (key === '1') return 22;
+
+ return value;
+});
+
+assert.sameValue(arr[0], 1);
+assert.sameValue(arr[1], 2);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-array-non-configurable-prop-delete.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-non-configurable-prop-delete.js
new file mode 100644
index 0000000000..550c232652
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-array-non-configurable-prop-delete.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: >
+ [[Delete]] does not remove non-configurable properties.
+ If [[Delete]] is unsuccessful, no exception is thrown.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ d. Return ? InternalizeJSONProperty(root, rootName).
+
+ InternalizeJSONProperty ( holder, name )
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ iii. Repeat, while I < len,
+ 1. Let newElement be ? InternalizeJSONProperty(val, ! ToString(I)).
+ 2. If newElement is undefined, then
+ a. Perform ? val.[[Delete]](! ToString(I)).
+
+ OrdinaryDelete ( O, P )
+
+ [...]
+ 4. If desc.[[Configurable]] is true, then
+ a. Remove the own property with name P from O.
+---*/
+
+var json = '[1, 2]';
+var arr = JSON.parse(json, function(key, value) {
+ if (key === '0') {
+ Object.defineProperty(this, '1', {configurable: false});
+ }
+ if (key === '1') return;
+
+ return value;
+});
+
+assert.sameValue(arr[0], 1);
+assert(arr.hasOwnProperty('1'));
+assert.sameValue(arr[1], 2);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-call-err.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-call-err.js
new file mode 100644
index 0000000000..20903a9473
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-call-err.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: >
+ Abrupt completion when reviver function returns an abrupt completion
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ Runtime Semantics: InternalizeJSONProperty ( holder, name)
+
+ [...]
+ 3. Return ? Call(reviver, holder, « name, val »).
+---*/
+
+assert.throws(Test262Error, function() {
+ JSON.parse('0', function() {
+ throw new Test262Error();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-call-order.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-call-order.js
new file mode 100644
index 0000000000..bdab32af01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-call-order.js
@@ -0,0 +1,22 @@
+// Copyright 2019 Kevin Gibbons. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-internalizejsonproperty
+description: JSON.parse reviver call order
+features: [for-in-order]
+includes: [compareArray.js]
+---*/
+
+var calls = [];
+function reviver(name, val) {
+ calls.push(name);
+ return val;
+}
+
+JSON.parse('{"p1":0,"p2":0,"p1":0,"2":0,"1":0}', reviver);
+
+// The empty string is the _rootName_ in JSON.parse
+assert.compareArray(calls, ['1', '2', 'p1', 'p2', '']);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-get-name-err.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-get-name-err.js
new file mode 100644
index 0000000000..7e2801ecac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-get-name-err.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: Abrupt completion from "holder" property access while reviving
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ Runtime Semantics: InternalizeJSONProperty ( holder, name)
+
+ 1. Let val be ? Get(holder, name).
+---*/
+
+var thrower = function() {
+ throw new Test262Error();
+};
+
+assert.throws(Test262Error, function() {
+ JSON.parse('[0,0]', function() {
+ Object.defineProperty(this, '1', {
+ get: thrower
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-object-define-prop-err.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-define-prop-err.js
new file mode 100644
index 0000000000..e42d327760
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-define-prop-err.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: Abrupt completion from defining object property while reviving
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ Runtime Semantics: InternalizeJSONProperty ( holder, name)
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ c. Else,
+ i. Let keys be ? EnumerableOwnProperties(val, "key").
+ ii. For each String P in keys do,
+ 1. Let newElement be ? InternalizeJSONProperty(val, P).
+ 2. If newElement is undefined, then
+ [...]
+ 3. Else,
+ a. Perform ? CreateDataProperty(val, P, newElement).
+features: [Proxy]
+---*/
+
+var badDefine = new Proxy({
+ 0: null
+}, {
+ defineProperty: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ JSON.parse('["first", null]', function(_, value) {
+ if (value === 'first') {
+ this[1] = badDefine;
+ }
+ return value;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-object-delete-err.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-delete-err.js
new file mode 100644
index 0000000000..079b494217
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-delete-err.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: Abrupt completion from object property deletion while reviving
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ Runtime Semantics: InternalizeJSONProperty ( holder, name)
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ c. Else,
+ i. Let keys be ? EnumerableOwnProperties(val, "key").
+ ii. For each String P in keys do,
+ 1. Let newElement be ? InternalizeJSONProperty(val, P).
+ 2. If newElement is undefined, then
+ a. Perform ? val.[[Delete]](P).
+features: [Proxy]
+---*/
+
+var badDelete = new Proxy({
+ a: 1
+}, {
+ deleteProperty: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ JSON.parse('[0,0]', function() {
+ this[1] = badDelete;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-object-get-prop-from-prototype.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-get-prop-from-prototype.js
new file mode 100644
index 0000000000..7a4589fe48
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-get-prop-from-prototype.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: >
+ `name` property is obtained with [[Get]] from prototype chain.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ d. Return ? InternalizeJSONProperty(root, rootName).
+
+ InternalizeJSONProperty ( holder, name )
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ c. Else,
+ i. Let keys be ? EnumerableOwnPropertyNames(val, "key").
+ ii. For each String P in keys, do
+ 1. Let newElement be ? InternalizeJSONProperty(val, P).
+ 2. If newElement is undefined, then
+ [...]
+ 3. Else,
+ a. Perform ? CreateDataProperty(val, P, newElement).
+---*/
+
+Object.prototype.b = 3;
+
+var json = '{"a": 1, "b": 2}';
+var obj = JSON.parse(json, function(key, value) {
+ if (key === 'a') {
+ assert(delete this.b);
+ }
+
+ return value;
+});
+
+assert(delete Object.prototype.b);
+assert.sameValue(obj.a, 1);
+assert(obj.hasOwnProperty('b'));
+assert.sameValue(obj.b, 3);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-object-non-configurable-prop-create.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-non-configurable-prop-create.js
new file mode 100644
index 0000000000..3a09a6806b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-non-configurable-prop-create.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: >
+ [[DefineOwnProperty]] validates property descriptor before applying.
+ If [[DefineOwnProperty]] is unsuccessful, no exception is thrown.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ d. Return ? InternalizeJSONProperty(root, rootName).
+
+ InternalizeJSONProperty ( holder, name )
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ c. Else,
+ i. Let keys be ? EnumerableOwnPropertyNames(val, "key").
+ ii. For each String P in keys, do
+ 1. Let newElement be ? InternalizeJSONProperty(val, P).
+ 2. If newElement is undefined, then
+ [...]
+ 3. Else,
+ a. Perform ? CreateDataProperty(val, P, newElement).
+
+ CreateDataProperty ( O, P, V )
+
+ [...]
+ 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
+---*/
+
+var json = '{"a": 1, "b": 2}';
+var obj = JSON.parse(json, function(key, value) {
+ if (key === 'a') {
+ Object.defineProperty(this, 'b', {configurable: false});
+ }
+ if (key === 'b') return 22;
+
+ return value;
+});
+
+assert.sameValue(obj.a, 1);
+assert.sameValue(obj.b, 2);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-object-non-configurable-prop-delete.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-non-configurable-prop-delete.js
new file mode 100644
index 0000000000..83f0a86fa0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-non-configurable-prop-delete.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: >
+ [[Delete]] does not remove non-configurable properties.
+ If [[Delete]] is unsuccessful, no exception is thrown.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ d. Return ? InternalizeJSONProperty(root, rootName).
+
+ InternalizeJSONProperty ( holder, name )
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ c. Else,
+ i. Let keys be ? EnumerableOwnPropertyNames(val, "key").
+ ii. For each String P in keys, do
+ 1. Let newElement be ? InternalizeJSONProperty(val, P).
+ 2. If newElement is undefined, then
+ a. Perform ? val.[[Delete]](P).
+
+ OrdinaryDelete ( O, P )
+
+ [...]
+ 4. If desc.[[Configurable]] is true, then
+ a. Remove the own property with name P from O.
+---*/
+
+var json = '{"a": 1, "b": 2}';
+var obj = JSON.parse(json, function(key, value) {
+ if (key === 'a') {
+ Object.defineProperty(this, 'b', {configurable: false});
+ }
+ if (key === 'b') return;
+
+ return value;
+});
+
+assert.sameValue(obj.a, 1);
+assert(obj.hasOwnProperty('b'));
+assert.sameValue(obj.b, 2);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-object-own-keys-err.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-own-keys-err.js
new file mode 100644
index 0000000000..d795500537
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-object-own-keys-err.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-internalizejsonproperty
+description: Abrupt completion from object property enumeration while reviving
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ [...]
+ e. Return ? InternalizeJSONProperty(root, rootName).
+
+ Runtime Semantics: InternalizeJSONProperty ( holder, name)
+
+ 1. Let val be ? Get(holder, name).
+ 2. If Type(val) is Object, then
+ a. Let isArray be ? IsArray(val).
+ b. If isArray is true, then
+ [...]
+ c. Else,
+ i. Let keys be ? EnumerableOwnProperties(val, "key").
+features: [Proxy]
+---*/
+
+var badKeys = new Proxy({}, {
+ ownKeys: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ JSON.parse('[0,0]', function() {
+ this[1] = badKeys;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/reviver-wrapper.js b/js/src/tests/test262/built-ins/JSON/parse/reviver-wrapper.js
new file mode 100644
index 0000000000..7545656d8c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/reviver-wrapper.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: >
+ Wrapper is plain extensible object with single data property.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ [...]
+ 7. If IsCallable(reviver) is true, then
+ a. Let root be ObjectCreate(%Object.prototype%).
+ b. Let rootName be the empty String.
+ c. Perform ! CreateDataPropertyOrThrow(root, rootName, unfiltered).
+includes: [propertyHelper.js]
+---*/
+
+Object.defineProperty(Object.prototype, '', {
+ set: function() {
+ throw new Test262Error('[[Set]] should not be called.');
+ },
+});
+
+var wrapper;
+JSON.parse('2', function() {
+ wrapper = this;
+});
+
+assert.sameValue(typeof wrapper, 'object');
+assert.sameValue(Object.getPrototypeOf(wrapper), Object.prototype);
+assert.sameValue(Object.getOwnPropertyNames(wrapper).length, 1);
+assert(Object.isExtensible(wrapper));
+
+verifyProperty(wrapper, '', {
+ value: 2,
+ writable: true,
+ enumerable: true,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/shell.js b/js/src/tests/test262/built-ins/JSON/parse/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/JSON/parse/text-negative-zero.js b/js/src/tests/test262/built-ins/JSON/parse/text-negative-zero.js
new file mode 100644
index 0000000000..198c6d70e3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/text-negative-zero.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: >
+ Top-level negative zero surrounded by whitespace is parsed correctly.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ 1. Let JText be ? ToString(text).
+ 2. Parse JText interpreted as UTF-16 encoded Unicode points (6.1.4) as a JSON
+ text as specified in ECMA-404. Throw a SyntaxError exception if JText is not
+ a valid JSON text as defined in that specification.
+---*/
+
+assert.sameValue(JSON.parse('-0'), -0);
+assert.sameValue(JSON.parse(' \n-0'), -0);
+assert.sameValue(JSON.parse('-0 \t'), -0);
+assert.sameValue(JSON.parse('\n\t -0\n '), -0);
+
+assert.sameValue(JSON.parse(-0), 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/text-non-string-primitive.js b/js/src/tests/test262/built-ins/JSON/parse/text-non-string-primitive.js
new file mode 100644
index 0000000000..9efe855a7b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/text-non-string-primitive.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: >
+ Primitive values are coerced to strings and parsed.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ 1. Let JText be ? ToString(text).
+ 2. Parse JText interpreted as UTF-16 encoded Unicode points (6.1.4) as a JSON
+ text as specified in ECMA-404. Throw a SyntaxError exception if JText is not
+ a valid JSON text as defined in that specification.
+features: [Symbol]
+---*/
+
+assert.throws(SyntaxError, function() {
+ JSON.parse();
+});
+
+assert.throws(SyntaxError, function() {
+ JSON.parse(undefined);
+});
+
+assert.sameValue(JSON.parse(null), null);
+assert.sameValue(JSON.parse(false), false);
+assert.sameValue(JSON.parse(true), true);
+assert.sameValue(JSON.parse(0), 0);
+assert.sameValue(JSON.parse(3.14), 3.14);
+
+var sym = Symbol('desc');
+assert.throws(TypeError, function() {
+ JSON.parse(sym);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/text-object-abrupt.js b/js/src/tests/test262/built-ins/JSON/parse/text-object-abrupt.js
new file mode 100644
index 0000000000..aa0a7a70ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/text-object-abrupt.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: >
+ Abrupt completion from Get and Call in ToPrimitive.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ 1. Let JText be ? ToString(text).
+---*/
+
+assert.throws(Test262Error, function() {
+ JSON.parse({
+ toString: null,
+ get valueOf() {
+ throw new Test262Error();
+ },
+ });
+});
+
+assert.throws(Test262Error, function() {
+ JSON.parse({
+ toString: function() {
+ throw new Test262Error();
+ },
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/JSON/parse/text-object.js b/js/src/tests/test262/built-ins/JSON/parse/text-object.js
new file mode 100644
index 0000000000..c3eb0e74fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/parse/text-object.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-json.parse
+description: >
+ Objects are coerced to strings using ToString.
+info: |
+ JSON.parse ( text [ , reviver ] )
+
+ 1. Let JText be ? ToString(text).
+ 2. Parse JText interpreted as UTF-16 encoded Unicode points (6.1.4) as a JSON
+ text as specified in ECMA-404. Throw a SyntaxError exception if JText is not
+ a valid JSON text as defined in that specification.
+---*/
+
+var hint = JSON.parse({
+ toString: function() {
+ return '"string"';
+ },
+ valueOf: function() {
+ return '"default_or_number"';
+ },
+});
+
+assert.sameValue(hint, 'string');
+
+reportCompare(0, 0);