Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: LayoutTests/svg/dom/SVGPathSeg-construction.html

Issue 925873005: Add TypeChecking=Unrestricted to SVGPathSeg interfaces and "constructors" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/svg/SVGPathElement.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | Source/core/svg/SVGPathElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698