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

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

Issue 1072403007: Fixup a bug about SVG text selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add test Created 5 years, 8 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
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
fs 2015/04/21 10:46:19 Drop <html> and <head>
4 <title>Test for per-character selection with SVG font</title>
fs 2015/04/21 10:46:19 This title doesn't look right.
5 </head>
6 <body>
7 This test checks that characters can be selected correctly with collapsed whites pace.
8 <div>
fs 2015/04/21 10:46:20 This <div> isn't needed.
9 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlin k" width="200" height="200">
fs 2015/04/21 10:46:19 This could be just <svg>, and you'll get 300x150 d
10 <text id="text" x="20" y="20"> happy debugging !!</text>
11 </svg>
12 </div>
13 <div id="passfail">
14 </div>
15 <script type="text/javascript">
16 function runTest() {
17 var text = document.getElementById('text');
18
19 if (!window.testRunner)
20 return;
21
22 var textWidth = text.offsetWidth;
23 var estCharWidth = textWidth / 18;
fs 2015/04/21 10:46:19 This appears to expect a monospaced font, but I do
24 eventSender.mouseMoveTo(text.offsetLeft + 2, text.offsetTop);
25 eventSender.mouseDown();
26 eventSender.mouseMoveTo(text.offsetLeft + (estCharWidth * 4) + 2, text.offse tTop);
27 eventSender.mouseUp();
28 verify();
29 }
30
31 function verify() {
32 var text = document.getElementById('text');
33
34 if (!window.testRunner)
35 return;
36
37 var range = window.getSelection().getRangeAt(0);
38 if (range.startOffset === 5 && range.endOffset === 9)
39 return pass("PASS");
40
41 return fail("FAIL: range was [" + range.startOffset + ", " + range.endOffset + "]; expected [5, 9]");
42 }
43
44 function pass(message) {
fs 2015/04/21 10:46:20 I'd suggest using the js-test framework here inste
45 log(true, message);
46 }
47
48 function fail(message) {
49 log(false, message);
50 }
51
52 function log(passed, message) {
53 var passfail = document.getElementById('passfail');
54 passfail.innerHTML = message;
55 passfail.className = (passed ? "pass" : "fail");
56 testRunner.dumpAsText();
57 }
58
59 runTest();
60 </script>
61 </body>
62 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698