| 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 <script src="./resources/geometry-interfaces-test-helpers.js"></script> | 4 <script src="./resources/geometry-interfaces-test-helpers.js"></script> |
| 5 <script> | 5 <script> |
| 6 test(function() { | 6 test(function() { |
| 7 var matrix = new DOMMatrix(); | 7 var matrix = new DOMMatrix(); |
| 8 matrix.a = 1; | 8 matrix.a = 1; |
| 9 matrix.b = 2; | 9 matrix.b = 2; |
| 10 matrix.c = 3; | 10 matrix.c = 3; |
| 11 matrix.d = 4; | 11 matrix.d = 4; |
| 12 matrix.e = 5; | 12 matrix.e = 5; |
| 13 matrix.f = 6; | 13 matrix.f = 6; |
| 14 assert_2d_matrix_equals(matrix, [1, 2, 3, 4, 5, 6]); | 14 assert_2d_matrix_equals(matrix, [1, 2, 3, 4, 5, 6]); |
| 15 var other = new DOMMatrix(); | 15 var other = new DOMMatrix(); |
| 16 other.m11 = 6; | 16 other.m11 = 6; |
| 17 other.m21 = 5; | 17 other.m21 = 5; |
| 18 other.m31 = 4; | 18 other.m31 = 4; |
| 19 other.m33 = 3; | 19 other.m33 = 3; |
| 20 other.m41 = 2; | 20 other.m41 = 2; |
| 21 other.m43 = 1; | 21 other.m43 = 1; |
| 22 assert_3d_matrix_equals(other, [6, 0, 0, 0, 5, 1, 0, 0, 4, 0, 3, 0, 2, 0, 1, 1
]); | 22 assert_3d_matrix_equals(other, [6, 0, 0, 0, 5, 1, 0, 0, 4, 0, 3, 0, 2, 0, 1, 1
]); |
| 23 var result = matrix.multiply(other); | 23 var result = matrix.multiply(other); |
| 24 assert_3d_matrix_equals(result, [6, 12, 0, 0, 8, 14, 0, 0, 4, 8, 3, 0, 7, 10,
1, 1]); | 24 assert_3d_matrix_equals(result, [6, 12, 0, 0, 8, 14, 0, 0, 4, 8, 3, 0, 7, 10,
1, 1]); |
| 25 matrix.multiplySelf(other); | 25 matrix.multiplySelf(other); |
| 26 assert_false(matrix.is2D); | 26 assert_false(matrix.is2D); |
| 27 assert_false(matrix.isIdentity); | 27 assert_false(matrix.isIdentity); |
| 28 assert_array_equals(matrix.toFloat64Array(), result.toFloat64Array()); | 28 assert_array_equals(matrix.toFloat64Array(), result.toFloat64Array()); |
| 29 assert_throws(new TypeError(), () => { matrix.multiplySelf({a: 2, m11: 3}) }); |
| 29 }, "DOMMatrix.multiply(other) and DOMMatrix.multiplySelf(other)"); | 30 }, "DOMMatrix.multiply(other) and DOMMatrix.multiplySelf(other)"); |
| 30 | 31 |
| 31 test(function() { | 32 test(function() { |
| 32 var matrix = new DOMMatrix(); | 33 var matrix = new DOMMatrix(); |
| 33 matrix.a = 1; | 34 matrix.a = 1; |
| 34 matrix.b = 2; | 35 matrix.b = 2; |
| 35 matrix.c = 3; | 36 matrix.c = 3; |
| 36 matrix.d = 4; | 37 matrix.d = 4; |
| 37 matrix.e = 5; | 38 matrix.e = 5; |
| 38 matrix.f = 6; | 39 matrix.f = 6; |
| 39 assert_2d_matrix_equals(matrix, [1, 2, 3, 4, 5, 6]); | 40 assert_2d_matrix_equals(matrix, [1, 2, 3, 4, 5, 6]); |
| 40 var other = new DOMMatrix(); | 41 var other = new DOMMatrix(); |
| 41 other.m11 = 6; | 42 other.m11 = 6; |
| 42 other.m21 = 5; | 43 other.m21 = 5; |
| 43 other.m31 = 4; | 44 other.m31 = 4; |
| 44 other.m33 = 3; | 45 other.m33 = 3; |
| 45 other.m41 = 2; | 46 other.m41 = 2; |
| 46 other.m43 = 1; | 47 other.m43 = 1; |
| 47 assert_3d_matrix_equals(other, [6, 0, 0, 0, 5, 1, 0, 0, 4, 0, 3, 0, 2, 0, 1, 1
]); | 48 assert_3d_matrix_equals(other, [6, 0, 0, 0, 5, 1, 0, 0, 4, 0, 3, 0, 2, 0, 1, 1
]); |
| 48 var result = matrix.preMultiplySelf(other); | 49 var result = matrix.preMultiplySelf(other); |
| 49 assert_3d_matrix_equals(result, [16, 2, 0, 0, 38, 4, 0, 0, 4, 0, 3, 0, 62, 6,
1, 1]); | 50 assert_3d_matrix_equals(result, [16, 2, 0, 0, 38, 4, 0, 0, 4, 0, 3, 0, 62, 6,
1, 1]); |
| 50 assert_array_equals(matrix.toFloat64Array(), result.toFloat64Array()); | 51 assert_array_equals(matrix.toFloat64Array(), result.toFloat64Array()); |
| 52 assert_throws(new TypeError(), () => { matrix.preMultiplySelf({b: 3, m12: 2})
}); |
| 51 }, "DOMMatrix.preMultiplySelf(other)"); | 53 }, "DOMMatrix.preMultiplySelf(other)"); |
| 52 </script> | 54 </script> |
| OLD | NEW |