OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <link rel="help" href="http://www.w3.org/TR/SVG2/text.html#InterfaceSVGTextConte
ntElement"> |
| 5 <script src="../../fast/js/resources/js-test-pre.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 <script> |
| 9 description("Check that SVGTextContentElement methods' parameters are correctly
validated"); |
| 10 |
| 11 var svgNS = "http://www.w3.org/2000/svg"; |
| 12 |
| 13 var svgRoot = document.createElementNS(svgNS, "svg"); |
| 14 document.documentElement.appendChild(svgRoot); |
| 15 |
| 16 var svgText = document.createElementNS(svgNS, "text"); |
| 17 svgText.style.fontFamily = "Ahem"; |
| 18 svgText.style.fontSize = "20px"; |
| 19 svgText.appendChild(document.createTextNode("abcdefg")); |
| 20 svgRoot.appendChild(svgText); |
| 21 |
| 22 var actualTestPoint, expectedTestPoint; |
| 23 function shouldBeEqualToSVGPoint(actualPoint, expectedPoint) |
| 24 { |
| 25 actualTestPoint = actualPoint; |
| 26 expectedTestPoint = expectedPoint; |
| 27 shouldBe("actualTestPoint.x", "expectedTestPoint.x"); |
| 28 shouldBe("actualTestPoint.y", "expectedTestPoint.y"); |
| 29 } |
| 30 |
| 31 var actualTestRect, expectedTestRect; |
| 32 function shouldBeEqualToSVGRect(actualRect, expectedRect) |
| 33 { |
| 34 actualTestRect = actualRect; |
| 35 expectedTestRect = expectedRect; |
| 36 shouldBe("actualTestRect.x", "expectedTestRect.x"); |
| 37 shouldBe("actualTestRect.y", "expectedTestRect.y"); |
| 38 shouldBe("actualTestRect.width", "expectedTestRect.width"); |
| 39 shouldBe("actualTestRect.height", "expectedTestRect.height"); |
| 40 } |
| 41 |
| 42 // Arguments should be mandatory. |
| 43 shouldThrow("svgText.getSubStringLength()", "'TypeError: Not enough arguments'")
; |
| 44 shouldThrow("svgText.getSubStringLength(2)", "'TypeError: Not enough arguments'"
); |
| 45 shouldThrow("svgText.getStartPositionOfChar()", "'TypeError: Not enough argument
s'"); |
| 46 shouldThrow("svgText.getEndPositionOfChar()", "'TypeError: Not enough arguments'
"); |
| 47 shouldThrow("svgText.getExtentOfChar()", "'TypeError: Not enough arguments'"); |
| 48 shouldThrow("svgText.getRotationOfChar()", "'TypeError: Not enough arguments'"); |
| 49 shouldThrow("svgText.getCharNumAtPosition()", "'TypeError: Not enough arguments'
"); |
| 50 shouldThrow("svgText.selectSubString()", "'TypeError: Not enough arguments'"); |
| 51 shouldThrow("svgText.selectSubString(2)", "'TypeError: Not enough arguments'"); |
| 52 |
| 53 // Should throw an IndexSizeError if charnum is greater than or equal to the num
ber of characters at this node. |
| 54 shouldThrow("svgText.getSubStringLength(999, 2)", "'IndexSizeError: Index or siz
e was negative, or greater than the allowed value.'"); |
| 55 shouldThrow("svgText.getStartPositionOfChar(999)", "'IndexSizeError: Index or si
ze was negative, or greater than the allowed value.'"); |
| 56 shouldThrow("svgText.getEndPositionOfChar(999)", "'IndexSizeError: Index or size
was negative, or greater than the allowed value.'"); |
| 57 shouldThrow("svgText.getExtentOfChar(999)", "'IndexSizeError: Index or size was
negative, or greater than the allowed value.'"); |
| 58 shouldThrow("svgText.getRotationOfChar(999)", "'IndexSizeError: Index or size wa
s negative, or greater than the allowed value.'"); |
| 59 shouldThrow("svgText.selectSubString(999, 2)", "'IndexSizeError: Index or size w
as negative, or greater than the allowed value.'"); |
| 60 |
| 61 // Should not throw if charnum is negative and wraps to a valid positive index (
-4294967294 wraps to 2). |
| 62 shouldBe("svgText.getSubStringLength(-4294967294, 2)", "svgText.getSubStringLeng
th(2, 2)"); |
| 63 shouldBeEqualToSVGPoint("svgText.getStartPositionOfChar(-4294967294)", "svgText.
getStartPositionOfChar(2)"); |
| 64 shouldBeEqualToSVGPoint("svgText.getEndPositionOfChar(-4294967294)", "svgText.ge
tEndPositionOfChar(2)"); |
| 65 shouldBeEqualToSVGRect("svgText.getExtentOfChar(-4294967294)", "svgText.getExten
tOfChar(2)"); |
| 66 shouldBe("svgText.getRotationOfChar(-4294967294)", "svgText.getRotationOfChar(2)
"); |
| 67 shouldNotThrow("svgText.selectSubString(-4294967294, 2)"); |
| 68 |
| 69 // Should throw an IndexSizeError if charnum is negative and wraps to an invalid
positive index. |
| 70 shouldThrow("svgText.getSubStringLength(-1, 2)", "'IndexSizeError: Index or size
was negative, or greater than the allowed value.'"); |
| 71 shouldThrow("svgText.getStartPositionOfChar(-1)", "'IndexSizeError: Index or siz
e was negative, or greater than the allowed value.'"); |
| 72 shouldThrow("svgText.getEndPositionOfChar(-1)", "'IndexSizeError: Index or size
was negative, or greater than the allowed value.'"); |
| 73 shouldThrow("svgText.getExtentOfChar(-1)", "'IndexSizeError: Index or size was n
egative, or greater than the allowed value.'"); |
| 74 shouldThrow("svgText.getRotationOfChar(-1)", "'IndexSizeError: Index or size was
negative, or greater than the allowed value.'"); |
| 75 shouldThrow("svgText.selectSubString(-1, 2)", "'IndexSizeError: Index or size wa
s negative, or greater than the allowed value.'"); |
| 76 |
| 77 // We should not throw if nchars is negative or too large. |
| 78 // If nchars specifies more characters than are available, then the substring wi
ll consist of all characters |
| 79 // starting with charnum until the end of the list of characters. |
| 80 shouldBe("svgText.getSubStringLength(2, 999)", "svgText.getSubStringLength(2, 5)
"); |
| 81 shouldBe("svgText.getSubStringLength(2, -1)", "svgText.getSubStringLength(2, 5)"
); |
| 82 shouldBe("svgText.getSubStringLength(2, 2)", "svgText.getSubStringLength(2, -429
4967294)"); |
| 83 shouldNotThrow("svgText.selectSubString(2, 999)"); |
| 84 shouldNotThrow("svgText.selectSubString(2, -1)"); |
| 85 shouldNotThrow("svgText.selectSubString(2, -4294967294)"); |
| 86 |
| 87 </script> |
| 88 <script src="../../fast/js/resources/js-test-post.js"></script> |
| 89 </body> |
| 90 </html> |
OLD | NEW |