From f510720b12c7d0dd3e0639bac35aceb237c2221c Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 8 May 2019 15:35:17 +0200 Subject: [PATCH] Add some initial tests for JSON modules. See . --- .../the-script-element/json-module/array.json | 1 + .../the-script-element/json-module/false.json | 1 + .../json-module/invalid-content-type.html | 26 ++++++++++++++ .../json-module/module.html | 18 ++++++++++ .../json-module/module.json | 3 ++ .../json-module/non-object.any.js | 14 ++++++++ .../the-script-element/json-module/null.json | 1 + .../json-module/parse-error.html | 21 +++++++++++ .../json-module/parse-error.json | 1 + .../json-module/string.json | 1 + .../the-script-element/json-module/true.json | 1 + .../the-script-element/json-module/utf8.html | 36 +++++++++++++++++++ .../the-script-element/json-module/utf8.json | 3 ++ .../json-module/valid-content-type.html | 36 +++++++++++++++++++ 14 files changed, 163 insertions(+) create mode 100644 html/semantics/scripting-1/the-script-element/json-module/array.json create mode 100644 html/semantics/scripting-1/the-script-element/json-module/false.json create mode 100644 html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.html create mode 100644 html/semantics/scripting-1/the-script-element/json-module/module.html create mode 100644 html/semantics/scripting-1/the-script-element/json-module/module.json create mode 100644 html/semantics/scripting-1/the-script-element/json-module/non-object.any.js create mode 100644 html/semantics/scripting-1/the-script-element/json-module/null.json create mode 100644 html/semantics/scripting-1/the-script-element/json-module/parse-error.html create mode 100644 html/semantics/scripting-1/the-script-element/json-module/parse-error.json create mode 100644 html/semantics/scripting-1/the-script-element/json-module/string.json create mode 100644 html/semantics/scripting-1/the-script-element/json-module/true.json create mode 100644 html/semantics/scripting-1/the-script-element/json-module/utf8.html create mode 100644 html/semantics/scripting-1/the-script-element/json-module/utf8.json create mode 100644 html/semantics/scripting-1/the-script-element/json-module/valid-content-type.html diff --git a/html/semantics/scripting-1/the-script-element/json-module/array.json b/html/semantics/scripting-1/the-script-element/json-module/array.json new file mode 100644 index 00000000000000..e77e32d3382e0a --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/array.json @@ -0,0 +1 @@ +["en", "try"] diff --git a/html/semantics/scripting-1/the-script-element/json-module/false.json b/html/semantics/scripting-1/the-script-element/json-module/false.json new file mode 100644 index 00000000000000..c508d5366f70bb --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/false.json @@ -0,0 +1 @@ +false diff --git a/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.html b/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.html new file mode 100644 index 00000000000000..e6da2db7ebc03a --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.html @@ -0,0 +1,26 @@ + + +JSON modules: invalid Content-Type + + +
+ diff --git a/html/semantics/scripting-1/the-script-element/json-module/module.html b/html/semantics/scripting-1/the-script-element/json-module/module.html new file mode 100644 index 00000000000000..93243853226806 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/module.html @@ -0,0 +1,18 @@ + + +JSON modules + + +
+ + diff --git a/html/semantics/scripting-1/the-script-element/json-module/module.json b/html/semantics/scripting-1/the-script-element/json-module/module.json new file mode 100644 index 00000000000000..f834b2a4e8fab0 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/module.json @@ -0,0 +1,3 @@ +{ + "test": true +} diff --git a/html/semantics/scripting-1/the-script-element/json-module/non-object.any.js b/html/semantics/scripting-1/the-script-element/json-module/non-object.any.js new file mode 100644 index 00000000000000..398da56595f0f1 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/non-object.any.js @@ -0,0 +1,14 @@ +// META: global=window,worker + +for (const value of [null, true, false, "string"]) { + promise_test(async t => { + const result = await import(`./${value}.json`); + assert_equals(result, value); + }, `Non-object: ${value}`); +} + +promise_test(async t => { + const result = await import("./array.json"); + assert_array_equals(result, ["en", "try"]); +}, "Non-object: array"); + diff --git a/html/semantics/scripting-1/the-script-element/json-module/null.json b/html/semantics/scripting-1/the-script-element/json-module/null.json new file mode 100644 index 00000000000000..19765bd501b636 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/null.json @@ -0,0 +1 @@ +null diff --git a/html/semantics/scripting-1/the-script-element/json-module/parse-error.html b/html/semantics/scripting-1/the-script-element/json-module/parse-error.html new file mode 100644 index 00000000000000..68d3ef0a9ad3e6 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/parse-error.html @@ -0,0 +1,21 @@ + + +JSON modules: parse error + + +
+ + diff --git a/html/semantics/scripting-1/the-script-element/json-module/parse-error.json b/html/semantics/scripting-1/the-script-element/json-module/parse-error.json new file mode 100644 index 00000000000000..98232c64fce936 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/parse-error.json @@ -0,0 +1 @@ +{ diff --git a/html/semantics/scripting-1/the-script-element/json-module/string.json b/html/semantics/scripting-1/the-script-element/json-module/string.json new file mode 100644 index 00000000000000..ace2d72d9d3d24 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/string.json @@ -0,0 +1 @@ +"string" diff --git a/html/semantics/scripting-1/the-script-element/json-module/true.json b/html/semantics/scripting-1/the-script-element/json-module/true.json new file mode 100644 index 00000000000000..27ba77ddaf6153 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/true.json @@ -0,0 +1 @@ +true diff --git a/html/semantics/scripting-1/the-script-element/json-module/utf8.html b/html/semantics/scripting-1/the-script-element/json-module/utf8.html new file mode 100644 index 00000000000000..1c0360b17e3f9e --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/utf8.html @@ -0,0 +1,36 @@ + + +JSON modules: UTF-8 decoding + + +
+ + + + + diff --git a/html/semantics/scripting-1/the-script-element/json-module/utf8.json b/html/semantics/scripting-1/the-script-element/json-module/utf8.json new file mode 100644 index 00000000000000..7bb9edd2f79e82 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/utf8.json @@ -0,0 +1,3 @@ +{ + "test": "…" +} diff --git a/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.html b/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.html new file mode 100644 index 00000000000000..78e8b1d23fed22 --- /dev/null +++ b/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.html @@ -0,0 +1,36 @@ + + +JSON modules: Content-Type + + +
+ + + + +