Index: LayoutTests/svg/dom/SVGPathSeg-construction.html |
diff --git a/LayoutTests/svg/dom/SVGPathSeg-construction.html b/LayoutTests/svg/dom/SVGPathSeg-construction.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..066bc4fcfbb5433acbd128c1ecdbe9e9c1e788fc |
--- /dev/null |
+++ b/LayoutTests/svg/dom/SVGPathSeg-construction.html |
@@ -0,0 +1,69 @@ |
+<!DOCTYPE html> |
+<script src=../../resources/testharness.js></script> |
+<script src=../../resources/testharnessreport.js></script> |
+<script> |
+setup(function() { |
+ window.pathElement = document.createElementNS('http://www.w3.org/2000/svg', 'path'); |
+}); |
+ |
+function constructorArity(name) { |
+ return SVGPathElement.prototype['create' + name].length; |
+} |
+ |
+function construct(name, args) { |
+ return SVGPathElement.prototype['create' + name].apply(pathElement, args); |
+} |
+ |
+function makeArgs(total, valueIndex, value) { |
+ var a = new Array(total); |
+ for (var i = 0; i < total; ++i) |
+ a[i] = i === valueIndex ? value : 0; |
+ return a; |
+} |
+ |
+var floatAttributes = [ 'x', 'y', 'x1', 'y1', 'r1', 'x2', 'y2', 'r2', 'angle' ]; |
+ |
+interfaces = [ |
+ { name: 'SVGPathSegArcAbs', nonFloatArity: 2 }, |
+ { name: 'SVGPathSegArcRel', nonFloatArity: 2 }, |
+ // SVGPathSegClosePath has arity 0 |
+ { name: 'SVGPathSegCurvetoCubicAbs' }, |
+ { name: 'SVGPathSegCurvetoCubicRel' }, |
+ { name: 'SVGPathSegCurvetoCubicSmoothAbs' }, |
+ { name: 'SVGPathSegCurvetoCubicSmoothRel' }, |
+ { name: 'SVGPathSegCurvetoQuadraticAbs' }, |
+ { name: 'SVGPathSegCurvetoQuadraticRel' }, |
+ { name: 'SVGPathSegCurvetoQuadraticSmoothAbs' }, |
+ { name: 'SVGPathSegCurvetoQuadraticSmoothRel' }, |
+ { name: 'SVGPathSegLinetoAbs' }, |
+ { name: 'SVGPathSegLinetoHorizontalAbs' }, |
+ { name: 'SVGPathSegLinetoHorizontalRel' }, |
+ { name: 'SVGPathSegLinetoRel' }, |
+ { name: 'SVGPathSegLinetoVerticalAbs' }, |
+ { name: 'SVGPathSegLinetoVerticalRel' }, |
+ { name: 'SVGPathSegMovetoAbs' }, |
+ { name: 'SVGPathSegMovetoRel' } |
+].forEach(function(item) { |
+ test(function() { |
+ var arity = constructorArity(item.name); |
+ var floatArgArity = arity - (item.nonFloatArity || 0); |
+ for (var i = 0; i < floatArgArity; ++i) { |
+ assert_throws(new TypeError, function() { construct(item.name, makeArgs(arity, i, Infinity)); }, 'passing Infinity (' + i + ')'); |
+ assert_throws(new TypeError, function() { construct(item.name, makeArgs(arity, i, NaN)); }, 'passing NaN (' + i + ')'); |
+ } |
+ }, 'SVGPathElement.create' + item.name + ' with non-finite arguments.'); |
+ test(function() { |
+ var segment = construct(item.name, makeArgs(constructorArity(item.name))); |
+ for (var prop in segment) { |
+ // Filter out non-float attributes. |
+ if (floatAttributes.indexOf(prop) < 0) |
+ continue; |
+ segment[prop] = 42; |
+ assert_equals(segment[prop], 42); |
+ assert_throws(new TypeError, function() { segment[prop] = Infinity; }, 'setting Infinity'); |
+ assert_throws(new TypeError, function() { segment[prop] = NaN; }, 'setting NaN'); |
+ assert_equals(segment[prop], 42); |
+ } |
+ }, item.name + ' attributes, non-finite values.'); |
+}); |
+</script> |