Index: third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-getTotalLength-attached.html |
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-getTotalLength-attached.html b/third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-getTotalLength-attached.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..19abf799e0c9de5bccf8e7e81a6e5668d277086f |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-getTotalLength-attached.html |
@@ -0,0 +1,51 @@ |
+<!DOCTYPE html> |
+<title>SVGGeometryElement.getTotalLength method (element attached)</title> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<svg></svg> |
+<script> |
+setup(function() { |
+ window.svgElement = document.querySelector("svg"); |
+}); |
+ |
+test(function() { |
+ var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path"); |
+ svgElement.appendChild(pathElement); |
+ |
+ function getTotalLength(string) { |
+ pathElement.setAttribute("d", string); |
+ return pathElement.getTotalLength(); |
+ } |
+ |
+ 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); |
+}, document.title + " with SVGPathElement"); |
+ |
+test(function() { |
+ var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect"); |
+ svgElement.appendChild(rectElement); |
+ |
+ function getTotalLength(rx, ry, width, height) { |
+ rectElement.setAttribute("rx", rx); |
+ rectElement.setAttribute("ry", ry); |
+ rectElement.setAttribute("width", width); |
+ rectElement.setAttribute("height", height); |
+ |
+ return rectElement.getTotalLength(); |
+ } |
+ |
+ assert_equals(getTotalLength(0, 0, 200, 300), 1000); |
+ assert_approx_equals(getTotalLength(50, 50, 200, 300), 913.65, 0.1); |
+}, document.title + " with SVGRectElement"); |
+ |
+test(function() { |
+ var circleElement = document.createElementNS("http://www.w3.org/2000/svg", "circle"); |
+ svgElement.appendChild(circleElement); |
+ |
+ 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); |
+}, document.title + " with SVGCircleElement"); |
+</script> |