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

Unified Diff: Source/web/tests/TextFinderTest.cpp

Issue 422443004: Fix incorrect number of matches and misleading highlighting in "Find on Page" results (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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 | « Source/web/TextFinder.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/TextFinderTest.cpp
diff --git a/Source/web/tests/TextFinderTest.cpp b/Source/web/tests/TextFinderTest.cpp
index 505b3e3b243d46bcce28aa5493f6b157e4836ef2..d5219ebd4baf6c486296f4f9d9802dd800a72b50 100644
--- a/Source/web/tests/TextFinderTest.cpp
+++ b/Source/web/tests/TextFinderTest.cpp
@@ -289,4 +289,26 @@ TEST_F(TextFinderTest, ScopeTextMatchesWithShadowDOM)
EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[2]);
}
+TEST_F(TextFinderTest, ScopeRepeatPatternTextMatches)
+{
+ document().body()->setInnerHTML("ab ab ab ab ab", ASSERT_NO_EXCEPTION);
+ Node* textNode = document().body()->firstChild();
+
+ int identifier = 0;
+ WebString searchText(String("ab ab"));
+ WebFindOptions findOptions; // Default.
+
+ textFinder().resetMatchCount();
+ textFinder().scopeStringMatches(identifier, searchText, findOptions, true);
+ while (textFinder().scopingInProgress())
+ FrameTestHelpers::runPendingTasks();
+
+ EXPECT_EQ(2, textFinder().totalMatchCount());
+ WebVector<WebFloatRect> matchRects;
+ textFinder().findMatchRects(matchRects);
+ ASSERT_EQ(2u, matchRects.size());
+ EXPECT_EQ(findInPageRect(textNode, 0, textNode, 5), matchRects[0]);
+ EXPECT_EQ(findInPageRect(textNode, 6, textNode, 11), matchRects[1]);
+}
+
} // namespace
« no previous file with comments | « Source/web/TextFinder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698