cascade-highlight-004.html (1871B)
1 <!DOCTYPE html> 2 3 <meta charset="UTF-8"> 4 5 <title>CSS Pseudo-Elements Test: inheritance of selection highlight colors from its parent element</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-cascade"> 9 <link rel="match" href="cascade-highlight-004-ref.html"> 10 11 <meta name="assert" content="In this test, 'color' and 'background-color' have not been given a value for the span element. Since its parent element has an highlight pseudo-element, then these values should be inherited. Therefore the span element should be green on a yellow background and should not use the OS default selection highlight color values."> 12 13 <!-- 14 When any supported property is not given a value by the 15 cascade, its value is determined by inheritance from the 16 corresponding highlight pseudo-element of its originating 17 element's parent element (regardless of whether that property 18 is an inherited property). 19 https://www.w3.org/TR/css-pseudo-4/#highlight-cascade 20 --> 21 22 <link rel="stylesheet" href="../support/highlights.css"> 23 <style> 24 div 25 { 26 font-size: 300%; 27 } 28 29 div::selection 30 { 31 background-color: yellow; 32 color: green; 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 "Text sample" is green and if its background color is yellow. 51 52 <div id="test" class="highlight_reftest"><span>Text sample</span></div>