Index: third_party/WebKit/LayoutTests/svg/dom/SVGMatrix.html |
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGMatrix.html b/third_party/WebKit/LayoutTests/svg/dom/SVGMatrix.html |
index a4132328824fc06fcfd5252cda1f7064f8e3dbaf..1a7d5acdaab888fc19473b3732a9a915f22d147f 100644 |
--- a/third_party/WebKit/LayoutTests/svg/dom/SVGMatrix.html |
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGMatrix.html |
@@ -1,11 +1,156 @@ |
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
-<html> |
-<head> |
-<script src="../../resources/js-test.js"></script> |
-</head> |
-<body> |
-<p id="description"></p> |
-<div id="console"></div> |
-<script src="script-tests/SVGMatrix.js"></script> |
-</body> |
-</html> |
+<!DOCTYPE HTML> |
+<title>SVGMatrix interface</title> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script> |
+var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
+ |
+function assert_matrix_component_numeric(matrix, component) { |
+ matrix[component] = matrix; |
+ assert_equals(matrix[component], NaN); |
+ matrix[component] = 0; |
+ assert_equals(matrix[component], 0); |
+ matrix[component] = svgElement; |
+ assert_equals(matrix[component], NaN); |
+ matrix[component] = 0; |
+ assert_equals(matrix[component], 0); |
+ matrix[component] = 'aString'; |
+ assert_equals(matrix[component], NaN); |
+} |
+ |
+test(function() { |
+ // This test checks the SVGMatrix API. |
+ var matrix = svgElement.createSVGMatrix(); |
+ |
+ // Check initial matrix values. |
+ assert_equals(matrix.a, 1); |
+ assert_equals(matrix.b, 0); |
+ assert_equals(matrix.c, 0); |
+ assert_equals(matrix.d, 1); |
+ assert_equals(matrix.e, 0); |
+ assert_equals(matrix.f, 0); |
+ |
+ // Check assigning matrices. |
+ matrix.a = 2; |
+ assert_equals(matrix.a, 2); |
+ matrix.f = 200; |
+ assert_equals(matrix.f, 200); |
+ |
+ // Check assigning invalid matrices. |
+ assert_matrix_component_numeric(matrix, 'a'); |
+ // Reset to previous value. |
+ matrix.a = 2; |
+ assert_equals(matrix.a, 2); |
+ |
+ assert_matrix_component_numeric(matrix, 'b'); |
+ // Reset to previous value. |
+ matrix.b = 0; |
+ assert_equals(matrix.b, 0); |
+ |
+ assert_matrix_component_numeric(matrix, 'c'); |
+ // Reset to previous value. |
+ matrix.c = 0; |
+ assert_equals(matrix.c, 0); |
+ |
+ assert_matrix_component_numeric(matrix, 'd'); |
+ // Reset to previous value. |
+ matrix.d = 1; |
+ assert_equals(matrix.d, 1); |
+ |
+ assert_matrix_component_numeric(matrix, 'e'); |
+ // Reset to previous value. |
+ matrix.e = 0; |
+ assert_equals(matrix.e, 0); |
+ |
+ assert_matrix_component_numeric(matrix, 'f'); |
+ // Reset to previous value. |
+ matrix.f = 200; |
+ assert_equals(matrix.f, 200); |
+ |
+ // Check that the matrix is still containing the correct values. |
+ assert_equals(matrix.a, 2); |
+ assert_equals(matrix.b, 0); |
+ assert_equals(matrix.c, 0); |
+ assert_equals(matrix.d, 1); |
+ assert_equals(matrix.e, 0); |
+ assert_equals(matrix.f, 200); |
+ |
+ // Check assigning null works as expected. |
+ matrix.f = null; |
+ assert_equals(matrix.a, 2); |
+ assert_equals(matrix.b, 0); |
+ assert_equals(matrix.c, 0); |
+ assert_equals(matrix.d, 1); |
+ assert_equals(matrix.e, 0); |
+ assert_equals(matrix.f, 0); |
+ |
+ // Check calling 'multiply' with invalid arguments. |
+ assert_throws(new TypeError(), function() { matrix.multiply(); }); |
+ assert_throws(new TypeError(), function() { matrix.multiply(true); }); |
+ assert_throws(new TypeError(), function() { matrix.multiply(2); }); |
+ assert_throws(new TypeError(), function() { matrix.multiply('aString'); }); |
+ assert_throws(new TypeError(), function() { matrix.multiply(svgElement); }); |
+ |
+ // Check calling 'translate' with invalid arguments. |
+ assert_throws(new TypeError(), function() { matrix.translate(); }); |
+ assert_throws(new TypeError(), function() { matrix.translate(true); }); |
+ assert_throws(new TypeError(), function() { matrix.translate(2); }); |
+ assert_throws(new TypeError(), function() { matrix.translate('aString'); }); |
+ assert_throws(new TypeError(), function() { matrix.translate(svgElement); }); |
+ // The following string and object arguments convert to NaN |
+ // per ECMA-262, 9.3, "ToNumber". |
+ assert_not_equals(matrix.translate('aString', 'aString'), null); |
+ assert_not_equals(matrix.translate(svgElement, svgElement), null); |
+ assert_not_equals(matrix.translate(2, 'aString'), null); |
+ assert_not_equals(matrix.translate(2, svgElement), null); |
+ assert_not_equals(matrix.translate('aString', 2), null); |
+ assert_not_equals(matrix.translate(svgElement, 2), null); |
+ |
+ // Check calling 'scale' with invalid arguments. |
+ assert_throws(new TypeError(), function() { matrix.scale(); }); |
+ assert_not_equals(matrix.scale('aString'), null); |
+ assert_not_equals(matrix.scale(svgElement), null); |
+ |
+ |
+ // Check calling 'scaleNonUniform' with invalid arguments. |
+ assert_throws(new TypeError(), function() { matrix.scaleNonUniform(); }); |
+ assert_throws(new TypeError(), function() { matrix.scaleNonUniform(true); }); |
+ assert_throws(new TypeError(), function() { matrix.scaleNonUniform(2); }); |
+ assert_throws(new TypeError(), function() { matrix.scaleNonUniform('aString'); }); |
+ assert_throws(new TypeError(), function() { matrix.scaleNonUniform(svgElement); }); |
+ assert_not_equals(matrix.scaleNonUniform('aString', 'aString'), null); |
+ assert_not_equals(matrix.scaleNonUniform(svgElement, svgElement), null); |
+ assert_not_equals(matrix.scaleNonUniform(2, 'aString'), null); |
+ assert_not_equals(matrix.scaleNonUniform(2, svgElement), null); |
+ assert_not_equals(matrix.scaleNonUniform('aString', 2), null); |
+ assert_not_equals(matrix.scaleNonUniform(svgElement, 2), null); |
+ |
+ // Check calling 'rotate' with invalid arguments. |
+ assert_throws(new TypeError(), function() { matrix.rotate(); }); |
+ assert_not_equals(matrix.rotate('aString'), null); |
+ assert_not_equals(matrix.rotate(svgElement), null); |
+ |
+ // Check calling 'rotateFromVector' with invalid arguments. |
+ assert_throws(new TypeError(), function() { matrix.rotateFromVector(); }); |
+ assert_throws(new TypeError(), function() { matrix.rotateFromVector(true); }); |
+ assert_throws(new TypeError(), function() { matrix.rotateFromVector(2); }); |
+ assert_throws(new TypeError(), function() { matrix.rotateFromVector('aString'); }); |
+ assert_throws(new TypeError(), function() { matrix.rotateFromVector(svgElement); }); |
+ assert_not_equals(matrix.rotateFromVector('aString', 'aString'), null); |
+ assert_not_equals(matrix.rotateFromVector(svgElement, svgElement), null); |
+ assert_not_equals(matrix.rotateFromVector(2, 'aString'), null); |
+ assert_not_equals(matrix.rotateFromVector(2, svgElement), null); |
+ assert_not_equals(matrix.rotateFromVector('aString', 2), null); |
+ assert_not_equals(matrix.rotateFromVector(svgElement, 2), null); |
+ |
+ // Check calling 'skewX' with invalid arguments. |
+ assert_throws(new TypeError(), function() { matrix.skewX(); }); |
+ assert_not_equals(matrix.skewX('aString'), null); |
+ assert_not_equals(matrix.skewX(svgElement), null); |
+ |
+ // Check calling 'skewY' with invalid arguments; |
+ assert_throws(new TypeError(), function() { matrix.skewY(); }); |
+ assert_not_equals(matrix.skewY('aString'), null); |
+ assert_not_equals(matrix.skewY(svgElement), null); |
+}); |
+</script> |