| Index: third_party/WebKit/LayoutTests/typedcssom/inlineStylePropertyMap.html
|
| diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlineStylePropertyMap.html b/third_party/WebKit/LayoutTests/typedcssom/inlineStylePropertyMap.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4b648b3beb962258af4349aedbe3c9cb2ccc9d1f
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/typedcssom/inlineStylePropertyMap.html
|
| @@ -0,0 +1,126 @@
|
| +<!DOCTYPE html>
|
| +<script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharnessreport.js"></script>
|
| +
|
| +<div id="testElement"></div>
|
| +
|
| +<script>
|
| +
|
| +// Set/get
|
| +test(function() {
|
| + testElement.styleMap.set('width', new SimpleLength(10, 'px'));
|
| + assert_equals('10px', testElement.styleMap.get('width').cssString);
|
| +}, "Setting and getting round trips");
|
| +
|
| +test(function() {
|
| + testElement.style.width = '10px';
|
| + assert_equals('10px', testElement.styleMap.get('width').cssString);
|
| +}, "Changes to element.style are reflected in the element.styleMap");
|
| +
|
| +test(function() {
|
| + testElement.styleMap.set('width', new SimpleLength(10, 'px'));
|
| + assert_equals('10px', testElement.style.width);
|
| +}, "Changes to element.styleMap are reflected in element.style");
|
| +
|
| +test(function() {
|
| + assert_throws(new TypeError(), function() {
|
| + testElement.styleMap.set('width', new NumberValue(4));
|
| + });
|
| +}, "Attempting to set an invalid type for a property throws");
|
| +
|
| +test(function() {
|
| + assert_throws(new TypeError(), function() {
|
| + testElement.styleMap.set('lemons', new NumberValue(4));
|
| + });
|
| + assert_throws(new TypeError(), function() {
|
| + testElement.styleMap.set('lemons', null);
|
| + });
|
| +}, "Attempting to set an invalid property throws");
|
| +
|
| +test(function() {
|
| + assert_equals(null, testElement.styleMap.get('height'));
|
| + assert_equals(null, testElement.styleMap.get('lemons'));
|
| +}, "Getting a property that doesn't exist or isn't set returns null");
|
| +
|
| +// Append
|
| +test(function() {
|
| + testElement.styleMap.set('width', new SimpleLength(10, 'px'));
|
| + assert_throws(new TypeError(), function() {
|
| + testElement.styleMap.append('width', new SimpleLength(10, 'px'));
|
| + });
|
| +}, "Attempting to append to a property that doesn't support multiple values throws");
|
| +
|
| +test(function() {
|
| + assert_throws(new TypeError(), function() {
|
| + testElement.styleMap.append('width', new SimpleLength(10, 'px'));
|
| + });
|
| +}, "Appending an invalid type to a property throws");
|
| +
|
| +test(function() {
|
| + assert_throws(new TypeError(), function() {
|
| + testElement.styleMap.append('lemons', new NumberValue(6));
|
| + });
|
| +}, "Attempting to append to an invalid property throws");
|
| +
|
| +test(function() {
|
| + testElement.styleMap.set('width', null);
|
| + // Force a style recalc.
|
| + getComputedStyle(testElement).width;
|
| +
|
| + testElement.styleMap.append('width', null);
|
| + getComputedStyle(testElement).width;
|
| +}, "Setting or appending null to a property does not crash");
|
| +
|
| +// Delete
|
| +test(function() {
|
| + testElement.style.width = '10px';
|
| + assert_equals('10px', testElement.styleMap.get('width').cssString);
|
| +
|
| + testElement.styleMap.delete('width');
|
| + assert_equals(null, testElement.styleMap.get('width'));
|
| + assert_equals('', testElement.style.width);
|
| +}, "delete() removes the value from the property");
|
| +
|
| +test(function() {
|
| + assert_equals(null, testElement.styleMap.get('height'));
|
| + testElement.styleMap.delete('height');
|
| + assert_equals(null, testElement.styleMap.get('height'));
|
| +}, "delete() does nothing if the property isn't set");
|
| +
|
| +test(function() {
|
| + assert_throws(new TypeError(), function() {
|
| + testElement.styleMap.delete('lemons');
|
| + });
|
| +}, "Attempting to delete an invalid property throws");
|
| +
|
| +// getAll
|
| +test(function() {
|
| + // TODO(meade): Add a test case for a property with multiple values when that is supported.
|
| + testElement.styleMap.set('width', new SimpleLength(10, 'px'));
|
| + var result = testElement.styleMap.getAll('width');
|
| + assert_equals(1, result.length);
|
| + assert_equals('10px', result[0].cssString);
|
| +}, "getAll() returns a list of values");
|
| +
|
| +test(function() {
|
| + assert_array_equals([], testElement.styleMap.getAll('height'));
|
| + assert_array_equals([], testElement.styleMap.getAll('lemons'));
|
| +}, "getAll() returns an empty list if the value is invalid or isn't set");
|
| +
|
| +// getProperties
|
| +test(function() {
|
| + testElement.style = '';
|
| + assert_array_equals([], testElement.styleMap.getProperties());
|
| +
|
| + testElement.styleMap.set('width', new SimpleLength(10, 'px'));
|
| + assert_array_equals(['width'], testElement.styleMap.getProperties());
|
| +
|
| + // Check that accessing doesn't add spurious results.
|
| + testElement.styleMap.get('height');
|
| + assert_array_equals(['width'], testElement.styleMap.getProperties());
|
| +
|
| + testElement.styleMap.delete('width');
|
| + assert_array_equals([], testElement.styleMap.getProperties());
|
| +}, "getProperties returns only the properties that have been set in the StyleMap");
|
| +
|
| +</script>
|
|
|