blob: 207d553c69e2016770171a1e572ec724cd835561 [file] [log] [blame]
<!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) {
// This tests potential streaming compilation of modules in
// Chromium that is triggered only for large (32>KiB) files in older
// versions.
const iframe = document.createElement("iframe");
iframe.src = "resources/css-module-basic-large-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 large 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, undefined);
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, but should not throw an exception");
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");
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>