OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3 .org/1999/xlink" width="400" height="400" style="border: 1px solid black;"> | |
3 <g> | |
4 <text x="130" y="30" font-family="Arial" font-size="10" fill="black">Happy, Web</text> | |
5 <text x="130" y="50" font-family="Arial" font-size="10" fill="black">Happy, SVG</text> | |
6 <text x="130" y="70" font-family="Arial" font-size="10" fill="black">Happy, ;)link</text> | |
7 </g> | |
8 <text id="line" x="130" y="150" font-family="Arial" font-size="10" fill="black ">Hello World. Hello, SVG.</text> | |
9 </svg> | |
10 <script src="../../resources/js-test.js"></script> | |
11 <script src="resources/SelectionTestCase.js"></script> | |
12 <script type="text/javascript"> | |
13 var range; | |
14 function runTest() { | |
15 selectTextFromCharToPoint({ id: 'line', offset: 0 }, { x: 300, y: 300 }, { sta rt: "0", end: "24" }); | |
16 selectTextFromCharToPoint({ id: 'line', offset: 6 }, { x: 300, y: 300 }, { sta rt: "6", end: "24" }); | |
17 selectTextFromCharToPoint({ id: 'line', offset: 12 }, { x: 300, y: 300 }, { st art: "12", end: "24" }); | |
18 } | |
19 | |
20 function selectTextFromCharToPoint(selectionInfo, mouse, expectedRange) { | |
21 var element = document.getElementById(selectionInfo.id); | |
22 var startPos = element.getStartPositionOfChar(selectionInfo.offset); | |
23 var absStartPos = toAbsoluteCoordinates(startPos, element); | |
24 if (window.eventSender) { | |
25 eventSender.mouseMoveTo(absStartPos.x, absStartPos.y); | |
26 eventSender.mouseDown(); | |
27 eventSender.mouseMoveTo(mouse.x, mouse.y); | |
28 eventSender.mouseUp(); | |
29 } | |
30 verify(expectedRange.start, expectedRange.end); | |
31 } | |
32 | |
33 function verify(start, end) { | |
fs
2016/01/25 15:31:28
Just include this directly in the above. No need f
| |
34 range = window.getSelection().getRangeAt(0); | |
35 shouldBe("range.startOffset", start); | |
36 shouldBe("range.endOffset", end); | |
37 if (window.eventSender) { | |
38 eventSender.mouseMoveTo(0,0); | |
39 eventSender.mouseDown(); | |
40 eventSender.mouseUp(); | |
41 } | |
42 } | |
43 | |
44 runTest(); | |
45 </script> | |
OLD | NEW |