Index: third_party/WebKit/LayoutTests/svg/dom/SVGLength.html |
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGLength.html b/third_party/WebKit/LayoutTests/svg/dom/SVGLength.html |
index c809e2db2b93c809106d30461903e2e682c016aa..e215fa50f0eb2bc8e2f8a2d22692b678d487766d 100644 |
--- a/third_party/WebKit/LayoutTests/svg/dom/SVGLength.html |
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGLength.html |
@@ -1,11 +1,107 @@ |
-<!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/SVGLength.js"></script> |
-</body> |
-</html> |
+<!DOCTYPE HTML> |
+<title>SVGLength interface</title> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script> |
+test(function() { |
+ var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
+ var length = svgElement.createSVGLength(); |
+ |
+ // Check initial length values. |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_NUMBER); |
+ assert_equals(length.value, 0); |
+ assert_equals(length.valueInSpecifiedUnits, 0); |
+ assert_equals(length.valueAsString, "0"); |
+ |
+ // Set value to be 2px. |
+ length.valueAsString = "2px"; |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
+ assert_equals(length.value, 2); |
+ assert_equals(length.valueInSpecifiedUnits, 2); |
+ assert_equals(length.valueAsString, "2px"); |
+ |
+ // Check invalid arguments for 'convertToSpecifiedUnits'. |
+ assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_UNKNOWN); }); |
+ assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits(-1); }); |
+ assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits(11); }); |
+ assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits('aString'); }); |
+ assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits(length); }); |
+ assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits(svgElement); }); |
+ assert_throws(new TypeError(), function() { length.convertToSpecifiedUnits(); }); |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
+ assert_equals(length.value, 2); |
+ assert_equals(length.valueInSpecifiedUnits, 2); |
+ assert_equals(length.valueAsString, "2px"); |
+ |
+ // Check invalid arguments for 'newValueSpecifiedUnits'. |
+ assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_UNKNOWN, 4); }); |
+ assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits(-1, 4); }); |
+ assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits(11, 4); }); |
+ // ECMA-262, 9.3, "ToNumber". |
+ length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 0); |
+ assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 'aString'); }); |
+ assert_equals(length.value, 0); |
+ assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, length); }); |
+ assert_equals(length.value, 0); |
+ assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, svgElement); }); |
+ assert_equals(length.value, 0); |
+ assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, NaN); }); |
+ assert_equals(length.value, 0); |
+ assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, Infinity); }); |
+ assert_equals(length.value, 0); |
+ assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX); }); |
+ // Reset to original value above. |
+ length.valueAsString = "2px"; |
+ assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits('aString', 4); }); |
+ assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits(length, 4); }); |
+ assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits(svgElement, 4); }); |
+ assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits('aString', 'aString'); }); |
+ assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(length, length); }); |
+ assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(svgElement, svgElement); }); |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
+ assert_equals(length.value, 2); |
+ assert_equals(length.valueInSpecifiedUnits, 2); |
+ assert_equals(length.valueAsString, "2px"); |
+ |
+ // Check setting invalid 'valueAsString' arguments. |
+ assert_throws("SyntaxError", function() { length.valueAsString = '10deg'; }); |
+ assert_equals(length.valueAsString, "2px"); |
+ assert_equals(length.value, 2); |
+ assert_equals(length.valueInSpecifiedUnits, 2); |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
+ |
+ length.valueAsString = '1pX'; // should not throw exception. |
+ assert_equals(length.valueAsString, "1px"); |
+ assert_equals(length.value, 1); |
+ assert_equals(length.valueInSpecifiedUnits, 1); |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
+ |
+ length.valueAsString = "2px"; // reset to 2px. |
+ |
+ assert_throws("SyntaxError", function() { length.valueAsString = ',5 em'; }); |
+ assert_equals(length.valueAsString, "2px"); |
+ assert_equals(length.value, 2); |
+ assert_equals(length.valueInSpecifiedUnits, 2); |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
+ |
+ assert_throws("SyntaxError", function() { length.valueAsString = null; }); |
+ assert_equals(length.valueAsString, "2px"); |
+ assert_equals(length.value, 2); |
+ assert_equals(length.valueInSpecifiedUnits, 2); |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
+ |
+ // Check setting invalid 'value' arguments. |
+ assert_throws(new TypeError(), function() { length.value = NaN; }); |
+ assert_throws(new TypeError(), function() { length.value = Infinity; }); |
+ assert_equals(length.value, 2); |
+ assert_equals(length.valueInSpecifiedUnits, 2); |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
+ |
+ // Check setting invalid 'valueInSpecifiedUnits' arguments. |
+ assert_throws(new TypeError(), function() { length.valueInSpecifiedUnits = NaN; }); |
+ assert_throws(new TypeError(), function() { length.valueInSpecifiedUnits = Infinity; }); |
+ assert_equals(length.value, 2); |
+ assert_equals(length.valueInSpecifiedUnits, 2); |
+ assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
+}); |
+</script> |