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 simpleLength1 = new CSSSimpleLength(5.1, 'px'); | 8 var simpleLength1 = new CSSSimpleLength(5.1, 'px'); |
9 var simpleLength2 = new CSSSimpleLength(10, 'px'); | 9 var simpleLength2 = new CSSSimpleLength(10, 'px'); |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 var result = simpleLength.divide(2); | 67 var result = simpleLength.divide(2); |
68 | 68 |
69 assert_not_equals(simpleLength, result); | 69 assert_not_equals(simpleLength, result); |
70 assert_true(result instanceof CSSSimpleLength); | 70 assert_true(result instanceof CSSSimpleLength); |
71 assert_equals(result.value, 12.5); | 71 assert_equals(result.value, 12.5); |
72 assert_equals(result.type, 'px'); | 72 assert_equals(result.type, 'px'); |
73 }, 'Test that dividing a CSSSimpleLength produces a new CSSSimpleLength with the
correct value.'); | 73 }, 'Test that dividing a CSSSimpleLength produces a new CSSSimpleLength with the
correct value.'); |
74 | 74 |
75 test(function() { | 75 test(function() { |
76 var values = [ | 76 var values = [ |
77 {input: new CSSSimpleLength(1, 'px'), cssString: '1px' }, | 77 {input: new CSSSimpleLength(1, 'px'), cssText: '1px' }, |
78 {input: new CSSSimpleLength(2, 'percent'), cssString: '2%' }, | 78 {input: new CSSSimpleLength(2, 'percent'), cssText: '2%' }, |
79 {input: new CSSSimpleLength(3, '%'), cssString: '3%' }, | 79 {input: new CSSSimpleLength(3, '%'), cssText: '3%' }, |
80 {input: new CSSSimpleLength(4, 'em'), cssString: '4em' }, | 80 {input: new CSSSimpleLength(4, 'em'), cssText: '4em' }, |
81 {input: new CSSSimpleLength(5, 'ex'), cssString: '5ex' }, | 81 {input: new CSSSimpleLength(5, 'ex'), cssText: '5ex' }, |
82 {input: new CSSSimpleLength(6, 'ch'), cssString: '6ch' }, | 82 {input: new CSSSimpleLength(6, 'ch'), cssText: '6ch' }, |
83 {input: new CSSSimpleLength(7, 'rem'), cssString: '7rem' }, | 83 {input: new CSSSimpleLength(7, 'rem'), cssText: '7rem' }, |
84 {input: new CSSSimpleLength(8, 'vw'), cssString: '8vw' }, | 84 {input: new CSSSimpleLength(8, 'vw'), cssText: '8vw' }, |
85 {input: new CSSSimpleLength(9, 'vh'), cssString: '9vh' }, | 85 {input: new CSSSimpleLength(9, 'vh'), cssText: '9vh' }, |
86 {input: new CSSSimpleLength(10, 'vmin'), cssString: '10vmin' }, | 86 {input: new CSSSimpleLength(10, 'vmin'), cssText: '10vmin' }, |
87 {input: new CSSSimpleLength(11, 'vmax'), cssString: '11vmax' }, | 87 {input: new CSSSimpleLength(11, 'vmax'), cssText: '11vmax' }, |
88 {input: new CSSSimpleLength(12, 'cm'), cssString: '12cm' }, | 88 {input: new CSSSimpleLength(12, 'cm'), cssText: '12cm' }, |
89 {input: new CSSSimpleLength(13, 'mm'), cssString: '13mm' }, | 89 {input: new CSSSimpleLength(13, 'mm'), cssText: '13mm' }, |
90 {input: new CSSSimpleLength(14, 'in'), cssString: '14in' }, | 90 {input: new CSSSimpleLength(14, 'in'), cssText: '14in' }, |
91 {input: new CSSSimpleLength(15, 'pc'), cssString: '15pc' }, | 91 {input: new CSSSimpleLength(15, 'pc'), cssText: '15pc' }, |
92 {input: new CSSSimpleLength(16, 'pt'), cssString: '16pt' }, | 92 {input: new CSSSimpleLength(16, 'pt'), cssText: '16pt' }, |
93 // Same again to double check that it's case insensitive. | 93 // Same again to double check that it's case insensitive. |
94 {input: new CSSSimpleLength(1, 'PX'), cssString: '1px' }, | 94 {input: new CSSSimpleLength(1, 'PX'), cssText: '1px' }, |
95 {input: new CSSSimpleLength(2, 'PERCENT'), cssString: '2%' }, | 95 {input: new CSSSimpleLength(2, 'PERCENT'), cssText: '2%' }, |
96 {input: new CSSSimpleLength(3, '%'), cssString: '3%' }, | 96 {input: new CSSSimpleLength(3, '%'), cssText: '3%' }, |
97 {input: new CSSSimpleLength(4, 'EM'), cssString: '4em' }, | 97 {input: new CSSSimpleLength(4, 'EM'), cssText: '4em' }, |
98 {input: new CSSSimpleLength(5, 'EX'), cssString: '5ex' }, | 98 {input: new CSSSimpleLength(5, 'EX'), cssText: '5ex' }, |
99 {input: new CSSSimpleLength(6, 'CH'), cssString: '6ch' }, | 99 {input: new CSSSimpleLength(6, 'CH'), cssText: '6ch' }, |
100 {input: new CSSSimpleLength(7, 'REM'), cssString: '7rem' }, | 100 {input: new CSSSimpleLength(7, 'REM'), cssText: '7rem' }, |
101 {input: new CSSSimpleLength(8, 'VW'), cssString: '8vw' }, | 101 {input: new CSSSimpleLength(8, 'VW'), cssText: '8vw' }, |
102 {input: new CSSSimpleLength(9, 'VH'), cssString: '9vh' }, | 102 {input: new CSSSimpleLength(9, 'VH'), cssText: '9vh' }, |
103 {input: new CSSSimpleLength(10, 'VMIN'), cssString: '10vmin' }, | 103 {input: new CSSSimpleLength(10, 'VMIN'), cssText: '10vmin' }, |
104 {input: new CSSSimpleLength(11, 'VMAX'), cssString: '11vmax' }, | 104 {input: new CSSSimpleLength(11, 'VMAX'), cssText: '11vmax' }, |
105 {input: new CSSSimpleLength(12, 'CM'), cssString: '12cm' }, | 105 {input: new CSSSimpleLength(12, 'CM'), cssText: '12cm' }, |
106 {input: new CSSSimpleLength(13, 'MM'), cssString: '13mm' }, | 106 {input: new CSSSimpleLength(13, 'MM'), cssText: '13mm' }, |
107 {input: new CSSSimpleLength(14, 'IN'), cssString: '14in' }, | 107 {input: new CSSSimpleLength(14, 'IN'), cssText: '14in' }, |
108 {input: new CSSSimpleLength(15, 'PC'), cssString: '15pc' }, | 108 {input: new CSSSimpleLength(15, 'PC'), cssText: '15pc' }, |
109 {input: new CSSSimpleLength(16, 'PT'), cssString: '16pt' }, | 109 {input: new CSSSimpleLength(16, 'PT'), cssText: '16pt' }, |
110 ]; | 110 ]; |
111 | 111 |
112 for (var i = 0; i < values.length; ++i) { | 112 for (var i = 0; i < values.length; ++i) { |
113 assert_equals(values[i].input.cssString, values[i].cssString); | 113 assert_equals(values[i].input.cssText, values[i].cssText); |
114 } | 114 } |
115 }, 'Test that the CSSSimpleLength css string is generated correctly for each uni
t type.'); | 115 }, 'Test that the CSSSimpleLength css string is generated correctly for each uni
t type.'); |
116 | 116 |
117 test(function() { | 117 test(function() { |
118 var values = [ | 118 var values = [ |
119 {value: NaN, unit: 'px'}, | 119 {value: NaN, unit: 'px'}, |
120 {value: Infinity, unit: 'px'}, | 120 {value: Infinity, unit: 'px'}, |
121 {value: -Infinity, unit: 'px'}, | 121 {value: -Infinity, unit: 'px'}, |
122 {value: 5, unit: 'puppies'} | 122 {value: 5, unit: 'puppies'} |
123 ]; | 123 ]; |
124 | 124 |
125 for (var i = 0; i < values.length; ++i) { | 125 for (var i = 0; i < values.length; ++i) { |
126 assert_throws(null, function() { new CSSSimpleLength(values[i].value, values
[i].unit); }); | 126 assert_throws(null, function() { new CSSSimpleLength(values[i].value, values
[i].unit); }); |
127 } | 127 } |
128 }, 'Test that invalid input throws an exception.'); | 128 }, 'Test that invalid input throws an exception.'); |
129 | 129 |
130 </script> | 130 </script> |
131 | 131 |
132 <body> | 132 <body> |
133 </body> | 133 </body> |
OLD | NEW |