| <!DOCTYPE html> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| |
| <div id="testElement"></div> |
| |
| <script> |
| |
| test(function() { |
| testElement.style = ''; |
| assert_array_equals(testElement.attributeStyleMap.getProperties(), []); |
| }, "getProperties returns an empty list when no properties have been set"); |
| |
| test(function() { |
| testElement.style = ''; |
| testElement.attributeStyleMap.set('width', new CSSUnitValue(10, 'px')); |
| assert_array_equals(testElement.attributeStyleMap.getProperties(), ['width']); |
| }, "getProperties returns the name of a property if it is set"); |
| |
| test(function() { |
| testElement.attributeStyleMap.set('width', new CSSUnitValue(10, 'px')); |
| assert_array_equals(testElement.attributeStyleMap.getProperties(), ['width']); |
| |
| testElement.attributeStyleMap.get('height'); |
| assert_array_equals(testElement.attributeStyleMap.getProperties(), ['width']); |
| }, "Accessing another property doesn't add a spurious result"); |
| |
| test(function() { |
| testElement.attributeStyleMap.set('width', new CSSUnitValue(10, 'px')); |
| assert_array_equals(testElement.attributeStyleMap.getProperties(), ['width']); |
| |
| testElement.attributeStyleMap.delete('width'); |
| assert_array_equals(testElement.attributeStyleMap.getProperties(), []); |
| }, "property name does not appear in result after deletion"); |
| |
| test(function() { |
| testElement.attributeStyleMap.set('width', new CSSUnitValue(10, 'px')); |
| assert_array_equals(testElement.attributeStyleMap.getProperties(), ['width']); |
| |
| testElement.attributeStyleMap.set('border-top-width', new CSSUnitValue(10, 'px')); |
| var result = testElement.attributeStyleMap.getProperties(); |
| // TODO(meade): The spec should describe an order for this. |
| assert_equals(result.length, 2); |
| assert_true(result.indexOf('width') >= 0); |
| assert_true(result.indexOf('border-top-width') >= 0); |
| }, "getProperties returns multiple properties if they are set."); |
| |
| test(function() { |
| testElement.style = ''; |
| testElement.style.setProperty('--my-custom-property', '5px'); |
| |
| assert_array_equals(testElement.attributeStyleMap.getProperties(), ['--my-custom-property']); |
| }, "getProperties returns expected values for custom properties"); |
| |
| </script> |