| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Geometry Interfaces: DOMMatrix</title> | 4 <title>Geometry Interfaces: DOMMatrix</title> |
| 5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="./resources/geometry-interfaces-test-helpers.js"></script> | 7 <script src="./resources/geometry-interfaces-test-helpers.js"></script> |
| 8 </head> | 8 </head> |
| 9 <body> | 9 <body> |
| 10 <script> | 10 <script> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 assert_equals(matrix.m34, 0); | 55 assert_equals(matrix.m34, 0); |
| 56 assert_equals(matrix.m41, 0); | 56 assert_equals(matrix.m41, 0); |
| 57 assert_equals(matrix.m42, 3); | 57 assert_equals(matrix.m42, 3); |
| 58 assert_equals(matrix.m43, 0); | 58 assert_equals(matrix.m43, 0); |
| 59 assert_equals(matrix.m44, 9); | 59 assert_equals(matrix.m44, 9); |
| 60 assert_false(matrix.is2D); | 60 assert_false(matrix.is2D); |
| 61 assert_false(matrix.isIdentity); | 61 assert_false(matrix.isIdentity); |
| 62 }, "DOMMatrix(other) constructor"); | 62 }, "DOMMatrix(other) constructor"); |
| 63 | 63 |
| 64 test(() => { | 64 test(() => { |
| 65 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]); | 65 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]); |
| 66 var matrix2d = DOMMatrix.fromFloat32Array(float32Array); | 66 var matrix2d = DOMMatrix.fromFloat32Array(float32Array); |
| 67 assert_true(matrix2d.is2D); | 67 assert_true(matrix2d.is2D); |
| 68 assert_equals(matrix2d.a, 1); | 68 assert_equals(matrix2d.a, 1); |
| 69 assert_equals(matrix2d.b, 2); | 69 assert_equals(matrix2d.b, 2); |
| 70 assert_equals(matrix2d.c, 3); | 70 assert_equals(matrix2d.c, 3); |
| 71 assert_equals(matrix2d.d, 4); | 71 assert_equals(matrix2d.d, 4); |
| 72 assert_equals(matrix2d.e, 5); | 72 assert_equals(matrix2d.e, 5); |
| 73 assert_equals(matrix2d.f, 6); | 73 assert_equals(matrix2d.f, 6); |
| 74 }, "DOMMatrix fromFloat32Array - 2D matrix"); | 74 }, "DOMMatrix fromFloat32Array - 2D matrix"); |
| 75 | 75 |
| 76 test(() => { | 76 test(() => { |
| 77 // 3.1 is not representable as a 32-bit float | 77 // 3.1 is not representable as a 32-bit float |
| 78 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]); | 78 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]); |
| 79 var matrix2d = DOMMatrix.fromFloat64Array(float64Array); | 79 var matrix2d = DOMMatrix.fromFloat64Array(float64Array); |
| 80 assert_true(matrix2d.is2D); | 80 assert_true(matrix2d.is2D); |
| 81 assert_equals(matrix2d.a, 1); | 81 assert_equals(matrix2d.a, 1); |
| 82 assert_equals(matrix2d.b, 2); | 82 assert_equals(matrix2d.b, 2); |
| 83 assert_equals(matrix2d.c, 3); | 83 assert_equals(matrix2d.c, 3); |
| 84 assert_equals(matrix2d.d, 3.1); | 84 assert_equals(matrix2d.d, 3.1); |
| 85 assert_equals(matrix2d.e, 4); | 85 assert_equals(matrix2d.e, 4); |
| 86 assert_equals(matrix2d.f, 5); | 86 assert_equals(matrix2d.f, 5); |
| 87 }, "DOMMatrix fromFloat64Array - 2D matrix"); | 87 }, "DOMMatrix fromFloat64Array - 2D matrix"); |
| 88 | 88 |
| 89 test(() => { | 89 test(() => { |
| 90 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16]); | 90 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
, 14, 15, 16]); |
| 91 var matrix3d = DOMMatrix.fromFloat32Array(float32Array); | 91 var matrix3d = DOMMatrix.fromFloat32Array(float32Array); |
| 92 assert_false(matrix3d.is2D); | 92 assert_false(matrix3d.is2D); |
| 93 assert_equals(matrix3d.m11, 1); | 93 assert_equals(matrix3d.m11, 1); |
| 94 assert_equals(matrix3d.m12, 2); | 94 assert_equals(matrix3d.m12, 2); |
| 95 assert_equals(matrix3d.m13, 3); | 95 assert_equals(matrix3d.m13, 3); |
| 96 assert_equals(matrix3d.m14, 4); | 96 assert_equals(matrix3d.m14, 4); |
| 97 assert_equals(matrix3d.m21, 5); | 97 assert_equals(matrix3d.m21, 5); |
| 98 assert_equals(matrix3d.m22, 6); | 98 assert_equals(matrix3d.m22, 6); |
| 99 assert_equals(matrix3d.m23, 7); | 99 assert_equals(matrix3d.m23, 7); |
| 100 assert_equals(matrix3d.m24, 8); | 100 assert_equals(matrix3d.m24, 8); |
| 101 assert_equals(matrix3d.m31, 9); | 101 assert_equals(matrix3d.m31, 9); |
| 102 assert_equals(matrix3d.m32, 10); | 102 assert_equals(matrix3d.m32, 10); |
| 103 assert_equals(matrix3d.m33, 11); | 103 assert_equals(matrix3d.m33, 11); |
| 104 assert_equals(matrix3d.m34, 12); | 104 assert_equals(matrix3d.m34, 12); |
| 105 assert_equals(matrix3d.m41, 13); | 105 assert_equals(matrix3d.m41, 13); |
| 106 assert_equals(matrix3d.m42, 14); | 106 assert_equals(matrix3d.m42, 14); |
| 107 assert_equals(matrix3d.m43, 15); | 107 assert_equals(matrix3d.m43, 15); |
| 108 assert_equals(matrix3d.m44, 16); | 108 assert_equals(matrix3d.m44, 16); |
| 109 }, "DOMMatrix fromFloat32Array - 3D matrix"); | 109 }, "DOMMatrix fromFloat32Array - 3D matrix"); |
| 110 | 110 |
| 111 test(() => { | 111 test(() => { |
| 112 // 10.1 and 16.6 are not representable as a 32-bit float | 112 // 10.1 and 16.6 are not representable as a 32-bit float |
| 113 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12
, 13, 14, 15, 16.6]); | 113 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12,
13, 14, 15, 16.6]); |
| 114 var matrix3d = DOMMatrix.fromFloat64Array(float64Array); | 114 var matrix3d = DOMMatrix.fromFloat64Array(float64Array); |
| 115 assert_false(matrix3d.is2D); | 115 assert_false(matrix3d.is2D); |
| 116 assert_equals(matrix3d.m11, 1); | 116 assert_equals(matrix3d.m11, 1); |
| 117 assert_equals(matrix3d.m12, 2); | 117 assert_equals(matrix3d.m12, 2); |
| 118 assert_equals(matrix3d.m13, 3); | 118 assert_equals(matrix3d.m13, 3); |
| 119 assert_equals(matrix3d.m14, 4); | 119 assert_equals(matrix3d.m14, 4); |
| 120 assert_equals(matrix3d.m21, 5); | 120 assert_equals(matrix3d.m21, 5); |
| 121 assert_equals(matrix3d.m22, 6); | 121 assert_equals(matrix3d.m22, 6); |
| 122 assert_equals(matrix3d.m23, 7); | 122 assert_equals(matrix3d.m23, 7); |
| 123 assert_equals(matrix3d.m24, 8); | 123 assert_equals(matrix3d.m24, 8); |
| 124 assert_equals(matrix3d.m31, 9); | 124 assert_equals(matrix3d.m31, 9); |
| 125 assert_equals(matrix3d.m32, 10.1); | 125 assert_equals(matrix3d.m32, 10.1); |
| 126 assert_equals(matrix3d.m33, 11); | 126 assert_equals(matrix3d.m33, 11); |
| 127 assert_equals(matrix3d.m34, 12); | 127 assert_equals(matrix3d.m34, 12); |
| 128 assert_equals(matrix3d.m41, 13); | 128 assert_equals(matrix3d.m41, 13); |
| 129 assert_equals(matrix3d.m42, 14); | 129 assert_equals(matrix3d.m42, 14); |
| 130 assert_equals(matrix3d.m43, 15); | 130 assert_equals(matrix3d.m43, 15); |
| 131 assert_equals(matrix3d.m44, 16.6); | 131 assert_equals(matrix3d.m44, 16.6); |
| 132 }, "DOMMatrix fromFloat64Array - 3D matrix"); | 132 }, "DOMMatrix fromFloat64Array - 3D matrix"); |
| 133 | 133 |
| 134 test(() => { | 134 test(() => { |
| 135 var matrix = new DOMMatrix(); | 135 var matrix = new DOMMatrix(); |
| 136 matrix.a = 10; | 136 matrix.a = 10; |
| 137 matrix.b = 20; | 137 matrix.b = 20; |
| 138 matrix.m24 = 2; | 138 matrix.m24 = 2; |
| 139 matrix.m33 = 3; | 139 matrix.m33 = 3; |
| 140 matrix.m42 = 3; | 140 matrix.m42 = 3; |
| 141 matrix.m44 = 9; | 141 matrix.m44 = 9; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 matrix.m33 = 0; | 173 matrix.m33 = 0; |
| 174 assert_false(matrix.is2D); | 174 assert_false(matrix.is2D); |
| 175 assert_false(matrix.isIdentity); | 175 assert_false(matrix.isIdentity); |
| 176 matrix.m31 = 0; | 176 matrix.m31 = 0; |
| 177 matrix.m33 = 1; | 177 matrix.m33 = 1; |
| 178 assert_false(matrix.is2D); | 178 assert_false(matrix.is2D); |
| 179 assert_true(matrix.isIdentity); | 179 assert_true(matrix.isIdentity); |
| 180 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before
calling setMatrixValue()."); | 180 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before
calling setMatrixValue()."); |
| 181 | 181 |
| 182 test(() => { | 182 test(() => { |
| 183 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3
2Array([1, 2, 3, 4, 5])); }, | 183 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float32A
rray([1, 2, 3, 4, 5])); }, |
| 184 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 184 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements
."); |
| 185 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6
4Array([1, 2, 3, 4, 5])); }, | 185 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float64A
rray([1, 2, 3, 4, 5])); }, |
| 186 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 186 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements
."); |
| 187 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3
2Array([1, 2, 3, 4, 5, 6 ,7])); }, | 187 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float32A
rray([1, 2, 3, 4, 5, 6 ,7])); }, |
| 188 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 188 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements
."); |
| 189 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6
4Array([1, 2, 3, 4, 5, 6 ,7])); }, | 189 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float64A
rray([1, 2, 3, 4, 5, 6 ,7])); }, |
| 190 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 190 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements
."); |
| 191 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 6"); | 191 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 6"); |
| 192 | 192 |
| 193 test(() => { | 193 test(() => { |
| 194 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3
2Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, | 194 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float32A
rray([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, |
| 195 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 195 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements
."); |
| 196 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6
4Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, | 196 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float64A
rray([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, |
| 197 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 197 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements
."); |
| 198 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3
2Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])); }, | 198 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float32A
rray([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])); }, |
| 199 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 199 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements
."); |
| 200 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6
4Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])); }, | 200 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float64A
rray([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])); }, |
| 201 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 201 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements
."); |
| 202 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 16"); | 202 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 16"); |
| 203 | 203 |
| 204 test(() => { | 204 test(() => { |
| 205 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3
2Array([])); }, | 205 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float32A
rray([])); }, |
| 206 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 206 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements
."); |
| 207 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6
4Array([])); }, | 207 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float64A
rray([])); }, |
| 208 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 208 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements
."); |
| 209 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3
2Array([1])); }, | 209 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float32A
rray([1])); }, |
| 210 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 210 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements
."); |
| 211 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6
4Array([1])); }, | 211 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float64A
rray([1])); }, |
| 212 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 212 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements
."); |
| 213 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3
2Array(65536)); }, | 213 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float32A
rray(65536)); }, |
| 214 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 214 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements
."); |
| 215 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6
4Array(65536)); }, | 215 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float64A
rray(65536)); }, |
| 216 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 216 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements
."); |
| 217 }, "DOMMatrix fromFloat*Array - invalid array size"); | 217 }, "DOMMatrix fromFloat*Array - invalid array size"); |
| 218 | 218 |
| 219 test(() => { | 219 test(() => { |
| 220 assert_identity_2d_matrix(DOMMatrix.fromMatrix()); | 220 assert_identity_2d_matrix(DOMMatrix.fromMatrix()); |
| 221 }, "DOMMatrix.fromMatrix() with no parameter."); | 221 }, "DOMMatrix.fromMatrix() with no parameter."); |
| 222 | 222 |
| 223 test(() => { | 223 test(() => { |
| 224 assert_identity_2d_matrix(DOMMatrix.fromMatrix(null)); | 224 assert_identity_2d_matrix(DOMMatrix.fromMatrix(null)); |
| 225 }, "DOMMatrix.fromMatrix() with null."); | 225 }, "DOMMatrix.fromMatrix() with null."); |
| 226 | 226 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: tru
e}); | 291 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: tru
e}); |
| 292 }, "The 'is2D' property is set to true but the input matrix is 3d matrix."
); | 292 }, "The 'is2D' property is set to true but the input matrix is 3d matrix."
); |
| 293 assert_throws(new TypeError(), () => { | 293 assert_throws(new TypeError(), () => { |
| 294 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m11: 3}); | 294 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m11: 3}); |
| 295 }, "The 'a' property should equal the 'm11' property."); | 295 }, "The 'a' property should equal the 'm11' property."); |
| 296 }, "DOMMatrix.fromMatrix(): Exception test."); | 296 }, "DOMMatrix.fromMatrix(): Exception test."); |
| 297 | 297 |
| 298 </script> | 298 </script> |
| 299 </body> | 299 </body> |
| 300 </html> | 300 </html> |
| OLD | NEW |