Chromium Code Reviews| OLD | NEW |
|---|---|
| (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> | |
| OLD | NEW |