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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGPathSeg-construction.html

Issue 1416273002: Remove SVGPathElement.pathSegList and related interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src=../../resources/testharness.js></script>
3 <script src=../../resources/testharnessreport.js></script>
4 <script>
5 setup(function() {
6 window.pathElement = document.createElementNS('http://www.w3.org/2000/svg', 'p ath');
7 });
8
9 function constructorArity(name) {
10 return SVGPathElement.prototype['create' + name].length;
11 }
12
13 function construct(name, args) {
14 return SVGPathElement.prototype['create' + name].apply(pathElement, args);
15 }
16
17 function makeArgs(total, valueIndex, value) {
18 var a = new Array(total);
19 for (var i = 0; i < total; ++i)
20 a[i] = i === valueIndex ? value : 0;
21 return a;
22 }
23
24 var floatAttributes = [ 'x', 'y', 'x1', 'y1', 'r1', 'x2', 'y2', 'r2', 'angle' ];
25
26 interfaces = [
27 { name: 'SVGPathSegArcAbs', nonFloatArity: 2 },
28 { name: 'SVGPathSegArcRel', nonFloatArity: 2 },
29 // SVGPathSegClosePath has arity 0
30 { name: 'SVGPathSegCurvetoCubicAbs' },
31 { name: 'SVGPathSegCurvetoCubicRel' },
32 { name: 'SVGPathSegCurvetoCubicSmoothAbs' },
33 { name: 'SVGPathSegCurvetoCubicSmoothRel' },
34 { name: 'SVGPathSegCurvetoQuadraticAbs' },
35 { name: 'SVGPathSegCurvetoQuadraticRel' },
36 { name: 'SVGPathSegCurvetoQuadraticSmoothAbs' },
37 { name: 'SVGPathSegCurvetoQuadraticSmoothRel' },
38 { name: 'SVGPathSegLinetoAbs' },
39 { name: 'SVGPathSegLinetoHorizontalAbs' },
40 { name: 'SVGPathSegLinetoHorizontalRel' },
41 { name: 'SVGPathSegLinetoRel' },
42 { name: 'SVGPathSegLinetoVerticalAbs' },
43 { name: 'SVGPathSegLinetoVerticalRel' },
44 { name: 'SVGPathSegMovetoAbs' },
45 { name: 'SVGPathSegMovetoRel' }
46 ].forEach(function(item) {
47 test(function() {
48 var arity = constructorArity(item.name);
49 var floatArgArity = arity - (item.nonFloatArity || 0);
50 for (var i = 0; i < floatArgArity; ++i) {
51 assert_throws(new TypeError, function() { construct(item.name, makeArgs(ar ity, i, Infinity)); }, 'passing Infinity (' + i + ')');
52 assert_throws(new TypeError, function() { construct(item.name, makeArgs(ar ity, i, NaN)); }, 'passing NaN (' + i + ')');
53 }
54 }, 'SVGPathElement.create' + item.name + ' with non-finite arguments.');
55 test(function() {
56 var segment = construct(item.name, makeArgs(constructorArity(item.name)));
57 for (var prop in segment) {
58 // Filter out non-float attributes.
59 if (floatAttributes.indexOf(prop) < 0)
60 continue;
61 segment[prop] = 42;
62 assert_equals(segment[prop], 42);
63 assert_throws(new TypeError, function() { segment[prop] = Infinity; }, 'se tting Infinity');
64 assert_throws(new TypeError, function() { segment[prop] = NaN; }, 'setting NaN');
65 assert_equals(segment[prop], 42);
66 }
67 }, item.name + ' attributes, non-finite values.');
68 });
69 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698