servo/tests/wpt/web-platform-tests/css/css-pseudo/highlight-cascade-007.html

75 lines
3.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: highlight cascade: inheritance with both universal and non-universal rules</title>
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-cascade">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7591">
<meta name="assert" content="This test verifies that non-applicable property declarations are ignored in highlight pseudos, that the computed values of font-size and line-height in highlight pseudos are taken from the originating element, and that text-shadow in highlight pseudos respects these values when given em and lh units.">
<script src="support/selections.js"></script>
<link rel="stylesheet" href="support/highlights.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
main {
font-size: 12px;
line-height: 13px;
}
main span {
font-size: 18px;
line-height: 19px;
}
/* * (universal) */::selection {
font-size: 42px;
line-height: 43px;
}
main .M::selection {
text-shadow: green 1em 0;
}
main .W::selection {
text-shadow: green 0 1lh;
}
/* * (universal) */::selection {
text-decoration-thickness: 1em;
}
</style>
<main>
<div class="M"><div><span>M</span></div></div>
<div class="W"><div><span>W</span></div></div>
<div class="U"><div><span>U</span></div></div>
</main>
<script>
selectNodeContents(document.querySelector("main"));
const m = getComputedStyle(document.querySelector("main .M"), "::selection");
const mSpan = getComputedStyle(document.querySelector("main .M span"), "::selection");
test(() => void assert_equals(m.fontSize, "12px"),
"M::selections font-size is the same as in M");
test(() => void assert_equals(mSpan.fontSize, "18px"),
"M span::selections font-size is the same as in M span");
test(() => void assert_equals(m.textShadow, "rgb(0, 128, 0) 12px 0px 0px"),
"M::selections own text-shadow respects Ms font-size");
test(() => void assert_equals(mSpan.textShadow, "rgb(0, 128, 0) 12px 0px 0px"),
"M span::selections inherited text-shadow respects Ms font-size");
const w = getComputedStyle(document.querySelector("main .W"), "::selection");
const wSpan = getComputedStyle(document.querySelector("main .W span"), "::selection");
test(() => void assert_equals(w.lineHeight, "13px"),
"W::selections line-height is the same as in W");
test(() => void assert_equals(wSpan.lineHeight, "19px"),
"W span::selections line-height is the same as in W span");
test(() => void assert_equals(w.textShadow, "rgb(0, 128, 0) 0px 13px 0px"),
"W::selections own text-shadow respects Ws line-height");
test(() => void assert_equals(wSpan.textShadow, "rgb(0, 128, 0) 0px 13px 0px"),
"W span::selections inherited text-shadow respects Ws line-height");
const u = getComputedStyle(document.querySelector("main .U"), "::selection");
const uSpan = getComputedStyle(document.querySelector("main .U span"), "::selection");
test(() => void assert_equals(u.fontSize, "12px"),
"U::selections font-size is the same as in U");
test(() => void assert_equals(uSpan.fontSize, "18px"),
"U span::selections font-size is the same as in U span");
test(() => void assert_equals(u.textDecorationThickness, "12px"),
"U::selections own text-decoration-thickness respects Us font-size");
test(() => void assert_equals(uSpan.textDecorationThickness, "18px"),
"U span::selections own text-decoration-thickness respects U spans font-size");
</script>