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 <script> | 5 <script> |
6 | 6 |
7 test(function() { | 7 test(function() { |
| 8 var simpleLength = new CSSSimpleLength(1, 'px'); |
| 9 assert_equals(simpleLength.value, 1); |
| 10 assert_equals(simpleLength.type, 'px'); |
| 11 |
| 12 simpleLength.value = 2; |
| 13 simpleLength.type = 'em'; |
| 14 |
| 15 assert_equals(simpleLength.value, 1); |
| 16 assert_equals(simpleLength.type, 'px'); |
| 17 }, 'CSSSimpleLengths are immutable'); |
| 18 |
| 19 test(function() { |
| 20 var units = ['px', 'percent', 'em', 'ex', 'ch', 'rem', 'vw', 'vh', 'vmin', 'vm
ax', 'cm', 'mm', 'in', 'pc', 'pt']; |
| 21 for (var i = 0; i < units.length; ++i) { |
| 22 var simpleLength = new CSSSimpleLength(i, units[i]); |
| 23 assert_equals(simpleLength.type, units[i]); |
| 24 } |
| 25 }, 'Each unit type is returned according to the spec'); |
| 26 |
| 27 test(function() { |
8 var simpleLength1 = new CSSSimpleLength(5.1, 'px'); | 28 var simpleLength1 = new CSSSimpleLength(5.1, 'px'); |
9 var simpleLength2 = new CSSSimpleLength(10, 'px'); | 29 var simpleLength2 = new CSSSimpleLength(10, 'px'); |
10 | 30 |
11 var result = simpleLength1.add(simpleLength2); | 31 var result = simpleLength1.add(simpleLength2); |
12 | 32 |
13 assert_not_equals(simpleLength1, result); | 33 assert_not_equals(simpleLength1, result); |
14 assert_not_equals(simpleLength2, result); | 34 assert_not_equals(simpleLength2, result); |
15 assert_true(result instanceof CSSSimpleLength); | 35 assert_true(result instanceof CSSSimpleLength); |
16 assert_equals(result.value, 15.1); | 36 assert_equals(result.value, 15.1); |
17 assert_equals(result.type, 'px'); | 37 assert_equals(result.type, 'px'); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 149 |
130 for (var i = 0; i < values.length; ++i) { | 150 for (var i = 0; i < values.length; ++i) { |
131 assert_throws(null, function() { new CSSSimpleLength(values[i].value, values
[i].unit); }); | 151 assert_throws(null, function() { new CSSSimpleLength(values[i].value, values
[i].unit); }); |
132 } | 152 } |
133 }, 'Invalid input throws an exception.'); | 153 }, 'Invalid input throws an exception.'); |
134 | 154 |
135 </script> | 155 </script> |
136 | 156 |
137 <body> | 157 <body> |
138 </body> | 158 </body> |
OLD | NEW |