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 | 6 |
7 test(() => { | 7 test(() => { |
8 var matrix = new DOMMatrixReadOnly(); | 8 var matrix = new DOMMatrixReadOnly(); |
9 assert_identity_2d_matrix(matrix); | 9 assert_identity_2d_matrix(matrix); |
10 }, "DOMMatrixReadOnly constructor"); | 10 }, "DOMMatrixReadOnly constructor"); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 test(() => { | 53 test(() => { |
54 var matrix = new DOMMatrixReadOnly("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) trans
late(44px, 55px) skewX(30deg)"); | 54 var matrix = new DOMMatrixReadOnly("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) trans
late(44px, 55px) skewX(30deg)"); |
55 var expectedMatrix = new DOMMatrixReadOnly(); | 55 var expectedMatrix = new DOMMatrixReadOnly(); |
56 expectedMatrix = expectedMatrix.multiply(new DOMMatrixReadOnly([1.0, 2.0, 3.0,
4.0, 5.0, 6.0])) | 56 expectedMatrix = expectedMatrix.multiply(new DOMMatrixReadOnly([1.0, 2.0, 3.0,
4.0, 5.0, 6.0])) |
57 expectedMatrix = expectedMatrix.translate(44, 55) | 57 expectedMatrix = expectedMatrix.translate(44, 55) |
58 expectedMatrix = expectedMatrix.skewX(30); | 58 expectedMatrix = expectedMatrix.skewX(30); |
59 assert_matrix_almost_equals(matrix, expectedMatrix); | 59 assert_matrix_almost_equals(matrix, expectedMatrix); |
60 }, "DOMMatrixReadOnly(transformList) - transformList"); | 60 }, "DOMMatrixReadOnly(transformList) - transformList"); |
61 | 61 |
62 test(() => { | 62 test(() => { |
63 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); | 63 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1.123456789]); |
64 assert_true(matrix2d.is2D); | 64 assert_true(matrix2d.is2D); |
65 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1)"); | 65 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1.123456789)"); |
66 }, "DOMMatrixReadOnly toString() - 2D matrix"); | 66 }, "DOMMatrixReadOnly toString() - 2D matrix"); |
67 | 67 |
68 test(() => { | 68 test(() => { |
69 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12,
13, 14, 15, 16.6]); | 69 var matrix2d = new DOMMatrixReadOnly([NaN, Infinity, NaN, Infinity, NaN, Infin
ity]); |
| 70 assert_true(matrix2d.is2D); |
| 71 assert_equals(matrix2d.toString(), "matrix(NaN, Infinity, NaN, Infinity, NaN,
Infinity)"); |
| 72 }, "DOMMatrixReadOnly toString() - 2D matrix with NaN and Infinity"); |
| 73 |
| 74 test(() => { |
| 75 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12,
13, 14, 15, 16.123456789]); |
70 assert_false(matrix3d.is2D); | 76 assert_false(matrix3d.is2D); |
71 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1,
11, 12, 13, 14, 15, 16.6)"); | 77 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1,
11, 12, 13, 14, 15, 16.123456789)"); |
72 }, "DOMMatrixReadOnly toString() - 3D matrix"); | 78 }, "DOMMatrixReadOnly toString() - 3D matrix"); |
73 | 79 |
74 test(() => { | 80 test(() => { |
75 var identity_matrix = DOMMatrixReadOnly.fromMatrix(); | 81 var matrix3d = new DOMMatrixReadOnly([NaN, Infinity, NaN, Infinity, NaN, Infin
ity, NaN, Infinity, NaN, Infinity, NaN, Infinity, NaN, Infinity, NaN, Infinity])
; |
| 82 assert_false(matrix3d.is2D); |
| 83 assert_equals(matrix3d.toString(), "matrix3d(NaN, Infinity, NaN, Infinity, NaN
, Infinity, NaN, Infinity, NaN, Infinity, NaN, Infinity, NaN, Infinity, NaN, Inf
inity)"); |
| 84 }, "DOMMatrixReadOnly toString() - 3D matrix with NaN and Infinity"); |
| 85 |
| 86 test(() => { var identity_matrix = DOMMatrixReadOnly.fromMatrix(); |
76 assert_true(identity_matrix.is2D); | 87 assert_true(identity_matrix.is2D); |
77 assert_object_equals(identity_matrix.toJSON(), | 88 assert_object_equals(identity_matrix.toJSON(), |
78 { a : 1, b : 0, c : 0, d : 1, e : 0, f : 0, | 89 { a : 1, b : 0, c : 0, d : 1, e : 0, f : 0, |
79 is2D : true, isIdentity : true, | 90 is2D : true, isIdentity : true, |
80 m11 : 1, m12 : 0, m13 : 0, m14 : 0, | 91 m11 : 1, m12 : 0, m13 : 0, m14 : 0, |
81 m21 : 0, m22 : 1, m23 : 0, m24 : 0, | 92 m21 : 0, m22 : 1, m23 : 0, m24 : 0, |
82 m31 : 0, m32 : 0, m33 : 1, m34 : 0, | 93 m31 : 0, m32 : 0, m33 : 1, m34 : 0, |
83 m41 : 0, m42 : 0, m43 : 0, m44 : 1}); | 94 m41 : 0, m42 : 0, m43 : 0, m44 : 1}); |
84 }, "DOMMatrixReadOnly toJSON() - identity matrix"); | 95 }, "DOMMatrixReadOnly toJSON() - identity matrix"); |
85 | 96 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 test(() => { | 246 test(() => { |
236 assert_throws(new TypeError(), () => { | 247 assert_throws(new TypeError(), () => { |
237 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true}); | 248 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true}); |
238 }, "The 'is2D' property is set to true but the input matrix is 3d matrix"); | 249 }, "The 'is2D' property is set to true but the input matrix is 3d matrix"); |
239 assert_throws(new TypeError(), () => { | 250 assert_throws(new TypeError(), () => { |
240 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3}); | 251 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3}); |
241 }, "The 'a' property should equal the 'm11' property"); | 252 }, "The 'a' property should equal the 'm11' property"); |
242 }, "DOMMatrixReadOnly.fromMatrix(): Exception test"); | 253 }, "DOMMatrixReadOnly.fromMatrix(): Exception test"); |
243 | 254 |
244 </script> | 255 </script> |
OLD | NEW |