Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / text / select-svg-text-with-collapsed-whitespace.html
blob83618330a1dfb0e9e30f6a2e4b912763f5410038
1 <!DOCTYPE html>
2 <title>Test for selection with collapsed whitespace</title>
3 <body>
4 This test checks that characters can be selected correctly with collapsed whitespace.
5 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300">
6 <text id="text1" x="20" y="20"> happy debugging !!</text>
7 <text id="text2" x="20" y="40"> <tspan id="tspan1" style="font-weight: bold;">happy</tspan> debugging !!</text>
8 <text id="text3" x="20" y="80"> <tspan id="tspan2" style="font-size: 25px;">happy</tspan> debugging !!</text>
9 <text id="text4" x="20" y="230" fill="black" transform="scale(0.5)" font-size="40"> happy debugging !!</text>
10 </svg>
11 <script src="../../resources/js-test.js"></script>
12 <script src="resources/SelectionTestCase.js"></script>
13 <script type="text/javascript">
14 var range;
15 function runTest() {
17 if (!window.testRunner)
18 return;
20 selectText('text1', 0, 3);
21 verify("5", "9");
23 selectText('text1', 0, 8);
24 verify("5", "24");
26 selectText('text1', 4, 9);
27 verify("9", "25");
29 selectText('text2', 0, 3);
30 verify("0", "4");
32 selectText('text2', 0, 8);
33 verify("0", "14");
35 selectText('text2', 3, 9);
36 verify("3", "15");
38 selectText('text3', 0, 3);
39 verify("0", "4");
41 selectText('text3', 0, 10);
42 verify("0", "15");
44 selectText('text3', 2, 14);
45 verify("2", "19");
47 selectText('text4', 0, 3);
48 verify("5", "9");
50 selectText('text4', 0, 8);
51 verify("5", "24");
53 selectText('text4', 6, 11);
54 verify("21", "27")
57 function verify(start, end) {
58 range = window.getSelection().getRangeAt(0);
59 shouldBe("range.startOffset", start);
60 shouldBe("range.endOffset", end);
61 if (window.eventSender) {
62 eventSender.mouseMoveTo(0,0);
63 eventSender.mouseDown();
64 eventSender.mouseUp();
68 function selectText(id, start, end) {
69 var element = document.getElementById(id);
70 var startPos = element.getStartPositionOfChar(start);
71 var endPos = element.getEndPositionOfChar(end);
72 var absStartPos = toAbsoluteCoordinates(startPos, element);
73 var absEndPos = toAbsoluteCoordinates(endPos, element);
74 if (window.eventSender) {
75 eventSender.mouseMoveTo(absStartPos.x, absStartPos.y);
76 eventSender.mouseDown();
77 eventSender.mouseMoveTo(absEndPos.x, absEndPos.y);
78 eventSender.mouseUp();
82 runTest();
83 </script>