setproperty-null-undefined.html (1430B)
1 <!doctype html> 2 <html> 3 <head> 4 <link rel="help" href="https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty"/> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 </head> 8 <body> 9 <script> 10 var style = document.body.style; 11 12 test(function() { 13 style.color = 'white'; 14 15 assert_equals(style.color, 'white'); 16 style.setProperty('color', undefined); 17 assert_equals(style.color, 'white'); 18 }, "Verify that setting a CSS property to undefined has no effect."); 19 20 test(function() { 21 style.color = 'white'; 22 23 assert_equals(style.color, 'white'); 24 assert_equals(style.getPropertyPriority('color'), ''); 25 style.setProperty('color', 'red', undefined); 26 assert_equals(style.color, 'red'); 27 assert_equals(style.getPropertyPriority('color'), ''); 28 }, "Verify that setting a CSS property priority to undefined is accepted."); 29 30 test(function() { 31 style.color = 'white'; 32 33 assert_equals(style.color, 'white'); 34 style.setProperty('color', null); 35 assert_equals(style.color, ''); 36 }, "Verify that setting a CSS property to null is treated like empty string."); 37 38 test(function() { 39 style.color = 'white'; 40 41 assert_equals(style.color, 'white'); 42 style.setProperty('color', 'red', null); 43 assert_equals(style.color, 'red'); 44 }, "Verify that setting a CSS property priority to null is treated like empty string."); 45 </script> 46 </body> 47 </html>