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 test(function() { | 6 test(function() { |
7 assert_throws(null, function() { new CSSCalcLength(); }); | 7 assert_throws(null, function() { new CSSCalcLength(); }); |
8 assert_throws(null, function() { new CSSCalcLength({}); }); | 8 assert_throws(null, function() { new CSSCalcLength({}); }); |
9 assert_throws(null, function() { new CSSCalcLength({foo: 1}); }); | 9 assert_throws(null, function() { new CSSCalcLength({foo: 1}); }); |
10 }, 'Test that passing invalid arguments to CSSCalcLength throws an exception.'); | 10 }, 'Test that passing invalid arguments to CSSCalcLength throws an exception.'); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 var calcLength = new CSSCalcLength({px: 3, percent: 15.6}); | 48 var calcLength = new CSSCalcLength({px: 3, percent: 15.6}); |
49 var result = calcLength.divide(3); | 49 var result = calcLength.divide(3); |
50 | 50 |
51 assert_not_equals(calcLength, result); | 51 assert_not_equals(calcLength, result); |
52 assert_equals(result.px, 1); | 52 assert_equals(result.px, 1); |
53 assert_equals(result.percent, 5.2); | 53 assert_equals(result.percent, 5.2); |
54 }, 'Test that dividing a CSSCalcLength produces a new CSSCalcLength with the cor
rect values.'); | 54 }, 'Test that dividing a CSSCalcLength produces a new CSSCalcLength with the cor
rect values.'); |
55 | 55 |
56 test(function() { | 56 test(function() { |
57 var values = [ | 57 var values = [ |
58 {input: new CSSCalcLength({px: 1}), cssString: 'calc(1px)'}, | 58 {input: new CSSCalcLength({px: 1}), cssText: 'calc(1px)'}, |
59 {input: new CSSCalcLength({px: -1}), cssString: 'calc(-1px)'}, | 59 {input: new CSSCalcLength({px: -1}), cssText: 'calc(-1px)'}, |
60 {input: new CSSCalcLength({px: 1, percent: 15.6}), cssString: 'calc(15.6% +
1px)'}, | 60 {input: new CSSCalcLength({px: 1, percent: 15.6}), cssText: 'calc(15.6% + 1p
x)'}, |
61 {input: new CSSCalcLength({px: 1, percent: -15.6}), cssString: 'calc(-15.6%
+ 1px)'}, | 61 {input: new CSSCalcLength({px: 1, percent: -15.6}), cssText: 'calc(-15.6% +
1px)'}, |
62 {input: new CSSCalcLength({px: -1, percent: -15.6}), cssString: 'calc(-15.6%
- 1px)'}, | 62 {input: new CSSCalcLength({px: -1, percent: -15.6}), cssText: 'calc(-15.6% -
1px)'}, |
63 {input: new CSSCalcLength({px: -1, percent: -15.6, vw: 5}), cssString: 'calc
((-15.6% - 1px) + 5vw)'}, | 63 {input: new CSSCalcLength({px: -1, percent: -15.6, vw: 5}), cssText: 'calc((
-15.6% - 1px) + 5vw)'}, |
64 {input: new CSSCalcLength({px: -1, percent: -15.6, vw: -5}), cssString: 'cal
c((-15.6% - 1px) - 5vw)'}, | 64 {input: new CSSCalcLength({px: -1, percent: -15.6, vw: -5}), cssText: 'calc(
(-15.6% - 1px) - 5vw)'}, |
65 ]; | 65 ]; |
66 | 66 |
67 for (var i = 0; i < values.length; ++i) { | 67 for (var i = 0; i < values.length; ++i) { |
68 assert_equals(values[i].input.cssString, values[i].cssString); | 68 assert_equals(values[i].input.cssText, values[i].cssText); |
69 } | 69 } |
70 | 70 |
71 }, 'Test that the CSS string method for a CSSCalcLength produces the correct res
ult'); | 71 }, 'Test that the CSS string method for a CSSCalcLength produces the correct res
ult'); |
72 | 72 |
73 </script> | 73 </script> |
74 | 74 |
75 <body> | 75 <body> |
76 </body> | 76 </body> |
OLD | NEW |