| 1 |
<svg id="svg-root" width="100%" height="100%" onload="test()" xmlns="http://www.w3.org/2000/svg" |
| 2 |
viewBox="0 0 480 360" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 3 |
<!--======================================================================--> |
| 4 |
<!--= Copyright 2008 World Wide Web Consortium, (Massachusetts =--> |
| 5 |
<!--= Institute of Technology, European Research Consortium for =--> |
| 6 |
<!--= Informatics and Mathematics (ERCIM), Keio University). =--> |
| 7 |
<!--= All Rights Reserved. =--> |
| 8 |
<!--= See http://www.w3.org/Consortium/Legal/. =--> |
| 9 |
<!--======================================================================--> |
| 10 |
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/" |
| 11 |
template-version="1.4" reviewer="AG" author="ED" status="reviewed" |
| 12 |
version="$Revision: 1.4 $" testname="$RCSfile: text-dom-04-f.svg,v $"> |
| 13 |
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/text.html#InterfaceSVGTextContentElement"> |
| 14 |
<p> |
| 15 |
This tests the SVGTextContentElement.getSubStringLength method. |
| 16 |
</p> |
| 17 |
</d:testDescription> |
| 18 |
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml"> |
| 19 |
<p> |
| 20 |
Run the test. No interaction required. |
| 21 |
</p> |
| 22 |
</d:operatorScript> |
| 23 |
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml"> |
| 24 |
<p> |
| 25 |
To pass the test there should be no red visible. |
| 26 |
</p> |
| 27 |
</d:passCriteria> |
| 28 |
</d:SVGTestCase> |
| 29 |
<title id="test-title">$RCSfile: text-dom-04-f.svg,v $</title> |
| 30 |
<defs> |
| 31 |
<font-face |
| 32 |
font-family="SVGFreeSansASCII" |
| 33 |
unicode-range="U+0-7F"> |
| 34 |
<font-face-src> |
| 35 |
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> |
| 36 |
</font-face-src> |
| 37 |
</font-face> |
| 38 |
</defs> |
| 39 |
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> |
| 40 |
<defs> |
| 41 |
<font horiz-adv-x="4000" id="mini"> |
| 42 |
<font-face font-family="simplesvgfont" units-per-em="4000" ascent="800" descent="-200" alphabetic="0"/> |
| 43 |
<missing-glyph horiz-adv-x="10000" d="M0 0 4000 0"/> |
| 44 |
<glyph unicode="a" glyph-name="a" horiz-adv-x="4100" d="M0 4000l2000 -4000l2000 4000Z"/> |
| 45 |
<glyph unicode="b" glyph-name="b" horiz-adv-x="2000" d="M0 0l2000 0000l0 2000l-2000 0Z"/> |
| 46 |
<glyph unicode="cb" d="M0 0l2000 2000l-2000 2000Z" horiz-adv-x="800"/> |
| 47 |
<glyph unicode="c" glyph-name="c" horiz-adv-x="1900" d="M0 0L2000 2000l-2000 0L2000 0Z"/> |
| 48 |
<glyph unicode="𝍒" glyph-name="compliance" d="M1000,0 h1000 v-1000 h-1000 z" horiz-adv-x="2100"/> |
| 49 |
<hkern u1="c" u2="a" k="500"/> |
| 50 |
</font> |
| 51 |
</defs> |
| 52 |
|
| 53 |
<script type="text/ecmascript"><![CDATA[ |
| 54 |
function test() |
| 55 |
{ |
| 56 |
var t = document.getElementById("t"); |
| 57 |
var r = document.getElementById("r"); |
| 58 |
var res = document.getElementById("res"); |
| 59 |
var isPassed = true; |
| 60 |
|
| 61 |
// string: abca𝍒cb |
| 62 |
// indices: 0123 4 5 67 |
| 63 |
|
| 64 |
var tests = new Array("getSubStringLength(0,1)", "4100", // 'a' |
| 65 |
"getSubStringLength(0,2)", "6100", // 'ab' |
| 66 |
"getSubStringLength(0,3)", "7500", // 'abc' |
| 67 |
"getSubStringLength(0,4)", "11600", // 'abca' |
| 68 |
"getSubStringLength(0,5)", "13700", // 'abca' and high surrogate of 1D352 |
| 69 |
"getSubStringLength(0,6)", "13700", // 'abca𝍒' |
| 70 |
"getSubStringLength(0,7)", "14500", // 'abca𝍒' and half of ligature 'cb' |
| 71 |
"getSubStringLength(0,8)", "14500", // 'abca�' |
| 72 |
"getSubStringLength(0,9)", "14500", // 'abca�' |
| 73 |
"getSubStringLength(3,1)", "4100", // 'a' |
| 74 |
"getSubStringLength(1,1)", "2000", // 'b' |
| 75 |
"getSubStringLength(4,1)", "2100", // high surrogate of 1D352 |
| 76 |
"getSubStringLength(4,2)", "2100", // '𝍒' |
| 77 |
"getSubStringLength(5,1)", "2100", // low surrogate of 1D352 |
| 78 |
"getSubStringLength(6,1)", "800", // first half of ligature 'cb' |
| 79 |
"getSubStringLength(6,2)", "800", // ligature 'cb' |
| 80 |
"getSubStringLength(7,1)", "800", // second half of ligature 'cb' |
| 81 |
"getSubStringLength(8,1)", "INDEX_SIZE_ERR", |
| 82 |
"getSubStringLength(9,0)", "INDEX_SIZE_ERR", |
| 83 |
"getSubStringLength(-1,1)", "INDEX_SIZE_ERR", |
| 84 |
"getSubStringLength(-57,0)", "INDEX_SIZE_ERR", |
| 85 |
"getSubStringLength(0,-52)", "INDEX_SIZE_ERR", |
| 86 |
"getSubStringLength(-1,-5)", "INDEX_SIZE_ERR", |
| 87 |
"getSubStringLength(7,0)", "0", // second half of ligature 'cb' |
| 88 |
"getSubStringLength(5,0)", "0", // high surrogate of 1D352 |
| 89 |
"getSubStringLength(4,0)", "0" // low surrogate of 1D352 |
| 90 |
); |
| 91 |
|
| 92 |
try |
| 93 |
{ |
| 94 |
for(var i = 0; i < tests.length; i=i+2) |
| 95 |
{ |
| 96 |
try |
| 97 |
{ |
| 98 |
val = eval("t."+tests[i]); |
| 99 |
} |
| 100 |
catch(e) |
| 101 |
{ |
| 102 |
if(e.code == DOMException.INDEX_SIZE_ERR) |
| 103 |
{ |
| 104 |
val = "INDEX_SIZE_ERR" |
| 105 |
} |
| 106 |
else |
| 107 |
{ |
| 108 |
val = e; |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
if(val != tests[i+1]) |
| 113 |
{ |
| 114 |
throw "Failed " + tests[i] + " got " + val + " but expected " + tests[i+1]; |
| 115 |
} |
| 116 |
} |
| 117 |
} |
| 118 |
catch(f) |
| 119 |
{ |
| 120 |
isPassed = false; |
| 121 |
res.textContent = f; |
| 122 |
} |
| 123 |
|
| 124 |
if(isPassed) |
| 125 |
{ |
| 126 |
r.setAttribute("fill", "none"); |
| 127 |
} |
| 128 |
} |
| 129 |
]]></script> |
| 130 |
|
| 131 |
<g transform="scale(0.02 0.02) translate(4000 2000)"> |
| 132 |
<g id="reference" fill="red"> |
| 133 |
<path d="M0 4000l2000 -4000l2000 4000Z" transform="scale(1 -1) translate(0 -8000)"/> |
| 134 |
<path d="M0 0l2000 0000l0 2000l-2000 0Z" transform="translate(4100 6000)"/> |
| 135 |
<path d="M0 0L2000 2000l-2000 0L2000 0Z" transform="translate(6100 6000)"/> |
| 136 |
<path d="M0 4000l2000 -4000l2000 4000Z" transform="scale(1 -1) translate(7500 -8000)"/> |
| 137 |
<path d="M1000,0 h1000 v-1000 h-1000 z" transform="scale(1 -1) translate(11600 -8000)"/> |
| 138 |
<path d="M0 0l2000 2000l-2000 2000Z" transform="scale(1 -1) translate(13700 -8000)"/> |
| 139 |
</g> |
| 140 |
|
| 141 |
<text id="t" font-family="simplesvgfont" font-size="4000" y="2em" fill="lime">abca𝍒cb</text> |
| 142 |
<rect id="r" x="5000" y="10%" width="2000" height="2000" fill="red"/> |
| 143 |
<text id="res" x="50%" text-anchor="middle" font-family="sans-serif" font-size="200" y="80%"></text> |
| 144 |
</g> |
| 145 |
</g> |
| 146 |
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> |
| 147 |
<text id="revision" x="10" y="340" stroke="none" |
| 148 |
fill="black">$Revision: 1.4 $</text> |
| 149 |
</g> |
| 150 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/> |
| 151 |
<!-- comment out this watermark once the test is approved --> |
| 152 |
<g id="draft-watermark"> |
| 153 |
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> |
| 154 |
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" |
| 155 |
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> |
| 156 |
</g> |
| 157 |
</svg> |