aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element
diff options
context:
space:
mode:
authorWPT Sync Bot <josh+wptsync@joshmatthews.net>2021-02-21 08:20:50 +0000
committerJosh Matthews <josh@joshmatthews.net>2021-02-21 11:31:07 -0500
commit87be1008ded90f39f42a04967f5e3456276e3232 (patch)
treee770e1a57693034c10da67a5a2cb9bd5e0c8cc91 /tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element
parent8050c95e31f4fa184f5d672bd1ed85b5a764906b (diff)
downloadservo-87be1008ded90f39f42a04967f5e3456276e3232.tar.gz
servo-87be1008ded90f39f42a04967f5e3456276e3232.zip
Update web-platform-tests to revision b'7af9d6ec48ab04043a2bea85a3599904a1a19efa'
Diffstat (limited to 'tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element')
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic.html13
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic.html22
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-at-import-iframe.html2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-iframe.html2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-large-iframe.html2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-without-assertion-iframe.html22
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed-iframe.html2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker-dynamic-import.js2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker.js2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html8
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https.tentative.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/module.tentative.html2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.tentative.any.js4
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker-dynamic-import.js2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker.js2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/utf8.tentative.html8
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.tentative.html8
17 files changed, 85 insertions, 28 deletions
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic.html
index 4ca2bb70899..207d553c69e 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic.html
@@ -54,5 +54,18 @@
});
document.body.appendChild(iframe);
}, "Malformed CSS should not load");
+
+ async_test(function (test) {
+ const iframe = document.createElement("iframe");
+ iframe.src = "resources/css-module-without-assertion-iframe.html";
+ iframe.onload = test.step_func_done(function () {
+ assert_equals(iframe.contentDocument.window_onerror, undefined);
+ assert_equals(iframe.contentDocument.script_onerror.type, "error");
+ assert_not_equals(getComputedStyle(iframe.contentDocument.querySelector('#test'))
+ .backgroundColor, "rgb(255, 0, 0)",
+ "CSS module without type assertion should result in a fetch error");
+ });
+ document.body.appendChild(iframe);
+ }, "CSS module without type assertion should result in a fetch error");
</script>
</body>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic.html
new file mode 100644
index 00000000000..4fbc11180fa
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic.html
@@ -0,0 +1,22 @@
+<!doctype html>
+
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+
+<body>
+ <script>
+ promise_test(async function (test) {
+ const css_module = await import("./resources/basic.css", { assert: { type: "css" }});
+ assert_true(css_module.default instanceof CSSStyleSheet);
+ assert_equals(css_module.default.cssRules[0].cssText, "#test { background-color: red; }");
+ }, "Load a CSS module with dynamic import()");
+
+ promise_test(function (test) {
+ return promise_rejects_js(test, TypeError,
+ import("./resources/basic.css"),
+ "Attempting to import() a CSS module without a type assertion should fail");
+ }, "Ensure that loading a CSS module with dymnamic import() fails without a type assertion");
+ </script>
+</body>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-at-import-iframe.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-at-import-iframe.html
index 86e7af7d51d..cce9e2163d7 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-at-import-iframe.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-at-import-iframe.html
@@ -8,7 +8,7 @@
};
</script>
<script type="module">
- import v from "./bad-import.css";
+ import v from "./bad-import.css" assert { type: "css" };
document.adoptedStyleSheets = [v];
</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-iframe.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-iframe.html
index 3a555c39271..e093d39898f 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-iframe.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-iframe.html
@@ -8,7 +8,7 @@
};
</script>
<script type="module">
- import v from "./basic.css";
+ import v from "./basic.css" assert { type: "css" };
document.adoptedStyleSheets = [v];
</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-large-iframe.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-large-iframe.html
index cc5b660e4cb..0cf11e9139f 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-large-iframe.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-large-iframe.html
@@ -8,7 +8,7 @@
};
</script>
<script type="module">
- import v from "./basic-large.css";
+ import v from "./basic-large.css" assert { type: "css" };
document.adoptedStyleSheets = [v];
</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-without-assertion-iframe.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-without-assertion-iframe.html
new file mode 100644
index 00000000000..3d1be841cee
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-without-assertion-iframe.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<body>
+ <script>
+ window.onerror = function (errorMsg, url, lineNumber, column, errorObj)
+ {
+ document.window_onerror = errorObj.name;
+ return true;
+ };
+
+ function scriptErrorHandler(e) {
+ document.script_onerror = e;
+ }
+ </script>
+ <script type="module" onerror="scriptErrorHandler(event)">
+ import v from "./basic.css";
+ document.adoptedStyleSheets = [v];
+ </script>
+
+ <div id="test">
+ I am a test div.
+ </div>
+</body> \ No newline at end of file
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed-iframe.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed-iframe.html
index 471edd680cf..f5c64f6b59e 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed-iframe.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed-iframe.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<body>
<script type="module">
- import v from "./malformed.css";
+ import v from "./malformed.css" assert { type: "css" };
document.adoptedStyleSheets = [v];
</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker-dynamic-import.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker-dynamic-import.js
index 9a3b0bb105b..6f6852ce550 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker-dynamic-import.js
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker-dynamic-import.js
@@ -1,3 +1,3 @@
-import("./basic.css")
+import("./basic.css", { assert: { type: "css" } })
.then(() => postMessage("LOADED"))
.catch(e => postMessage("NOT LOADED")); \ No newline at end of file
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker.js
index 397a12c3b53..c97d9652d35 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker.js
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker.js
@@ -1,2 +1,2 @@
-import "./basic.css";
+import "./basic.css" assert { type: "css" };
postMessage("Unexpectedly loaded"); \ No newline at end of file
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html
index f71339b4d59..6adcd716328 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html
@@ -17,18 +17,18 @@ const t3 = async_test("windows-1252");
const t4 = async_test("utf-7");
</script>
<script type="module" onerror="t1.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=utf-8";
+import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=utf-8" assert { type: "css" };
check(t1, v);
</script>
<script type="module" onerror="t2.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=shift-jis";
+import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=shift-jis" assert { type: "css" };
check(t2, v);
</script>
<script type="module" onerror="t3.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=windows-1252";
+import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=windows-1252" assert { type: "css" };
check(t3, v);
</script>
<script type="module" onerror="t4.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=utf-7";
+import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=utf-7" assert { type: "css" };
check(t4, v);
</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https.tentative.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https.tentative.html
index 2e1f9d8179c..cc47da1499f 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https.tentative.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https.tentative.html
@@ -10,11 +10,11 @@
assert_not_equals(reg.installing, undefined);
}, "Javascript importing JSON Module should load within the context of a service worker");
- promise_test(async (test) => {
- const reg = await navigator.serviceWorker.register('./module.json', { type: 'module' });
- test.add_cleanup(() => reg.unregister());
- assert_not_equals(reg.installing, undefined);
- }, "JSON Modules should load within the context of a service worker");
+ promise_test(test => {
+ return promise_rejects_dom(test, "SecurityError",
+ navigator.serviceWorker.register('./module.json', { type: 'module' }),
+ "Attempting to load JSON as a service worker should fail");
+ }, "Trying to register a service worker with a top-level JSON Module should fail");
promise_test(async (test) => {
const reg = await navigator.serviceWorker.register('./serviceworker-dynamic-import.js', { type: 'module' });
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/module.tentative.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/module.tentative.html
index 93243853226..a495d4ac186 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/module.tentative.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/module.tentative.html
@@ -8,7 +8,7 @@
const t = async_test();
</script>
<script type="module" onerror="t.step(() => assert_unreached(event))">
-import v from "./module.json";
+import v from "./module.json" assert { type: "json" };
t.step(() => {
assert_equals(typeof v, "object");
assert_array_equals(Object.keys(v), ["test"]);
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.tentative.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.tentative.any.js
index dcbe60f2c2f..6d507177e1e 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.tentative.any.js
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.tentative.any.js
@@ -2,13 +2,13 @@
for (const value of [null, true, false, "string"]) {
promise_test(async t => {
- const result = await import(`./${value}.json`);
+ const result = await import(`./${value}.json`, { assert: { type: "json" } });
assert_equals(result.default, value);
}, `Non-object: ${value}`);
}
promise_test(async t => {
- const result = await import("./array.json");
+ const result = await import("./array.json", { assert: { type: "json" } });
assert_array_equals(result.default, ["en", "try"]);
}, "Non-object: array");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker-dynamic-import.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker-dynamic-import.js
index 3c7d29488db..9466c6fbe40 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker-dynamic-import.js
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker-dynamic-import.js
@@ -1,5 +1,5 @@
onmessage = e => {
- e.waitUntil(import("./module.json")
+ e.waitUntil(import("./module.json", { assert: { type: "json" } })
.then(module => e.source.postMessage("LOADED"))
.catch(error => e.source.postMessage("FAILED")));
}; \ No newline at end of file
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker.js
index 6d71f0175c7..3f0a4d16640 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker.js
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker.js
@@ -1 +1 @@
-import './module.json'; \ No newline at end of file
+import './module.json' assert { type: "json" }; \ No newline at end of file
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/utf8.tentative.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/utf8.tentative.html
index 1c0360b17e3..24a6f109e1c 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/utf8.tentative.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/utf8.tentative.html
@@ -19,18 +19,18 @@ const t3 = async_test("windows-1252");
const t4 = async_test("utf-7");
</script>
<script type="module" onerror="t1.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=utf-8";
+import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=utf-8" assert { type: "json"};
check(t1, v);
</script>
<script type="module" onerror="t2.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=shift-jis";
+import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=shift-jis" assert { type: "json"};
check(t2, v);
</script>
<script type="module" onerror="t3.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=windows-1252";
+import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=windows-1252" assert { type: "json"};
check(t3, v);
</script>
<script type="module" onerror="t4.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=utf-7";
+import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=utf-7" assert { type: "json"};;
check(t4, v);
</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.tentative.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.tentative.html
index 78e8b1d23fe..ff5953cb700 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.tentative.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.tentative.html
@@ -19,18 +19,18 @@ const t3 = async_test("text/html+json");
const t4 = async_test("image/svg+json");
</script>
<script type="module" onerror="t1.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=text/json";
+import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=text/json" assert { type: "json"};
check(t1, v);
</script>
<script type="module" onerror="t2.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=application/json";
+import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=application/json" assert { type: "json"};
check(t2, v);
</script>
<script type="module" onerror="t3.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=text/html+json";
+import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=text/html+json" assert { type: "json"};
check(t3, v);
</script>
<script type="module" onerror="t4.step(() => assert_unreached(event))">
-import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=image/svg+json";
+import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=image/svg+json" assert { type: "json"};
check(t4, v);
</script>