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

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

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

Powered by Google App Engine
This is Rietveld 408576698