| OLD | NEW |
| 1 /** | 1 /** |
| 2 * A standard set of tests for using a single property in an | 2 * A standard set of tests for using a single property in an |
| 3 * inline StylePropertyMap | 3 * inline StylePropertyMap |
| 4 * (https://www.w3.org/TR/css-typed-om-1/#the-stylepropertymap). | 4 * (https://www.w3.org/TR/css-typed-om-1/#the-stylepropertymap). |
| 5 * | 5 * |
| 6 * Create a config object containing { | 6 * Create a config object containing { |
| 7 * validKeywords: array of strings, | 7 * validKeywords: array of strings, |
| 8 * validObjects: array of CSSStyleValue instances that are valid for the | 8 * validObjects: array of CSSStyleValue instances that are valid for the |
| 9 * property, | 9 * property, |
| 10 * validStringMappings: object containing a mapping of string to | 10 * validStringMappings: object containing a mapping of string to |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Force a style recalc to check for crashes in style recalculation. | 96 // Force a style recalc to check for crashes in style recalculation. |
| 97 getComputedStyle(element)[propertyName]; | 97 getComputedStyle(element)[propertyName]; |
| 98 assert_equals(element.style[propertyName], validObject.toString()); | 98 assert_equals(element.style[propertyName], validObject.toString()); |
| 99 }, 'Setting ' + propertyName + ' to ' + validObject.constructor.name + | 99 }, 'Setting ' + propertyName + ' to ' + validObject.constructor.name + |
| 100 ' with value ' + validObject.toString()); | 100 ' with value ' + validObject.toString()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Negative tests | 103 // Negative tests |
| 104 for (let invalidObject of invalidObjects) { | 104 for (let invalidObject of invalidObjects) { |
| 105 let name = invalidObject instanceof CSSStyleValue ? | 105 let name = invalidObject instanceof CSSStyleValue ? |
| 106 invalidObject.constructor.name : invalidObject; | 106 invalidObject.constructor.name + ' "' + invalidObject.toString() + '"' : |
| 107 invalidObject; |
| 107 test(function() { | 108 test(function() { |
| 108 assert_throws(new TypeError(), function() { | 109 assert_throws(new TypeError(), function() { |
| 109 element.styleMap.set(propertyName, invalidObject); | 110 element.styleMap.set(propertyName, invalidObject); |
| 110 }); | 111 }); |
| 111 }, 'Setting ' + propertyName + ' to invalid value ' + name + ' throws'); | 112 }, 'Setting ' + propertyName + ' to invalid value ' + name + ' throws'); |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 | 115 |
| 115 function runGetterTests( | 116 function runGetterTests( |
| 116 propertyName, validKeywords, validObjects, validStringMappings, element) { | 117 propertyName, validKeywords, validObjects, validStringMappings, element) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 }, 'Setting ' + propertyName + ' to a sequence throws'); | 290 }, 'Setting ' + propertyName + ' to a sequence throws'); |
| 290 | 291 |
| 291 test(function() { | 292 test(function() { |
| 292 element.style = ''; | 293 element.style = ''; |
| 293 assert_throws(new TypeError(), function() { | 294 assert_throws(new TypeError(), function() { |
| 294 element.styleMap.append(propertyName, validObject); | 295 element.styleMap.append(propertyName, validObject); |
| 295 }); | 296 }); |
| 296 }, 'Appending to ' + propertyName + ' throws'); | 297 }, 'Appending to ' + propertyName + ' throws'); |
| 297 } | 298 } |
| 298 | 299 |
| OLD | NEW |