summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/import
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/import')
-rw-r--r--js/src/tests/test262/language/import/browser.js0
-rw-r--r--js/src/tests/test262/language/import/dup-bound-names.js17
-rw-r--r--js/src/tests/test262/language/import/escaped-as-import-specifier.js27
-rw-r--r--js/src/tests/test262/language/import/escaped-as-namespace-import.js25
-rw-r--r--js/src/tests/test262/language/import/escaped-from.js25
-rw-r--r--js/src/tests/test262/language/import/import-assertions/README.md2
-rw-r--r--js/src/tests/test262/language/import/import-assertions/browser.js0
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-extensibility-array.js23
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-extensibility-object.js23
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-idempotency-indirect_FIXTURE.js7
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-idempotency.js22
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-idempotency_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-invalid.js24
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-invalid_FIXTURE.json3
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-named-bindings.js21
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-named-bindings_FIXTURE.json3
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-array.js50
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-array_FIXTURE.json10
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-boolean.js23
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-boolean_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-null.js23
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-null_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-number.js23
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-number_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-object.js70
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-object_FIXTURE.json10
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-string.js23
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-value-string_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-via-namespace.js16
-rw-r--r--js/src/tests/test262/language/import/import-assertions/json-via-namespace_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-assertions/shell.js0
-rw-r--r--js/src/tests/test262/language/import/import-attributes/README.md2
-rw-r--r--js/src/tests/test262/language/import/import-attributes/browser.js0
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-extensibility-array.js23
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-extensibility-object.js23
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-idempotency-indirect_FIXTURE.js7
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-idempotency.js22
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-idempotency_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-invalid.js24
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-invalid_FIXTURE.json3
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-named-bindings.js21
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-named-bindings_FIXTURE.json3
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-array.js50
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-array_FIXTURE.json10
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-boolean.js23
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-boolean_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-null.js23
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-null_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-number.js23
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-number_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-object.js70
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-object_FIXTURE.json10
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-string.js23
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-value-string_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-via-namespace.js16
-rw-r--r--js/src/tests/test262/language/import/import-attributes/json-via-namespace_FIXTURE.json1
-rw-r--r--js/src/tests/test262/language/import/import-attributes/shell.js0
-rw-r--r--js/src/tests/test262/language/import/shell.js0
58 files changed, 858 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/import/browser.js b/js/src/tests/test262/language/import/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/import/browser.js
diff --git a/js/src/tests/test262/language/import/dup-bound-names.js b/js/src/tests/test262/language/import/dup-bound-names.js
new file mode 100644
index 0000000000..fd4193612e
--- /dev/null
+++ b/js/src/tests/test262/language/import/dup-bound-names.js
@@ -0,0 +1,17 @@
+// |reftest| error:SyntaxError module
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 15.2.1.1
+description: >
+ It is a Syntax Error if the BoundNames of ImportDeclaration contains any
+ duplicate entries.
+flags: [module]
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+import { x, y as x } from 'z';
diff --git a/js/src/tests/test262/language/import/escaped-as-import-specifier.js b/js/src/tests/test262/language/import/escaped-as-import-specifier.js
new file mode 100644
index 0000000000..e33799d271
--- /dev/null
+++ b/js/src/tests/test262/language/import/escaped-as-import-specifier.js
@@ -0,0 +1,27 @@
+// |reftest| error:SyntaxError module
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-grammar-notation
+description: >
+ The `as` contextual keyword must not contain Unicode escape sequences.
+info: |
+ Terminal symbols are shown
+ in fixed width font, both in the productions of the grammars and throughout this
+ specification whenever the text directly refers to such a terminal symbol. These
+ are to appear in a script exactly as written. All terminal symbol code points
+ specified in this way are to be understood as the appropriate Unicode code points
+ from the Basic Latin range, as opposed to any similar-looking code points from
+ other Unicode ranges.
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [module]
+---*/
+
+$DONOTEVALUATE();
+
+export var a = 0;
+
+import {a \u0061s b} from "./escaped-as-import-specifier.js";
diff --git a/js/src/tests/test262/language/import/escaped-as-namespace-import.js b/js/src/tests/test262/language/import/escaped-as-namespace-import.js
new file mode 100644
index 0000000000..1e9d036b64
--- /dev/null
+++ b/js/src/tests/test262/language/import/escaped-as-namespace-import.js
@@ -0,0 +1,25 @@
+// |reftest| error:SyntaxError module
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-grammar-notation
+description: >
+ The `as` contextual keyword must not contain Unicode escape sequences.
+info: |
+ Terminal symbols are shown
+ in fixed width font, both in the productions of the grammars and throughout this
+ specification whenever the text directly refers to such a terminal symbol. These
+ are to appear in a script exactly as written. All terminal symbol code points
+ specified in this way are to be understood as the appropriate Unicode code points
+ from the Basic Latin range, as opposed to any similar-looking code points from
+ other Unicode ranges.
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [module]
+---*/
+
+$DONOTEVALUATE();
+
+import* \u0061s self from "./escaped-as-namespace-import.js";
diff --git a/js/src/tests/test262/language/import/escaped-from.js b/js/src/tests/test262/language/import/escaped-from.js
new file mode 100644
index 0000000000..402d58980d
--- /dev/null
+++ b/js/src/tests/test262/language/import/escaped-from.js
@@ -0,0 +1,25 @@
+// |reftest| error:SyntaxError module
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-grammar-notation
+description: >
+ The `from` contextual keyword must not contain Unicode escape sequences.
+info: |
+ Terminal symbols are shown
+ in fixed width font, both in the productions of the grammars and throughout this
+ specification whenever the text directly refers to such a terminal symbol. These
+ are to appear in a script exactly as written. All terminal symbol code points
+ specified in this way are to be understood as the appropriate Unicode code points
+ from the Basic Latin range, as opposed to any similar-looking code points from
+ other Unicode ranges.
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [module]
+---*/
+
+$DONOTEVALUATE();
+
+import {} \u0066rom "./escaped-from.js";
diff --git a/js/src/tests/test262/language/import/import-assertions/README.md b/js/src/tests/test262/language/import/import-assertions/README.md
new file mode 100644
index 0000000000..d80cf27f8e
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/README.md
@@ -0,0 +1,2 @@
+Make sure to keep the tests in this folder aligned
+with the tests in the import-attributes folder.
diff --git a/js/src/tests/test262/language/import/import-assertions/browser.js b/js/src/tests/test262/language/import/import-assertions/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/browser.js
diff --git a/js/src/tests/test262/language/import/import-assertions/json-extensibility-array.js b/js/src/tests/test262/language/import/import-assertions/json-extensibility-array.js
new file mode 100644
index 0000000000..bcd7f27f0f
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-extensibility-array.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Creates extensible arrays
+flags: [module]
+includes: [propertyHelper.js]
+features: [import-assertions, json-modules]
+---*/
+
+import value from './json-value-array_FIXTURE.json' assert { type: 'json' };
+
+value.test262property = 'test262 value';
+
+verifyProperty(value, 'test262property', {
+ value: 'test262 value',
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-extensibility-object.js b/js/src/tests/test262/language/import/import-assertions/json-extensibility-object.js
new file mode 100644
index 0000000000..bf68fb37f2
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-extensibility-object.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Creates extensible objects
+flags: [module]
+includes: [propertyHelper.js]
+features: [import-assertions, json-modules]
+---*/
+
+import value from './json-value-object_FIXTURE.json' assert { type: 'json' };
+
+value.test262property = 'test262 value';
+
+verifyProperty(value, 'test262property', {
+ value: 'test262 value',
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-idempotency-indirect_FIXTURE.js b/js/src/tests/test262/language/import/import-assertions/json-idempotency-indirect_FIXTURE.js
new file mode 100644
index 0000000000..08381e0071
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-idempotency-indirect_FIXTURE.js
@@ -0,0 +1,7 @@
+// |reftest| skip -- not a test file
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+import value from './json-idempotency_FIXTURE.json' assert { type: 'json' };
+
+globalThis.viaSecondModule = value;
diff --git a/js/src/tests/test262/language/import/import-assertions/json-idempotency.js b/js/src/tests/test262/language/import/import-assertions/json-idempotency.js
new file mode 100644
index 0000000000..8b7e7fc85d
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-idempotency.js
@@ -0,0 +1,22 @@
+// |reftest| skip module async -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: The same object representation is returned to all import sites
+flags: [module, async]
+features: [import-assertions, json-modules, globalThis, dynamic-import]
+---*/
+
+import viaStaticImport1 from './json-idempotency_FIXTURE.json' assert { type: 'json' };
+import {default as viaStaticImport2} from './json-idempotency_FIXTURE.json' assert { type: 'json' };
+import './json-idempotency-indirect_FIXTURE.js';
+
+assert.sameValue(viaStaticImport1, viaStaticImport2);
+assert.sameValue(globalThis.viaSecondModule, viaStaticImport1);
+
+import('./json-idempotency_FIXTURE.json', { assert: { type: 'json' } })
+ .then(function(viaDynamicImport) {
+ assert.sameValue(viaDynamicImport.default, viaStaticImport1);
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-idempotency_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-idempotency_FIXTURE.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-idempotency_FIXTURE.json
@@ -0,0 +1 @@
+{}
diff --git a/js/src/tests/test262/language/import/import-assertions/json-invalid.js b/js/src/tests/test262/language/import/import-assertions/json-invalid.js
new file mode 100644
index 0000000000..a4aab457d3
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-invalid.js
@@ -0,0 +1,24 @@
+// |reftest| skip error:SyntaxError module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Does not define
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-assertions, json-modules]
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+import value from './json-invalid_FIXTURE.json' assert { type: 'json' };
diff --git a/js/src/tests/test262/language/import/import-assertions/json-invalid_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-invalid_FIXTURE.json
new file mode 100644
index 0000000000..64809bccc4
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-invalid_FIXTURE.json
@@ -0,0 +1,3 @@
+{
+ notJson: 0
+}
diff --git a/js/src/tests/test262/language/import/import-assertions/json-named-bindings.js b/js/src/tests/test262/language/import/import-assertions/json-named-bindings.js
new file mode 100644
index 0000000000..5d2f5faabb
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-named-bindings.js
@@ -0,0 +1,21 @@
+// |reftest| skip error:SyntaxError module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Does not define named bindings
+info: |
+ In the early design of JSON modules, contributors considered allowing the
+ properties of object values in JSON modules to be imported directly by name.
+ This was ultimately rejected, so attempting to import in this way should
+ produce a SyntaxError.
+flags: [module]
+features: [import-assertions, json-modules]
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+import {name} from './json-named-bindings_FIXTURE.json' assert { type: 'json' };
diff --git a/js/src/tests/test262/language/import/import-assertions/json-named-bindings_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-named-bindings_FIXTURE.json
new file mode 100644
index 0000000000..ead2bb7c66
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-named-bindings_FIXTURE.json
@@ -0,0 +1,3 @@
+{
+ "name": 0
+}
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-array.js b/js/src/tests/test262/language/import/import-assertions/json-value-array.js
new file mode 100644
index 0000000000..ffc2061793
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-array.js
@@ -0,0 +1,50 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of an array
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+
+ To more fully verify parsing correctness, the source text of the imported
+ module record includes non-printable characters (specifically, all four forms
+ of JSON's so-called "whitespace" token) both before and after the "value."
+flags: [module]
+features: [import-assertions, json-modules]
+---*/
+
+import value from './json-value-array_FIXTURE.json' assert { type: 'json' };
+
+assert(Array.isArray(value), 'the exported value is an array');
+assert.sameValue(
+ Object.getPrototypeOf(value),
+ Array.prototype,
+ 'the exported value is not a subclass of Array'
+);
+assert.sameValue(Object.getOwnPropertyNames(value).length, 7);
+assert.sameValue(value.length, 6);
+
+assert.sameValue(value[0], -1.2345);
+assert.sameValue(value[1], true);
+assert.sameValue(value[2], 'a string value');
+assert.sameValue(value[3], null);
+
+assert.sameValue(Object.getPrototypeOf(value[4]), Object.prototype);
+assert.sameValue(Object.getOwnPropertyNames(value[4]).length, 0);
+
+assert(Array.isArray(value[5]), 'the fifth element is an array');
+assert.sameValue(
+ Object.getPrototypeOf(value[5]),
+ Array.prototype,
+ 'the fifth element is not a subclass of Array'
+);
+assert.sameValue(Object.getOwnPropertyNames(value[5]).length, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-array_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-value-array_FIXTURE.json
new file mode 100644
index 0000000000..9520048793
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-array_FIXTURE.json
@@ -0,0 +1,10 @@
+
+ [
+ -1234.500e-003,
+ true,
+ "a string value",
+ null,
+ {},
+ []
+]
+
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-boolean.js b/js/src/tests/test262/language/import/import-assertions/json-value-boolean.js
new file mode 100644
index 0000000000..cd3425681d
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-boolean.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of a boolean
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-assertions, json-modules]
+---*/
+
+import value from './json-value-boolean_FIXTURE.json' assert { type: 'json' };
+
+assert.sameValue(value, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-boolean_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-value-boolean_FIXTURE.json
new file mode 100644
index 0000000000..27ba77ddaf
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-boolean_FIXTURE.json
@@ -0,0 +1 @@
+true
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-null.js b/js/src/tests/test262/language/import/import-assertions/json-value-null.js
new file mode 100644
index 0000000000..14a7b89ef8
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-null.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of null
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-assertions, json-modules]
+---*/
+
+import value from './json-value-null_FIXTURE.json' assert { type: 'json' };
+
+assert.sameValue(value, null);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-null_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-value-null_FIXTURE.json
new file mode 100644
index 0000000000..19765bd501
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-null_FIXTURE.json
@@ -0,0 +1 @@
+null
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-number.js b/js/src/tests/test262/language/import/import-assertions/json-value-number.js
new file mode 100644
index 0000000000..9fc19d060a
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-number.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of a number
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-assertions, json-modules]
+---*/
+
+import value from './json-value-number_FIXTURE.json' assert { type: 'json' };
+
+assert.sameValue(value, -1.2345);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-number_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-value-number_FIXTURE.json
new file mode 100644
index 0000000000..859603baed
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-number_FIXTURE.json
@@ -0,0 +1 @@
+-1234.500e-003
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-object.js b/js/src/tests/test262/language/import/import-assertions/json-value-object.js
new file mode 100644
index 0000000000..0a042d45c3
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-object.js
@@ -0,0 +1,70 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of an ordinary object
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+
+ To more fully verify parsing correctness, the source text of the imported
+ module record includes non-printable characters (specifically, all four forms
+ of JSON's so-called "whitespace" token) both before and after the "value."
+flags: [module]
+includes: [propertyHelper.js]
+features: [import-assertions, json-modules]
+---*/
+
+import value from './json-value-object_FIXTURE.json' assert { type: 'json' };
+
+assert.sameValue(Object.getPrototypeOf(value), Object.prototype);
+assert.sameValue(Object.getOwnPropertyNames(value).length, 6);
+
+verifyProperty(value, 'number', {
+ value: -1.2345,
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+verifyProperty(value, 'boolean', {
+ value: true,
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+verifyProperty(value, 'string', {
+ value: 'a string value',
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+verifyProperty(value, 'null', {
+ value: null,
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+assert.sameValue(Object.getPrototypeOf(value.object), Object.prototype);
+assert.sameValue(Object.getOwnPropertyNames(value.object).length, 0);
+
+assert(
+ Array.isArray(value.array), 'the value of the "array" property is an array'
+);
+assert.sameValue(
+ Object.getPrototypeOf(value.array),
+ Array.prototype,
+ 'the value of the "array" property is not a subclass of Array'
+);
+assert.sameValue(Object.getOwnPropertyNames(value.array).length, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-object_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-value-object_FIXTURE.json
new file mode 100644
index 0000000000..814ec45e4d
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-object_FIXTURE.json
@@ -0,0 +1,10 @@
+
+ {
+ "number": -1234.500e-003,
+ "boolean": true,
+ "string": "a string value",
+ "null": null,
+ "object": {},
+ "array": []
+}
+
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-string.js b/js/src/tests/test262/language/import/import-assertions/json-value-string.js
new file mode 100644
index 0000000000..a02e3381a4
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-string.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of a string
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-assertions, json-modules]
+---*/
+
+import value from './json-value-string_FIXTURE.json' assert { type: 'json' };
+
+assert.sameValue(value, 'a string value');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-value-string_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-value-string_FIXTURE.json
new file mode 100644
index 0000000000..d98e333143
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-value-string_FIXTURE.json
@@ -0,0 +1 @@
+"a string value"
diff --git a/js/src/tests/test262/language/import/import-assertions/json-via-namespace.js b/js/src/tests/test262/language/import/import-assertions/json-via-namespace.js
new file mode 100644
index 0000000000..c4142df74b
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-via-namespace.js
@@ -0,0 +1,16 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: May be imported via a module namespace object
+flags: [module]
+features: [import-assertions, json-modules]
+---*/
+
+import * as ns from './json-via-namespace_FIXTURE.json' assert { type: 'json' };
+
+assert.sameValue(Object.getOwnPropertyNames(ns).length, 1);
+assert.sameValue(ns.default, 262);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-assertions/json-via-namespace_FIXTURE.json b/js/src/tests/test262/language/import/import-assertions/json-via-namespace_FIXTURE.json
new file mode 100644
index 0000000000..5484d82917
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/json-via-namespace_FIXTURE.json
@@ -0,0 +1 @@
+262
diff --git a/js/src/tests/test262/language/import/import-assertions/shell.js b/js/src/tests/test262/language/import/import-assertions/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-assertions/shell.js
diff --git a/js/src/tests/test262/language/import/import-attributes/README.md b/js/src/tests/test262/language/import/import-attributes/README.md
new file mode 100644
index 0000000000..bf4a0de27f
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/README.md
@@ -0,0 +1,2 @@
+Make sure to keep the tests in this folder aligned
+with the tests in the import-assertions folder.
diff --git a/js/src/tests/test262/language/import/import-attributes/browser.js b/js/src/tests/test262/language/import/import-attributes/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/browser.js
diff --git a/js/src/tests/test262/language/import/import-attributes/json-extensibility-array.js b/js/src/tests/test262/language/import/import-attributes/json-extensibility-array.js
new file mode 100644
index 0000000000..c654861c19
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-extensibility-array.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Creates extensible arrays
+flags: [module]
+includes: [propertyHelper.js]
+features: [import-attributes, json-modules]
+---*/
+
+import value from './json-value-array_FIXTURE.json' with { type: 'json' };
+
+value.test262property = 'test262 value';
+
+verifyProperty(value, 'test262property', {
+ value: 'test262 value',
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-extensibility-object.js b/js/src/tests/test262/language/import/import-attributes/json-extensibility-object.js
new file mode 100644
index 0000000000..12883345a9
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-extensibility-object.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Creates extensible objects
+flags: [module]
+includes: [propertyHelper.js]
+features: [import-attributes, json-modules]
+---*/
+
+import value from './json-value-object_FIXTURE.json' with { type: 'json' };
+
+value.test262property = 'test262 value';
+
+verifyProperty(value, 'test262property', {
+ value: 'test262 value',
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-idempotency-indirect_FIXTURE.js b/js/src/tests/test262/language/import/import-attributes/json-idempotency-indirect_FIXTURE.js
new file mode 100644
index 0000000000..638ce0a691
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-idempotency-indirect_FIXTURE.js
@@ -0,0 +1,7 @@
+// |reftest| skip -- not a test file
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+import value from './json-idempotency_FIXTURE.json' with { type: 'json' };
+
+globalThis.viaSecondModule = value;
diff --git a/js/src/tests/test262/language/import/import-attributes/json-idempotency.js b/js/src/tests/test262/language/import/import-attributes/json-idempotency.js
new file mode 100644
index 0000000000..1cadd19aae
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-idempotency.js
@@ -0,0 +1,22 @@
+// |reftest| skip module async -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: The same object representation is returned to all import sites
+flags: [module, async]
+features: [import-attributes, json-modules, globalThis, dynamic-import]
+---*/
+
+import viaStaticImport1 from './json-idempotency_FIXTURE.json' with { type: 'json' };
+import {default as viaStaticImport2} from './json-idempotency_FIXTURE.json' with { type: 'json' };
+import './json-idempotency-indirect_FIXTURE.js';
+
+assert.sameValue(viaStaticImport1, viaStaticImport2);
+assert.sameValue(globalThis.viaSecondModule, viaStaticImport1);
+
+import('./json-idempotency_FIXTURE.json', { with: { type: 'json' } })
+ .then(function(viaDynamicImport) {
+ assert.sameValue(viaDynamicImport.default, viaStaticImport1);
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-idempotency_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-idempotency_FIXTURE.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-idempotency_FIXTURE.json
@@ -0,0 +1 @@
+{}
diff --git a/js/src/tests/test262/language/import/import-attributes/json-invalid.js b/js/src/tests/test262/language/import/import-attributes/json-invalid.js
new file mode 100644
index 0000000000..4e121f368a
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-invalid.js
@@ -0,0 +1,24 @@
+// |reftest| skip error:SyntaxError module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Does not define
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-attributes, json-modules]
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+import value from './json-invalid_FIXTURE.json' with { type: 'json' };
diff --git a/js/src/tests/test262/language/import/import-attributes/json-invalid_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-invalid_FIXTURE.json
new file mode 100644
index 0000000000..64809bccc4
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-invalid_FIXTURE.json
@@ -0,0 +1,3 @@
+{
+ notJson: 0
+}
diff --git a/js/src/tests/test262/language/import/import-attributes/json-named-bindings.js b/js/src/tests/test262/language/import/import-attributes/json-named-bindings.js
new file mode 100644
index 0000000000..a45e97ce54
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-named-bindings.js
@@ -0,0 +1,21 @@
+// |reftest| skip error:SyntaxError module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Does not define named bindings
+info: |
+ In the early design of JSON modules, contributors considered allowing the
+ properties of object values in JSON modules to be imported directly by name.
+ This was ultimately rejected, so attempting to import in this way should
+ produce a SyntaxError.
+flags: [module]
+features: [import-attributes, json-modules]
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+import {name} from './json-named-bindings_FIXTURE.json' with { type: 'json' };
diff --git a/js/src/tests/test262/language/import/import-attributes/json-named-bindings_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-named-bindings_FIXTURE.json
new file mode 100644
index 0000000000..ead2bb7c66
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-named-bindings_FIXTURE.json
@@ -0,0 +1,3 @@
+{
+ "name": 0
+}
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-array.js b/js/src/tests/test262/language/import/import-attributes/json-value-array.js
new file mode 100644
index 0000000000..41fa87ca79
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-array.js
@@ -0,0 +1,50 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of an array
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+
+ To more fully verify parsing correctness, the source text of the imported
+ module record includes non-printable characters (specifically, all four forms
+ of JSON's so-called "whitespace" token) both before and after the "value."
+flags: [module]
+features: [import-attributes, json-modules]
+---*/
+
+import value from './json-value-array_FIXTURE.json' with { type: 'json' };
+
+assert(Array.isArray(value), 'the exported value is an array');
+assert.sameValue(
+ Object.getPrototypeOf(value),
+ Array.prototype,
+ 'the exported value is not a subclass of Array'
+);
+assert.sameValue(Object.getOwnPropertyNames(value).length, 7);
+assert.sameValue(value.length, 6);
+
+assert.sameValue(value[0], -1.2345);
+assert.sameValue(value[1], true);
+assert.sameValue(value[2], 'a string value');
+assert.sameValue(value[3], null);
+
+assert.sameValue(Object.getPrototypeOf(value[4]), Object.prototype);
+assert.sameValue(Object.getOwnPropertyNames(value[4]).length, 0);
+
+assert(Array.isArray(value[5]), 'the fifth element is an array');
+assert.sameValue(
+ Object.getPrototypeOf(value[5]),
+ Array.prototype,
+ 'the fifth element is not a subclass of Array'
+);
+assert.sameValue(Object.getOwnPropertyNames(value[5]).length, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-array_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-value-array_FIXTURE.json
new file mode 100644
index 0000000000..9520048793
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-array_FIXTURE.json
@@ -0,0 +1,10 @@
+
+ [
+ -1234.500e-003,
+ true,
+ "a string value",
+ null,
+ {},
+ []
+]
+
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-boolean.js b/js/src/tests/test262/language/import/import-attributes/json-value-boolean.js
new file mode 100644
index 0000000000..91d62565f2
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-boolean.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of a boolean
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-attributes, json-modules]
+---*/
+
+import value from './json-value-boolean_FIXTURE.json' with { type: 'json' };
+
+assert.sameValue(value, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-boolean_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-value-boolean_FIXTURE.json
new file mode 100644
index 0000000000..27ba77ddaf
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-boolean_FIXTURE.json
@@ -0,0 +1 @@
+true
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-null.js b/js/src/tests/test262/language/import/import-attributes/json-value-null.js
new file mode 100644
index 0000000000..a1c1ff35f5
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-null.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of null
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-attributes, json-modules]
+---*/
+
+import value from './json-value-null_FIXTURE.json' with { type: 'json' };
+
+assert.sameValue(value, null);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-null_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-value-null_FIXTURE.json
new file mode 100644
index 0000000000..19765bd501
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-null_FIXTURE.json
@@ -0,0 +1 @@
+null
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-number.js b/js/src/tests/test262/language/import/import-attributes/json-value-number.js
new file mode 100644
index 0000000000..2bd1c60270
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-number.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of a number
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-attributes, json-modules]
+---*/
+
+import value from './json-value-number_FIXTURE.json' with { type: 'json' };
+
+assert.sameValue(value, -1.2345);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-number_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-value-number_FIXTURE.json
new file mode 100644
index 0000000000..859603baed
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-number_FIXTURE.json
@@ -0,0 +1 @@
+-1234.500e-003
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-object.js b/js/src/tests/test262/language/import/import-attributes/json-value-object.js
new file mode 100644
index 0000000000..6c1b6d36f1
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-object.js
@@ -0,0 +1,70 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of an ordinary object
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+
+ To more fully verify parsing correctness, the source text of the imported
+ module record includes non-printable characters (specifically, all four forms
+ of JSON's so-called "whitespace" token) both before and after the "value."
+flags: [module]
+includes: [propertyHelper.js]
+features: [import-attributes, json-modules]
+---*/
+
+import value from './json-value-object_FIXTURE.json' with { type: 'json' };
+
+assert.sameValue(Object.getPrototypeOf(value), Object.prototype);
+assert.sameValue(Object.getOwnPropertyNames(value).length, 6);
+
+verifyProperty(value, 'number', {
+ value: -1.2345,
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+verifyProperty(value, 'boolean', {
+ value: true,
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+verifyProperty(value, 'string', {
+ value: 'a string value',
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+verifyProperty(value, 'null', {
+ value: null,
+ writable: true,
+ enumerable: true,
+ configurable: true
+});
+
+assert.sameValue(Object.getPrototypeOf(value.object), Object.prototype);
+assert.sameValue(Object.getOwnPropertyNames(value.object).length, 0);
+
+assert(
+ Array.isArray(value.array), 'the value of the "array" property is an array'
+);
+assert.sameValue(
+ Object.getPrototypeOf(value.array),
+ Array.prototype,
+ 'the value of the "array" property is not a subclass of Array'
+);
+assert.sameValue(Object.getOwnPropertyNames(value.array).length, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-object_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-value-object_FIXTURE.json
new file mode 100644
index 0000000000..814ec45e4d
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-object_FIXTURE.json
@@ -0,0 +1,10 @@
+
+ {
+ "number": -1234.500e-003,
+ "boolean": true,
+ "string": "a string value",
+ "null": null,
+ "object": {},
+ "array": []
+}
+
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-string.js b/js/src/tests/test262/language/import/import-attributes/json-value-string.js
new file mode 100644
index 0000000000..4b938405b2
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-string.js
@@ -0,0 +1,23 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: Correctly parses the JSON representation of a string
+info: |
+ # 1.4 ParseJSONModule ( source )
+
+ The abstract operation ParseJSONModule takes a single argument source which
+ is a String representing the contents of a module.
+
+ 1. Let json be ? Call(%JSON.parse%, undefined, « source »).
+ 2. Return CreateDefaultExportSyntheticModule(json).
+flags: [module]
+features: [import-attributes, json-modules]
+---*/
+
+import value from './json-value-string_FIXTURE.json' with { type: 'json' };
+
+assert.sameValue(value, 'a string value');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-value-string_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-value-string_FIXTURE.json
new file mode 100644
index 0000000000..d98e333143
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-value-string_FIXTURE.json
@@ -0,0 +1 @@
+"a string value"
diff --git a/js/src/tests/test262/language/import/import-attributes/json-via-namespace.js b/js/src/tests/test262/language/import/import-attributes/json-via-namespace.js
new file mode 100644
index 0000000000..a115b30412
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-via-namespace.js
@@ -0,0 +1,16 @@
+// |reftest| skip module -- json-modules is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-parse-json-module
+description: May be imported via a module namespace object
+flags: [module]
+features: [import-attributes, json-modules]
+---*/
+
+import * as ns from './json-via-namespace_FIXTURE.json' with { type: 'json' };
+
+assert.sameValue(Object.getOwnPropertyNames(ns).length, 1);
+assert.sameValue(ns.default, 262);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/import/import-attributes/json-via-namespace_FIXTURE.json b/js/src/tests/test262/language/import/import-attributes/json-via-namespace_FIXTURE.json
new file mode 100644
index 0000000000..5484d82917
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/json-via-namespace_FIXTURE.json
@@ -0,0 +1 @@
+262
diff --git a/js/src/tests/test262/language/import/import-attributes/shell.js b/js/src/tests/test262/language/import/import-attributes/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/import/import-attributes/shell.js
diff --git a/js/src/tests/test262/language/import/shell.js b/js/src/tests/test262/language/import/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/import/shell.js