highlight-pseudos-computed-search-text.tentative.html (1464B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>CSS Pseudo-Elements Test: ::search-text getComputedStyle</title> 4 <link rel="author" name="Delan Azabani" href="mailto:dazabani@igalia.com"> 5 <link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-selectors"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <style> 9 #target::search-text { 10 background-color: blue; 11 color: lime; 12 } 13 #target::search-text:not(:current) { 14 background-color: green; 15 } 16 #target::search-text:current { 17 /* FAIL if this matches */ 18 background-color: red; 19 } 20 </style> 21 <div id="target"></div> 22 <script> 23 for (const pseudo of ["::search-text"]) { 24 test(() => { 25 let style = getComputedStyle(target, pseudo); 26 assert_equals(style.backgroundColor, "rgb(0, 128, 0)", "Background color is green."); 27 assert_equals(style.color, "rgb(0, 255, 0)", "Color is lime."); 28 }, `getComputedStyle() for ${pseudo}`); 29 30 for (illFormedPseudo of [`${pseudo}:`, `${pseudo})`, `${pseudo}(`, `${pseudo}(foo)`, `${pseudo}()`, `:${pseudo}`, `${pseudo}.`]) { 31 test(() => { 32 let style = getComputedStyle(target, illFormedPseudo); 33 let defaultStyle = getComputedStyle(target); 34 assert_equals(style.backgroundColor, ""); 35 assert_equals(style.color, ""); 36 }, `getComputedStyle() for ${illFormedPseudo} should return an empty CSSStyleDeclaration`); 37 } 38 } 39 </script>