ladybird/Tests/LibWeb/Text/input/css/constructed-style-sheets.html
Tim Ledbetter b9f0ea2178 LibWeb: Evaluate media rules for adopted style sheets
Previously, media rules were not evaluated for adopted style sheets.
2024-04-29 08:10:38 +02:00

21 lines
1,021 B
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
test(() => {
function constructedStyleSheetAppliesToDocument(options) {
const textDiv = document.createElement("div");
document.body.appendChild(textDiv);
const sheet = new CSSStyleSheet(options);
const newColor = "rgb(0, 128, 0)";
sheet.replaceSync(`div { color: ${newColor}; }`);
document.adoptedStyleSheets = [sheet];
const styleSheetAppliedToDocument = getComputedStyle(textDiv).color === newColor;
document.body.removeChild(textDiv);
document.adoptedStyleSheets = [];
return styleSheetAppliedToDocument;
}
println(`Disabled constructed style sheet applies to document: ${constructedStyleSheetAppliesToDocument({ disabled: true })}`);
println(`Constructed style sheet with media rules applies to document: ${constructedStyleSheetAppliesToDocument({ media: "screen, print" })}`);
});
</script>