generic-family-keywords-002.html (1557B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Generic font family: -webkit-* treated as <font-family></title> 6 <link rel="help" href="https://drafts.csswg.org/css-fonts-4/#generic-font-families"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/css/css-fonts/support/font-family-keywords.js"></script> 10 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css"/> 11 <style> 12 div { 13 font-size: 10px; 14 } 15 #ahem { 16 font-family: Ahem; 17 } 18 </style> 19 </head> 20 <body> 21 <div><span id="ahem">00000</span></div> 22 <div><span id="test">00000</span></div> 23 <script> 24 setup({ explicit_done: true }); 25 window.addEventListener("load", () => { document.fonts.ready.then(runTests); }); 26 function SetFontFamilyAndMeasure(fontFamilyValue) { 27 var element = document.getElementById('test'); 28 element.setAttribute("style", `font-family: ${fontFamilyValue}, Ahem;`); 29 return element.offsetWidth; 30 } 31 function runTests() { 32 let ahem = document.getElementById('ahem'); 33 let ahem_expected_width = ahem.offsetWidth; 34 let families = kGenericFontFamilyKeywords.map(keyword => `-webkit-${keyword}`).concat(kNonGenericFontFamilyKeywords); 35 families.forEach(name => { 36 test(function() { 37 assert_equals(SetFontFamilyAndMeasure(name), ahem_expected_width); 38 }, `font-family: ${name} treated as <font-family>, not <generic-name>`); 39 }); 40 done(); 41 } 42 </script> 43 </body> 44 </html>