OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Geometry Interfaces: DOMMatrixReadOnly</title> | 4 <title>Geometry Interfaces: DOMMatrixReadOnly</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 </head> | 8 </head> |
8 <body> | 9 <body> |
9 <script> | 10 <script> |
10 test(function() { | 11 test(() => { |
11 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); | 12 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); |
12 assert_true(matrix2d.is2D); | 13 assert_true(matrix2d.is2D); |
13 assert_equals(matrix2d.a, 1); | 14 assert_equals(matrix2d.a, 1); |
14 assert_equals(matrix2d.b, 2); | 15 assert_equals(matrix2d.b, 2); |
15 assert_equals(matrix2d.c, 3); | 16 assert_equals(matrix2d.c, 3); |
16 assert_equals(matrix2d.d, 3.1); | 17 assert_equals(matrix2d.d, 3.1); |
17 assert_equals(matrix2d.e, 2); | 18 assert_equals(matrix2d.e, 2); |
18 assert_equals(matrix2d.f, 1); | 19 assert_equals(matrix2d.f, 1); |
19 }, "DOMMatrixReadOnly constructor - 2D matrix"); | 20 }, "DOMMatrixReadOnly constructor - 2D matrix"); |
20 | 21 |
21 test(function() { | 22 test(() => { |
22 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 1
2, 13, 14, 15, 16.6]); | 23 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 1
2, 13, 14, 15, 16.6]); |
23 assert_false(matrix3d.is2D); | 24 assert_false(matrix3d.is2D); |
24 assert_equals(matrix3d.m11, 1); | 25 assert_equals(matrix3d.m11, 1); |
25 assert_equals(matrix3d.m12, 2); | 26 assert_equals(matrix3d.m12, 2); |
26 assert_equals(matrix3d.m13, 3); | 27 assert_equals(matrix3d.m13, 3); |
27 assert_equals(matrix3d.m14, 4); | 28 assert_equals(matrix3d.m14, 4); |
28 assert_equals(matrix3d.m21, 5); | 29 assert_equals(matrix3d.m21, 5); |
29 assert_equals(matrix3d.m22, 6); | 30 assert_equals(matrix3d.m22, 6); |
30 assert_equals(matrix3d.m23, 7); | 31 assert_equals(matrix3d.m23, 7); |
31 assert_equals(matrix3d.m24, 8); | 32 assert_equals(matrix3d.m24, 8); |
32 assert_equals(matrix3d.m31, 9); | 33 assert_equals(matrix3d.m31, 9); |
33 assert_equals(matrix3d.m32, 10.1); | 34 assert_equals(matrix3d.m32, 10.1); |
34 assert_equals(matrix3d.m33, 11); | 35 assert_equals(matrix3d.m33, 11); |
35 assert_equals(matrix3d.m34, 12); | 36 assert_equals(matrix3d.m34, 12); |
36 assert_equals(matrix3d.m41, 13); | 37 assert_equals(matrix3d.m41, 13); |
37 assert_equals(matrix3d.m42, 14); | 38 assert_equals(matrix3d.m42, 14); |
38 assert_equals(matrix3d.m43, 15); | 39 assert_equals(matrix3d.m43, 15); |
39 assert_equals(matrix3d.m44, 16.6); | 40 assert_equals(matrix3d.m44, 16.6); |
40 }, "DOMMatrixReadOnly constructor - 3D matrix"); | 41 }, "DOMMatrixReadOnly constructor - 3D matrix"); |
41 | 42 |
42 test(function() { | 43 test(() => { |
43 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]); | 44 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]); |
44 var matrix2d = DOMMatrixReadOnly.fromFloat32Array(float32Array); | 45 var matrix2d = DOMMatrixReadOnly.fromFloat32Array(float32Array); |
45 assert_true(matrix2d.is2D); | 46 assert_true(matrix2d.is2D); |
46 assert_equals(matrix2d.a, 1); | 47 assert_equals(matrix2d.a, 1); |
47 assert_equals(matrix2d.b, 2); | 48 assert_equals(matrix2d.b, 2); |
48 assert_equals(matrix2d.c, 3); | 49 assert_equals(matrix2d.c, 3); |
49 assert_equals(matrix2d.d, 4); | 50 assert_equals(matrix2d.d, 4); |
50 assert_equals(matrix2d.e, 5); | 51 assert_equals(matrix2d.e, 5); |
51 assert_equals(matrix2d.f, 6); | 52 assert_equals(matrix2d.f, 6); |
52 }, "DOMMatrixReadOnly fromFloat32Array - 2D matrix"); | 53 }, "DOMMatrixReadOnly fromFloat32Array - 2D matrix"); |
53 | 54 |
54 test(function() { | 55 test(() => { |
55 // 3.1 is not representable as a 32-bit float | 56 // 3.1 is not representable as a 32-bit float |
56 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]); | 57 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]); |
57 var matrix2d = DOMMatrixReadOnly.fromFloat64Array(float64Array); | 58 var matrix2d = DOMMatrixReadOnly.fromFloat64Array(float64Array); |
58 assert_true(matrix2d.is2D); | 59 assert_true(matrix2d.is2D); |
59 assert_equals(matrix2d.a, 1); | 60 assert_equals(matrix2d.a, 1); |
60 assert_equals(matrix2d.b, 2); | 61 assert_equals(matrix2d.b, 2); |
61 assert_equals(matrix2d.c, 3); | 62 assert_equals(matrix2d.c, 3); |
62 assert_equals(matrix2d.d, 3.1); | 63 assert_equals(matrix2d.d, 3.1); |
63 assert_equals(matrix2d.e, 4); | 64 assert_equals(matrix2d.e, 4); |
64 assert_equals(matrix2d.f, 5); | 65 assert_equals(matrix2d.f, 5); |
65 }, "DOMMatrixReadOnly fromFloat64Array - 2D matrix"); | 66 }, "DOMMatrixReadOnly fromFloat64Array - 2D matrix"); |
66 | 67 |
67 test(function() { | 68 test(() => { |
68 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16]); | 69 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16]); |
69 var matrix3d = DOMMatrixReadOnly.fromFloat32Array(float32Array); | 70 var matrix3d = DOMMatrixReadOnly.fromFloat32Array(float32Array); |
70 assert_false(matrix3d.is2D); | 71 assert_false(matrix3d.is2D); |
71 assert_equals(matrix3d.m11, 1); | 72 assert_equals(matrix3d.m11, 1); |
72 assert_equals(matrix3d.m12, 2); | 73 assert_equals(matrix3d.m12, 2); |
73 assert_equals(matrix3d.m13, 3); | 74 assert_equals(matrix3d.m13, 3); |
74 assert_equals(matrix3d.m14, 4); | 75 assert_equals(matrix3d.m14, 4); |
75 assert_equals(matrix3d.m21, 5); | 76 assert_equals(matrix3d.m21, 5); |
76 assert_equals(matrix3d.m22, 6); | 77 assert_equals(matrix3d.m22, 6); |
77 assert_equals(matrix3d.m23, 7); | 78 assert_equals(matrix3d.m23, 7); |
78 assert_equals(matrix3d.m24, 8); | 79 assert_equals(matrix3d.m24, 8); |
79 assert_equals(matrix3d.m31, 9); | 80 assert_equals(matrix3d.m31, 9); |
80 assert_equals(matrix3d.m32, 10); | 81 assert_equals(matrix3d.m32, 10); |
81 assert_equals(matrix3d.m33, 11); | 82 assert_equals(matrix3d.m33, 11); |
82 assert_equals(matrix3d.m34, 12); | 83 assert_equals(matrix3d.m34, 12); |
83 assert_equals(matrix3d.m41, 13); | 84 assert_equals(matrix3d.m41, 13); |
84 assert_equals(matrix3d.m42, 14); | 85 assert_equals(matrix3d.m42, 14); |
85 assert_equals(matrix3d.m43, 15); | 86 assert_equals(matrix3d.m43, 15); |
86 assert_equals(matrix3d.m44, 16); | 87 assert_equals(matrix3d.m44, 16); |
87 }, "DOMMatrixReadOnly fromFloat32Array - 3D matrix"); | 88 }, "DOMMatrixReadOnly fromFloat32Array - 3D matrix"); |
88 | 89 |
89 test(function() { | 90 test(() => { |
90 // 10.1 and 16.6 are not representable as a 32-bit float | 91 // 10.1 and 16.6 are not representable as a 32-bit float |
91 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12
, 13, 14, 15, 16.6]); | 92 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12
, 13, 14, 15, 16.6]); |
92 var matrix3d = DOMMatrixReadOnly.fromFloat64Array(float64Array); | 93 var matrix3d = DOMMatrixReadOnly.fromFloat64Array(float64Array); |
93 assert_false(matrix3d.is2D); | 94 assert_false(matrix3d.is2D); |
94 assert_equals(matrix3d.m11, 1); | 95 assert_equals(matrix3d.m11, 1); |
95 assert_equals(matrix3d.m12, 2); | 96 assert_equals(matrix3d.m12, 2); |
96 assert_equals(matrix3d.m13, 3); | 97 assert_equals(matrix3d.m13, 3); |
97 assert_equals(matrix3d.m14, 4); | 98 assert_equals(matrix3d.m14, 4); |
98 assert_equals(matrix3d.m21, 5); | 99 assert_equals(matrix3d.m21, 5); |
99 assert_equals(matrix3d.m22, 6); | 100 assert_equals(matrix3d.m22, 6); |
100 assert_equals(matrix3d.m23, 7); | 101 assert_equals(matrix3d.m23, 7); |
101 assert_equals(matrix3d.m24, 8); | 102 assert_equals(matrix3d.m24, 8); |
102 assert_equals(matrix3d.m31, 9); | 103 assert_equals(matrix3d.m31, 9); |
103 assert_equals(matrix3d.m32, 10.1); | 104 assert_equals(matrix3d.m32, 10.1); |
104 assert_equals(matrix3d.m33, 11); | 105 assert_equals(matrix3d.m33, 11); |
105 assert_equals(matrix3d.m34, 12); | 106 assert_equals(matrix3d.m34, 12); |
106 assert_equals(matrix3d.m41, 13); | 107 assert_equals(matrix3d.m41, 13); |
107 assert_equals(matrix3d.m42, 14); | 108 assert_equals(matrix3d.m42, 14); |
108 assert_equals(matrix3d.m43, 15); | 109 assert_equals(matrix3d.m43, 15); |
109 assert_equals(matrix3d.m44, 16.6); | 110 assert_equals(matrix3d.m44, 16.6); |
110 }, "DOMMatrixReadOnly fromFloat64Array - 3D matrix"); | 111 }, "DOMMatrixReadOnly fromFloat64Array - 3D matrix"); |
111 | 112 |
112 test(function() { | 113 test(() => { |
113 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); | 114 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); |
114 assert_true(matrix2d.is2D); | 115 assert_true(matrix2d.is2D); |
115 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1)"); | 116 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1)"); |
116 }, "DOMMatrixReadOnly toString() - 2D matrix"); | 117 }, "DOMMatrixReadOnly toString() - 2D matrix"); |
117 | 118 |
118 test(function() { | 119 test(() => { |
119 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 1
2, 13, 14, 15, 16.6]); | 120 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 1
2, 13, 14, 15, 16.6]); |
120 assert_false(matrix3d.is2D); | 121 assert_false(matrix3d.is2D); |
121 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1
, 11, 12, 13, 14, 15, 16.6)"); | 122 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1
, 11, 12, 13, 14, 15, 16.6)"); |
122 }, "DOMMatrixReadOnly toString() - 3D matrix"); | 123 }, "DOMMatrixReadOnly toString() - 3D matrix"); |
123 | 124 |
124 test(function() { | 125 test(() => { |
125 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly(1, 2, 3, 4
, 5, 6); }, | 126 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly(1, 2, 3, 4, 5,
6); }, |
126 "DOMMatrixReadOnly constructor only accepts 1 argument"); | 127 "DOMMatrixReadOnly constructor only accepts 1 argument"); |
127 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly("myString"
); }, | 128 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly("myString"); }, |
128 "DOMMatrixReadOnly constructor only accepts 1 number sequence"); | 129 "DOMMatrixReadOnly constructor only accepts 1 number sequence"); |
129 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly([1, 2, 3])
; }, | 130 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly([1, 2, 3]); }, |
130 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6
or 16 elements."); | 131 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6
or 16 elements."); |
131 }, "DOMMatrixReadOnly constructor - invalid arguments"); | 132 }, "DOMMatrixReadOnly constructor - invalid arguments"); |
132 | 133 |
133 test(function() { | 134 test(() => { |
134 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr
ay(new Float32Array([1, 2, 3, 4, 5])); }, | 135 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(ne
w Float32Array([1, 2, 3, 4, 5])); }, |
135 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 136 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
136 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr
ay(new Float64Array([1, 2, 3, 4, 5])); }, | 137 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat64Array(ne
w Float64Array([1, 2, 3, 4, 5])); }, |
137 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 138 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
138 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr
ay(new Float32Array([1, 2, 3, 4, 5, 6 ,7])); }, | 139 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(ne
w Float32Array([1, 2, 3, 4, 5, 6 ,7])); }, |
139 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 140 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
140 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr
ay(new Float64Array([1, 2, 3, 4, 5, 6 ,7])); }, | 141 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat64Array(ne
w Float64Array([1, 2, 3, 4, 5, 6 ,7])); }, |
141 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 142 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
142 }, "DOMMatrixReadOnly fromFloat*Array - invalid array size of nearby 6"); | 143 }, "DOMMatrixReadOnly fromFloat*Array - invalid array size of nearby 6"); |
143 | 144 |
144 test(function() { | 145 test(() => { |
145 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr
ay(new Float32Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, | 146 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(ne
w Float32Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, |
146 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 147 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
147 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr
ay(new Float64Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, | 148 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat64Array(ne
w Float64Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); }, |
148 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 149 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
149 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr
ay(new Float32Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])
); }, | 150 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(ne
w Float32Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])); }, |
150 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 151 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
151 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr
ay(new Float64Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])
); }, | 152 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat64Array(ne
w Float64Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])); }, |
152 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 153 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
153 }, "DOMMatrixReadOnly fromFloat*Array - invalid array size of nearby 16"); | 154 }, "DOMMatrixReadOnly fromFloat*Array - invalid array size of nearby 16"); |
154 | 155 |
155 test(function() { | 156 test(() => { |
156 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr
ay(new Float32Array([])); }, | 157 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(ne
w Float32Array([])); }, |
157 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 158 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
158 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr
ay(new Float64Array([])); }, | 159 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat64Array(ne
w Float64Array([])); }, |
159 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 160 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
160 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr
ay(new Float32Array([1])); }, | 161 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(ne
w Float32Array([1])); }, |
161 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 162 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
162 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr
ay(new Float64Array([1])); }, | 163 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat64Array(ne
w Float64Array([1])); }, |
163 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 164 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
164 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr
ay(new Float32Array(65536)); }, | 165 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(ne
w Float32Array(65536)); }, |
165 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); | 166 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16
elements."); |
166 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr
ay(new Float64Array(65536)); }, | 167 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat64Array(ne
w Float64Array(65536)); }, |
167 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); | 168 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16
elements."); |
168 }, "DOMMatrixReadOnly fromFloat*Array - invalid array size"); | 169 }, "DOMMatrixReadOnly fromFloat*Array - invalid array size"); |
169 | 170 |
| 171 test(() => { |
| 172 var matrix = DOMMatrixReadOnly.fromMatrix(); |
| 173 assert_identity_2d_matrix(matrix); |
| 174 }, "DOMMatrixReadOnly.fromMatrix() with no parameter."); |
| 175 |
| 176 test(() => { |
| 177 var matrix = DOMMatrixReadOnly.fromMatrix(null); |
| 178 assert_identity_2d_matrix(matrix); |
| 179 }, "DOMMatrixReadOnly.fromMatrix() with null."); |
| 180 |
| 181 test(() => { |
| 182 var matrix = DOMMatrixReadOnly.fromMatrix(undefined); |
| 183 assert_identity_2d_matrix(matrix); |
| 184 }, "DOMMatrixReadOnly.fromMatrix() with undefined."); |
| 185 |
| 186 test(() => { |
| 187 var matrix = DOMMatrixReadOnly.fromMatrix({}); |
| 188 assert_identity_2d_matrix(matrix); |
| 189 }, "DOMMatrixReadOnly.fromMatrix() with empty object."); |
| 190 |
| 191 test(() => { |
| 192 var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}
); |
| 193 assert_2d_matrix_equals(matrix, { |
| 194 m11: 1, m12: 2, |
| 195 m21: 3, m22: 4, |
| 196 m41: 5, m42: 6, |
| 197 isIdentity: false |
| 198 }); |
| 199 }, "DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}) should cr
eate a 2D DOMMatrixReadOnly."); |
| 200 |
| 201 test(() => { |
| 202 var matrix = DOMMatrixReadOnly.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23
: 5, m43: 6}); |
| 203 assert_3d_matrix_equals(matrix, { |
| 204 m11: 1, m12: 0, m13: 0, m14: 0, |
| 205 m21: 0, m22: 2, m23: 5, m24: 0, |
| 206 m31: 0, m32: 0, m33: 3, m34: 0, |
| 207 m41: 0, m42: 0, m43: 6, m44: 4, |
| 208 isIdentity: false |
| 209 }); |
| 210 }, "DOMMatrixReadOnly.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6
}) should create a 3D DOMMatrixReadOnly."); |
| 211 |
| 212 test(() => { |
| 213 var matrix = DOMMatrixReadOnly.fromMatrix({a: 7, c: 9}); |
| 214 assert_2d_matrix_equals(matrix, { |
| 215 m11: 7, m12: 0, |
| 216 m21: 9, m22: 1, |
| 217 m41: 0, m42: 0, |
| 218 isIdentity: false |
| 219 }); |
| 220 }, "If 2d related properties don't be set, should set to fallback."); |
| 221 |
| 222 test(() => { |
| 223 var matrix = DOMMatrixReadOnly.fromMatrix({ |
| 224 m11: NaN, m12: NaN, m13: NaN, m14: NaN, |
| 225 m21: NaN, m22: NaN, m23: NaN, m24: NaN, |
| 226 m31: NaN, m32: NaN, m33: NaN, m34: NaN, |
| 227 m41: NaN, m42: NaN, m43: NaN, m44: NaN, |
| 228 is2D: false |
| 229 }); |
| 230 assert_equals(matrix.a, matrix.m11); |
| 231 assert_equals(matrix.b, matrix.m12); |
| 232 assert_equals(matrix.c, matrix.m21); |
| 233 assert_equals(matrix.d, matrix.m22); |
| 234 assert_equals(matrix.e, matrix.m41); |
| 235 assert_equals(matrix.f, matrix.m42); |
| 236 assert_3d_matrix_equals(matrix, { |
| 237 m11: NaN, m12: NaN, m13: NaN, m14: NaN, |
| 238 m21: NaN, m22: NaN, m23: NaN, m24: NaN, |
| 239 m31: NaN, m32: NaN, m33: NaN, m34: NaN, |
| 240 m41: NaN, m42: NaN, m43: NaN, m44: NaN, |
| 241 isIdentity: false, is2D: false |
| 242 }); |
| 243 }, "DOMMatrixReadOnly.fromMatrix(): NaN test"); |
| 244 |
| 245 test(() => { |
| 246 assert_throws(new TypeError(), () => { |
| 247 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true}); |
| 248 }, "The 'is2D' property is set to true but the input matrix is 3d matrix."
); |
| 249 assert_throws(new TypeError(), () => { |
| 250 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3}); |
| 251 }, "The 'a' property should equal the 'm11' property."); |
| 252 }, "DOMMatrixReadOnly.fromMatrix(): Exception test."); |
| 253 |
170 </script> | 254 </script> |
171 </body> | 255 </body> |
172 </html> | 256 </html> |
OLD | NEW |