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

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: Draft 19 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
« no previous file with comments | « no previous file | LayoutTests/svg/text/select-svg-text-with-collapsed-whitespace-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..83618330a1dfb0e9e30f6a2e4b912763f5410038
--- /dev/null
+++ b/LayoutTests/svg/text/select-svg-text-with-collapsed-whitespace.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<title>Test for selection with collapsed whitespace</title>
+<body>
+This test checks that characters can be selected correctly with collapsed whitespace.
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300">
+ <text id="text1" x="20" y="20"> happy debugging !!</text>
+ <text id="text2" x="20" y="40"> <tspan id="tspan1" style="font-weight: bold;">happy</tspan> debugging !!</text>
+ <text id="text3" x="20" y="80"> <tspan id="tspan2" style="font-size: 25px;">happy</tspan> debugging !!</text>
+ <text id="text4" x="20" y="230" fill="black" transform="scale(0.5)" font-size="40"> happy debugging !!</text>
+</svg>
+<script src="../../resources/js-test.js"></script>
+<script src="resources/SelectionTestCase.js"></script>
+<script type="text/javascript">
+var range;
+function runTest() {
+
+ if (!window.testRunner)
+ return;
+
+ selectText('text1', 0, 3);
+ verify("5", "9");
+
+ selectText('text1', 0, 8);
+ verify("5", "24");
+
+ selectText('text1', 4, 9);
+ verify("9", "25");
+
+ selectText('text2', 0, 3);
+ verify("0", "4");
+
+ selectText('text2', 0, 8);
+ verify("0", "14");
+
+ selectText('text2', 3, 9);
+ verify("3", "15");
+
+ selectText('text3', 0, 3);
+ verify("0", "4");
+
+ selectText('text3', 0, 10);
+ verify("0", "15");
+
+ selectText('text3', 2, 14);
+ verify("2", "19");
+
+ selectText('text4', 0, 3);
+ verify("5", "9");
+
+ selectText('text4', 0, 8);
+ verify("5", "24");
+
+ selectText('text4', 6, 11);
+ verify("21", "27")
+}
+
+function verify(start, end) {
+ range = window.getSelection().getRangeAt(0);
+ shouldBe("range.startOffset", start);
+ shouldBe("range.endOffset", end);
+ if (window.eventSender) {
+ eventSender.mouseMoveTo(0,0);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+}
+
+function selectText(id, start, end) {
+ var element = document.getElementById(id);
+ var startPos = element.getStartPositionOfChar(start);
+ var endPos = element.getEndPositionOfChar(end);
+ var absStartPos = toAbsoluteCoordinates(startPos, element);
+ var absEndPos = toAbsoluteCoordinates(endPos, element);
+ if (window.eventSender) {
+ eventSender.mouseMoveTo(absStartPos.x, absStartPos.y);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(absEndPos.x, absEndPos.y);
+ eventSender.mouseUp();
+ }
+}
+
+runTest();
+</script>
« no previous file with comments | « no previous file | LayoutTests/svg/text/select-svg-text-with-collapsed-whitespace-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698