| 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 CSSUnitValue(0, "px"); |
| 8 var decimalLength = new CSSSimpleLength(1.1, "px"); | 8 var decimalLength = new CSSUnitValue(1.1, "px"); |
| 9 var negativeLength = new CSSSimpleLength(-2.2, "em"); | 9 var negativeLength = new CSSUnitValue(-2.2, "em"); |
| 10 var calcLengthPx = new CSSCalcLength({px: 1}); | 10 // var calcLengthPx = new CSSCalcValue({px: 1}); |
| 11 var calcLength = new CSSCalcLength({px: 1, em: -2.2}); | 11 // var calcLength = new CSSCalcValue({px: 1, em: -2.2}); |
| 12 | 12 |
| 13 var simplePercent = new CSSSimpleLength(10, "percent"); | 13 var simplePercent = new CSSUnitValue(10, "percent"); |
| 14 var calcPercent = new CSSCalcLength({px: 1, percent: 2.2}); | 14 // var calcPercent = new CSSCalcValue({px: 1, percent: 2.2}); |
| 15 | 15 |
| 16 var values = [ | 16 var values = [ |
| 17 // 2D CSSTranslation Transform Components | 17 // 2D CSSTranslation Transform Components |
| 18 {input: new CSSTranslation(simpleLength, simpleLength), | 18 {input: new CSSTranslation(simpleLength, simpleLength), |
| 19 x: simpleLength, y: simpleLength, is2D: true}, | 19 x: simpleLength, y: simpleLength, is2D: true}, |
| 20 {input: new CSSTranslation(decimalLength, negativeLength), | 20 {input: new CSSTranslation(decimalLength, negativeLength), |
| 21 x: decimalLength, y: negativeLength, is2D: true}, | 21 x: decimalLength, y: negativeLength, is2D: true}, |
| 22 {input: new CSSTranslation(negativeLength, calcLengthPx), | 22 // {input: new CSSTranslation(negativeLength, calcLengthPx), |
| 23 x: negativeLength, y: calcLengthPx, is2D: true}, | 23 // x: negativeLength, y: calcLengthPx, is2D: true}, |
| 24 {input: new CSSTranslation(calcLengthPx, negativeLength), | 24 // {input: new CSSTranslation(calcLengthPx, negativeLength), |
| 25 x: calcLengthPx, y: negativeLength, is2D: true}, | 25 // x: calcLengthPx, y: negativeLength, is2D: true}, |
| 26 {input: new CSSTranslation(calcLengthPx, calcLength), | 26 // {input: new CSSTranslation(calcLengthPx, calcLength), |
| 27 x: calcLengthPx, y: calcLength, is2D: true}, | 27 // x: calcLengthPx, y: calcLength, is2D: true}, |
| 28 {input: new CSSTranslation(simplePercent, simpleLength), | 28 {input: new CSSTranslation(simplePercent, simpleLength), |
| 29 x: simplePercent, y: simpleLength, is2D: true}, | 29 x: simplePercent, y: simpleLength, is2D: true}, |
| 30 {input: new CSSTranslation(calcLengthPx, simplePercent), | 30 // {input: new CSSTranslation(calcLengthPx, simplePercent), |
| 31 x: calcLengthPx, y: simplePercent, is2D: true}, | 31 // x: calcLengthPx, y: simplePercent, is2D: true}, |
| 32 {input: new CSSTranslation(calcPercent, calcLength), | 32 // {input: new CSSTranslation(calcPercent, calcLength), |
| 33 x: calcPercent, y: calcLength, is2D: true}, | 33 // x: calcPercent, y: calcLength, is2D: true}, |
| 34 {input: new CSSTranslation(simplePercent, calcPercent), | 34 // {input: new CSSTranslation(simplePercent, calcPercent), |
| 35 x: simplePercent, y: calcPercent, is2D: true}, | 35 // x: simplePercent, y: calcPercent, is2D: true}, |
| 36 | 36 |
| 37 // 3D CSSTranslation Transform Components | 37 // 3D CSSTranslation Transform Components |
| 38 {input: new CSSTranslation(simpleLength, simpleLength, simpleLength), | 38 {input: new CSSTranslation(simpleLength, simpleLength, simpleLength), |
| 39 x: simpleLength, y: simpleLength, z: simpleLength, is2D: false}, | 39 x: simpleLength, y: simpleLength, z: simpleLength, is2D: false}, |
| 40 {input: new CSSTranslation(simpleLength, decimalLength, negativeLength), | 40 {input: new CSSTranslation(simpleLength, decimalLength, negativeLength), |
| 41 x: simpleLength, y: decimalLength, z: negativeLength, is2D: false}, | 41 x: simpleLength, y: decimalLength, z: negativeLength, is2D: false}, |
| 42 {input: new CSSTranslation(simpleLength, simpleLength, calcLengthPx), | 42 // {input: new CSSTranslation(simpleLength, simpleLength, calcLengthPx), |
| 43 x: simpleLength, y: simpleLength, z: calcLengthPx, is2D: false}, | 43 // x: simpleLength, y: simpleLength, z: calcLengthPx, is2D: false}, |
| 44 {input: new CSSTranslation(calcLengthPx, calcLength, calcLength), | 44 // {input: new CSSTranslation(calcLengthPx, calcLength, calcLength), |
| 45 x: calcLengthPx, y: calcLength, z: calcLength, is2D: false}, | 45 // x: calcLengthPx, y: calcLength, z: calcLength, is2D: false}, |
| 46 {input: new CSSTranslation(simplePercent, decimalLength, simpleLength), | 46 {input: new CSSTranslation(simplePercent, decimalLength, simpleLength), |
| 47 x: simplePercent, y: decimalLength, z: simpleLength, is2D: false}, | 47 x: simplePercent, y: decimalLength, z: simpleLength, is2D: false}, |
| 48 {input: new CSSTranslation(simpleLength, calcPercent, decimalLength), | 48 // {input: new CSSTranslation(simpleLength, calcPercent, decimalLength), |
| 49 x: simpleLength, y: calcPercent, z: decimalLength, is2D: false}, | 49 // x: simpleLength, y: calcPercent, z: decimalLength, is2D: false}, |
| 50 {input: new CSSTranslation(calcPercent, simplePercent, calcLength), | 50 // {input: new CSSTranslation(calcPercent, simplePercent, calcLength), |
| 51 x: calcPercent, y: simplePercent, z: calcLength, is2D: false} | 51 // x: calcPercent, y: simplePercent, z: calcLength, is2D: false} |
| 52 ]; | 52 ]; |
| 53 | 53 |
| 54 function expectedCssString(obj) { | 54 function expectedCssString(obj) { |
| 55 var cssText = obj.is2D ? "translate(" : "translate3d("; | 55 var cssText = obj.is2D ? "translate(" : "translate3d("; |
| 56 cssText += obj.x.cssText + ", " + obj.y.cssText; | 56 cssText += obj.x.cssText + ", " + obj.y.cssText; |
| 57 if (!obj.is2D) | 57 if (!obj.is2D) |
| 58 cssText += ", " + obj.z.cssText; | 58 cssText += ", " + obj.z.cssText; |
| 59 cssText += ")"; | 59 cssText += ")"; |
| 60 return cssText; | 60 return cssText; |
| 61 } | 61 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 77 } | 77 } |
| 78 }, "Test that the is2D values for CSSTranslation is correct."); | 78 }, "Test that the is2D 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.toString(), expectedCssString(values[i])); | 82 assert_equals(values[i].input.toString(), expectedCssString(values[i])); |
| 83 } | 83 } |
| 84 }, "Test that toString values for CSSTranslation is correct."); | 84 }, "Test that toString 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(new TypeError(), function() { new CSSTranslation(simpleLength, s
impleLength, simplePercent); }); |
| 88 assert_throws(null, function() { new CSSTranslation(simpleLength, simpleLength
, calcPercent); }); | 88 // assert_throws(null, function() { new CSSTranslation(simpleLength, simpleLen
gth, calcPercent); }); |
| 89 assert_throws(null, function() { new CSSTranslation(simplePercent, simplePerce
nt, simplePercent); }); | 89 assert_throws(new TypeError(), function() { new CSSTranslation(simplePercent,
simplePercent, 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(new TypeError(), function() { new CSSTranslation(); }); |
| 94 assert_throws(null, function() { new CSSTranslation(simpleLength); }); | 94 assert_throws(new TypeError(), 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 |