Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-totalLength.html |
| diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-totalLength.html b/third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-totalLength.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..86c9a55d1032348eff362a90713b8b0a27319cb4 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-totalLength.html |
| @@ -0,0 +1,53 @@ |
| +<!DOCTYPE html> |
| +<title>SVGGeometryElement.totalLength method</title> |
|
fs
2016/10/24 10:48:53
getTotalLength (here, below, and in the filename f
Shanmuga Pandi
2016/10/26 09:52:12
Done.
|
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<p></p> |
| +<script> |
| +test(function() { |
| + var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path"); |
|
fs
2016/10/24 10:48:52
So here we're testing an element not in the docume
Shanmuga Pandi
2016/10/26 09:52:12
Done.
|
| + |
| + function getTotalLength(string) { |
| + pathElement.setAttributeNS(null, "d", string); |
|
fs
2016/10/24 10:48:52
Could just use setAttribute.
Shanmuga Pandi
2016/10/26 09:52:12
Done.
|
| + |
| + var length = pathElement.getTotalLength(); |
| + return length; |
|
fs
2016/10/24 10:48:53
return pathElement.getTotalLength();
?
Shanmuga Pandi
2016/10/26 09:52:12
Done.
|
| + } |
| + |
| + assert_equals(getTotalLength('M0,20 L400,20 L640,20'), 640); |
| + assert_equals(getTotalLength('M0,20 L400,20 L640,20 z'), 1280); |
| + assert_equals(getTotalLength('M0,20 L400,20 z M 320,20 L640,20'), 1120); |
| +}, "SVGGeometryElement.totalLength with SVGPathElement"); |
| + |
| +test(function() { |
| + var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
|
fs
2016/10/24 10:48:52
Make this is something that could either be handle
Shanmuga Pandi
2016/10/26 09:52:12
Done.
|
| + var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect"); |
| + svgElement.appendChild(rectElement); |
| + document.querySelector("p").appendChild(svgElement); |
| + |
| + function getTotalLength(rx, ry, width, height) { |
| + rectElement.setAttribute("rx", rx); |
| + rectElement.setAttribute("ry", ry); |
| + rectElement.setAttribute("width", width); |
| + rectElement.setAttribute("height", height); |
| + |
| + var length = rectElement.getTotalLength(); |
| + return length; |
|
fs
2016/10/24 10:48:52
return rectElement.getTotalLength();
?
Shanmuga Pandi
2016/10/26 09:52:12
Done.
|
| + } |
| + |
| + assert_equals(getTotalLength('0', '0', '200', '300'), 1000); |
|
fs
2016/10/24 10:48:52
Shouldn't need to explicitly "stringify" here, the
Shanmuga Pandi
2016/10/26 09:52:12
Done.
|
| + assert_approx_equals(getTotalLength('50', '50', '200', '300'), 913.65, 0.1); |
| +}, "SVGGeometryElement.totalLength with SVGRectElement"); |
| + |
| +test(function() { |
| + var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
| + var circleElement = document.createElementNS("http://www.w3.org/2000/svg", "circle"); |
| + svgElement.appendChild(circleElement); |
| + document.querySelector("p").appendChild(svgElement); |
| + |
| + circleElement.setAttribute("r", 10); |
| + assert_approx_equals(circleElement.getTotalLength(), 62.42, 0.1); |
| + circleElement.setAttribute("r", 20); |
| + assert_approx_equals(circleElement.getTotalLength(), 124.85, 0.1); |
| +}, "SVGGeometryElement.totalLength with SVGCircleElement"); |
| +</script> |