servo/tests/wpt/web-platform-tests/css/css-pseudo/active-selection-024.html

49 lines
1.3 KiB
HTML

<!DOCTYPE html>
<meta charset="UTF-8">
<title>CSS Pseudo-Elements Test: active selection and first-letter pseudo-element</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
<link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-selectors">
<link rel="match" href="reference/active-selection-024-ref.html">
<meta content="" name="flags">
<meta name="assert" content="In this test, the ::selection pseudo-element must paint over the ::first-letter pseudo-element since the first letter is being selected.">
<style>
div
{
color: black;
font-size: 300%;
}
div::first-letter
{
color: red;
}
div::selection
{
background-color: yellow;
color: green;
}
</style>
<script>
function startTest()
{
var targetRange = document.createRange();
/* We first create an empty range */
targetRange.selectNodeContents(document.getElementById("test"));
/* Then we set the range boundaries to the children of div#test */
window.getSelection().addRange(targetRange);
/* Finally, we now select such range of content */
}
</script>
<body onload="startTest();">
<p>Test passes if background color of "Selected Text" is yellow and if each glyph of "Selected Text" is green.
<div id="test">Selected Text</div>