2 <title>Test for selection with collapsed whitespace
</title>
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>
11 <script src=
"../../resources/js-test.js"></script>
12 <script src=
"resources/SelectionTestCase.js"></script>
13 <script type=
"text/javascript">
17 if (!window
.testRunner
)
20 selectText('text1', 0, 3);
23 selectText('text1', 0, 8);
26 selectText('text1', 4, 9);
29 selectText('text2', 0, 3);
32 selectText('text2', 0, 8);
35 selectText('text2', 3, 9);
38 selectText('text3', 0, 3);
41 selectText('text3', 0, 10);
44 selectText('text3', 2, 14);
47 selectText('text4', 0, 3);
50 selectText('text4', 0, 8);
53 selectText('text4', 6, 11);
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();