Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / W3C-SVG-1.1 / text-tselect-02-f.svg
blobe6c955849e0fb253e6f66cccb2d32ef3b3d642d3
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Full//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-flat.dtd">
3 <svg version="1.1" baseProfile="full" id="svg-root" width="100%" height="100%" viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg"
4 xmlns:xlink="http://www.w3.org/1999/xlink" onload="doSelection(0,0);">
5 <!--========================================================================-->
6 <!--= Copyright 2006 World Wide Web Consortium, (Massachusetts =-->
7 <!--= Institute of Technology, European Research Consortium for =-->
8 <!--= Informatics and Mathematics (ERCIM), Keio University). =-->
9 <!--= All Rights Reserved. =-->
10 <!--= See http://www.w3.org/Consortium/Legal/. =-->
11 <!--========================================================================-->
12 <!-- NOTE: CVS will automatically update the -->
13 <!-- "$RCSfile: text-tselect-02-f.svg,v $" and "$Revision: 1.2 $" -->
14 <!-- fields in the file. -->
15 <!-- There is no need to update this information. -->
16 <!-- =====================================================================-->
17 <SVGTestCase xmlns="http://www.w3.org/2000/02/svg/testsuite/description/" reviewer="CL" owner="ED" desc="Tests bidirectional text selection" status="created" version="$Revision: 1.2 $" testname="$RCSfile: text-tselect-02-f.svg,v $">
18 <OperatorScript>
19 <Paragraph>
20 This test demonstrates text selection of bidirectional text.
21 The initial result should be that the first 9 characters in logical order
22 starting from logical position 0 are selected. Visually the selection is
23 discontigous and these substrings must be selected (listed in visual order):
24 </Paragraph>
25 <Paragraph>
26 "abc"
27 </Paragraph>
28 <Paragraph>
29 the space between "c" and "&#1493;"
30 </Paragraph>
31 <Paragraph>
32 "1"
33 </Paragraph>
34 <Paragraph>
35 the space between "3" and "&#1490;"
36 </Paragraph>
37 <Paragraph>
38 "&#1488;&#1489;&#1490;"
39 </Paragraph>
40 <Paragraph>
41 If only the substrings listed above were selected then the test has passed.
42 </Paragraph>
43 <Paragraph>
44 A user agent that allows selecting text in logical order would have generated the same selection
45 as in this testcase if the user started the selection on the character "a" and ended it on the
46 character "1".
48 A user agent that allows selecting text in visual order would not have a discontigous selection
49 if the user started the selection on the character "a" and ended it on the character "1". The copied
50 text would be discontigous instead in this case.
52 Note that the SVG DOM method requires logical order text selection, so for both types of user agents
53 this testcase must look the same.
54 </Paragraph>
55 <Paragraph>
56 The testcase also shows what happens when the selection is modified via DOM (click the buttons below
57 the bidi-text). Compliant viewers must throw an exception when the first parameter handed
58 to SVGTextContentElement.selectSubString is out-of-range.
59 That means the variable 'startIndex' must always be in the range 0 &lt;= startIndex &lt;= 18.
60 It can be noted that the parameter 'numChars' is not restricted in this way.
61 </Paragraph>
62 <Paragraph>
63 Note that the color of the text selection is UA dependent and not defined in the SVG specification.
64 </Paragraph>
65 </OperatorScript>
66 </SVGTestCase>
67 <title id="test-title">$RCSfile: text-tselect-02-f.svg,v $</title>
68 <!--======================================================================-->
69 <!--Content of Test Case follows... =====================-->
70 <!--======================================================================-->
71 <g id="test-body-content">
72 <defs>
73 <script><![CDATA[
74 var startIndex = 0;
75 var numChars = 9;
77 function doSelection(indexDelta, numCharsDelta)
79 try
81 document.getElementById('text').selectSubString(startIndex+indexDelta, numChars+numCharsDelta);
83 catch(e)
85 if(e.code == DOMException.INDEX_SIZE_ERR)
87 // If there was an error, re-select the last range
88 document.getElementById('text').selectSubString(startIndex, numChars);
89 return;
93 startIndex += indexDelta;
94 numChars += numCharsDelta;
96 document.getElementById('info').firstChild.data = "StartIndex: " + startIndex + ". NumChars: " + numChars;
98 ]]></script>
99 </defs>
101 <g transform="translate(0,60)">
102 <text id="info" font-size="16" x="10" y="70">StartIndex: 0 NumChars: 0</text>
104 <text id="text" font-size="48" y="128" x="10">
105 abc &#1488;&#1489;&#1490; 123 &#1491;&#1492;&#1493; def
106 </text>
108 <g id="buttons">
109 <rect x="10" y="160" width="100" height="20" fill="blue" onclick="doSelection(1,0);"/>
110 <text x="60" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">startIndex++</text>
112 <rect x="120" y="160" width="100" height="20" fill="blue" onclick="doSelection(-1,0);"/>
113 <text x="170" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">startIndex--</text>
115 <rect x="230" y="160" width="100" height="20" fill="blue" onclick="doSelection(0,1);"/>
116 <text x="280" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">numChars++</text>
118 <rect x="340" y="160" width="100" height="20" fill="blue" onclick="doSelection(0,-1);"/>
119 <text x="390" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">numChars--</text>
120 </g>
121 </g>
122 </g>
123 <text id="revision" x="10" y="340" font-size="40" stroke="none" fill="black">$Revision: 1.2 $</text>
124 <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
125 </svg>