Chromium Code Reviews| Index: LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html |
| diff --git a/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html b/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d87ce9383df8c3a1423846651822f86ef7ee5fa9 |
| --- /dev/null |
| +++ b/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html |
| @@ -0,0 +1,90 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<link rel="help" href="http://www.w3.org/TR/SVG2/text.html#InterfaceSVGTextContentElement"> |
| +<script src="../../fast/js/resources/js-test-pre.js"></script> |
| +</head> |
| +<body> |
| +<script> |
| +description("Check that SVGTextContentElement methods' parameters are correctly validated"); |
| + |
| +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.appendChild(document.createTextNode("abcdefg")); |
| +svgRoot.appendChild(svgText); |
| + |
| +var actual_point, expected_point; |
| +function shouldBeEqualToSVGPoint(_actual_point, _expected_point) |
| +{ |
| + actual_point = _actual_point; |
|
arv (Not doing code reviews)
2013/08/12 13:47:21
Do not use underscores in identifier names.
|
| + expected_point = _expected_point; |
| + shouldBe("actual_point.x", "expected_point.x"); |
| + shouldBe("actual_point.y", "expected_point.y"); |
| +} |
| + |
| +var actual_rect, expected_rect; |
| +function shouldBeEqualToSVGRect(_actual_rect, _expected_rect) |
| +{ |
| + actual_rect = _actual_rect; |
| + expected_rect = _expected_rect; |
| + shouldBe("actual_rect.x", "expected_rect.x"); |
| + shouldBe("actual_rect.y", "expected_rect.y"); |
| + shouldBe("actual_rect.width", "expected_rect.width"); |
| + shouldBe("actual_rect.height", "expected_rect.height"); |
| +} |
| + |
| +// Arguments should be mandatory. |
| +shouldThrow("svgText.getSubStringLength()", "'TypeError: Not enough arguments'"); |
| +shouldThrow("svgText.getSubStringLength(2)", "'TypeError: Not enough arguments'"); |
| +shouldThrow("svgText.getStartPositionOfChar()", "'TypeError: Not enough arguments'"); |
| +shouldThrow("svgText.getEndPositionOfChar()", "'TypeError: Not enough arguments'"); |
| +shouldThrow("svgText.getExtentOfChar()", "'TypeError: Not enough arguments'"); |
| +shouldThrow("svgText.getRotationOfChar()", "'TypeError: Not enough arguments'"); |
| +shouldThrow("svgText.getCharNumAtPosition()", "'TypeError: Not enough arguments'"); |
| +shouldThrow("svgText.selectSubString()", "'TypeError: Not enough arguments'"); |
| +shouldThrow("svgText.selectSubString(2)", "'TypeError: Not enough arguments'"); |
| + |
| +// 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: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.getStartPositionOfChar(999)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.getEndPositionOfChar(999)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.getExtentOfChar(999)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.getRotationOfChar(999)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.selectSubString(999, 2)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| + |
| +// 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)"); |
| + |
| +// Should throw an IndexSizeError if charnum is negative and wraps to an invalid positive index. |
| +shouldThrow("svgText.getSubStringLength(-1, 2)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.getStartPositionOfChar(-1)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.getEndPositionOfChar(-1)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.getExtentOfChar(-1)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.getRotationOfChar(-1)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| +shouldThrow("svgText.selectSubString(-1, 2)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); |
| + |
| +// 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)"); |
| + |
| +</script> |
| +<script src="../../fast/js/resources/js-test-post.js"></script> |
| +</body> |
| +</html> |