Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1129)

Side by Side Diff: third_party/WebKit/LayoutTests/svg/text/select-svg-text-with-collapsed-whitespace.html

Issue 2260763002: Convert LayoutTests/svg/text/* js-tests.js tests to testharness.js based tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Align with review comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Test for selection with collapsed whitespace</title> 2 <title>Test for selection with collapsed whitespace</title>
3 <body> 3 <body>
4 This test checks that characters can be selected correctly with collapsed whites pace. 4 This test checks that characters can be selected correctly with collapsed whites pace.
5 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlin k" width="300" height="300"> 5 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlin k" width="300" height="300">
6 <text id="text1" x="20" y="20"> happy debugging !!</text> 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: bol d;">happy</tspan> debugging !!</text> 7 <text id="text2" x="20" y="40"> <tspan id="tspan1" style="font-weight: bol d;">happy</tspan> debugging !!</text>
8 <text id="text3" x="20" y="80"> <tspan id="tspan2" style="font-size: 25px; ">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> 9 <text id="text4" x="20" y="230" fill="black" transform="scale(0.5)" font-size= "40"> happy debugging !!</text>
10 </svg> 10 </svg>
11 <script src="../../resources/js-test.js"></script> 11 <script src="../../resources/testharness.js"></script>
12 <script src="../../resources/testharnessreport.js"></script>
12 <script src="resources/SelectionTestCase.js"></script> 13 <script src="resources/SelectionTestCase.js"></script>
13 <script type="text/javascript"> 14 <script>
14 var range; 15 test(function() {
15 function runTest() { 16 selectText('text1', 0, 3);
17 verify(5, 9);
16 18
17 if (!window.testRunner) 19 selectText('text1', 0, 8);
18 return; 20 verify(5, 24);
19 21
20 selectText('text1', 0, 3); 22 selectText('text1', 4, 9);
21 verify("5", "9"); 23 verify(9, 25);
22 24
23 selectText('text1', 0, 8); 25 selectText('text2', 0, 3);
24 verify("5", "24"); 26 verify(0, 4);
25 27
26 selectText('text1', 4, 9); 28 selectText('text2', 0, 8);
27 verify("9", "25"); 29 verify(0, 14);
28 30
29 selectText('text2', 0, 3); 31 selectText('text2', 3, 9);
30 verify("0", "4"); 32 verify(3, 15);
31 33
32 selectText('text2', 0, 8); 34 selectText('text3', 0, 3);
33 verify("0", "14"); 35 verify(0, 4);
34 36
35 selectText('text2', 3, 9); 37 selectText('text3', 0, 10);
36 verify("3", "15"); 38 verify(0, 15);
37 39
38 selectText('text3', 0, 3); 40 selectText('text3', 2, 14);
39 verify("0", "4"); 41 verify(2, 19);
40 42
41 selectText('text3', 0, 10); 43 selectText('text4', 0, 3);
42 verify("0", "15"); 44 verify(5, 9);
43 45
44 selectText('text3', 2, 14); 46 selectText('text4', 0, 8);
45 verify("2", "19"); 47 verify(5, 24);
46 48
47 selectText('text4', 0, 3); 49 selectText('text4', 6, 11);
48 verify("5", "9"); 50 verify(21, 27)
49 51
50 selectText('text4', 0, 8); 52 function verify(start, end) {
51 verify("5", "24"); 53 var range = window.getSelection().getRangeAt(0);
52 54 assert_equals(range.startOffset, start);
53 selectText('text4', 6, 11); 55 assert_equals(range.endOffset, end);
54 verify("21", "27")
55 }
56
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) { 56 if (window.eventSender) {
62 eventSender.mouseMoveTo(0,0); 57 eventSender.mouseMoveTo(0,0);
63 eventSender.mouseDown(); 58 eventSender.mouseDown();
64 eventSender.mouseUp(); 59 eventSender.mouseUp();
65 } 60 }
66 } 61 }
67 62
68 function selectText(id, start, end) { 63 function selectText(id, start, end) {
69 var element = document.getElementById(id); 64 var element = document.getElementById(id);
70 var startPos = element.getStartPositionOfChar(start); 65 var startPos = element.getStartPositionOfChar(start);
71 var endPos = element.getEndPositionOfChar(end); 66 var endPos = element.getEndPositionOfChar(end);
72 var absStartPos = toAbsoluteCoordinates(startPos, element); 67 var absStartPos = toAbsoluteCoordinates(startPos, element);
73 var absEndPos = toAbsoluteCoordinates(endPos, element); 68 var absEndPos = toAbsoluteCoordinates(endPos, element);
74 if (window.eventSender) { 69 if (window.eventSender) {
75 eventSender.mouseMoveTo(absStartPos.x, absStartPos.y); 70 eventSender.mouseMoveTo(absStartPos.x, absStartPos.y);
76 eventSender.mouseDown(); 71 eventSender.mouseDown();
77 eventSender.mouseMoveTo(absEndPos.x, absEndPos.y); 72 eventSender.mouseMoveTo(absEndPos.x, absEndPos.y);
78 eventSender.mouseUp(); 73 eventSender.mouseUp();
79 } 74 }
80 } 75 }
81 76 });
82 runTest();
83 </script> 77 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698