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 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <script> | 9 <script> |
10 | 10 |
(...skipping 43 matching lines...) Loading... |
54 assert_equals(matrix.m34, 0); | 54 assert_equals(matrix.m34, 0); |
55 assert_equals(matrix.m41, 0); | 55 assert_equals(matrix.m41, 0); |
56 assert_equals(matrix.m42, 3); | 56 assert_equals(matrix.m42, 3); |
57 assert_equals(matrix.m43, 0); | 57 assert_equals(matrix.m43, 0); |
58 assert_equals(matrix.m44, 9); | 58 assert_equals(matrix.m44, 9); |
59 assert_false(matrix.is2D); | 59 assert_false(matrix.is2D); |
60 assert_false(matrix.isIdentity); | 60 assert_false(matrix.isIdentity); |
61 }, "DOMMatrix(other) constructor"); | 61 }, "DOMMatrix(other) constructor"); |
62 | 62 |
63 test(function() { | 63 test(function() { |
| 64 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]); |
| 65 var matrix2d = DOMMatrix.fromFloat32Array(float32Array); |
| 66 assert_true(matrix2d.is2D); |
| 67 assert_equals(matrix2d.a, 1); |
| 68 assert_equals(matrix2d.b, 2); |
| 69 assert_equals(matrix2d.c, 3); |
| 70 assert_equals(matrix2d.d, 4); |
| 71 assert_equals(matrix2d.e, 5); |
| 72 assert_equals(matrix2d.f, 6); |
| 73 }, "DOMMatrix fromFloat32Array - 2D matrix"); |
| 74 |
| 75 test(function() { |
| 76 // 3.1 is not representable as a 32-bit float |
| 77 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]); |
| 78 var matrix2d = DOMMatrix.fromFloat64Array(float64Array); |
| 79 assert_true(matrix2d.is2D); |
| 80 assert_equals(matrix2d.a, 1); |
| 81 assert_equals(matrix2d.b, 2); |
| 82 assert_equals(matrix2d.c, 3); |
| 83 assert_equals(matrix2d.d, 3.1); |
| 84 assert_equals(matrix2d.e, 4); |
| 85 assert_equals(matrix2d.f, 5); |
| 86 }, "DOMMatrix fromFloat64Array - 2D matrix"); |
| 87 |
| 88 test(function() { |
| 89 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16]); |
| 90 var matrix3d = DOMMatrix.fromFloat32Array(float32Array); |
| 91 assert_false(matrix3d.is2D); |
| 92 assert_equals(matrix3d.m11, 1); |
| 93 assert_equals(matrix3d.m12, 2); |
| 94 assert_equals(matrix3d.m13, 3); |
| 95 assert_equals(matrix3d.m14, 4); |
| 96 assert_equals(matrix3d.m21, 5); |
| 97 assert_equals(matrix3d.m22, 6); |
| 98 assert_equals(matrix3d.m23, 7); |
| 99 assert_equals(matrix3d.m24, 8); |
| 100 assert_equals(matrix3d.m31, 9); |
| 101 assert_equals(matrix3d.m32, 10); |
| 102 assert_equals(matrix3d.m33, 11); |
| 103 assert_equals(matrix3d.m34, 12); |
| 104 assert_equals(matrix3d.m41, 13); |
| 105 assert_equals(matrix3d.m42, 14); |
| 106 assert_equals(matrix3d.m43, 15); |
| 107 assert_equals(matrix3d.m44, 16); |
| 108 }, "DOMMatrix fromFloat32Array - 3D matrix"); |
| 109 |
| 110 test(function() { |
| 111 // 10.1 and 16.6 are not representable as a 32-bit float |
| 112 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12
, 13, 14, 15, 16.6]); |
| 113 var matrix3d = DOMMatrix.fromFloat64Array(float64Array); |
| 114 assert_false(matrix3d.is2D); |
| 115 assert_equals(matrix3d.m11, 1); |
| 116 assert_equals(matrix3d.m12, 2); |
| 117 assert_equals(matrix3d.m13, 3); |
| 118 assert_equals(matrix3d.m14, 4); |
| 119 assert_equals(matrix3d.m21, 5); |
| 120 assert_equals(matrix3d.m22, 6); |
| 121 assert_equals(matrix3d.m23, 7); |
| 122 assert_equals(matrix3d.m24, 8); |
| 123 assert_equals(matrix3d.m31, 9); |
| 124 assert_equals(matrix3d.m32, 10.1); |
| 125 assert_equals(matrix3d.m33, 11); |
| 126 assert_equals(matrix3d.m34, 12); |
| 127 assert_equals(matrix3d.m41, 13); |
| 128 assert_equals(matrix3d.m42, 14); |
| 129 assert_equals(matrix3d.m43, 15); |
| 130 assert_equals(matrix3d.m44, 16.6); |
| 131 }, "DOMMatrix fromFloat64Array - 3D matrix"); |
| 132 |
| 133 test(function() { |
64 var matrix = new DOMMatrix(); | 134 var matrix = new DOMMatrix(); |
65 matrix.a = 10; | 135 matrix.a = 10; |
66 matrix.b = 20; | 136 matrix.b = 20; |
67 matrix.m24 = 2; | 137 matrix.m24 = 2; |
68 matrix.m33 = 3; | 138 matrix.m33 = 3; |
69 matrix.m42 = 3; | 139 matrix.m42 = 3; |
70 matrix.m44 = 9; | 140 matrix.m44 = 9; |
71 assert_equals(matrix.a, matrix.m11); | 141 assert_equals(matrix.a, matrix.m11); |
72 assert_equals(matrix.b, matrix.m12); | 142 assert_equals(matrix.b, matrix.m12); |
73 assert_equals(matrix.c, matrix.m21); | 143 assert_equals(matrix.c, matrix.m21); |
(...skipping 27 matching lines...) Loading... |
101 matrix.m31 = 1; | 171 matrix.m31 = 1; |
102 matrix.m33 = 0; | 172 matrix.m33 = 0; |
103 assert_false(matrix.is2D); | 173 assert_false(matrix.is2D); |
104 assert_false(matrix.isIdentity); | 174 assert_false(matrix.isIdentity); |
105 matrix.m31 = 0; | 175 matrix.m31 = 0; |
106 matrix.m33 = 1; | 176 matrix.m33 = 1; |
107 assert_false(matrix.is2D); | 177 assert_false(matrix.is2D); |
108 assert_true(matrix.isIdentity); | 178 assert_true(matrix.isIdentity); |
109 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before
calling setMatrixValue()."); | 179 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before
calling setMatrixValue()."); |
110 | 180 |
| 181 test(function() { |
| 182 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F
loat32Array([1, 2, 3, 4, 5])); }, |
| 183 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
| 184 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F
loat64Array([1, 2, 3, 4, 5])); }, |
| 185 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
| 186 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F
loat32Array([1, 2, 3, 4, 5, 6 ,7])); }, |
| 187 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
| 188 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F
loat64Array([1, 2, 3, 4, 5, 6 ,7])); }, |
| 189 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
| 190 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 6"); |
| 191 |
| 192 test(function() { |
| 193 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F
loat32Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, |
| 194 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
| 195 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F
loat64Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, |
| 196 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
| 197 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F
loat32Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])); }, |
| 198 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
| 199 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F
loat64Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])); }, |
| 200 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
| 201 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 16"); |
| 202 |
| 203 test(function() { |
| 204 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F
loat32Array([])); }, |
| 205 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
| 206 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F
loat64Array([])); }, |
| 207 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
| 208 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F
loat32Array([1])); }, |
| 209 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
| 210 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F
loat64Array([1])); }, |
| 211 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
| 212 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F
loat32Array(65536)); }, |
| 213 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
| 214 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F
loat64Array(65536)); }, |
| 215 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
| 216 }, "DOMMatrix fromFloat*Array - invalid array size"); |
111 </script> | 217 </script> |
112 </body> | 218 </body> |
113 </html> | 219 </html> |
OLD | NEW |