first-letter-allowed-properties.html (2879B)
1 <!DOCTYPE html> 2 <title>CSS Test: Properties allowed on ::first-letter pseudo elements</title> 3 <link rel="author" title="Chris Nardi" href="mailto:cnardi@chromium.org"> 4 <link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#first-letter-styling"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <style> 8 #target::first-letter {} 9 #target { visibility: hidden; } 10 </style> 11 <div id="target">text</div> 12 <script> 13 'use strict'; 14 var style; 15 const target = document.querySelector("#target"); 16 var defaultComputedStyle = getComputedStyle(target); 17 18 test(function() { 19 var styleRule = document.styleSheets[0].cssRules[0]; 20 assert_equals(styleRule.selectorText, '#target::first-letter', 'make sure we have the correct style rule'); 21 style = styleRule.style; 22 }, 'pre test setup'); 23 24 var validProperties = { 25 backgroundAttachment: 'fixed', 26 backgroundBlendMode: 'hue', 27 backgroundClip: 'padding-box', 28 backgroundColor: 'rgb(10, 20, 30)', 29 backgroundImage: 'linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255))', 30 backgroundOrigin: 'border-box', 31 backgroundPosition: '10px 20px', 32 backgroundRepeat: 'no-repeat', 33 backgroundSize: '10px 20px', 34 border: '40px dotted rgb(10, 20, 30)', 35 borderImage: 'linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255)) 10% / 20 / 30px repeat', 36 borderRadius: '10px 20px', 37 boxShadow: 'rgb(10, 20, 30) 10px 20px 30px 40px inset', 38 color: 'rgba(10, 20, 30, 0.4)', 39 float: 'right', 40 font: 'italic small-caps 900 10px / 20px sans-serif', 41 fontFeatureSettings: '"vert" 2', 42 fontSizeAdjust: '0.5', 43 fontKerning: 'none', 44 fontVariationSettings: '"XHGT" 0.7', 45 letterSpacing: '12px', 46 margin: '10px 20px 30px 40px', 47 padding: '10px 20px 30px 40px', 48 opacity: '0.5', 49 textDecoration: 'overline wavy rgb(10, 20, 30)', 50 textJustify: 'inter-word', 51 textShadow: 'rgb(10, 20, 30) 10px 20px 30px', 52 textTransform: 'capitalize', 53 textUnderlinePosition: 'under', 54 verticalAlign: '12%', 55 wordSpacing: '12px' 56 }; 57 58 var invalidProperties = { 59 position: 'absolute', 60 transition: 'transform 1s', 61 transform: 'rotate(45deg)', 62 wordBreak: 'break-all' 63 }; 64 65 function testFirstLetterProperty(property, rule, expected, reason) { 66 test(function() { 67 style[property] = ""; 68 style[property] = rule; 69 assert_equals(getComputedStyle(target, '::first-letter')[property], expected); 70 style[property] = ""; 71 }, reason); 72 } 73 74 for (var property in validProperties) { 75 testFirstLetterProperty(property, validProperties[property], validProperties[property], 76 property + " should be applied to first-letter pseudo elements."); 77 } 78 79 for (var property in invalidProperties) { 80 testFirstLetterProperty(property, invalidProperties[property], defaultComputedStyle[property], 81 property + " should not be applied to first-letter pseudo elements."); 82 } 83 </script>