OLD | NEW |
1 var svgNS = "http://www.w3.org/2000/svg"; | 1 var svgNS = "http://www.w3.org/2000/svg"; |
2 | 2 |
3 var svgRoot = document.createElementNS(svgNS, "svg"); | 3 var svgRoot = document.createElementNS(svgNS, "svg"); |
4 document.documentElement.appendChild(svgRoot); | 4 document.documentElement.appendChild(svgRoot); |
5 | 5 |
6 var svgText = document.createElementNS(svgNS, "text"); | 6 var svgText = document.createElementNS(svgNS, "text"); |
7 svgText.style.fontFamily = "Ahem"; | 7 svgText.style.fontFamily = "Ahem"; |
8 svgText.style.fontSize = "20px"; | 8 svgText.style.fontSize = "20px"; |
9 svgText.appendChild(document.createTextNode("abc")); | 9 svgText.appendChild(document.createTextNode("abc")); |
10 svgRoot.appendChild(svgText); | 10 svgRoot.appendChild(svgText); |
11 | 11 |
12 shouldThrow("svgText.getSubStringLength(-1, 2)"); | 12 shouldThrow("svgText.getSubStringLength(-1, 2)"); |
13 shouldThrow("svgText.getSubStringLength(-1, 0)"); | 13 shouldThrow("svgText.getSubStringLength(-1, 0)"); |
14 shouldBe("svgText.getSubStringLength(1, 3)", "40"); | 14 shouldBe("svgText.getSubStringLength(1, 3)", "40"); |
15 shouldBe("svgText.getSubStringLength(0, 4)", "60"); | 15 shouldBe("svgText.getSubStringLength(0, 4)", "60"); |
16 shouldThrow("svgText.getSubStringLength(3, 0)"); | 16 shouldThrow("svgText.getSubStringLength(3, 0)"); |
17 | 17 |
18 shouldBe("svgText.getSubStringLength(0, 0)", "0"); | 18 shouldBe("svgText.getSubStringLength(0, 0)", "0"); |
19 shouldBe("svgText.getSubStringLength(2, 0)", "0"); | 19 shouldBe("svgText.getSubStringLength(2, 0)", "0"); |
20 | 20 |
21 shouldBe("svgText.getSubStringLength(0, 1)", "20"); | 21 shouldBe("svgText.getSubStringLength(0, 1)", "20"); |
22 shouldBe("svgText.getSubStringLength(1, 1)", "20"); | 22 shouldBe("svgText.getSubStringLength(1, 1)", "20"); |
23 shouldBe("svgText.getSubStringLength(2, 1)", "20"); | 23 shouldBe("svgText.getSubStringLength(2, 1)", "20"); |
24 shouldBe("svgText.getSubStringLength(0, 3)", "60"); | 24 shouldBe("svgText.getSubStringLength(0, 3)", "60"); |
25 | 25 |
26 shouldThrow("svgText.getSubStringLength(1, -1)"); | 26 shouldNotThrow("svgText.getSubStringLength(1, -1)"); |
27 shouldThrow("svgText.getSubStringLength(2, -1)"); | 27 shouldNotThrow("svgText.getSubStringLength(2, -1)"); |
28 shouldThrow("svgText.getSubStringLength(3, -1)"); | 28 shouldThrow("svgText.getSubStringLength(3, -1)", "'IndexSizeError: Index or size
was negative, or greater than the allowed value.'"); |
29 shouldThrow("svgText.getSubStringLength(3, -3)"); | 29 shouldThrow("svgText.getSubStringLength(3, -3)", "'IndexSizeError: Index or size
was negative, or greater than the allowed value.'"); |
30 | 30 |
31 // cleanup | 31 // cleanup |
32 document.documentElement.removeChild(svgRoot); | 32 document.documentElement.removeChild(svgRoot); |
33 | 33 |
34 var successfullyParsed = true; | 34 var successfullyParsed = true; |
OLD | NEW |