| 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 28 matching lines...) Expand all Loading... |
| 39 }, "DOMMatrixReadOnly fromFloat32Array - 3D matrix"); | 39 }, "DOMMatrixReadOnly fromFloat32Array - 3D matrix"); |
| 40 | 40 |
| 41 test(() => { | 41 test(() => { |
| 42 // 10.1 and 16.6 are not representable as a 32-bit float | 42 // 10.1 and 16.6 are not representable as a 32-bit float |
| 43 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12,
13, 14, 15, 16.6]); | 43 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12,
13, 14, 15, 16.6]); |
| 44 var matrix3d = DOMMatrixReadOnly.fromFloat64Array(float64Array); | 44 var matrix3d = DOMMatrixReadOnly.fromFloat64Array(float64Array); |
| 45 assert_3d_matrix_equals(matrix3d, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13
, 14, 15, 16.6]); | 45 assert_3d_matrix_equals(matrix3d, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13
, 14, 15, 16.6]); |
| 46 }, "DOMMatrixReadOnly fromFloat64Array - 3D matrix"); | 46 }, "DOMMatrixReadOnly fromFloat64Array - 3D matrix"); |
| 47 | 47 |
| 48 test(() => { | 48 test(() => { |
| 49 var matrix = new DOMMatrixReadOnly(""); |
| 50 assert_identity_2d_matrix(matrix); |
| 51 }, "DOMMatrixReadOnly(transformList) - emptyString"); |
| 52 |
| 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)"); |
| 55 var expectedMatrix = new DOMMatrixReadOnly(); |
| 56 expectedMatrix = expectedMatrix.multiply(new DOMMatrixReadOnly([1.0, 2.0, 3.0,
4.0, 5.0, 6.0])) |
| 57 expectedMatrix = expectedMatrix.translate(44, 55) |
| 58 expectedMatrix = expectedMatrix.skewX(30); |
| 59 assert_matrix_almost_equals(matrix, expectedMatrix); |
| 60 }, "DOMMatrixReadOnly(transformList) - transformList"); |
| 61 |
| 62 test(() => { |
| 49 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); | 63 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); |
| 50 assert_true(matrix2d.is2D); | 64 assert_true(matrix2d.is2D); |
| 51 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)"); |
| 52 }, "DOMMatrixReadOnly toString() - 2D matrix"); | 66 }, "DOMMatrixReadOnly toString() - 2D matrix"); |
| 53 | 67 |
| 54 test(() => { | 68 test(() => { |
| 55 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12,
13, 14, 15, 16.6]); | 69 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12,
13, 14, 15, 16.6]); |
| 56 assert_false(matrix3d.is2D); | 70 assert_false(matrix3d.is2D); |
| 57 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1,
11, 12, 13, 14, 15, 16.6)"); | 71 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1,
11, 12, 13, 14, 15, 16.6)"); |
| 58 }, "DOMMatrixReadOnly toString() - 3D matrix"); | 72 }, "DOMMatrixReadOnly toString() - 3D matrix"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 87 assert_object_equals(matrix3d.toJSON(), | 101 assert_object_equals(matrix3d.toJSON(), |
| 88 { a : 1, b : 2, c : 5, d : 6, e : 13, f : 14, | 102 { a : 1, b : 2, c : 5, d : 6, e : 13, f : 14, |
| 89 is2D : false, isIdentity : false, | 103 is2D : false, isIdentity : false, |
| 90 m11 : 1, m12 : 2, m13 : 3, m14 : 4, | 104 m11 : 1, m12 : 2, m13 : 3, m14 : 4, |
| 91 m21 : 5, m22 : 6, m23 : 7, m24 : 8, | 105 m21 : 5, m22 : 6, m23 : 7, m24 : 8, |
| 92 m31 : 9, m32 : 10.1, m33 : 11, m34 : 12, | 106 m31 : 9, m32 : 10.1, m33 : 11, m34 : 12, |
| 93 m41 : 13, m42 : 14, m43 : 15, m44 : 16.6}); | 107 m41 : 13, m42 : 14, m43 : 15, m44 : 16.6}); |
| 94 }, "DOMMatrixReadOnly toJSON() - 3D matrix"); | 108 }, "DOMMatrixReadOnly toJSON() - 3D matrix"); |
| 95 | 109 |
| 96 test(() => { | 110 test(() => { |
| 97 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly(1, 2, 3, 4, 5, 6)
; }, | 111 assert_throws(new SyntaxError(), () => { new DOMMatrixReadOnly(1, 2, 3, 4, 5,
6); }, |
| 98 "DOMMatrixReadOnly constructor only accepts 1 argument"); | 112 "DOMMatrixReadOnly(transformList) can't parse unknown keyword - DOMMatrixRea
dOnly(1, 2, 3, 4, 5, 6) is same DOMMatrixReadOnly('1')"); |
| 99 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly("myString"); }, | 113 assert_throws(new SyntaxError(), () => { new DOMMatrixReadOnly("myString"); }, |
| 100 "DOMMatrixReadOnly constructor only accepts 1 number sequence"); | 114 "DOMMatrixReadOnly(transformList) can't parse unknown keyword."); |
| 101 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly([1, 2, 3]); }, | 115 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly([1, 2, 3]); }, |
| 102 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 e
lements."); | 116 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 e
lements."); |
| 103 }, "DOMMatrixReadOnly constructor - invalid arguments"); | 117 }, "DOMMatrixReadOnly constructor - invalid arguments"); |
| 104 | 118 |
| 105 test(() => { | 119 test(() => { |
| 106 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(new
Float32Array([1, 2, 3, 4, 5])); }, | 120 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(new
Float32Array([1, 2, 3, 4, 5])); }, |
| 107 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements
."); | 121 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements
."); |
| 108 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat64Array(new
Float64Array([1, 2, 3, 4, 5])); }, | 122 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat64Array(new
Float64Array([1, 2, 3, 4, 5])); }, |
| 109 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements
."); | 123 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements
."); |
| 110 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(new
Float32Array([1, 2, 3, 4, 5, 6 ,7])); }, | 124 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(new
Float32Array([1, 2, 3, 4, 5, 6 ,7])); }, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 test(() => { | 202 test(() => { |
| 189 assert_throws(new TypeError(), () => { | 203 assert_throws(new TypeError(), () => { |
| 190 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true}); | 204 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true}); |
| 191 }, "The 'is2D' property is set to true but the input matrix is 3d matrix."); | 205 }, "The 'is2D' property is set to true but the input matrix is 3d matrix."); |
| 192 assert_throws(new TypeError(), () => { | 206 assert_throws(new TypeError(), () => { |
| 193 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3}); | 207 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3}); |
| 194 }, "The 'a' property should equal the 'm11' property."); | 208 }, "The 'a' property should equal the 'm11' property."); |
| 195 }, "DOMMatrixReadOnly.fromMatrix(): Exception test."); | 209 }, "DOMMatrixReadOnly.fromMatrix(): Exception test."); |
| 196 | 210 |
| 197 </script> | 211 </script> |
| OLD | NEW |