mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
b9f0ea2178
Previously, media rules were not evaluated for adopted style sheets.
21 lines
1,021 B
HTML
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>
|