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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGGradientElement.html

Issue 2416163002: Convert LayoutTests/svg/dom/SVGAnimatedEnumeration*.html js-tests.js to testharness.js based tests. (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML>
2 <html> 2 <title>Use of SVGAnimatedEnumeration within SVGGradientElement</title>
3 <head> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 </head> 5 <script>
6 <body> 6 test(function() {
7 <p id="description"></p> 7 // This test checks the use of SVGAnimatedEnumeration within SVGGradientElemen t.
8 <div id="console"></div> 8
9 <script src="script-tests/SVGAnimatedEnumeration-SVGGradientElement.js"></script > 9 var gradientElement = document.createElementNS("http://www.w3.org/2000/svg", " linearGradient");
10 </body> 10 gradientElement.setAttribute("gradientUnits", "userSpaceOnUse");
11 </html> 11 gradientElement.setAttribute("spreadMethod", "pad");
12
13 // gradientUnits
14 // Check initial 'gradientUnits' value.
15 assert_true(gradientElement.gradientUnits instanceof SVGAnimatedEnumeration);
16 assert_equals(typeof(gradientElement.gradientUnits.baseVal), "number");
17 assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP E_USERSPACEONUSE);
18
19 // Switch to 'objectBoundingBox'.
20 gradientElement.gradientUnits.baseVal = SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUND INGBOX;
21 assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP E_OBJECTBOUNDINGBOX);
22 assert_equals(gradientElement.getAttribute('gradientUnits'), "objectBoundingBo x");
23
24 // Try setting invalid values.
25 assert_throws(new TypeError(), function() { gradientElement.gradientUnits.base Val = 3; });
26 assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP E_OBJECTBOUNDINGBOX);
27 assert_equals(gradientElement.getAttribute('gradientUnits'), "objectBoundingBo x");
28
29 assert_throws(new TypeError(), function() { gradientElement.gradientUnits.base Val = -1; });
30 assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP E_OBJECTBOUNDINGBOX);
31 assert_equals(gradientElement.getAttribute('gradientUnits'), "objectBoundingBo x");
32
33 assert_throws(new TypeError(), function() { gradientElement.gradientUnits.base Val = 0; });
34 assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP E_OBJECTBOUNDINGBOX);
35 assert_equals(gradientElement.getAttribute('gradientUnits'), "objectBoundingBo x");
36
37 // Switch to 'userSpaceOnUse'.
38 gradientElement.gradientUnits.baseVal = SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEON USE;
39 assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP E_USERSPACEONUSE);
40 assert_equals(gradientElement.getAttribute('gradientUnits'), "userSpaceOnUse") ;
41
42 // spreadMethod
43 // Check initial 'spreadMethod' value.
44 assert_true(gradientElement.spreadMethod instanceof SVGAnimatedEnumeration);
45 assert_equals(typeof(gradientElement.spreadMethod.baseVal), "number");
46 assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPR EADMETHOD_PAD);
47
48 // Switch to 'reflect' value.
49 gradientElement.spreadMethod.baseVal = SVGGradientElement.SVG_SPREADMETHOD_REF LECT;
50 assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPR EADMETHOD_REFLECT);
51 assert_equals(gradientElement.getAttribute('spreadMethod'), "reflect");
52
53 // Switch to 'repeat' value.
54 gradientElement.spreadMethod.baseVal = SVGGradientElement.SVG_SPREADMETHOD_REP EAT;
55 assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPR EADMETHOD_REPEAT);
56 assert_equals(gradientElement.getAttribute('spreadMethod'), "repeat");
57
58 // Try setting invalid values.
59 assert_throws(new TypeError(), function() { gradientElement.spreadMethod.baseV al = 4; });
60 assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPR EADMETHOD_REPEAT);
61 assert_equals(gradientElement.getAttribute('spreadMethod'), "repeat");
62
63 assert_throws(new TypeError(), function() { gradientElement.spreadMethod.baseV al = -1; });
64 assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPR EADMETHOD_REPEAT);
65 assert_equals(gradientElement.getAttribute('spreadMethod'), "repeat");
66
67 assert_throws(new TypeError(), function() { gradientElement.spreadMethod.baseV al = 0; });
68 assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPR EADMETHOD_REPEAT);
69 assert_equals(gradientElement.getAttribute('spreadMethod'), "repeat");
70
71 // Switch to 'pad'.
72 gradientElement.spreadMethod.baseVal = SVGGradientElement.SVG_SPREADMETHOD_PAD ;
73 assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPR EADMETHOD_PAD);
74 assert_equals(gradientElement.getAttribute('spreadMethod'), "pad");
75 });
76 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698