| 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 var EPSILON = 1e-6; // float epsilon | 6 var EPSILON = 1e-6; // float epsilon | 
| 7 var values = [ | 7 var values = [ | 
| 8   {input: new CSSRotation(0), angle: 0, x: 0, y: 0, z: 1, | 8   {input: new CSSRotation(0), angle: 0, x: 0, y: 0, z: 1, | 
| 9     is2DComponent: true, cssString: "rotate(0deg)", | 9     is2DComponent: true, cssText: "rotate(0deg)", | 
| 10     asMatrix: new CSSMatrix(1, 0, 0, 1, 0, 0)}, | 10     asMatrix: new CSSMatrix(1, 0, 0, 1, 0, 0)}, | 
| 11   {input: new CSSRotation(10), angle: 10, x: 0, y: 0, z: 1, | 11   {input: new CSSRotation(10), angle: 10, x: 0, y: 0, z: 1, | 
| 12     is2DComponent: true, cssString: "rotate(10deg)", | 12     is2DComponent: true, cssText: "rotate(10deg)", | 
| 13     asMatrix: new CSSMatrix(0.9848077, 0.1736481, -0.1736481, 0.9848077, 0, 0)}, | 13     asMatrix: new CSSMatrix(0.9848077, 0.1736481, -0.1736481, 0.9848077, 0, 0)}, | 
| 14   {input: new CSSRotation(new CSSAngleValue(10, 'deg')), angle: 10, x: 0, y: 0, 
    z: 1, | 14   {input: new CSSRotation(new CSSAngleValue(10, 'deg')), angle: 10, x: 0, y: 0, 
    z: 1, | 
| 15     is2DComponent: true, cssString: "rotate(10deg)", | 15     is2DComponent: true, cssText: "rotate(10deg)", | 
| 16     asMatrix: new CSSMatrix(0.9848077, 0.1736481, -0.1736481, 0.9848077, 0, 0)}, | 16     asMatrix: new CSSMatrix(0.9848077, 0.1736481, -0.1736481, 0.9848077, 0, 0)}, | 
| 17   {input: new CSSRotation(-21), angle: -21, x: 0, y: 0, z: 1, | 17   {input: new CSSRotation(-21), angle: -21, x: 0, y: 0, z: 1, | 
| 18     is2DComponent: true, cssString: "rotate(-21deg)", | 18     is2DComponent: true, cssText: "rotate(-21deg)", | 
| 19     asMatrix: new CSSMatrix(0.9335804, -0.3583679, 0.3583679, 0.9335804, 0, 0)}, | 19     asMatrix: new CSSMatrix(0.9335804, -0.3583679, 0.3583679, 0.9335804, 0, 0)}, | 
| 20   {input: new CSSRotation(3.2), angle: 3.2, x: 0, y: 0, z: 1, | 20   {input: new CSSRotation(3.2), angle: 3.2, x: 0, y: 0, z: 1, | 
| 21     is2DComponent: true, cssString: "rotate(3.2deg)", | 21     is2DComponent: true, cssText: "rotate(3.2deg)", | 
| 22     asMatrix: new CSSMatrix(0.9984407, 0.0558215, -0.0558215, 0.9984407, 0, 0)}, | 22     asMatrix: new CSSMatrix(0.9984407, 0.0558215, -0.0558215, 0.9984407, 0, 0)}, | 
| 23   {input: new CSSRotation(0, 0, 1, 90), angle: 90, x: 0, y: 0, z: 1, | 23   {input: new CSSRotation(0, 0, 1, 90), angle: 90, x: 0, y: 0, z: 1, | 
| 24     is2DComponent: false, cssString: "rotate3d(0, 0, 1, 90deg)", | 24     is2DComponent: false, cssText: "rotate3d(0, 0, 1, 90deg)", | 
| 25     asMatrix: new CSSMatrix(0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)}, | 25     asMatrix: new CSSMatrix(0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)}, | 
| 26   {input: new CSSRotation(2.7, -3, 4.4, 0), angle: 0, x: 2.7, y: -3, z: 4.4, | 26   {input: new CSSRotation(2.7, -3, 4.4, 0), angle: 0, x: 2.7, y: -3, z: 4.4, | 
| 27     is2DComponent: false, cssString: "rotate3d(2.7, -3, 4.4, 0deg)", | 27     is2DComponent: false, cssText: "rotate3d(2.7, -3, 4.4, 0deg)", | 
| 28     asMatrix: new CSSMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)}, | 28     asMatrix: new CSSMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)}, | 
| 29   {input: new CSSRotation(2, 3, 4, 10), angle: 10, x: 2, y: 3, z: 4, | 29   {input: new CSSRotation(2, 3, 4, 10), angle: 10, x: 2, y: 3, z: 4, | 
| 30     is2DComponent: false, cssString: "rotate3d(2, 3, 4, 10deg)", | 30     is2DComponent: false, cssText: "rotate3d(2, 3, 4, 10deg)", | 
| 31     asMatrix: new CSSMatrix(0.9869032, 0.1321258, -0.0925460, 0, -0.1258394, | 31     asMatrix: new CSSMatrix(0.9869032, 0.1321258, -0.0925460, 0, -0.1258394, | 
| 32       0.9895225, 0.0707777, 0, 0.1009279, -0.0582048, 0.9931896, 0, 0, 0, 0, 1)}
    , | 32       0.9895225, 0.0707777, 0, 0.1009279, -0.0582048, 0.9931896, 0, 0, 0, 0, 1)}
    , | 
| 33   {input: new CSSRotation(2, 3.7, -4, -1.2), angle: -1.2, x: 2, y: 3.7, z: -4, | 33   {input: new CSSRotation(2, 3.7, -4, -1.2), angle: -1.2, x: 2, y: 3.7, z: -4, | 
| 34     is2DComponent: false, cssString: "rotate3d(2, 3.7, -4, -1.2deg)", | 34     is2DComponent: false, cssText: "rotate3d(2, 3.7, -4, -1.2deg)", | 
| 35     asMatrix: new CSSMatrix(0.9998067, 0.01448049, 0.0132978, 0, -0.0143841, | 35     asMatrix: new CSSMatrix(0.9998067, 0.01448049, 0.0132978, 0, -0.0143841, | 
| 36     0.9998698, -0.0073125, 0, -0.0134019, 0.0071198, 0.9998848, 0, 0, 0, 0, 1)}, | 36     0.9998698, -0.0073125, 0, -0.0134019, 0.0071198, 0.9998848, 0, 0, 0, 0, 1)}, | 
| 37   {input: new CSSRotation(1, 0, 0, new CSSAngleValue(0.5, 'turn')), angle: 180, 
    x: 1, y: 0, z: 0, | 37   {input: new CSSRotation(1, 0, 0, new CSSAngleValue(0.5, 'turn')), angle: 180, 
    x: 1, y: 0, z: 0, | 
| 38     is2DComponent: false, cssString: "rotate3d(1, 0, 0, 180deg)", | 38     is2DComponent: false, cssText: "rotate3d(1, 0, 0, 180deg)", | 
| 39     asMatrix: new CSSMatrix(1, 0, 0, 0, 0, -1, 1.2246467991473532e-16, 0, 0, | 39     asMatrix: new CSSMatrix(1, 0, 0, 0, 0, -1, 1.2246467991473532e-16, 0, 0, | 
| 40     -1.2246467991473532e-16, -1, 0, 0, 0, 0, 1)} | 40     -1.2246467991473532e-16, -1, 0, 0, 0, 0, 1)} | 
| 41 ]; | 41 ]; | 
| 42 | 42 | 
| 43 test(function() { | 43 test(function() { | 
| 44   for (var i = 0; i < values.length; ++i) { | 44   for (var i = 0; i < values.length; ++i) { | 
| 45     assert_equals(values[i].input.angle, values[i].angle); | 45     assert_equals(values[i].input.angle, values[i].angle); | 
| 46     assert_equals(values[i].input.x, values[i].x); | 46     assert_equals(values[i].input.x, values[i].x); | 
| 47     assert_equals(values[i].input.y, values[i].y); | 47     assert_equals(values[i].input.y, values[i].y); | 
| 48     assert_equals(values[i].input.z, values[i].z); | 48     assert_equals(values[i].input.z, values[i].z); | 
| 49   } | 49   } | 
| 50 }, "Test that the (x, y, z, angle) values for CSSRotation are correct."); | 50 }, "Test that the (x, y, z, angle) values for CSSRotation are correct."); | 
| 51 | 51 | 
| 52 test(function() { | 52 test(function() { | 
| 53   for (var i = 0; i < values.length; ++i) { | 53   for (var i = 0; i < values.length; ++i) { | 
| 54     assert_equals(values[i].input.is2DComponent(), values[i].is2DComponent); | 54     assert_equals(values[i].input.is2DComponent(), values[i].is2DComponent); | 
| 55   } | 55   } | 
| 56 }, "Test that the is2DComponent values for CSSRotation is correct."); | 56 }, "Test that the is2DComponent values for CSSRotation is correct."); | 
| 57 | 57 | 
| 58 test(function() { | 58 test(function() { | 
| 59   for (var i = 0; i < values.length; ++i) { | 59   for (var i = 0; i < values.length; ++i) { | 
| 60     assert_equals(values[i].input.cssString, values[i].cssString); | 60     assert_equals(values[i].input.cssText, values[i].cssText); | 
| 61   } | 61   } | 
| 62 }, "Test that cssString values for CSSRotation is correct."); | 62 }, "Test that cssText values for CSSRotation is correct."); | 
| 63 | 63 | 
| 64 test(function() { | 64 test(function() { | 
| 65   for (var i = 0; i < values.length; ++i) { | 65   for (var i = 0; i < values.length; ++i) { | 
| 66     var input = values[i].input; | 66     var input = values[i].input; | 
| 67     var inputAsMatrix = input.asMatrix(); | 67     var inputAsMatrix = input.asMatrix(); | 
| 68     assert_equals(inputAsMatrix.is2DComponent(), input.is2DComponent()); | 68     assert_equals(inputAsMatrix.is2DComponent(), input.is2DComponent()); | 
| 69     var expectedMatrix = values[i].asMatrix; | 69     var expectedMatrix = values[i].asMatrix; | 
| 70     for (var attribute in expectedMatrix) { | 70     for (var attribute in expectedMatrix) { | 
| 71       if (typeof expectedMatrix[attribute] === "number") { | 71       if (typeof expectedMatrix[attribute] === "number") { | 
| 72         assert_approx_equals(inputAsMatrix[attribute], expectedMatrix[attribute]
    , EPSILON); | 72         assert_approx_equals(inputAsMatrix[attribute], expectedMatrix[attribute]
    , EPSILON); | 
| 73       } else if (attribute != "cssString") { | 73       } else if (attribute != "cssText") { | 
| 74         // Due to the complex trigonometric calculations required for a CSSRotat
    ion matrix, | 74         // Due to the complex trigonometric calculations required for a CSSRotat
    ion matrix, | 
| 75         // the 6 significant figures of each value in the cssString might be dif
    ferent. | 75         // the 6 significant figures of each value in the cssText might be diffe
    rent. | 
| 76         // Hence, do not check cssString. | 76         // Hence, do not check cssText. | 
| 77         assert_equals(inputAsMatrix[attribute], expectedMatrix[attribute]); | 77         assert_equals(inputAsMatrix[attribute], expectedMatrix[attribute]); | 
| 78       } | 78       } | 
| 79     } | 79     } | 
| 80   } | 80   } | 
| 81 }, "Test that asMatrix is constructed correctly for CSSRotation."); | 81 }, "Test that asMatrix is constructed correctly for CSSRotation."); | 
| 82 | 82 | 
| 83 </script> | 83 </script> | 
| OLD | NEW | 
|---|