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

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

Issue 2846523002: Update the stringifier behavior for DOMMatrixReadOnly (Closed)
Patch Set: Update the stringifier behavior for DOMMatrixReadOnly Created 3 years, 6 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 <script src="../../resources/testharness.js"></script> 2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script> 3 <script src="../../resources/testharnessreport.js"></script>
4 <script src="./resources/geometry-interfaces-test-helpers.js"></script> 4 <script src="./resources/geometry-interfaces-test-helpers.js"></script>
5 <script> 5 <script>
6 6
7 test(() => { 7 test(() => {
8 var matrix = new DOMMatrixReadOnly(); 8 var matrix = new DOMMatrixReadOnly();
9 assert_identity_2d_matrix(matrix); 9 assert_identity_2d_matrix(matrix);
10 }, "DOMMatrixReadOnly constructor"); 10 }, "DOMMatrixReadOnly constructor");
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 test(() => { 53 test(() => {
54 var matrix = new DOMMatrixReadOnly("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) trans late(44px, 55px) skewX(30deg)"); 54 var matrix = new DOMMatrixReadOnly("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) trans late(44px, 55px) skewX(30deg)");
55 var expectedMatrix = new DOMMatrixReadOnly(); 55 var expectedMatrix = new DOMMatrixReadOnly();
56 expectedMatrix = expectedMatrix.multiply(new DOMMatrixReadOnly([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])) 56 expectedMatrix = expectedMatrix.multiply(new DOMMatrixReadOnly([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]))
57 expectedMatrix = expectedMatrix.translate(44, 55) 57 expectedMatrix = expectedMatrix.translate(44, 55)
58 expectedMatrix = expectedMatrix.skewX(30); 58 expectedMatrix = expectedMatrix.skewX(30);
59 assert_matrix_almost_equals(matrix, expectedMatrix); 59 assert_matrix_almost_equals(matrix, expectedMatrix);
60 }, "DOMMatrixReadOnly(transformList) - transformList"); 60 }, "DOMMatrixReadOnly(transformList) - transformList");
61 61
62 test(() => { 62 test(() => {
63 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); 63 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1.1]);
64 assert_true(matrix2d.is2D); 64 assert_true(matrix2d.is2D);
65 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1)"); 65 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1.1)");
66 }, "DOMMatrixReadOnly toString() - 2D matrix"); 66 }, "DOMMatrixReadOnly toString() - 2D matrix");
67 67
68 test(() => { 68 test(() => {
69 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6]); 69 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6]);
70 assert_false(matrix3d.is2D); 70 assert_false(matrix3d.is2D);
71
71 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6)"); 72 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6)");
72 }, "DOMMatrixReadOnly toString() - 3D matrix"); 73 }, "DOMMatrixReadOnly toString() - 3D matrix");
73 74
74 test(() => { 75 [NaN, Infinity, -Infinity].forEach(num => {
75 var identity_matrix = DOMMatrixReadOnly.fromMatrix(); 76 test(() => {
77 for (let i = 0; i < 6; ++i) {
78 let seq = [1, 0, 0, 1, 0, 0];
79 seq[i] = num;
80 var matrix2d = new DOMMatrixReadOnly(seq, 6);
81 assert_true(matrix2d.is2D);
82 assert_throws("InvalidStateError", () => { matrix2d.toString() });
83 }
84 }, `DOMMatrixReadOnly toString() - 2D matrix with ${num}`);
85
86 test(() => {
87 for (let i = 0; i < 12; ++i) {
88 let seq = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
89 seq[i] = num;
90 var matrix3d = new DOMMatrixReadOnly(seq, 12);
91 assert_false(matrix3d.is2D);
92 assert_throws("InvalidStateError", () => { matrix3d.toString() });
93 }
94 }, `DOMMatrixReadOnly toString() - 3D matrix with ${num}`);
95 });
96
97 test(() => { var identity_matrix = DOMMatrixReadOnly.fromMatrix();
76 assert_true(identity_matrix.is2D); 98 assert_true(identity_matrix.is2D);
77 assert_object_equals(identity_matrix.toJSON(), 99 assert_object_equals(identity_matrix.toJSON(),
78 { a : 1, b : 0, c : 0, d : 1, e : 0, f : 0, 100 { a : 1, b : 0, c : 0, d : 1, e : 0, f : 0,
79 is2D : true, isIdentity : true, 101 is2D : true, isIdentity : true,
80 m11 : 1, m12 : 0, m13 : 0, m14 : 0, 102 m11 : 1, m12 : 0, m13 : 0, m14 : 0,
81 m21 : 0, m22 : 1, m23 : 0, m24 : 0, 103 m21 : 0, m22 : 1, m23 : 0, m24 : 0,
82 m31 : 0, m32 : 0, m33 : 1, m34 : 0, 104 m31 : 0, m32 : 0, m33 : 1, m34 : 0,
83 m41 : 0, m42 : 0, m43 : 0, m44 : 1}); 105 m41 : 0, m42 : 0, m43 : 0, m44 : 1});
84 }, "DOMMatrixReadOnly toJSON() - identity matrix"); 106 }, "DOMMatrixReadOnly toJSON() - identity matrix");
85 107
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 test(() => { 257 test(() => {
236 assert_throws(new TypeError(), () => { 258 assert_throws(new TypeError(), () => {
237 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true}); 259 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true});
238 }, "The 'is2D' property is set to true but the input matrix is 3d matrix"); 260 }, "The 'is2D' property is set to true but the input matrix is 3d matrix");
239 assert_throws(new TypeError(), () => { 261 assert_throws(new TypeError(), () => {
240 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3}); 262 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3});
241 }, "The 'a' property should equal the 'm11' property"); 263 }, "The 'a' property should equal the 'm11' property");
242 }, "DOMMatrixReadOnly.fromMatrix(): Exception test"); 264 }, "DOMMatrixReadOnly.fromMatrix(): Exception test");
243 265
244 </script> 266 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698