summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/conformance-checkers/html-svg/text-dom-04-f-isvalid.html
blob: 76ac4659814f938f994408aab6258ac0fefadb5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html lang='en'>
<head>
 <title>text-dom-04-f-manual.svg</title>
 <meta charset='utf-8'>
</head>
<body>
 <h1>Source SVG: text-dom-04-f-manual.svg</h1>
<svg id="svg-root" width="100%" height="100%" onload="test()" xmlns="http://www.w3.org/2000/svg"
  viewBox="0 0 480 360" xmlns:xlink="http://www.w3.org/1999/xlink">
  <!--======================================================================-->
  <!--=  Copyright 2008 World Wide Web Consortium, (Massachusetts          =-->
  <!--=  Institute of Technology, European Research Consortium for         =-->
  <!--=  Informatics and Mathematics (ERCIM), Keio University).            =-->
  <!--=  All Rights Reserved.                                              =-->
  <!--=  See http://www.w3.org/Consortium/Legal/.                          =-->
  <!--======================================================================-->
  
  <title id="test-title">$RCSfile: text-dom-04-f.svg,v $</title>
  <defs>
    <font-face
      font-family="SVGFreeSansASCII"
      unicode-range="U+0-7F">
      <font-face-src>
        <font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/>
      </font-face-src>
    </font-face>
  </defs>
  <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
	<defs>
		<font horiz-adv-x="4000" id="mini">
			<font-face font-family="simplesvgfont" units-per-em="4000" ascent="800" descent="-200" alphabetic="0"/>
			<missing-glyph horiz-adv-x="10000" d="M0 0 4000 0"/>
			<glyph unicode="a" glyph-name="a" horiz-adv-x="4100" d="M0 4000l2000 -4000l2000 4000Z"/>
			<glyph unicode="b" glyph-name="b" horiz-adv-x="2000" d="M0 0l2000 0000l0 2000l-2000 0Z"/>
			<glyph unicode="cb" d="M0 0l2000 2000l-2000 2000Z" horiz-adv-x="800"/>
			<glyph unicode="c" glyph-name="c" horiz-adv-x="1900" d="M0 0L2000 2000l-2000 0L2000 0Z"/>
			<glyph unicode="&#x1D352;" glyph-name="compliance" d="M1000,0 h1000 v-1000 h-1000 z" horiz-adv-x="2100"/>
			<hkern u1="c" u2="a" k="500"/>
		</font>
	</defs>

	<script type="text/ecmascript"><![CDATA[
		function test()
		{
			var t = document.getElementById("t");
			var r = document.getElementById("r");
			var res = document.getElementById("res");
			var isPassed = true;
			
			// string:  abca&#x1D352;cb
			// indices: 0123   4  5  67
			
			var tests = new Array("getSubStringLength(0,1)", "4100", 	// 'a'
								  "getSubStringLength(0,2)", "6100", 	// 'ab'
								  "getSubStringLength(0,3)", "7500", 	// 'abc'
								  "getSubStringLength(0,4)", "11600", 	// 'abca'
								  "getSubStringLength(0,5)", "13700",	// 'abca' and high surrogate of 1D352
								  "getSubStringLength(0,6)", "13700",	// 'abca&#x1D352'
								  "getSubStringLength(0,7)", "14500",	// 'abca&#x1D352' and half of ligature 'cb'
								  "getSubStringLength(0,8)", "14500",	// 'abca&#x1D352cb'
								  "getSubStringLength(0,9)", "14500",	// 'abca&#x1D352cb'
								  "getSubStringLength(3,1)", "4100",	// 'a'
								  "getSubStringLength(1,1)", "2000",	// 'b'
								  "getSubStringLength(4,1)", "2100",	// high surrogate of 1D352
								  "getSubStringLength(4,2)", "2100",	// '&#x1D352'
								  "getSubStringLength(5,1)", "2100",	// low surrogate of 1D352
								  "getSubStringLength(6,1)", "800",		// first half of ligature 'cb'
								  "getSubStringLength(6,2)", "800",		// ligature 'cb'
								  "getSubStringLength(7,1)", "800",		// second half of ligature 'cb'
								  "getSubStringLength(8,1)", "INDEX_SIZE_ERR",
								  "getSubStringLength(9,0)", "INDEX_SIZE_ERR",
								  "getSubStringLength(-1,1)", "INDEX_SIZE_ERR",
								  "getSubStringLength(-57,0)", "INDEX_SIZE_ERR",
								  "getSubStringLength(0,-52)", "INDEX_SIZE_ERR",
								  "getSubStringLength(-1,-5)", "INDEX_SIZE_ERR",
								  "getSubStringLength(7,0)", "0", 		// second half of ligature 'cb'
								  "getSubStringLength(5,0)", "0",		// high surrogate of 1D352
								  "getSubStringLength(4,0)", "0"		// low surrogate of 1D352
								  );
			
			try
			{
				for(var i = 0; i < tests.length; i=i+2)
				{
					try
					{
						val = eval("t."+tests[i]);
					}
					catch(e)
					{
						if(e.code == DOMException.INDEX_SIZE_ERR)
						{
							val = "INDEX_SIZE_ERR"
						}
						else
						{
							val = e;
						}
					}
					
					if(val != tests[i+1])
					{
						throw "Failed " + tests[i] + " got " + val + " but expected " + tests[i+1];
					}
				}
			}
			catch(f)
			{
				isPassed = false;
				res.textContent = f;
			}
			
			if(isPassed)
			{
				r.setAttribute("fill", "none");
			}
		}
	]]></script>
	
	<g transform="scale(0.02 0.02) translate(4000 2000)">
		<g id="reference" fill="red">
			<path d="M0 4000l2000 -4000l2000 4000Z" transform="scale(1 -1) translate(0 -8000)"/>
			<path d="M0 0l2000 0000l0 2000l-2000 0Z" transform="translate(4100 6000)"/>
			<path d="M0 0L2000 2000l-2000 0L2000 0Z" transform="translate(6100 6000)"/>
			<path d="M0 4000l2000 -4000l2000 4000Z" transform="scale(1 -1) translate(7500 -8000)"/>
			<path d="M1000,0 h1000 v-1000 h-1000 z" transform="scale(1 -1) translate(11600 -8000)"/>
			<path d="M0 0l2000 2000l-2000 2000Z" transform="scale(1 -1) translate(13700 -8000)"/>
		</g>
		
		<text id="t" font-family="simplesvgfont" font-size="4000" y="2em" fill="lime">abca&#x1D352;cb</text>
		<rect id="r" x="5000" y="10%" width="2000" height="2000" fill="red"/>
		<text id="res" x="50%" text-anchor="middle" font-family="sans-serif" font-size="200" y="80%"></text>
	</g>
  </g>
  <g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
    <text id="revision" x="10" y="340" stroke="none"
      fill="black">$Revision: 1.4 $</text>
  </g>
  <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
  <!-- comment out this watermark once the test is approved -->
  <g id="draft-watermark">
    <rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
    <text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
      text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
  </g>
</svg>
</body>
</html>