1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
<!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_equals(iframe.contentDocument.adoptedStyleSheets[0].cssRules.length, 1, "Parser should skip @import rule");
assert_not_equals(getComputedStyle(iframe.contentDocument.querySelector('#test'))
.backgroundColor, "rgb(255, 0, 0)",
"CSS module @import should not succeed");
assert_equals(getComputedStyle(iframe.contentDocument.querySelector('#test2'))
.backgroundColor, "rgb(0, 255, 0)",
"Rule after @import should still be applied");
});
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_equals(iframe.contentDocument.load_error, undefined);
assert_equals(iframe.contentDocument.adoptedStyleSheets[0].cssRules.length, 1, "Import of malformed CSS should succeed and rules after the parse error should still be parsed");
assert_not_equals(getComputedStyle(iframe.contentDocument.querySelector('#test'))
.backgroundColor, "rgb(255, 0, 0)",
"Malformed CSS rule should not be applied");
assert_equals(getComputedStyle(iframe.contentDocument.querySelector('#test2'))
.backgroundColor, "rgb(0, 255, 0)",
"Parsing should recover and rules after malformed rules should be applied");
});
document.body.appendChild(iframe);
}, "A parse error should not prevent subsequent rules from being included in a CSS module");
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>
|