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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp

Issue 1607213002: Prevent copyTextTo() from Breaking Code Points (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
index 4a1890b1188d3e753c65b26781d70c271cfee20a..7dc224ac57b6aeac6229f93129714f9311aaf28a 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
@@ -493,4 +493,24 @@ TEST_F(TextIteratorTest, characterAt)
EXPECT_EQ('o', iter2.characterAt(4)) << message2;
}
+TEST_F(TextIteratorTest, CopyWholeCodePoints)
+{
+ const char* bodyContent = "&#x13000;&#x13001;&#x13002; &#x13140;&#x13141;.";
+ setBodyContent(bodyContent);
+ updateLayoutAndStyleForPainting();
+
+ const UChar expected[] = {0xD80C, 0xDC00, 0xD80C, 0xDC01, 0xD80C, 0xDC02, ' ', 0xD80C, 0xDD40, 0xD80C, 0xDD41, '.'};
+
+ EphemeralRange range(EphemeralRange::rangeOfContents(document()));
+ TextIterator iter(range.startPosition(), range.endPosition());
+ Vector<UChar> buffer;
+ EXPECT_EQ(2, iter.copyTextTo(buffer, 0, 1)) << "Should emit 2 UChars for 'U+13000'.";
+ EXPECT_EQ(4, iter.copyTextTo(buffer, 2, 3)) << "Should emit 4 UChars for 'U+13001U+13002'.";
+ EXPECT_EQ(3, iter.copyTextTo(buffer, 6, 2)) << "Should emit 3 UChars for ' U+13140'.";
+ EXPECT_EQ(2, iter.copyTextTo(buffer, 9, 2)) << "Should emit 2 UChars for 'U+13141'.";
+ EXPECT_EQ(1, iter.copyTextTo(buffer, 11, 1)) << "Should emit 1 UChar for '.'.";
+ for (int i = 0; i < 12; i++)
+ EXPECT_EQ(expected[i], buffer[i]);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698