Chromium Code Reviews| Index: LayoutTests/svg/text/select-svg-text-with-collapsed-whitespace.html |
| diff --git a/LayoutTests/svg/text/select-svg-text-with-collapsed-whitespace.html b/LayoutTests/svg/text/select-svg-text-with-collapsed-whitespace.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cc284390fba328614258026663f3619f3099508e |
| --- /dev/null |
| +++ b/LayoutTests/svg/text/select-svg-text-with-collapsed-whitespace.html |
| @@ -0,0 +1,62 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
|
fs
2015/04/21 10:46:19
Drop <html> and <head>
|
| +<title>Test for per-character selection with SVG font</title> |
|
fs
2015/04/21 10:46:19
This title doesn't look right.
|
| +</head> |
| +<body> |
| +This test checks that characters can be selected correctly with collapsed whitespace. |
| +<div> |
|
fs
2015/04/21 10:46:20
This <div> isn't needed.
|
| +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"> |
|
fs
2015/04/21 10:46:19
This could be just <svg>, and you'll get 300x150 d
|
| + <text id="text" x="20" y="20"> happy debugging !!</text> |
| +</svg> |
| +</div> |
| +<div id="passfail"> |
| +</div> |
| +<script type="text/javascript"> |
| +function runTest() { |
| + var text = document.getElementById('text'); |
| + |
| + if (!window.testRunner) |
| + return; |
| + |
| + var textWidth = text.offsetWidth; |
| + var estCharWidth = textWidth / 18; |
|
fs
2015/04/21 10:46:19
This appears to expect a monospaced font, but I do
|
| + eventSender.mouseMoveTo(text.offsetLeft + 2, text.offsetTop); |
| + eventSender.mouseDown(); |
| + eventSender.mouseMoveTo(text.offsetLeft + (estCharWidth * 4) + 2, text.offsetTop); |
| + eventSender.mouseUp(); |
| + verify(); |
| +} |
| + |
| +function verify() { |
| + var text = document.getElementById('text'); |
| + |
| + if (!window.testRunner) |
| + return; |
| + |
| + var range = window.getSelection().getRangeAt(0); |
| + if (range.startOffset === 5 && range.endOffset === 9) |
| + return pass("PASS"); |
| + |
| + return fail("FAIL: range was [" + range.startOffset + ", " + range.endOffset + "]; expected [5, 9]"); |
| +} |
| + |
| +function pass(message) { |
|
fs
2015/04/21 10:46:20
I'd suggest using the js-test framework here inste
|
| + log(true, message); |
| +} |
| + |
| +function fail(message) { |
| + log(false, message); |
| +} |
| + |
| +function log(passed, message) { |
| + var passfail = document.getElementById('passfail'); |
| + passfail.innerHTML = message; |
| + passfail.className = (passed ? "pass" : "fail"); |
| + testRunner.dumpAsText(); |
| +} |
| + |
| +runTest(); |
| +</script> |
| +</body> |
| +</html> |