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

Unified 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 side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698