From 670bad8c39afafa31913e9145f2a11b37ba194f6 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Fri, 4 Oct 2019 06:44:52 +0000 Subject: [PATCH] Bug 1557436 [wpt PR 16734] - Add some initial tests for JSON modules., a=testonly Automatic update from web-platform-tests Add some initial tests for JSON modules. See . -- wp5At-commits: f510720b12c7d0dd3e0639bac35aceb237c2221c wpt-pr: 16734 UltraBlame original commit: d18767ce41b850b8929ad67e8367a5fb80eda67d --- .../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 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/array.json create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/false.json create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.html create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/module.html create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/module.json create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.js create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/null.json create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/parse-error.html create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/parse-error.json create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/string.json create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/true.json create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/utf8.html create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/utf8.json create mode 100644 testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.html diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/array.json b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/array.json new file mode 100644 index 000000000000..e77e32d3382e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/array.json @@ -0,0 +1 @@ +["en", "try"] diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/false.json b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/false.json new file mode 100644 index 000000000000..c508d5366f70 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/false.json @@ -0,0 +1 @@ +false diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.html new file mode 100644 index 000000000000..e6da2db7ebc0 --- /dev/null +++ b/testing/web-platform/tests/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/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/module.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/module.html new file mode 100644 index 000000000000..932438532268 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/module.html @@ -0,0 +1,18 @@ + + +JSON modules + + +
+ + diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/module.json b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/module.json new file mode 100644 index 000000000000..f834b2a4e8fa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/module.json @@ -0,0 +1,3 @@ +{ + "test": true +} diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.js b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.js new file mode 100644 index 000000000000..2c7d8a7683c5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.js @@ -0,0 +1,14 @@ + + +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/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/null.json b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/null.json new file mode 100644 index 000000000000..19765bd501b6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/null.json @@ -0,0 +1 @@ +null diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/parse-error.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/parse-error.html new file mode 100644 index 000000000000..68d3ef0a9ad3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/parse-error.html @@ -0,0 +1,21 @@ + + +JSON modules: parse error + + +
+ + diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/parse-error.json b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/parse-error.json new file mode 100644 index 000000000000..98232c64fce9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/parse-error.json @@ -0,0 +1 @@ +{ diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/string.json b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/string.json new file mode 100644 index 000000000000..ace2d72d9d3d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/string.json @@ -0,0 +1 @@ +"string" diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/true.json b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/true.json new file mode 100644 index 000000000000..27ba77ddaf61 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/true.json @@ -0,0 +1 @@ +true diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/utf8.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/utf8.html new file mode 100644 index 000000000000..1c0360b17e3f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/utf8.html @@ -0,0 +1,36 @@ + + +JSON modules: UTF-8 decoding + + +
+ + + + + diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/utf8.json b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/utf8.json new file mode 100644 index 000000000000..7bb9edd2f79e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/utf8.json @@ -0,0 +1,3 @@ +{ + "test": "…" +} diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.html new file mode 100644 index 000000000000..78e8b1d23fed --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.html @@ -0,0 +1,36 @@ + + +JSON modules: Content-Type + + +
+ + + + +