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 var simpleLength = new CSSSimpleLength(0, "px"); | 7 var simpleLength = new CSSSimpleLength(0, "px"); |
8 var decimalLength = new CSSSimpleLength(1.1, "px"); | 8 var decimalLength = new CSSSimpleLength(1.1, "px"); |
9 var negativeLength = new CSSSimpleLength(-2.2, "em"); | 9 var negativeLength = new CSSSimpleLength(-2.2, "em"); |
10 var calcLengthPx = new CSSCalcLength({px: 1}); | 10 var calcLengthPx = new CSSCalcLength({px: 1}); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 x: calcLengthPx, y: calcLength, z: calcLength, is2DComponent: false}, | 45 x: calcLengthPx, y: calcLength, z: calcLength, is2DComponent: false}, |
46 {input: new CSSTranslation(simplePercent, decimalLength, simpleLength), | 46 {input: new CSSTranslation(simplePercent, decimalLength, simpleLength), |
47 x: simplePercent, y: decimalLength, z: simpleLength, is2DComponent: false}, | 47 x: simplePercent, y: decimalLength, z: simpleLength, is2DComponent: false}, |
48 {input: new CSSTranslation(simpleLength, calcPercent, decimalLength), | 48 {input: new CSSTranslation(simpleLength, calcPercent, decimalLength), |
49 x: simpleLength, y: calcPercent, z: decimalLength, is2DComponent: false}, | 49 x: simpleLength, y: calcPercent, z: decimalLength, is2DComponent: false}, |
50 {input: new CSSTranslation(calcPercent, simplePercent, calcLength), | 50 {input: new CSSTranslation(calcPercent, simplePercent, calcLength), |
51 x: calcPercent, y: simplePercent, z: calcLength, is2DComponent: false} | 51 x: calcPercent, y: simplePercent, z: calcLength, is2DComponent: false} |
52 ]; | 52 ]; |
53 | 53 |
54 function expectedCssString(obj) { | 54 function expectedCssString(obj) { |
55 var cssString = obj.is2DComponent ? "translate(" : "translate3d("; | 55 var cssText = obj.is2DComponent ? "translate(" : "translate3d("; |
56 cssString += obj.x.cssString + ", " + obj.y.cssString; | 56 cssText += obj.x.cssText + ", " + obj.y.cssText; |
57 if (!obj.is2DComponent) | 57 if (!obj.is2DComponent) |
58 cssString += ", " + obj.z.cssString; | 58 cssText += ", " + obj.z.cssText; |
59 cssString += ")"; | 59 cssText += ")"; |
60 return cssString; | 60 return cssText; |
61 } | 61 } |
62 | 62 |
63 test(function() { | 63 test(function() { |
64 for (var i = 0; i < values.length; ++i) { | 64 for (var i = 0; i < values.length; ++i) { |
65 assert_equals(values[i].input.x, values[i].x); | 65 assert_equals(values[i].input.x, values[i].x); |
66 assert_equals(values[i].input.y, values[i].y); | 66 assert_equals(values[i].input.y, values[i].y); |
67 if (values[i].is2DComponent) | 67 if (values[i].is2DComponent) |
68 assert_equals(values[i].input.z, null); | 68 assert_equals(values[i].input.z, null); |
69 else | 69 else |
70 assert_equals(values[i].input.z, values[i].z); | 70 assert_equals(values[i].input.z, values[i].z); |
71 } | 71 } |
72 }, "Test that the (x, y, z) values for CSSTranslation are correct."); | 72 }, "Test that the (x, y, z) values for CSSTranslation are correct."); |
73 | 73 |
74 test(function() { | 74 test(function() { |
75 for (var i = 0; i < values.length; ++i) { | 75 for (var i = 0; i < values.length; ++i) { |
76 assert_equals(values[i].input.is2DComponent(), values[i].is2DComponent); | 76 assert_equals(values[i].input.is2DComponent(), values[i].is2DComponent); |
77 } | 77 } |
78 }, "Test that the is2DComponent values for CSSTranslation is correct."); | 78 }, "Test that the is2DComponent values for CSSTranslation is correct."); |
79 | 79 |
80 test(function() { | 80 test(function() { |
81 for (var i = 0; i < values.length; ++i) { | 81 for (var i = 0; i < values.length; ++i) { |
82 assert_equals(values[i].input.cssString, expectedCssString(values[i])); | 82 assert_equals(values[i].input.cssText, expectedCssString(values[i])); |
83 } | 83 } |
84 }, "Test that cssString values for CSSTranslation is correct."); | 84 }, "Test that cssText values for CSSTranslation is correct."); |
85 | 85 |
86 test(function() { | 86 test(function() { |
87 assert_throws(null, function() { new CSSTranslation(simpleLength, simpleLength
, simplePercent); }); | 87 assert_throws(null, function() { new CSSTranslation(simpleLength, simpleLength
, simplePercent); }); |
88 assert_throws(null, function() { new CSSTranslation(simpleLength, simpleLength
, calcPercent); }); | 88 assert_throws(null, function() { new CSSTranslation(simpleLength, simpleLength
, calcPercent); }); |
89 assert_throws(null, function() { new CSSTranslation(simplePercent, simplePerce
nt, simplePercent); }); | 89 assert_throws(null, function() { new CSSTranslation(simplePercent, simplePerce
nt, simplePercent); }); |
90 }, "Test that CSSTranslation constructor throws when z component contains percen
t."); | 90 }, "Test that CSSTranslation constructor throws when z component contains percen
t."); |
91 | 91 |
92 test(function() { | 92 test(function() { |
93 assert_throws(null, function() { new CSSTranslation(); }); | 93 assert_throws(null, function() { new CSSTranslation(); }); |
94 assert_throws(null, function() { new CSSTranslation(simpleLength); }); | 94 assert_throws(null, function() { new CSSTranslation(simpleLength); }); |
95 }, "Test that invalid number of arguments for CSSTranslation throws an exception
."); | 95 }, "Test that invalid number of arguments for CSSTranslation throws an exception
."); |
96 | 96 |
97 </script> | 97 </script> |
OLD | NEW |