active-selection-012.html (1572B)
1 <!DOCTYPE html> 2 3 <meta charset="UTF-8"> 4 5 <title>CSS Pseudo-Elements Test: active selection and background-color (basic)</title> 6 7 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> 8 <link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-selectors"> 9 <link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-styling"> 10 <link rel="match" href="reference/active-selection-012-ref.html"> 11 12 13 <link rel="stylesheet" href="support/highlights.css"> 14 <style> 15 div 16 { 17 background-color: red; 18 color: fuchsia; 19 display: inline; 20 font-size: 300%; 21 } 22 23 div::selection 24 { 25 background-color: green; 26 color: aqua; 27 } 28 29 /* 30 Chromium 77.0.3855.0 and above create a background-color #334C00 or 31 rgb(51, 76, 0) and not a green (#008000 or rgb(0, 128, 0)) background 32 color. 33 */ 34 </style> 35 36 <script> 37 function startTest() 38 { 39 var targetRange = document.createRange(); 40 /* We first create an empty range */ 41 targetRange.selectNodeContents(document.getElementById("test")); 42 /* Then we set the range boundaries to the children of div#test */ 43 window.getSelection().addRange(targetRange); 44 /* Finally, we now select such range of content */ 45 } 46 </script> 47 48 <body onload="startTest();"> 49 50 <p>Test passes if the background color of each glyph of "Selected Text" is green and <strong>not red</strong> while each glyph of "Selected Text" is aqua and <strong>not fuchsia</strong>. 51 52 <div id="test" class="highlight_reftest">Selected Text</div>