Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix.html

Issue 2283363003: GeometryInterface: Add DOMMatrixInit and fromMatrix(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 </head> 8 </head>
8 <body> 9 <body>
9 <script> 10 <script>
10 11
11 test(function() { 12 test(() => {
12 var matrix = new DOMMatrix(); 13 var matrix = new DOMMatrix();
13 assert_equals(matrix.m11, 1); 14 assert_equals(matrix.m11, 1);
14 assert_equals(matrix.m12, 0); 15 assert_equals(matrix.m12, 0);
15 assert_equals(matrix.m13, 0); 16 assert_equals(matrix.m13, 0);
16 assert_equals(matrix.m14, 0); 17 assert_equals(matrix.m14, 0);
17 assert_equals(matrix.m21, 0); 18 assert_equals(matrix.m21, 0);
18 assert_equals(matrix.m22, 1); 19 assert_equals(matrix.m22, 1);
19 assert_equals(matrix.m23, 0); 20 assert_equals(matrix.m23, 0);
20 assert_equals(matrix.m24, 0); 21 assert_equals(matrix.m24, 0);
21 assert_equals(matrix.m31, 0); 22 assert_equals(matrix.m31, 0);
22 assert_equals(matrix.m32, 0); 23 assert_equals(matrix.m32, 0);
23 assert_equals(matrix.m33, 1); 24 assert_equals(matrix.m33, 1);
24 assert_equals(matrix.m34, 0); 25 assert_equals(matrix.m34, 0);
25 assert_equals(matrix.m41, 0); 26 assert_equals(matrix.m41, 0);
26 assert_equals(matrix.m42, 0); 27 assert_equals(matrix.m42, 0);
27 assert_equals(matrix.m43, 0); 28 assert_equals(matrix.m43, 0);
28 assert_equals(matrix.m44, 1); 29 assert_equals(matrix.m44, 1);
29 assert_true(matrix.is2D); 30 assert_true(matrix.is2D);
30 assert_true(matrix.isIdentity); 31 assert_true(matrix.isIdentity);
31 }, "DOMMatrix() constructor"); 32 }, "DOMMatrix() constructor");
32 33
33 test(function() { 34 test(() => {
34 var other = new DOMMatrix(); 35 var other = new DOMMatrix();
35 other.m11 = 10; 36 other.m11 = 10;
36 other.m12 = 20; 37 other.m12 = 20;
37 other.m24 = 2; 38 other.m24 = 2;
38 other.m33 = 3; 39 other.m33 = 3;
39 other.m42 = 3; 40 other.m42 = 3;
40 other.m44 = 9; 41 other.m44 = 9;
41 42
42 var matrix = new DOMMatrix(other); 43 var matrix = new DOMMatrix(other);
43 assert_equals(matrix.m11, 10); 44 assert_equals(matrix.m11, 10);
44 assert_equals(matrix.m12, 20); 45 assert_equals(matrix.m12, 20);
45 assert_equals(matrix.m13, 0); 46 assert_equals(matrix.m13, 0);
46 assert_equals(matrix.m14, 0); 47 assert_equals(matrix.m14, 0);
47 assert_equals(matrix.m21, 0); 48 assert_equals(matrix.m21, 0);
48 assert_equals(matrix.m22, 1); 49 assert_equals(matrix.m22, 1);
49 assert_equals(matrix.m23, 0); 50 assert_equals(matrix.m23, 0);
50 assert_equals(matrix.m24, 2); 51 assert_equals(matrix.m24, 2);
51 assert_equals(matrix.m31, 0); 52 assert_equals(matrix.m31, 0);
52 assert_equals(matrix.m32, 0); 53 assert_equals(matrix.m32, 0);
53 assert_equals(matrix.m33, 3); 54 assert_equals(matrix.m33, 3);
54 assert_equals(matrix.m34, 0); 55 assert_equals(matrix.m34, 0);
55 assert_equals(matrix.m41, 0); 56 assert_equals(matrix.m41, 0);
56 assert_equals(matrix.m42, 3); 57 assert_equals(matrix.m42, 3);
57 assert_equals(matrix.m43, 0); 58 assert_equals(matrix.m43, 0);
58 assert_equals(matrix.m44, 9); 59 assert_equals(matrix.m44, 9);
59 assert_false(matrix.is2D); 60 assert_false(matrix.is2D);
60 assert_false(matrix.isIdentity); 61 assert_false(matrix.isIdentity);
61 }, "DOMMatrix(other) constructor"); 62 }, "DOMMatrix(other) constructor");
62 63
63 test(function() { 64 test(() => {
64 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]); 65 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]);
65 var matrix2d = DOMMatrix.fromFloat32Array(float32Array); 66 var matrix2d = DOMMatrix.fromFloat32Array(float32Array);
66 assert_true(matrix2d.is2D); 67 assert_true(matrix2d.is2D);
67 assert_equals(matrix2d.a, 1); 68 assert_equals(matrix2d.a, 1);
68 assert_equals(matrix2d.b, 2); 69 assert_equals(matrix2d.b, 2);
69 assert_equals(matrix2d.c, 3); 70 assert_equals(matrix2d.c, 3);
70 assert_equals(matrix2d.d, 4); 71 assert_equals(matrix2d.d, 4);
71 assert_equals(matrix2d.e, 5); 72 assert_equals(matrix2d.e, 5);
72 assert_equals(matrix2d.f, 6); 73 assert_equals(matrix2d.f, 6);
73 }, "DOMMatrix fromFloat32Array - 2D matrix"); 74 }, "DOMMatrix fromFloat32Array - 2D matrix");
74 75
75 test(function() { 76 test(() => {
76 // 3.1 is not representable as a 32-bit float 77 // 3.1 is not representable as a 32-bit float
77 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]); 78 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]);
78 var matrix2d = DOMMatrix.fromFloat64Array(float64Array); 79 var matrix2d = DOMMatrix.fromFloat64Array(float64Array);
79 assert_true(matrix2d.is2D); 80 assert_true(matrix2d.is2D);
80 assert_equals(matrix2d.a, 1); 81 assert_equals(matrix2d.a, 1);
81 assert_equals(matrix2d.b, 2); 82 assert_equals(matrix2d.b, 2);
82 assert_equals(matrix2d.c, 3); 83 assert_equals(matrix2d.c, 3);
83 assert_equals(matrix2d.d, 3.1); 84 assert_equals(matrix2d.d, 3.1);
84 assert_equals(matrix2d.e, 4); 85 assert_equals(matrix2d.e, 4);
85 assert_equals(matrix2d.f, 5); 86 assert_equals(matrix2d.f, 5);
86 }, "DOMMatrix fromFloat64Array - 2D matrix"); 87 }, "DOMMatrix fromFloat64Array - 2D matrix");
87 88
88 test(function() { 89 test(() => {
89 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]);
90 var matrix3d = DOMMatrix.fromFloat32Array(float32Array); 91 var matrix3d = DOMMatrix.fromFloat32Array(float32Array);
91 assert_false(matrix3d.is2D); 92 assert_false(matrix3d.is2D);
92 assert_equals(matrix3d.m11, 1); 93 assert_equals(matrix3d.m11, 1);
93 assert_equals(matrix3d.m12, 2); 94 assert_equals(matrix3d.m12, 2);
94 assert_equals(matrix3d.m13, 3); 95 assert_equals(matrix3d.m13, 3);
95 assert_equals(matrix3d.m14, 4); 96 assert_equals(matrix3d.m14, 4);
96 assert_equals(matrix3d.m21, 5); 97 assert_equals(matrix3d.m21, 5);
97 assert_equals(matrix3d.m22, 6); 98 assert_equals(matrix3d.m22, 6);
98 assert_equals(matrix3d.m23, 7); 99 assert_equals(matrix3d.m23, 7);
99 assert_equals(matrix3d.m24, 8); 100 assert_equals(matrix3d.m24, 8);
100 assert_equals(matrix3d.m31, 9); 101 assert_equals(matrix3d.m31, 9);
101 assert_equals(matrix3d.m32, 10); 102 assert_equals(matrix3d.m32, 10);
102 assert_equals(matrix3d.m33, 11); 103 assert_equals(matrix3d.m33, 11);
103 assert_equals(matrix3d.m34, 12); 104 assert_equals(matrix3d.m34, 12);
104 assert_equals(matrix3d.m41, 13); 105 assert_equals(matrix3d.m41, 13);
105 assert_equals(matrix3d.m42, 14); 106 assert_equals(matrix3d.m42, 14);
106 assert_equals(matrix3d.m43, 15); 107 assert_equals(matrix3d.m43, 15);
107 assert_equals(matrix3d.m44, 16); 108 assert_equals(matrix3d.m44, 16);
108 }, "DOMMatrix fromFloat32Array - 3D matrix"); 109 }, "DOMMatrix fromFloat32Array - 3D matrix");
109 110
110 test(function() { 111 test(() => {
111 // 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
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 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 var matrix3d = DOMMatrix.fromFloat64Array(float64Array);
114 assert_false(matrix3d.is2D); 115 assert_false(matrix3d.is2D);
115 assert_equals(matrix3d.m11, 1); 116 assert_equals(matrix3d.m11, 1);
116 assert_equals(matrix3d.m12, 2); 117 assert_equals(matrix3d.m12, 2);
117 assert_equals(matrix3d.m13, 3); 118 assert_equals(matrix3d.m13, 3);
118 assert_equals(matrix3d.m14, 4); 119 assert_equals(matrix3d.m14, 4);
119 assert_equals(matrix3d.m21, 5); 120 assert_equals(matrix3d.m21, 5);
120 assert_equals(matrix3d.m22, 6); 121 assert_equals(matrix3d.m22, 6);
121 assert_equals(matrix3d.m23, 7); 122 assert_equals(matrix3d.m23, 7);
122 assert_equals(matrix3d.m24, 8); 123 assert_equals(matrix3d.m24, 8);
123 assert_equals(matrix3d.m31, 9); 124 assert_equals(matrix3d.m31, 9);
124 assert_equals(matrix3d.m32, 10.1); 125 assert_equals(matrix3d.m32, 10.1);
125 assert_equals(matrix3d.m33, 11); 126 assert_equals(matrix3d.m33, 11);
126 assert_equals(matrix3d.m34, 12); 127 assert_equals(matrix3d.m34, 12);
127 assert_equals(matrix3d.m41, 13); 128 assert_equals(matrix3d.m41, 13);
128 assert_equals(matrix3d.m42, 14); 129 assert_equals(matrix3d.m42, 14);
129 assert_equals(matrix3d.m43, 15); 130 assert_equals(matrix3d.m43, 15);
130 assert_equals(matrix3d.m44, 16.6); 131 assert_equals(matrix3d.m44, 16.6);
131 }, "DOMMatrix fromFloat64Array - 3D matrix"); 132 }, "DOMMatrix fromFloat64Array - 3D matrix");
132 133
133 test(function() { 134 test(() => {
134 var matrix = new DOMMatrix(); 135 var matrix = new DOMMatrix();
135 matrix.a = 10; 136 matrix.a = 10;
136 matrix.b = 20; 137 matrix.b = 20;
137 matrix.m24 = 2; 138 matrix.m24 = 2;
138 matrix.m33 = 3; 139 matrix.m33 = 3;
139 matrix.m42 = 3; 140 matrix.m42 = 3;
140 matrix.m44 = 9; 141 matrix.m44 = 9;
141 assert_equals(matrix.a, matrix.m11); 142 assert_equals(matrix.a, matrix.m11);
142 assert_equals(matrix.b, matrix.m12); 143 assert_equals(matrix.b, matrix.m12);
143 assert_equals(matrix.c, matrix.m21); 144 assert_equals(matrix.c, matrix.m21);
(...skipping 13 matching lines...) Expand all
157 assert_equals(matrix.m33, 3); 158 assert_equals(matrix.m33, 3);
158 assert_equals(matrix.m34, 0); 159 assert_equals(matrix.m34, 0);
159 assert_equals(matrix.m41, 0); 160 assert_equals(matrix.m41, 0);
160 assert_equals(matrix.m42, 3); 161 assert_equals(matrix.m42, 3);
161 assert_equals(matrix.m43, 0); 162 assert_equals(matrix.m43, 0);
162 assert_equals(matrix.m44, 9); 163 assert_equals(matrix.m44, 9);
163 assert_false(matrix.is2D); 164 assert_false(matrix.is2D);
164 assert_false(matrix.isIdentity); 165 assert_false(matrix.isIdentity);
165 }, "DOMMatrix attributes"); 166 }, "DOMMatrix attributes");
166 167
167 test(function() { 168 test(() => {
168 var matrix = new DOMMatrix(); 169 var matrix = new DOMMatrix();
169 assert_true(matrix.is2D); 170 assert_true(matrix.is2D);
170 assert_true(matrix.isIdentity); 171 assert_true(matrix.isIdentity);
171 matrix.m31 = 1; 172 matrix.m31 = 1;
172 matrix.m33 = 0; 173 matrix.m33 = 0;
173 assert_false(matrix.is2D); 174 assert_false(matrix.is2D);
174 assert_false(matrix.isIdentity); 175 assert_false(matrix.isIdentity);
175 matrix.m31 = 0; 176 matrix.m31 = 0;
176 matrix.m33 = 1; 177 matrix.m33 = 1;
177 assert_false(matrix.is2D); 178 assert_false(matrix.is2D);
178 assert_true(matrix.isIdentity); 179 assert_true(matrix.isIdentity);
179 }, "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().");
180 181
181 test(function() { 182 test(() => {
182 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array([1, 2, 3, 4, 5])); }, 183 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3 2Array([1, 2, 3, 4, 5])); },
183 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements."); 184 "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 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6 4Array([1, 2, 3, 4, 5])); },
185 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements."); 186 "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 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3 2Array([1, 2, 3, 4, 5, 6 ,7])); },
187 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements."); 188 "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 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6 4Array([1, 2, 3, 4, 5, 6 ,7])); },
189 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements."); 190 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
190 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 6"); 191 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 6");
191 192
192 test(function() { 193 test(() => {
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 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 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements."); 195 "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 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 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements."); 197 "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 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 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements."); 199 "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 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 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements."); 201 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
201 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 16"); 202 }, "DOMMatrix fromFloat*Array - invalid array size of nearby 16");
202 203
203 test(function() { 204 test(() => {
204 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array([])); }, 205 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3 2Array([])); },
205 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements."); 206 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
206 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array([])); }, 207 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6 4Array([])); },
207 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements."); 208 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
208 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array([1])); }, 209 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3 2Array([1])); },
209 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements."); 210 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
210 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array([1])); }, 211 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6 4Array([1])); },
211 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements."); 212 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
212 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array(65536)); }, 213 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat32Array(new Float3 2Array(65536)); },
213 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements."); 214 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
214 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array(65536)); }, 215 assert_throws(new TypeError(), () => { DOMMatrix.fromFloat64Array(new Float6 4Array(65536)); },
215 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements."); 216 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
216 }, "DOMMatrix fromFloat*Array - invalid array size"); 217 }, "DOMMatrix fromFloat*Array - invalid array size");
218
219 test(() => {
220 assert_identity_2d_matrix(DOMMatrix.fromMatrix());
221 }, "DOMMatrix.fromMatrix() with no parameter.");
222
223 test(() => {
224 assert_identity_2d_matrix(DOMMatrix.fromMatrix(null));
225 }, "DOMMatrix.fromMatrix() with null.");
226
227 test(() => {
228 assert_identity_2d_matrix(DOMMatrix.fromMatrix(undefined));
229 }, "DOMMatrix.fromMatrix() with undefined.");
230
231 test(() => {
232 assert_identity_2d_matrix(DOMMatrix.fromMatrix({}));
233 }, "DOMMatrix.fromMatrix() with empty object.");
234
235 test(() => {
236 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6});
237 assert_2d_matrix_equals(matrix, {
238 m11: 1, m12: 2,
239 m21: 3, m22: 4,
240 m41: 5, m42: 6,
241 isIdentity: false
242 });
243 }, "DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}) should create a 2 D DOMMatrix.");
244
245 test(() => {
246 var matrix = DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43 : 6});
247 assert_3d_matrix_equals(matrix, {
248 m11: 1, m12: 0, m13: 0, m14: 0,
249 m21: 0, m22: 2, m23: 5, m24: 0,
250 m31: 0, m32: 0, m33: 3, m34: 0,
251 m41: 0, m42: 0, m43: 6, m44: 4,
252 isIdentity: false
253 });
254 }, "DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6}) shoul d create a 3D DOMMatrix.");
255
256 test(() => {
257 var matrix = DOMMatrix.fromMatrix({a: 7, c: 9});
258 assert_2d_matrix_equals(matrix, {
259 m11: 7, m12: 0,
260 m21: 9, m22: 1,
261 m41: 0, m42: 0,
262 isIdentity: false
263 });
264 }, "If 2d related properties don't be set, should set to fallback.");
265
266 test(() => {
267 var matrix = DOMMatrix.fromMatrix({
268 m11: NaN, m12: NaN, m13: NaN, m14: NaN,
269 m21: NaN, m22: NaN, m23: NaN, m24: NaN,
270 m31: NaN, m32: NaN, m33: NaN, m34: NaN,
271 m41: NaN, m42: NaN, m43: NaN, m44: NaN,
272 is2D: false
273 });
274 assert_equals(matrix.a, matrix.m11);
275 assert_equals(matrix.b, matrix.m12);
276 assert_equals(matrix.c, matrix.m21);
277 assert_equals(matrix.d, matrix.m22);
278 assert_equals(matrix.e, matrix.m41);
279 assert_equals(matrix.f, matrix.m42);
280 assert_3d_matrix_equals(matrix, {
281 m11: NaN, m12: NaN, m13: NaN, m14: NaN,
282 m21: NaN, m22: NaN, m23: NaN, m24: NaN,
283 m31: NaN, m32: NaN, m33: NaN, m34: NaN,
284 m41: NaN, m42: NaN, m43: NaN, m44: NaN,
285 isIdentity: false, is2D: false
286 });
287 }, "DOMMatrix.fromMatrix(): NaN test");
288
289 test(() => {
290 assert_throws(new TypeError(), () => {
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." );
293 assert_throws(new TypeError(), () => {
294 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m11: 3});
295 }, "The 'a' property should equal the 'm11' property.");
296 }, "DOMMatrix.fromMatrix(): Exception test.");
297
217 </script> 298 </script>
218 </body> 299 </body>
219 </html> 300 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698