| 1 |
<svg version="1.1" baseProfile="full" id="svg-root" |
| 2 |
width="100%" height="100%" viewBox="0 0 480 360" |
| 3 |
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 4 |
<!--======================================================================--> |
| 5 |
<!--= SVG 1.1 2nd Edition Test Case =--> |
| 6 |
<!--======================================================================--> |
| 7 |
<!--= Copyright 2009 World Wide Web Consortium, (Massachusetts =--> |
| 8 |
<!--= Institute of Technology, European Research Consortium for =--> |
| 9 |
<!--= Informatics and Mathematics (ERCIM), Keio University). =--> |
| 10 |
<!--= All Rights Reserved. =--> |
| 11 |
<!--= See http://www.w3.org/Consortium/Legal/. =--> |
| 12 |
<!--======================================================================--> |
| 13 |
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/" |
| 14 |
template-version="1.3" reviewer="DAS" author="CM" status="accepted" |
| 15 |
version="$Revision: 1.9 $" testname="$RCSfile: text-dom-03-f.svg,v $"> |
| 16 |
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/text.html#InterfaceSVGTextContentElement"> |
| 17 |
<p> |
| 18 |
This tests that SVGTextContentElement.getSubStringLength() |
| 19 |
handles out-of-range charnum and nchars parameter values correctly. |
| 20 |
</p> |
| 21 |
<p> |
| 22 |
The test consists of 5 sub-tests, which test the different |
| 23 |
combinations of values passed to SVGTextContentElement.getSubStringLength(). |
| 24 |
The result of each sub-test is shown as a small rectangle: black |
| 25 |
indicates that the sub-test did not run, red indicates that |
| 26 |
the sub-test failed and green indicates that the sub-test |
| 27 |
succeeded. |
| 28 |
</p> |
| 29 |
</d:testDescription> |
| 30 |
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml"> |
| 31 |
<p> |
| 32 |
Run the test. No interaction required. The test relies on support for SVG Fonts. |
| 33 |
</p> |
| 34 |
</d:operatorScript> |
| 35 |
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml"> |
| 36 |
<p> |
| 37 |
The test is passed if all 5 rectangles are green. |
| 38 |
</p> |
| 39 |
</d:passCriteria> |
| 40 |
</d:SVGTestCase> |
| 41 |
<title id="test-title">$RCSfile: text-dom-03-f.svg,v $</title> |
| 42 |
<defs> |
| 43 |
<font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F"> |
| 44 |
<font-face-src> |
| 45 |
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> |
| 46 |
</font-face-src> |
| 47 |
</font-face> |
| 48 |
</defs> |
| 49 |
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> |
| 50 |
<text x='10' y='30' font-size='13'>Test that getSubStringLength() handles out-of-range arguments</text> |
| 51 |
|
| 52 |
<font horiz-adv-x='1000'> |
| 53 |
<font-face font-family='TestFont'/> |
| 54 |
<glyph unicode='a' horiz-adv-x='100' d='M0,0 h80 v1000 h-80 z'/> |
| 55 |
<glyph unicode='𐀀' horiz-adv-x='200' d='M0,0 h180 v1000 h-180 z'/> |
| 56 |
<glyph unicode='b' horiz-adv-x='400' d='M0,0 h380 v1000 h-380 z'/> |
| 57 |
</font> |
| 58 |
|
| 59 |
<text id='t' x='50' y='50' visibility='hidden' font-family='TestFont' font-size='10'>ababa</text> |
| 60 |
|
| 61 |
<rect id='r1' x='10' y='40' width='30' height='30'/> |
| 62 |
<text x='50' y='60'>charnum < 0</text> |
| 63 |
|
| 64 |
<rect id='r2' x='10' y='80' width='30' height='30'/> |
| 65 |
<text x='50' y='100'>nchars < 0</text> |
| 66 |
|
| 67 |
<rect id='r3' x='10' y='120' width='30' height='30'/> |
| 68 |
<text x='50' y='140'>charnum = 0, nchars = length</text> |
| 69 |
|
| 70 |
<rect id='r4' x='10' y='160' width='30' height='30'/> |
| 71 |
<text x='50' y='180'>charnum = 0, nchars = length + 10</text> |
| 72 |
|
| 73 |
<rect id='r5' x='10' y='200' width='30' height='30'/> |
| 74 |
<text x='50' y='220'>charnum = 1, nchars = -1</text> |
| 75 |
|
| 76 |
<script><![CDATA[ |
| 77 |
function $(x) { return document.getElementById(x) } |
| 78 |
|
| 79 |
var b, t = $('t'); |
| 80 |
|
| 81 |
b = false; |
| 82 |
try { |
| 83 |
t.getSubStringLength(-1, 1); |
| 84 |
} catch (e) { |
| 85 |
b = e.code == 1; // DOMException.INDEX_SIZE_ERR |
| 86 |
} |
| 87 |
$('r1').setAttribute('fill', b ? 'green' : 'red'); |
| 88 |
|
| 89 |
b = false; |
| 90 |
try { |
| 91 |
t.getSubStringLength(1, -1); |
| 92 |
} catch (e) { |
| 93 |
b = e.code == 1; // DOMException.INDEX_SIZE_ERR |
| 94 |
} |
| 95 |
$('r2').setAttribute('fill', b ? 'green' : 'red'); |
| 96 |
|
| 97 |
b = false; |
| 98 |
try { |
| 99 |
b = t.getSubStringLength(0, 5) == 11; |
| 100 |
} catch (e) { |
| 101 |
} |
| 102 |
$('r3').setAttribute('fill', b ? 'green' : 'red'); |
| 103 |
|
| 104 |
b = false; |
| 105 |
try { |
| 106 |
b = t.getSubStringLength(0, 15) == 11; |
| 107 |
} catch (e) { |
| 108 |
} |
| 109 |
$('r4').setAttribute('fill', b ? 'green' : 'red'); |
| 110 |
|
| 111 |
b = false; |
| 112 |
try { |
| 113 |
t.getSubStringLength(1, -1); |
| 114 |
} catch (e) { |
| 115 |
b = e.code == 1; // DOMException.INDEX_SIZE_ERR |
| 116 |
} |
| 117 |
$('r5').setAttribute('fill', b ? 'green' : 'red'); |
| 118 |
]]></script> |
| 119 |
</g> |
| 120 |
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> |
| 121 |
<text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.9 $</text> |
| 122 |
</g> |
| 123 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/> |
| 124 |
<!-- comment out this watermark once the test is approved --><!-- |
| 125 |
<g id="draft-watermark"> |
| 126 |
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> |
| 127 |
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" |
| 128 |
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> |
| 129 |
</g>--> |
| 130 |
</svg> |