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

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

Issue 2482743002: [GeometryInterface] add toJson() function in DOMMatrixReadOnly. (Closed)
Patch Set: add test for DOMMatrix Created 4 years, 1 month 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 test(() => { 6 test(() => {
7 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); 7 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]);
8 assert_2d_matrix_equals(matrix2d, [1, 2, 3, 3.1, 2, 1]); 8 assert_2d_matrix_equals(matrix2d, [1, 2, 3, 3.1, 2, 1]);
9 }, "DOMMatrixReadOnly constructor - 2D matrix"); 9 }, "DOMMatrixReadOnly constructor - 2D matrix");
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 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)");
46 }, "DOMMatrixReadOnly toString() - 2D matrix"); 46 }, "DOMMatrixReadOnly toString() - 2D matrix");
47 47
48 test(() => { 48 test(() => {
49 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 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]);
50 assert_false(matrix3d.is2D); 50 assert_false(matrix3d.is2D);
51 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)");
52 }, "DOMMatrixReadOnly toString() - 3D matrix"); 52 }, "DOMMatrixReadOnly toString() - 3D matrix");
53 53
54 test(() => { 54 test(() => {
55 var identity_matrix = DOMMatrixReadOnly.fromMatrix();
56 assert_true(identity_matrix.is2D);
57 assert_object_equals(identity_matrix.toJSON(),
58 { a : 1, b : 0, c : 0, d : 1, e : 0, f : 0,
59 is2D : true, isIdentity : true,
60 m11 : 1, m12 : 0, m13 : 0, m14 : 0,
61 m21 : 0, m22 : 1, m23 : 0, m24 : 0,
62 m31 : 0, m32 : 0, m33 : 1, m34 : 0,
63 m41 : 0, m42 : 0, m43 : 0, m44 : 1});
64 }, "DOMMatrixReadOnly toJSON() - identity matrix");
65
66 test(() => {
67 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]);
68 assert_true(matrix2d.is2D);
69 assert_object_equals(matrix2d.toJSON(),
70 { a : 1, b : 2, c : 3, d : 3.1, e : 2, f : 1,
71 is2D : true, isIdentity : false,
72 m11 : 1, m12 : 2, m13 : 0, m14 : 0,
73 m21 : 3, m22 : 3.1, m23 : 0, m24 : 0,
74 m31 : 0, m32 : 0, m33 : 1, m34 : 0,
75 m41 : 2, m42 : 1, m43 : 0, m44 : 1});
76 }, "DOMMatrixReadOnly toJSON() - 2D matrix");
77
78 test(() => {
79 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6]);
80 assert_false(matrix3d.is2D);
81 assert_object_equals(matrix3d.toJSON(),
82 { a : 1, b : 2, c : 5, d : 6, e : 13, f : 14,
83 is2D : false, isIdentity : false,
84 m11 : 1, m12 : 2, m13 : 3, m14 : 4,
85 m21 : 5, m22 : 6, m23 : 7, m24 : 8,
86 m31 : 9, m32 : 10.1, m33 : 11, m34 : 12,
87 m41 : 13, m42 : 14, m43 : 15, m44 : 16.6});
88 }, "DOMMatrixReadOnly toJSON() - 3D matrix");
89
90 test(() => {
55 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly(1, 2, 3, 4, 5, 6) ; }, 91 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly(1, 2, 3, 4, 5, 6) ; },
56 "DOMMatrixReadOnly constructor only accepts 1 argument"); 92 "DOMMatrixReadOnly constructor only accepts 1 argument");
57 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly("myString"); }, 93 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly("myString"); },
58 "DOMMatrixReadOnly constructor only accepts 1 number sequence"); 94 "DOMMatrixReadOnly constructor only accepts 1 number sequence");
59 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly([1, 2, 3]); }, 95 assert_throws(new TypeError(), () => { new DOMMatrixReadOnly([1, 2, 3]); },
60 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 e lements."); 96 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 e lements.");
61 }, "DOMMatrixReadOnly constructor - invalid arguments"); 97 }, "DOMMatrixReadOnly constructor - invalid arguments");
62 98
63 test(() => { 99 test(() => {
64 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(new Float32Array([1, 2, 3, 4, 5])); }, 100 assert_throws(new TypeError(), () => { DOMMatrixReadOnly.fromFloat32Array(new Float32Array([1, 2, 3, 4, 5])); },
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 test(() => { 182 test(() => {
147 assert_throws(new TypeError(), () => { 183 assert_throws(new TypeError(), () => {
148 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true}); 184 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true});
149 }, "The 'is2D' property is set to true but the input matrix is 3d matrix."); 185 }, "The 'is2D' property is set to true but the input matrix is 3d matrix.");
150 assert_throws(new TypeError(), () => { 186 assert_throws(new TypeError(), () => {
151 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3}); 187 DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3});
152 }, "The 'a' property should equal the 'm11' property."); 188 }, "The 'a' property should equal the 'm11' property.");
153 }, "DOMMatrixReadOnly.fromMatrix(): Exception test."); 189 }, "DOMMatrixReadOnly.fromMatrix(): Exception test.");
154 190
155 </script> 191 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698