font-variation-settings-inherit.html (2816B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Testing the inheritance of the font-variation-settings property</title> 5 <link rel="help" href="https://www.w3.org/TR/css-fonts-4/#propdef-font-variation-settings" /> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 </head> 9 <body> 10 <div id="inheritanceTestParent" style="font-variation-settings: 'xxxx' 1, 'xxxx' 2;"> 11 <span id="inheritanceTestChildInherited">Abc</span> 12 <span id="inheritanceTestChildOverride" style="font-variation-settings: 'cccc' 1, 'bbbb' 2, 'aaaa' 3, 'aaaa' calc(2 + 2);">Abc</span> 13 </div> 14 <script> 15 16 // Verify computed inheritance of nested elements. 17 var elementParent = document.getElementById("inheritanceTestParent"); 18 var elementChildInherited = document.getElementById("inheritanceTestChildInherited"); 19 var elementChildOverride = document.getElementById("inheritanceTestChildOverride"); 20 21 var parentValue = "'yyyy' 1, 'yyyy' 2"; 22 elementParent.style.fontVariationSettings = parentValue; 23 24 test(() => { 25 var actualValue = window.getComputedStyle(elementParent).fontVariationSettings; 26 // The following strict test is subject to debate; softening for now: 27 // assert_equals(actualValue, "\"yyyy\" 2", "Duplicate axis tags should be removed, favoring the latter axis tag's value."); 28 assert_equals((/.*(?:"|')yyyy(?:"|') (\d)/.exec(actualValue)||[])[1], '2', "Child should override parent value."); 29 }, "Test font-variation-settings for duplicates using " + parentValue); 30 31 test(() => { 32 var actualValue = window.getComputedStyle(elementChildInherited).fontVariationSettings; 33 // The following strict test is subject to debate; softening for now: 34 // assert_equals(actualValue, "\"yyyy\" 2", "Child should inherit the parent value directly."); 35 assert_equals((/.*(?:"|')yyyy(?:"|') (\d)/.exec(actualValue)||[])[1], '2', "Child should override parent value."); 36 }, "Test font-variation-settings for child inheritance"); 37 38 test(() => { 39 var actualValue = window.getComputedStyle(elementChildOverride).fontVariationSettings; 40 // The following strict test is subject to debate; softening for now: 41 // assert_equals(actualValue, "\"aaaa\" 4, \"bbbb\" 2, \"cccc\" 1", "Child should override parent value."); 42 assert_equals((/.*(?:"|')aaaa(?:"|') (\d)/.exec(actualValue)||[])[1], '4', "Child should override parent value."); 43 assert_equals((/.*(?:"|')yyyy(?:"|') (\d)/.exec(actualValue)||[])[1], undefined, "Child should override parent value."); 44 }, "Test font-variation-settings for child override"); 45 46 </script> 47 </body> 48 </html>