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

Side by Side Diff: LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html

Issue 1321783002: Throw exceptions for charnum == getNumberOfChars in get{...}OfChar APIs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/svg/text/svgtextcontentelement-methods-parameters-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <link rel="help" href="http://www.w3.org/TR/SVG2/text.html#InterfaceSVGTextConte ntElement"> 4 <link rel="help" href="http://www.w3.org/TR/SVG2/text.html#InterfaceSVGTextConte ntElement">
5 <script src="../../resources/js-test.js"></script> 5 <script src="../../resources/js-test.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <script> 8 <script>
9 description("Check that SVGTextContentElement methods' parameters are correctly validated"); 9 description("Check that SVGTextContentElement methods' parameters are correctly validated");
10 10
11 var svgNS = "http://www.w3.org/2000/svg"; 11 var svgNS = "http://www.w3.org/2000/svg";
12 12
13 var svgRoot = document.createElementNS(svgNS, "svg"); 13 var svgRoot = document.createElementNS(svgNS, "svg");
14 document.documentElement.appendChild(svgRoot); 14 document.documentElement.appendChild(svgRoot);
15 15
16 var svgText = document.createElementNS(svgNS, "text"); 16 var svgText = document.createElementNS(svgNS, "text");
17 svgText.style.fontFamily = "Ahem"; 17 svgText.style.fontFamily = "Ahem";
18 svgText.style.fontSize = "20px"; 18 svgText.style.fontSize = "20px";
19 svgText.appendChild(document.createTextNode("abcdefg")); 19 svgText.appendChild(document.createTextNode("abcdefg"));
20 svgRoot.appendChild(svgText); 20 svgRoot.appendChild(svgText);
21 21
22 var emptySvgText = document.createElementNS(svgNS, "text");
23 svgRoot.appendChild(emptySvgText);
24
22 var actualTestPoint, expectedTestPoint; 25 var actualTestPoint, expectedTestPoint;
23 function shouldBeEqualToSVGPoint(actualPoint, expectedPoint) 26 function shouldBeEqualToSVGPoint(actualPoint, expectedPoint)
24 { 27 {
25 actualTestPoint = actualPoint; 28 actualTestPoint = actualPoint;
26 expectedTestPoint = expectedPoint; 29 expectedTestPoint = expectedPoint;
27 shouldBe("actualTestPoint.x", "expectedTestPoint.x"); 30 shouldBe("actualTestPoint.x", "expectedTestPoint.x");
28 shouldBe("actualTestPoint.y", "expectedTestPoint.y"); 31 shouldBe("actualTestPoint.y", "expectedTestPoint.y");
29 } 32 }
30 33
31 var actualTestRect, expectedTestRect; 34 var actualTestRect, expectedTestRect;
(...skipping 20 matching lines...) Expand all
52 shouldThrow("svgText.selectSubString()", '"TypeError: Failed to execute \'select SubString\' on \'SVGTextContentElement\': 2 arguments required, but only 0 prese nt."'); 55 shouldThrow("svgText.selectSubString()", '"TypeError: Failed to execute \'select SubString\' on \'SVGTextContentElement\': 2 arguments required, but only 0 prese nt."');
53 shouldThrow("svgText.selectSubString(2)", '"TypeError: Failed to execute \'selec tSubString\' on \'SVGTextContentElement\': 2 arguments required, but only 1 pres ent."'); 56 shouldThrow("svgText.selectSubString(2)", '"TypeError: Failed to execute \'selec tSubString\' on \'SVGTextContentElement\': 2 arguments required, but only 1 pres ent."');
54 57
55 // Should throw an IndexSizeError if charnum is greater than or equal to the num ber of characters at this node. 58 // Should throw an IndexSizeError if charnum is greater than or equal to the num ber of characters at this node.
56 shouldThrow("svgText.getSubStringLength(999, 2)", '"IndexSizeError: Failed to ex ecute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); 59 shouldThrow("svgText.getSubStringLength(999, 2)", '"IndexSizeError: Failed to ex ecute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
57 shouldThrow("svgText.getStartPositionOfChar(999)", '"IndexSizeError: Failed to e xecute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum prov ided (999) is greater than the maximum bound (7)."'); 60 shouldThrow("svgText.getStartPositionOfChar(999)", '"IndexSizeError: Failed to e xecute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum prov ided (999) is greater than the maximum bound (7)."');
58 shouldThrow("svgText.getEndPositionOfChar(999)", '"IndexSizeError: Failed to exe cute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); 61 shouldThrow("svgText.getEndPositionOfChar(999)", '"IndexSizeError: Failed to exe cute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
59 shouldThrow("svgText.getExtentOfChar(999)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); 62 shouldThrow("svgText.getExtentOfChar(999)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
60 shouldThrow("svgText.getRotationOfChar(999)", '"IndexSizeError: Failed to execut e \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); 63 shouldThrow("svgText.getRotationOfChar(999)", '"IndexSizeError: Failed to execut e \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
61 shouldThrow("svgText.selectSubString(999, 2)", '"IndexSizeError: Failed to execu te \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."'); 64 shouldThrow("svgText.selectSubString(999, 2)", '"IndexSizeError: Failed to execu te \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
65 // Test the equality part of the restriction.
66 shouldThrow("svgText.getSubStringLength(7, 2)", '"IndexSizeError: Failed to exec ute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (7 ) is greater than or equal to the maximum bound (7)."');
67 shouldThrow("svgText.getStartPositionOfChar(7)", '"IndexSizeError: Failed to exe cute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum provid ed (7) is greater than or equal to the maximum bound (7)."');
68 shouldThrow("svgText.getEndPositionOfChar(7)", '"IndexSizeError: Failed to execu te \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided ( 7) is greater than or equal to the maximum bound (7)."');
69 shouldThrow("svgText.getExtentOfChar(7)", '"IndexSizeError: Failed to execute \' getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (7) is grea ter than or equal to the maximum bound (7)."');
70 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)."');
71 shouldThrow("svgText.selectSubString(7, 2)", '"IndexSizeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (7) is g reater than or equal to the maximum bound (7)."');
72 // Test the equality part of the restriction for the <number of chars> == 0 case .
73 shouldThrow("emptySvgText.getSubStringLength(0, 2)", '"IndexSizeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provid ed (0) is greater than or equal to the maximum bound (0)."');
74 shouldThrow("emptySvgText.getStartPositionOfChar(0)", '"IndexSizeError: Failed t o execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum p rovided (0) is greater than or equal to the maximum bound (0)."');
75 shouldThrow("emptySvgText.getEndPositionOfChar(0)", '"IndexSizeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provi ded (0) is greater than or equal to the maximum bound (0)."');
76 shouldThrow("emptySvgText.getExtentOfChar(0)", '"IndexSizeError: Failed to execu te \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."');
77 shouldThrow("emptySvgText.getRotationOfChar(0)", '"IndexSizeError: Failed to exe cute \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (0 ) is greater than or equal to the maximum bound (0)."');
78 shouldThrow("emptySvgText.selectSubString(0, 2)", '"IndexSizeError: Failed to ex ecute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."');
62 79
63 // Should not throw if charnum is negative and wraps to a valid positive index ( -4294967294 wraps to 2). 80 // Should not throw if charnum is negative and wraps to a valid positive index ( -4294967294 wraps to 2).
64 shouldBe("svgText.getSubStringLength(-4294967294, 2)", "svgText.getSubStringLeng th(2, 2)"); 81 shouldBe("svgText.getSubStringLength(-4294967294, 2)", "svgText.getSubStringLeng th(2, 2)");
65 shouldBeEqualToSVGPoint("svgText.getStartPositionOfChar(-4294967294)", "svgText. getStartPositionOfChar(2)"); 82 shouldBeEqualToSVGPoint("svgText.getStartPositionOfChar(-4294967294)", "svgText. getStartPositionOfChar(2)");
66 shouldBeEqualToSVGPoint("svgText.getEndPositionOfChar(-4294967294)", "svgText.ge tEndPositionOfChar(2)"); 83 shouldBeEqualToSVGPoint("svgText.getEndPositionOfChar(-4294967294)", "svgText.ge tEndPositionOfChar(2)");
67 shouldBeEqualToSVGRect("svgText.getExtentOfChar(-4294967294)", "svgText.getExten tOfChar(2)"); 84 shouldBeEqualToSVGRect("svgText.getExtentOfChar(-4294967294)", "svgText.getExten tOfChar(2)");
68 shouldBe("svgText.getRotationOfChar(-4294967294)", "svgText.getRotationOfChar(2) "); 85 shouldBe("svgText.getRotationOfChar(-4294967294)", "svgText.getRotationOfChar(2) ");
69 shouldNotThrow("svgText.selectSubString(-4294967294, 2)"); 86 shouldNotThrow("svgText.selectSubString(-4294967294, 2)");
70 87
71 // Should throw an IndexSizeError if charnum is negative and wraps to an invalid positive index. 88 // Should throw an IndexSizeError if charnum is negative and wraps to an invalid positive index.
(...skipping 10 matching lines...) Expand all
82 shouldBe("svgText.getSubStringLength(2, 999)", "svgText.getSubStringLength(2, 5) "); 99 shouldBe("svgText.getSubStringLength(2, 999)", "svgText.getSubStringLength(2, 5) ");
83 shouldBe("svgText.getSubStringLength(2, -1)", "svgText.getSubStringLength(2, 5)" ); 100 shouldBe("svgText.getSubStringLength(2, -1)", "svgText.getSubStringLength(2, 5)" );
84 shouldBe("svgText.getSubStringLength(2, 2)", "svgText.getSubStringLength(2, -429 4967294)"); 101 shouldBe("svgText.getSubStringLength(2, 2)", "svgText.getSubStringLength(2, -429 4967294)");
85 shouldNotThrow("svgText.selectSubString(2, 999)"); 102 shouldNotThrow("svgText.selectSubString(2, 999)");
86 shouldNotThrow("svgText.selectSubString(2, -1)"); 103 shouldNotThrow("svgText.selectSubString(2, -1)");
87 shouldNotThrow("svgText.selectSubString(2, -4294967294)"); 104 shouldNotThrow("svgText.selectSubString(2, -4294967294)");
88 105
89 </script> 106 </script>
90 </body> 107 </body>
91 </html> 108 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/svg/text/svgtextcontentelement-methods-parameters-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698