serialize-all-longhands.html (1242B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Serialize all longhands</title> 4 <link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com" /> 5 <link rel="help" href="https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue"> 6 <meta name="assert" content="Checks that all longhands indexed in a CSSStyleDeclaration can be serialized to a non-empty string when set to their initial value."> 7 8 <div id="target"></div> 9 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 <script> 13 function nonSerializableProperties(style) { 14 const result = []; 15 assert_greater_than(style.length, 0, "Should have longhands"); 16 for (let property of style) { 17 if (!style.getPropertyValue(property)) { 18 result.push(property); 19 } 20 } 21 return result; 22 } 23 24 const target = document.getElementById("target"); 25 target.style.cssText = "all: initial; direction: initial; unicode-bidi: initial;"; 26 27 test(function() { 28 const props = nonSerializableProperties(target.style); 29 assert_array_equals(props, []); 30 }, "Specified style"); 31 32 test(function() { 33 const props = nonSerializableProperties(getComputedStyle(target)); 34 assert_array_equals(props, []); 35 }, "Computed style"); 36 </script>