cssom-setProperty-shorthand.html (3002B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>CSSOM: CSSStyleDeclaration (set|remove)PropertyValue sets/removes shorthand properties</title> 5 <link rel="author" title="Paul Irish" href="mailto:paul.irish@gmail.com"> 6 <link rel="help" href="http://www.w3.org/TR/cssom-1/#the-cssstyledeclaration-interface"> 7 8 <link rel="source" href="http://trac.webkit.org/export/120528/trunk/LayoutTests/fast/css/cssom-remove-shorthand-property.html"> 9 <meta name="flags" content="dom"> 10 11 <script src="/resources/testharness.js"></script> 12 <script src="/resources/testharnessreport.js"></script> 13 </head> 14 15 <body> 16 <div id="log"></div> 17 18 <div id="box"></div> 19 20 <script> 21 shorthandProperties = [ 22 "font", 23 "border-top", 24 "border-right", 25 "border-bottom", 26 "border-left", 27 "border", 28 "border-color", 29 "border-style", 30 "border-width", 31 "background-position", 32 "background-repeat", 33 "border-spacing", 34 "list-style", 35 "margin", 36 "outline", 37 "padding", 38 "background", 39 "overflow", 40 "border-radius" 41 ]; 42 43 element = document.createElement('span'); 44 45 function canSetProperty(propertyName, priority) { 46 element.style.setProperty(propertyName, 'initial', priority); 47 return element.style.getPropertyValue(propertyName) == 'initial'; 48 } 49 50 function canRemoveProperty(propertyName) { 51 element.style.removeProperty(propertyName); 52 return element.style.getPropertyValue(propertyName) != 'initial'; 53 } 54 55 for (i = 0; i < shorthandProperties.length; ++i) { 56 var propertyName = shorthandProperties[i]; 57 58 test(function(){ 59 assert_true(canSetProperty(propertyName, ''), 'can setPropertyValue with shorthand'); 60 }, 'shorthand ' + propertyName + ' can be set with setProperty'); 61 62 test(function(){ 63 assert_true(canRemoveProperty(propertyName), 'can setPropertyValue with shorthand'); 64 }, 'shorthand ' + propertyName + ' can be removed with removeProperty'); 65 66 test(function(){ 67 assert_true(canSetProperty(propertyName, 'important'), 'can setPropertyValue with shorthand'); 68 }, 'shorthand ' + propertyName + ' can be set with setProperty and priority !important'); 69 70 test(function(){ 71 assert_true(canRemoveProperty(propertyName), 'can setPropertyValue with shorthand'); 72 }, 'shorthand ' + propertyName + ' can be removed with removeProperty even when set with !important'); 73 74 } 75 </script> 76 </body> 77 </html>