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

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

Issue 2283363003: GeometryInterface: Add DOMMatrixInit and fromMatrix(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-readonly.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-readonly.html b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-readonly.html
index b6b3cb71b677610702b49966819255e64586eb6f..a6a1fa7864e47c12e3cad384e8e86486b3309ddb 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-readonly.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-readonly.html
@@ -4,61 +4,135 @@
<title>Geometry Interfaces: DOMMatrixReadOnly</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
+<script src="./resources/geometry-interfaces-test-helpers.js"></script>
</head>
<body>
<script>
-test(function() {
+test(() => {
var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]);
- assert_true(matrix2d.is2D);
- assert_equals(matrix2d.a, 1);
- assert_equals(matrix2d.b, 2);
- assert_equals(matrix2d.c, 3);
- assert_equals(matrix2d.d, 3.1);
- assert_equals(matrix2d.e, 2);
- assert_equals(matrix2d.f, 1);
+ assert_2d_matrix_equals(matrix2d, {
+ m11: 1, m12: 2,
+ m21: 3, m22: 3.1,
+ m41: 2, m42: 1,
+ isIdentity: false
+ });
}, "DOMMatrixReadOnly constructor - 2D matrix");
-test(function() {
+test(() => {
var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6]);
- assert_false(matrix3d.is2D);
- assert_equals(matrix3d.m11, 1);
- assert_equals(matrix3d.m12, 2);
- assert_equals(matrix3d.m13, 3);
- assert_equals(matrix3d.m14, 4);
- assert_equals(matrix3d.m21, 5);
- assert_equals(matrix3d.m22, 6);
- assert_equals(matrix3d.m23, 7);
- assert_equals(matrix3d.m24, 8);
- assert_equals(matrix3d.m31, 9);
- assert_equals(matrix3d.m32, 10.1);
- assert_equals(matrix3d.m33, 11);
- assert_equals(matrix3d.m34, 12);
- assert_equals(matrix3d.m41, 13);
- assert_equals(matrix3d.m42, 14);
- assert_equals(matrix3d.m43, 15);
- assert_equals(matrix3d.m44, 16.6);
+ assert_3d_matrix_equals(matrix3d, {
+ m11: 1, m12: 2, m13: 3, m14: 4,
+ m21: 5, m22: 6, m23: 7, m24: 8,
+ m31: 9, m32: 10.1, m33: 11, m34: 12,
+ m41: 13, m42: 14, m43: 15, m44: 16.6,
+ isIdentity: false
+ });
}, "DOMMatrixReadOnly constructor - 3D matrix");
-test(function() {
+test(() => {
var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]);
assert_true(matrix2d.is2D);
assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1)");
}, "DOMMatrixReadOnly toString() - 2D matrix");
-test(function() {
+test(() => {
var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6]);
assert_false(matrix3d.is2D);
assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6)");
}, "DOMMatrixReadOnly toString() - 3D matrix");
-test(function() {
- assert_throws(new TypeError(), function() { new DOMMatrixReadOnly(1, 2, 3, 4, 5, 6); },
+test(() => {
+ assert_throws(new TypeError(), () => { new DOMMatrixReadOnly(1, 2, 3, 4, 5, 6); },
"DOMMatrixReadOnly constructor only accepts 1 argument");
- assert_throws(new TypeError(), function() { new DOMMatrixReadOnly("myString"); },
+ assert_throws(new TypeError(), () => { new DOMMatrixReadOnly("myString"); },
"DOMMatrixReadOnly constructor only accepts 1 number sequence");
- assert_throws(new TypeError(), function() { new DOMMatrixReadOnly([1, 2, 3]); },
+ assert_throws(new TypeError(), () => { new DOMMatrixReadOnly([1, 2, 3]); },
"DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 elements.");
}, "DOMMatrixReadOnly constructor - invalid arguments");
+
+test(() => {
+ var matrix = DOMMatrixReadOnly.fromMatrix();
+ assert_identity_2d_matrix(matrix);
+}, "DOMMatrixReadOnly.fromMatrix() with no parameter.");
+
+test(() => {
+ var matrix = DOMMatrixReadOnly.fromMatrix(null);
+ assert_identity_2d_matrix(matrix);
+}, "DOMMatrixReadOnly.fromMatrix() with null.");
+
+test(() => {
+ var matrix = DOMMatrixReadOnly.fromMatrix(undefined);
+ assert_identity_2d_matrix(matrix);
+}, "DOMMatrixReadOnly.fromMatrix() with undefined.");
+
+test(() => {
+ var matrix = DOMMatrixReadOnly.fromMatrix({});
+ assert_identity_2d_matrix(matrix);
+}, "DOMMatrixReadOnly.fromMatrix() with empty object.");
+
+test(() => {
+ var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6});
+ assert_2d_matrix_equals(matrix, {
+ m11: 1, m12: 2,
+ m21: 3, m22: 4,
+ m41: 5, m42: 6,
+ isIdentity: false
+ });
+}, "DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}) should create a 2D DOMMatrixReadOnly.");
+
+test(() => {
+ var matrix = DOMMatrixReadOnly.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6});
+ assert_3d_matrix_equals(matrix, {
+ m11: 1, m12: 0, m13: 0, m14: 0,
+ m21: 0, m22: 2, m23: 5, m24: 0,
+ m31: 0, m32: 0, m33: 3, m34: 0,
+ m41: 0, m42: 0, m43: 6, m44: 4,
+ isIdentity: false
+ });
+}, "DOMMatrixReadOnly.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6}) should create a 3D DOMMatrixReadOnly.");
+
+test(() => {
+ var matrix = DOMMatrixReadOnly.fromMatrix({a: 7, c: 9});
+ assert_2d_matrix_equals(matrix, {
+ m11: 7, m12: 0,
+ m21: 9, m22: 1,
+ m41: 0, m42: 0,
+ isIdentity: false
+ });
+}, "If 2d related properties don't be set, should set to fallback.");
+
+test(function() {
+ var matrix = DOMMatrixReadOnly.fromMatrix({
+ m11: NaN, m12: NaN, m13: NaN, m14: NaN,
+ m21: NaN, m22: NaN, m23: NaN, m24: NaN,
+ m31: NaN, m32: NaN, m33: NaN, m34: NaN,
+ m41: NaN, m42: NaN, m43: NaN, m44: NaN,
+ is2D: false
+ });
+ assert_equals(matrix.a, matrix.m11);
+ assert_equals(matrix.b, matrix.m12);
+ assert_equals(matrix.c, matrix.m21);
+ assert_equals(matrix.d, matrix.m22);
+ assert_equals(matrix.e, matrix.m41);
+ assert_equals(matrix.f, matrix.m42);
+ assert_3d_matrix_equals(matrix, {
+ m11: NaN, m12: NaN, m13: NaN, m14: NaN,
+ m21: NaN, m22: NaN, m23: NaN, m24: NaN,
+ m31: NaN, m32: NaN, m33: NaN, m34: NaN,
+ m41: NaN, m42: NaN, m43: NaN, m44: NaN,
+ isIdentity: false, is2D: false
+ });
+}, "DOMMatrixReadOnly.fromMatrix(): NaN test");
+
+test(() => {
+ assert_throws(new TypeError(), () => {
+ DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true});
+ }, "The 'is2D' property is set to true but the input matrix is 3d matrix.");
+ assert_throws(new TypeError(), () => {
+ DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3});
+ }, "The 'a' property should equal the 'm11' property.");
+}, "DOMMatrixReadOnly.fromMatrix(): Exception test.");
+
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698