diff options
author | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2019-12-14 08:23:07 +0000 |
---|---|---|
committer | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2019-12-14 10:59:49 +0000 |
commit | 0dae9ef764b849741de814d79a9803ced51acb35 (patch) | |
tree | d1d8cc0823c312918cba7ca38ca25f60e1fccbe4 /tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module | |
parent | 3f663d7ab216a841e6250b5b10ce64d34caff97c (diff) | |
download | servo-0dae9ef764b849741de814d79a9803ced51acb35.tar.gz servo-0dae9ef764b849741de814d79a9803ced51acb35.zip |
Update web-platform-tests to revision 6fbd872e9ac5fe60e32946bc9b318be6eeada123
Diffstat (limited to 'tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module')
12 files changed, 177 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test.html new file mode 100644 index 00000000000..1618f40eb61 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test.html @@ -0,0 +1,37 @@ +<!doctype html> + +<head> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> +</head> + +<body> + <script> + setup({allow_uncaught_exception: true}); + async_test(function (test) { + const worker = new Worker("./resources/worker.js", { + type: "module" + }); + worker.onmessage = test.unreached_func("A CSS Module within a web worker should not load."); + worker.onerror = test.step_func_done(); + }, "A static import CSS Module within a web worker should not load."); + + async_test(function (test) { + const worker = new Worker("./resources/worker-dynamic-import.js", { + type: "module" + }); + worker.onmessage = test.step_func_done(e => { + assert_equals(e.data, "NOT LOADED"); + }); + }, "A dynamic import CSS Module within a web worker should not load."); + + async_test(function (test) { + const worker = new Worker("./resources/basic.css", { + type: "module" + }); + worker.onerror = test.step_func_done(); + }, "A CSS Module within a web worker should not load."); + + </script> + +</body>
\ No newline at end of file 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 new file mode 100644 index 00000000000..902430d0779 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic.html @@ -0,0 +1,44 @@ +<!doctype html> + +<head> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> +</head> + +<body> + <script> + async_test(function (test) { + const iframe = document.createElement("iframe"); + iframe.src = "resources/css-module-basic-iframe.html"; + iframe.onload = test.step_func_done(function () { + assert_equals(getComputedStyle(iframe.contentDocument.querySelector('#test')) + .backgroundColor, "rgb(255, 0, 0)", + "CSS module import should succeed"); + }); + document.body.appendChild(iframe); + }, "A CSS Module should load"); + + async_test(function (test) { + const iframe = document.createElement("iframe"); + iframe.src = "resources/css-module-at-import-iframe.html"; + iframe.onload = test.step_func_done(function () { + assert_equals(iframe.contentDocument.load_error, "NotAllowedError"); + assert_not_equals(getComputedStyle(iframe.contentDocument.querySelector('#test')) + .backgroundColor, "rgb(255, 0, 0)", + "CSS module @import should not succeed"); + }); + document.body.appendChild(iframe); + }, "An @import CSS Module should not load"); + + async_test(function (test) { + const iframe = document.createElement("iframe"); + iframe.src = "resources/malformed-iframe.html"; + iframe.onload = test.step_func_done(function () { + assert_not_equals(getComputedStyle(iframe.contentDocument.querySelector('#test')) + .backgroundColor, "rgb(255, 0, 0)", + "Malformed CSS should not load"); + }); + document.body.appendChild(iframe); + }, "Malformed CSS should not load"); + </script> +</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/bad-import.css b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/bad-import.css new file mode 100644 index 00000000000..796446b525c --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/bad-import.css @@ -0,0 +1 @@ +@import "basic.css"
\ No newline at end of file diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/basic.css b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/basic.css new file mode 100644 index 00000000000..3ea2ef45339 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/basic.css @@ -0,0 +1,3 @@ +#test { + background-color:red; +}
\ No newline at end of file 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 new file mode 100644 index 00000000000..86e7af7d51d --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-at-import-iframe.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<body> + <script> + window.onerror = function (errorMsg, url, lineNumber, column, errorObj) + { + document.load_error = errorObj.name; + return true; + }; + </script> + <script type="module"> + import v from "./bad-import.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/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 new file mode 100644 index 00000000000..3a555c39271 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-iframe.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<body> + <script> + window.onerror = function (errorMsg, url, lineNumber, column, errorObj) + { + document.load_error = errorObj.name; + return true; + }; + </script> + <script type="module"> + 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 new file mode 100644 index 00000000000..471edd680cf --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed-iframe.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<body> + <script type="module"> + import v from "./malformed.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.css b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed.css new file mode 100644 index 00000000000..fb20336584e --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed.css @@ -0,0 +1,3 @@ +#test {{ + background-color:red; +}
\ No newline at end of file diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/utf8.css b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/utf8.css new file mode 100644 index 00000000000..35d16cd1c5b --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/utf8.css @@ -0,0 +1,3 @@ +#test { + content: "…"; +}
\ 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-dynamic-import.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker-dynamic-import.js new file mode 100644 index 00000000000..9a3b0bb105b --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker-dynamic-import.js @@ -0,0 +1,3 @@ +import("./basic.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 new file mode 100644 index 00000000000..397a12c3b53 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker.js @@ -0,0 +1,2 @@ +import "./basic.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 new file mode 100644 index 00000000000..f71339b4d59 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS modules: UTF-8 decoding</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +function check(t, v) { + t.step(() => { + assert_equals(typeof v, "object"); + assert_equals(v.rules[0].style.content, "\"…\""); + t.done(); + }); +} +const t1 = async_test("utf-8"); +const t2 = async_test("shift-jis"); +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"; +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"; +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"; +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"; +check(t4, v); +</script> |