import-css-module-dynamic.html (924B)
1 <!doctype html> 2 3 <head> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 </head> 7 8 <body> 9 <script> 10 promise_test(async function (test) { 11 const css_module = await import("./resources/basic.css", { with: { type: "css" }}); 12 assert_true(css_module.default instanceof CSSStyleSheet); 13 assert_equals(css_module.default.cssRules[0].cssText, 14 "#test { background-color: rgb(255, 0, 0); }"); 15 }, "Load a CSS module with dynamic import()"); 16 17 promise_test(function (test) { 18 return promise_rejects_js(test, TypeError, 19 import("./resources/basic.css"), 20 "Attempting to import() a CSS module without a type attribute should fail"); 21 }, "Ensure that loading a CSS module with dymnamic import() fails without a type attribute"); 22 </script> 23 </body>