Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 66 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-highlight-api/custom-highlight-animation-properties.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Highlight animation, transition, and opacity properties</title>
<meta name="assert" content="All highlight pseudos accept animation, transition, and opacity properties.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
@keyframes pulse {
from { color: red; }
to { color: blue; }
}
#target::highlight(test),
#target::selection,
#target::target-text,
#target::spelling-error,
#target::grammar-error,
#target::search-text {
animation: pulse 2s linear 1s 2 alternate both paused;
animation-duration: 4s;
transition: color 3s ease-in 500ms;
opacity: 0.25;
display: block;
}
</style>
<div id="parent"><span id="target">Highlighted text</span></div>
<script>
const range = new Range();
range.selectNodeContents(target);
CSS.highlights.set("test", new Highlight(range));
for (const pseudo of [
"::highlight(test)", "::selection", "::target-text", "::spelling-error",
"::grammar-error", "::search-text",
]) {
for (const [property, expected] of [
["animation-name", "pulse"],
["animation-duration", "4s"],
["animation-delay", "1s"],
["animation-iteration-count", "2"],
["animation-direction", "alternate"],
["animation-fill-mode", "both"],
["animation-play-state", "paused"],
["transition-property", "color"],
["transition-duration", "3s"],
["transition-delay", "0.5s"],
["opacity", "0.25"],
]) {
test(() => {
assert_equals(getComputedStyle(target, pseudo).getPropertyValue(property),
expected);
}, `${pseudo} accepts ${property}`);
}
}
</script>