Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="UTF-8">
<title>CSS Color Test: system color highlights values versus getSelection().addRange(targetRange)</title>
<link rel="author" title="GĂ©rard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
<link rel="match" href="reference/system-color-hightlights-vs-getSelection-001-ref.html">
<!--
Created: March 29th 2023
Last modified: July 12th 2023
Chromium bug report 932343 comment #c20: Issue 932343: Support text decoration properties in ::selection
Chromium bug report 1429019: Issue 1429019: [CSS4 Color] [CSS4 Pseudo] getSelection() color and background color should match system color highlights
WebKit Bug report 254691: [CSS4 Color] [CSS4 Pseudo] getSelection() color and background color should match system color highlights
-->
<meta content="" name="flags">
<meta content="This test checks that color and background color generated by window.getSelection().addRange(targetRange) correspond to system color highlights values." name="assert">
<style>
div
{
font-size: 40px;
line-height: 1;
}
/*
For text, the corresponding overlay must cover at least
the entire em box and may extend further above/below the
em box to the line box edges.
*/
span.system-color-highlight
{
background-color: Highlight;
color: HighlightText;
}
/*
Highlight
Background of item(s) selected in a control.
HighlightText
Text of item(s) selected in a control.
CSS4 Color Module
5.2 System Colors
*/
</style>
<script type="text/javascript">
function startTest()
{
/* We first create an empty range */
var targetRange = document.createRange();
/* Then we select the node */
targetRange.selectNode(document.getElementById("getSelection"));
/* Finally, we now select such range of content */
window.getSelection().addRange(targetRange);
}
</script>
<body onload="startTest();">
<div><span class="system-color-highlight">With system-color-highlight</span></div>
<div>
<span id="getSelection">With getSelection()</span>
</div>