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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGGradientElement.html
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGGradientElement.html b/third_party/WebKit/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGGradientElement.html
index 1093ab4a12c156355526f3e586b466391135ec4e..e1afede438e03e2e5adb761ae209b1a447d574b7 100644
--- a/third_party/WebKit/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGGradientElement.html
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGGradientElement.html
@@ -1,11 +1,76 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-<script src="script-tests/SVGAnimatedEnumeration-SVGGradientElement.js"></script>
-</body>
-</html>
+<!DOCTYPE HTML>
+<title>Use of SVGAnimatedEnumeration within SVGGradientElement</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+test(function() {
+ // This test checks the use of SVGAnimatedEnumeration within SVGGradientElement.
+
+ var gradientElement = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
+ gradientElement.setAttribute("gradientUnits", "userSpaceOnUse");
+ gradientElement.setAttribute("spreadMethod", "pad");
+
+ // gradientUnits
+ // Check initial 'gradientUnits' value.
+ assert_true(gradientElement.gradientUnits instanceof SVGAnimatedEnumeration);
+ assert_equals(typeof(gradientElement.gradientUnits.baseVal), "number");
+ assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE);
+
+ // Switch to 'objectBoundingBox'.
+ gradientElement.gradientUnits.baseVal = SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
+ assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
+ assert_equals(gradientElement.getAttribute('gradientUnits'), "objectBoundingBox");
+
+ // Try setting invalid values.
+ assert_throws(new TypeError(), function() { gradientElement.gradientUnits.baseVal = 3; });
+ assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
+ assert_equals(gradientElement.getAttribute('gradientUnits'), "objectBoundingBox");
+
+ assert_throws(new TypeError(), function() { gradientElement.gradientUnits.baseVal = -1; });
+ assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
+ assert_equals(gradientElement.getAttribute('gradientUnits'), "objectBoundingBox");
+
+ assert_throws(new TypeError(), function() { gradientElement.gradientUnits.baseVal = 0; });
+ assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
+ assert_equals(gradientElement.getAttribute('gradientUnits'), "objectBoundingBox");
+
+ // Switch to 'userSpaceOnUse'.
+ gradientElement.gradientUnits.baseVal = SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE;
+ assert_equals(gradientElement.gradientUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE);
+ assert_equals(gradientElement.getAttribute('gradientUnits'), "userSpaceOnUse");
+
+ // spreadMethod
+ // Check initial 'spreadMethod' value.
+ assert_true(gradientElement.spreadMethod instanceof SVGAnimatedEnumeration);
+ assert_equals(typeof(gradientElement.spreadMethod.baseVal), "number");
+ assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPREADMETHOD_PAD);
+
+ // Switch to 'reflect' value.
+ gradientElement.spreadMethod.baseVal = SVGGradientElement.SVG_SPREADMETHOD_REFLECT;
+ assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPREADMETHOD_REFLECT);
+ assert_equals(gradientElement.getAttribute('spreadMethod'), "reflect");
+
+ // Switch to 'repeat' value.
+ gradientElement.spreadMethod.baseVal = SVGGradientElement.SVG_SPREADMETHOD_REPEAT;
+ assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPREADMETHOD_REPEAT);
+ assert_equals(gradientElement.getAttribute('spreadMethod'), "repeat");
+
+ // Try setting invalid values.
+ assert_throws(new TypeError(), function() { gradientElement.spreadMethod.baseVal = 4; });
+ assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPREADMETHOD_REPEAT);
+ assert_equals(gradientElement.getAttribute('spreadMethod'), "repeat");
+
+ assert_throws(new TypeError(), function() { gradientElement.spreadMethod.baseVal = -1; });
+ assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPREADMETHOD_REPEAT);
+ assert_equals(gradientElement.getAttribute('spreadMethod'), "repeat");
+
+ assert_throws(new TypeError(), function() { gradientElement.spreadMethod.baseVal = 0; });
+ assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPREADMETHOD_REPEAT);
+ assert_equals(gradientElement.getAttribute('spreadMethod'), "repeat");
+
+ // Switch to 'pad'.
+ gradientElement.spreadMethod.baseVal = SVGGradientElement.SVG_SPREADMETHOD_PAD;
+ assert_equals(gradientElement.spreadMethod.baseVal, SVGGradientElement.SVG_SPREADMETHOD_PAD);
+ assert_equals(gradientElement.getAttribute('spreadMethod'), "pad");
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698