Index: third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html |
diff --git a/third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html b/third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html |
index ea7ac89ad7ae7be421ef0b80303293031860db9f..a8b5a00693757b4ca9c6200fbd60472eb6493df8 100644 |
--- a/third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html |
+++ b/third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html |
@@ -1,21 +1,18 @@ |
<!DOCTYPE html> |
-<html> |
-<head> |
+<title>Check that SVGTextContentElement methods' parameters are correctly validated</title> |
<link rel="help" href="http://www.w3.org/TR/SVG2/text.html#InterfaceSVGTextContentElement"> |
-<script src="../../resources/js-test.js"></script> |
-</head> |
-<body> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
<script> |
-description("Check that SVGTextContentElement methods' parameters are correctly validated"); |
- |
+test(function() { |
var svgNS = "http://www.w3.org/2000/svg"; |
- |
var svgRoot = document.createElementNS(svgNS, "svg"); |
document.documentElement.appendChild(svgRoot); |
var svgText = document.createElementNS(svgNS, "text"); |
svgText.style.fontFamily = "Ahem"; |
svgText.style.fontSize = "20px"; |
+svgText.style.visibility = "hidden"; |
svgText.appendChild(document.createTextNode("abcdefg")); |
svgRoot.appendChild(svgText); |
@@ -23,86 +20,86 @@ var emptySvgText = document.createElementNS(svgNS, "text"); |
svgRoot.appendChild(emptySvgText); |
var actualTestPoint, expectedTestPoint; |
-function shouldBeEqualToSVGPoint(actualPoint, expectedPoint) |
+function assert_equals_to_SVGPoint(actualPoint, expectedPoint) |
{ |
actualTestPoint = actualPoint; |
expectedTestPoint = expectedPoint; |
- shouldBe("actualTestPoint.x", "expectedTestPoint.x"); |
- shouldBe("actualTestPoint.y", "expectedTestPoint.y"); |
+ assert_equals(actualTestPoint.x, expectedTestPoint.x); |
+ assert_equals(actualTestPoint.y, expectedTestPoint.y); |
} |
var actualTestRect, expectedTestRect; |
-function shouldBeEqualToSVGRect(actualRect, expectedRect) |
+function assert_equals_to_SVGRect(actualRect, expectedRect) |
{ |
actualTestRect = actualRect; |
expectedTestRect = expectedRect; |
- shouldBe("actualTestRect.x", "expectedTestRect.x"); |
- shouldBe("actualTestRect.y", "expectedTestRect.y"); |
- shouldBe("actualTestRect.width", "expectedTestRect.width"); |
- shouldBe("actualTestRect.height", "expectedTestRect.height"); |
+ assert_equals(actualTestRect.x, expectedTestRect.x); |
+ assert_equals(actualTestRect.y, expectedTestRect.y); |
+ assert_equals(actualTestRect.width, expectedTestRect.width); |
+ assert_equals(actualTestRect.height, expectedTestRect.height); |
} |
// Arguments should be mandatory. |
-shouldThrow("svgText.getSubStringLength()", '"TypeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': 2 arguments required, but only 0 present."'); |
-shouldThrow("svgText.getSubStringLength(2)", '"TypeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': 2 arguments required, but only 1 present."'); |
-shouldThrow("svgText.getStartPositionOfChar()", '"TypeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."'); |
-shouldThrow("svgText.getEndPositionOfChar()", '"TypeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."'); |
-shouldThrow("svgText.getExtentOfChar()", '"TypeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."'); |
-shouldThrow("svgText.getRotationOfChar()", '"TypeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."'); |
-shouldThrow("svgText.getCharNumAtPosition()", '"TypeError: Failed to execute \'getCharNumAtPosition\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."'); |
-shouldThrow("svgText.getCharNumAtPosition('aString')", '"TypeError: Failed to execute \'getCharNumAtPosition\' on \'SVGTextContentElement\': parameter 1 is not of type \'SVGPoint\'."'); |
-shouldThrow("svgText.getCharNumAtPosition(svgText)", '"TypeError: Failed to execute \'getCharNumAtPosition\' on \'SVGTextContentElement\': parameter 1 is not of type \'SVGPoint\'."'); |
-shouldThrow("svgText.selectSubString()", '"TypeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': 2 arguments required, but only 0 present."'); |
-shouldThrow("svgText.selectSubString(2)", '"TypeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': 2 arguments required, but only 1 present."'); |
+assert_throws(new TypeError(), function() { svgText.getSubStringLength(); }); |
+assert_throws(new TypeError(), function() { svgText.getSubStringLength(2); }); |
+assert_throws(new TypeError(), function() { svgText.getStartPositionOfChar(); }); |
+assert_throws(new TypeError(), function() { svgText.getEndPositionOfChar(); }); |
+assert_throws(new TypeError(), function() { svgText.getExtentOfChar(); }); |
+assert_throws(new TypeError(), function() { svgText.getRotationOfChar(); }); |
+assert_throws(new TypeError(), function() { svgText.getCharNumAtPosition(); }); |
+assert_throws(new TypeError(), function() { svgText.getCharNumAtPosition('aString'); }); |
+assert_throws(new TypeError(), function() { svgText.getCharNumAtPosition(svgText); }); |
+assert_throws(new TypeError(), function() { svgText.selectSubString(); }); |
+assert_throws(new TypeError(), function() { svgText.selectSubString(2); }); |
// Should throw an IndexSizeError if charnum is greater than or equal to the number of characters at this node. |
-shouldThrow("svgText.getSubStringLength(999, 2)", '"IndexSizeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.getStartPositionOfChar(999)", '"IndexSizeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.getEndPositionOfChar(999)", '"IndexSizeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.getExtentOfChar(999)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.getRotationOfChar(999)", '"IndexSizeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.selectSubString(999, 2)", '"IndexSizeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); |
+assert_throws("IndexSizeError", function() { svgText.getSubStringLength(999, 2); }); |
+assert_throws("IndexSizeError", function() { svgText.getStartPositionOfChar(999); }); |
+assert_throws("IndexSizeError", function() { svgText.getEndPositionOfChar(999); }); |
+assert_throws("IndexSizeError", function() { svgText.getExtentOfChar(999); }); |
+assert_throws("IndexSizeError", function() { svgText.getRotationOfChar(999); }); |
+assert_throws("IndexSizeError", function() { svgText.selectSubString(999, 2); }); |
+ |
// Test the equality part of the restriction. |
-shouldThrow("svgText.getSubStringLength(7, 2)", '"IndexSizeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."'); |
-shouldThrow("svgText.getStartPositionOfChar(7)", '"IndexSizeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."'); |
-shouldThrow("svgText.getEndPositionOfChar(7)", '"IndexSizeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."'); |
-shouldThrow("svgText.getExtentOfChar(7)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."'); |
-shouldThrow("svgText.getRotationOfChar(7)", '"IndexSizeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."'); |
-shouldThrow("svgText.selectSubString(7, 2)", '"IndexSizeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."'); |
+assert_throws("IndexSizeError", function() { svgText.getSubStringLength(7, 2); }); |
+assert_throws("IndexSizeError", function() { svgText.getStartPositionOfChar(7); }); |
+assert_throws("IndexSizeError", function() { svgText.getEndPositionOfChar(7); }); |
+assert_throws("IndexSizeError", function() { svgText.getExtentOfChar(7); }); |
+assert_throws("IndexSizeError", function() { svgText.getRotationOfChar(7); }); |
+assert_throws("IndexSizeError", function() { svgText.selectSubString(7, 2); }); |
+ |
// Test the equality part of the restriction for the <number of chars> == 0 case. |
-shouldThrow("emptySvgText.getSubStringLength(0, 2)", '"IndexSizeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."'); |
-shouldThrow("emptySvgText.getStartPositionOfChar(0)", '"IndexSizeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."'); |
-shouldThrow("emptySvgText.getEndPositionOfChar(0)", '"IndexSizeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."'); |
-shouldThrow("emptySvgText.getExtentOfChar(0)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."'); |
-shouldThrow("emptySvgText.getRotationOfChar(0)", '"IndexSizeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."'); |
-shouldThrow("emptySvgText.selectSubString(0, 2)", '"IndexSizeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."'); |
+assert_throws("IndexSizeError", function() { emptySvgText.getSubStringLength(0, 2); }); |
+assert_throws("IndexSizeError", function() { emptySvgText.getStartPositionOfChar(0); }); |
+assert_throws("IndexSizeError", function() { emptySvgText.getEndPositionOfChar(0); }); |
+assert_throws("IndexSizeError", function() { emptySvgText.getExtentOfChar(0); }); |
+assert_throws("IndexSizeError", function() { emptySvgText.getRotationOfChar(0); }); |
+assert_throws("IndexSizeError", function() { emptySvgText.selectSubString(0, 2); }); |
// Should not throw if charnum is negative and wraps to a valid positive index (-4294967294 wraps to 2). |
-shouldBe("svgText.getSubStringLength(-4294967294, 2)", "svgText.getSubStringLength(2, 2)"); |
-shouldBeEqualToSVGPoint("svgText.getStartPositionOfChar(-4294967294)", "svgText.getStartPositionOfChar(2)"); |
-shouldBeEqualToSVGPoint("svgText.getEndPositionOfChar(-4294967294)", "svgText.getEndPositionOfChar(2)"); |
-shouldBeEqualToSVGRect("svgText.getExtentOfChar(-4294967294)", "svgText.getExtentOfChar(2)"); |
-shouldBe("svgText.getRotationOfChar(-4294967294)", "svgText.getRotationOfChar(2)"); |
-shouldNotThrow("svgText.selectSubString(-4294967294, 2)"); |
+assert_equals(svgText.getSubStringLength(-4294967294, 2), svgText.getSubStringLength(2, 2)); |
+assert_equals_to_SVGPoint(svgText.getStartPositionOfChar(-4294967294), svgText.getStartPositionOfChar(2)); |
+assert_equals_to_SVGPoint(svgText.getEndPositionOfChar(-4294967294), svgText.getEndPositionOfChar(2)); |
+assert_equals_to_SVGRect(svgText.getExtentOfChar(-4294967294), svgText.getExtentOfChar(2)); |
+assert_equals(svgText.getRotationOfChar(-4294967294), svgText.getRotationOfChar(2)); |
+svgText.selectSubString(-4294967294, 2); |
// Should throw an IndexSizeError if charnum is negative and wraps to an invalid positive index. |
-shouldThrow("svgText.getSubStringLength(-1, 2)", '"IndexSizeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.getStartPositionOfChar(-1)", '"IndexSizeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.getEndPositionOfChar(-1)", '"IndexSizeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.getExtentOfChar(-1)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.getRotationOfChar(-1)", '"IndexSizeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."'); |
-shouldThrow("svgText.selectSubString(-1, 2)", '"IndexSizeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."'); |
+assert_throws("IndexSizeError", function() { svgText.getSubStringLength(-1, 2); }); |
+assert_throws("IndexSizeError", function() { svgText.getStartPositionOfChar(-1); }); |
+assert_throws("IndexSizeError", function() { svgText.getEndPositionOfChar(-1); }); |
+assert_throws("IndexSizeError", function() { svgText.getExtentOfChar(-1); }); |
+assert_throws("IndexSizeError", function() { svgText.getRotationOfChar(-1); }); |
+assert_throws("IndexSizeError", function() { svgText.selectSubString(-1, 2); }); |
// We should not throw if nchars is negative or too large. |
// If nchars specifies more characters than are available, then the substring will consist of all characters |
// starting with charnum until the end of the list of characters. |
-shouldBe("svgText.getSubStringLength(2, 999)", "svgText.getSubStringLength(2, 5)"); |
-shouldBe("svgText.getSubStringLength(2, -1)", "svgText.getSubStringLength(2, 5)"); |
-shouldBe("svgText.getSubStringLength(2, 2)", "svgText.getSubStringLength(2, -4294967294)"); |
-shouldNotThrow("svgText.selectSubString(2, 999)"); |
-shouldNotThrow("svgText.selectSubString(2, -1)"); |
-shouldNotThrow("svgText.selectSubString(2, -4294967294)"); |
- |
+assert_equals(svgText.getSubStringLength(2, 999), svgText.getSubStringLength(2, 5)); |
+assert_equals(svgText.getSubStringLength(2, -1), svgText.getSubStringLength(2, 5)); |
+assert_equals(svgText.getSubStringLength(2, 2), svgText.getSubStringLength(2, -4294967294)); |
+svgText.selectSubString(2, 999); |
+svgText.selectSubString(2, -1); |
+svgText.selectSubString(2, -4294967294); |
+}); |
</script> |
-</body> |
-</html> |