Chromium Code Reviews| 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..95e5b7243c5bef0ea2992c8fb4685465f7202ef2 100644 |
| --- a/third_party/WebKit/LayoutTests/svg/dom/SVGLength.html |
| +++ b/third_party/WebKit/LayoutTests/svg/dom/SVGLength.html |
| @@ -1,11 +1,108 @@ |
| -<!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>Checks the SVGLength API</title> |
|
fs
2016/08/25 10:16:52
Make this just 'SVGLength interface'.
Shanmuga Pandi
2016/08/26 07:35:18
Done.
|
| +<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 |
|
fs
2016/08/25 10:16:52
End sentences with full stop (".").
Shanmuga Pandi
2016/08/26 07:35:18
Done.
|
| + 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(null, function() { length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_UNKNOWN); }); |
|
fs
2016/08/25 10:16:52
'NotSupportedError'? (same for the following five)
Shanmuga Pandi
2016/08/26 07:35:18
Done.
|
| + assert_throws(null, function() { length.convertToSpecifiedUnits(-1); }); |
| + assert_throws(null, function() { length.convertToSpecifiedUnits(11); }); |
| + assert_throws(null, function() { length.convertToSpecifiedUnits('aString'); }); |
| + assert_throws(null, function() { length.convertToSpecifiedUnits(length); }); |
| + assert_throws(null, 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.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
|
fs
2016/08/25 10:16:52
You can drop one of these two asserts of unitType.
Shanmuga Pandi
2016/08/26 07:35:18
Done.
|
| + |
| + // Check invalid arguments for 'newValueSpecifiedUnits' |
| + assert_throws(null, function() { length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_UNKNOWN, 4); }); |
|
fs
2016/08/25 10:16:52
'NotSupportedError' (+two more)
Shanmuga Pandi
2016/08/26 07:35:18
Done.
|
| + assert_throws(null, function() { length.newValueSpecifiedUnits(-1, 4); }); |
| + assert_throws(null, 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(null, function() { length.newValueSpecifiedUnits('aString', 4); }); |
|
fs
2016/08/25 10:16:52
NotSupportedError (+2)
Shanmuga Pandi
2016/08/26 07:35:18
Done.
|
| + assert_throws(null, function() { length.newValueSpecifiedUnits(length, 4); }); |
| + assert_throws(null, 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.unitType, SVGLength.SVG_LENGTHTYPE_PX); |
|
fs
2016/08/25 10:16:52
Drop one of the unitType asserts. (Or replace with
Shanmuga Pandi
2016/08/26 07:35:19
Done.
|
| + |
| + // Check setting invalid 'valueAsString' arguments |
| + assert_throws(null, function() { length.valueAsString = '10deg'; }); |
|
fs
2016/08/25 10:16:52
SyntaxError
Shanmuga Pandi
2016/08/26 07:35:19
Done.
|
| + 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(null, function() { length.valueAsString = ',5 em'; }); |
|
fs
2016/08/25 10:16:52
SyntaxError
|
| + 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(null, function() { length.valueAsString = null; }); |
|
fs
2016/08/25 10:16:52
SyntaxError
|
| + 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> |
| + |
|
fs
2016/08/25 10:16:52
Drop blank line.
Shanmuga Pandi
2016/08/26 07:35:18
Done.
|