| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 | 4 |
| 5 <div id="testElement"></div> | 5 <div id="testElement"></div> |
| 6 | 6 |
| 7 <script> | 7 <script> |
| 8 | 8 |
| 9 test(function() { | 9 test(function() { |
| 10 testElement.styleMap.set('width', new CSSSimpleLength(10, 'px')); | 10 testElement.styleMap.set('width', new CSSUnitValue(10, 'px')); |
| 11 assert_equals(testElement.styleMap.get('width').cssText, '10px'); | 11 assert_equals(testElement.styleMap.get('width').cssText, '10px'); |
| 12 }, "Setting and getting round trips"); | 12 }, "Setting and getting round trips"); |
| 13 | 13 |
| 14 test(function() { | 14 test(function() { |
| 15 testElement.styleMap.set('WIDTH', new CSSSimpleLength(40, 'px')); | 15 testElement.styleMap.set('WIDTH', new CSSUnitValue(40, 'px')); |
| 16 assert_equals(testElement.styleMap.get('WiDtH').cssText, '40px'); | 16 assert_equals(testElement.styleMap.get('WiDtH').cssText, '40px'); |
| 17 testElement.styleMap.set('wIdTh', new CSSSimpleLength(50, 'px')); | 17 testElement.styleMap.set('wIdTh', new CSSUnitValue(50, 'px')); |
| 18 assert_equals(testElement.styleMap.get('width').cssText, '50px'); | 18 assert_equals(testElement.styleMap.get('width').cssText, '50px'); |
| 19 }, "Setting and getting is not case sensitive"); | 19 }, "Setting and getting is not case sensitive"); |
| 20 | 20 |
| 21 test(function() { | 21 test(function() { |
| 22 testElement.style.width = '20px'; | 22 testElement.style.width = '20px'; |
| 23 assert_equals(testElement.styleMap.get('width').cssText, '20px'); | 23 assert_equals(testElement.styleMap.get('width').cssText, '20px'); |
| 24 }, "Changes to element.style are reflected in the element.styleMap"); | 24 }, "Changes to element.style are reflected in the element.styleMap"); |
| 25 | 25 |
| 26 test(function() { | 26 test(function() { |
| 27 testElement.styleMap.set('width', new CSSSimpleLength(30, 'px')); | 27 testElement.styleMap.set('width', new CSSUnitValue(30, 'px')); |
| 28 assert_equals(testElement.style.width, '30px'); | 28 assert_equals(testElement.style.width, '30px'); |
| 29 }, "Changes to element.styleMap are reflected in element.style"); | 29 }, "Changes to element.styleMap are reflected in element.style"); |
| 30 | 30 |
| 31 test(function() { | 31 test(function() { |
| 32 assert_throws(new TypeError(), function() { | 32 assert_throws(new TypeError(), function() { |
| 33 testElement.styleMap.set('width', new CSSNumberValue(4)); | 33 testElement.styleMap.set('width', new CSSUnitValue(4, 'number')); |
| 34 }); | 34 }); |
| 35 }, "Attempting to set an invalid type for a property throws"); | 35 }, "Attempting to set an invalid type for a property throws"); |
| 36 | 36 |
| 37 test(function() { | 37 test(function() { |
| 38 testElement.styleMap.set('width', new CSSSimpleLength(2, 'px')); | 38 testElement.styleMap.set('width', new CSSUnitValue(2, 'px')); |
| 39 assert_throws(new TypeError(), function() { | 39 assert_throws(new TypeError(), function() { |
| 40 testElement.styleMap.set('width', new CSSNumberValue(4)); | 40 testElement.styleMap.set('width', new CSSUnitValue(4, 'number')); |
| 41 }); | 41 }); |
| 42 assert_equals(testElement.styleMap.get('width').cssText, '2px'); | 42 assert_equals(testElement.styleMap.get('width').cssText, '2px'); |
| 43 }, "Attempting to set an invalid type for a property does not change the value")
; | 43 }, "Attempting to set an invalid type for a property does not change the value")
; |
| 44 | 44 |
| 45 test(function() { | 45 test(function() { |
| 46 assert_throws(new TypeError(), function() { | 46 assert_throws(new TypeError(), function() { |
| 47 testElement.styleMap.set('lemons', new CSSNumberValue(4)); | 47 testElement.styleMap.set('lemons', new CSSUnitValue(4, 'number')); |
| 48 }); | 48 }); |
| 49 assert_throws(new TypeError(), function() { | 49 assert_throws(new TypeError(), function() { |
| 50 testElement.styleMap.set('lemons', null); | 50 testElement.styleMap.set('lemons', null); |
| 51 }); | 51 }); |
| 52 }, "Attempting to set an invalid property throws"); | 52 }, "Attempting to set an invalid property throws"); |
| 53 | 53 |
| 54 test(function() { | 54 test(function() { |
| 55 assert_equals(testElement.styleMap.get('height'), null); | 55 assert_equals(testElement.styleMap.get('height'), null); |
| 56 }, "Getting a property that isn't set returns null"); | 56 }, "Getting a property that isn't set returns null"); |
| 57 | 57 |
| 58 test(function() { | 58 test(function() { |
| 59 assert_throws(new TypeError(), function() { | 59 assert_throws(new TypeError(), function() { |
| 60 testElement.styleMap.get('lemons'); | 60 testElement.styleMap.get('lemons'); |
| 61 }); | 61 }); |
| 62 }, "Getting a property that doesn't exist throws"); | 62 }, "Getting a property that doesn't exist throws"); |
| 63 | 63 |
| 64 test(function() { | 64 test(function() { |
| 65 assert_throws(new TypeError(), function() { | 65 assert_throws(new TypeError(), function() { |
| 66 testElement.styleMap.set('width', null); | 66 testElement.styleMap.set('width', null); |
| 67 }); | 67 }); |
| 68 // Force a style recalc. | 68 // Force a style recalc. |
| 69 getComputedStyle(testElement).width; | 69 getComputedStyle(testElement).width; |
| 70 }, "Setting null to a property does not crash"); | 70 }, "Setting null to a property does not crash"); |
| 71 | 71 |
| 72 | 72 |
| 73 </script> | 73 </script> |
| OLD | NEW |