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..cf0dbc498601b4ffdfccd3ca2476ecd61ca005a9 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 |
@@ -59,6 +59,84 @@ test(function() { |
assert_throws(new TypeError(), function() { new DOMMatrixReadOnly([1, 2, 3]); }, |
"DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 elements."); |
}, "DOMMatrixReadOnly constructor - invalid arguments"); |
+ |
+test(function() { |
+ var matrix = DOMMatrixReadOnly.fromMatrix(); |
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); |
+ assert_true(matrix.is2D); |
+ assert_true(matrix.isIdentity); |
+}, "DOMMatrixReadOnly.fromMatrix() with no parameter."); |
+ |
+test(function() { |
+ var matrix = DOMMatrixReadOnly.fromMatrix(null); |
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); |
+ assert_true(matrix.is2D); |
+ assert_true(matrix.isIdentity); |
+}, "DOMMatrixReadOnly.fromMatrix() with null."); |
+ |
+test(function() { |
+ var matrix = DOMMatrixReadOnly.fromMatrix(undefined); |
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); |
+ assert_true(matrix.is2D); |
+ assert_true(matrix.isIdentity); |
+}, "DOMMatrixReadOnly.fromMatrix() with undefined."); |
+ |
+test(function() { |
+ var matrix = DOMMatrixReadOnly.fromMatrix({}); |
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); |
+ assert_true(matrix.is2D); |
+ assert_true(matrix.isIdentity); |
+}, "DOMMatrixReadOnly.fromMatrix() with empty object."); |
+ |
+test(function() { |
+ var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}); |
+ assert_array_equals(matrix.toFloat64Array(), [1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 1, 0, 5, 6, 0, 1]); |
+ assert_true(matrix.is2D); |
+ assert_false(matrix.isIdentity); |
+}, "DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}) should create a 2D DOMMatrixReadOnly."); |
+ |
+test(function() { |
+ var matrix = DOMMatrixReadOnly.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6}); |
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 2, 5, 0, 0, 0, 3, 0, 0, 0, 6, 4]); |
+ assert_false(matrix.is2D); |
+ assert_false(matrix.isIdentity); |
+}, "DOMMatrixReadOnly.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6}) should create a 2D DOMMatrixReadOnly."); |
+ |
+test(function() { |
+ var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, m12: 2, m21: 3, d: 4, m41: 5, f: 6}); |
+ assert_equals(matrix.m11, 1); |
+ assert_equals(matrix.b, 2); |
+ assert_equals(matrix.c, 3); |
+ assert_equals(matrix.m22, 4); |
+ assert_equals(matrix.e, 5); |
+ assert_equals(matrix.m42, 6); |
+}, "[a, b, c, d, e, f] members should equals [m11, m12, m21, m22, m41, m42]."); |
+ |
+test(function() { |
+ var matrix = DOMMatrixReadOnly.fromMatrix({a: 7, c: 9}); |
+ assert_equals(matrix.a, 7); |
+ assert_equals(matrix.b, 0); |
+ assert_equals(matrix.c, 9); |
+ assert_equals(matrix.d, 1); |
+ assert_equals(matrix.e, 0); |
+ assert_equals(matrix.f, 0); |
+ assert_equals(matrix.m11, 7); |
+ assert_equals(matrix.m12, 0); |
+ assert_equals(matrix.m21, 9); |
+ assert_equals(matrix.m22, 1); |
+ assert_equals(matrix.m41, 0); |
+ assert_equals(matrix.m42, 0); |
+}, "If 2d related members don't be set, should set to fallback."); |
+ |
+test(function() { |
+ assert_throws(new TypeError(), function() { |
dominicc (has gone to gerrit)
2016/08/30 02:13:42
Consider using arrow functions. They're slightly m
zino
2016/09/10 10:18:15
Done.
|
+ var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true}); |
dominicc (has gone to gerrit)
2016/08/30 02:13:43
Why do you need this variable?
zino
2016/09/10 10:18:15
Done.
|
+ }, "The is2D member is set to true but the input matrix is 3d matrix."); |
+ assert_throws(new TypeError(), function() { |
+ var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3}); |
+ }, "The a member should equal the m11 member."); |
+}, "DOMMatrixReadOnly.fromMatrix(): Exception tests."); |
+ |
</script> |
</body> |
</html> |