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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 1707083002: Fix find in page behavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android_webview test Created 4 years, 10 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: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index a9fbdd44bd4fdca2e423dea7113601938e41478c..7242f225202833f92d52ce6c06fe41aeb562b8e0 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -3716,6 +3716,7 @@ public:
FindUpdateWebFrameClient()
: m_findResultsAreReady(false)
, m_count(-1)
+ , m_activeIndex(-1)
{
}
@@ -3726,12 +3727,19 @@ public:
m_findResultsAreReady = true;
}
+ void reportFindInPageSelection(int, int activeMatchOrdinal, const WebRect&) override
+ {
+ m_activeIndex = activeMatchOrdinal;
+ }
+
bool findResultsAreReady() const { return m_findResultsAreReady; }
int count() const { return m_count; }
+ int activeIndex() const { return m_activeIndex; }
private:
bool m_findResultsAreReady;
int m_count;
+ int m_activeIndex;
};
TEST_P(ParameterizedWebFrameTest, FindInPageMatchRects)
@@ -3854,6 +3862,54 @@ TEST_P(ParameterizedWebFrameTest, FindInPageMatchRects)
EXPECT_TRUE(mainFrame->findMatchMarkersVersion() != rectsVersion);
}
+TEST_F(WebFrameTest, FindInPageActiveIndex)
+{
+ registerMockedHttpURLLoad("find_match_count.html");
+
+ FindUpdateWebFrameClient client;
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ webViewHelper.initializeAndLoad(m_baseURL + "find_match_count.html", true, &client);
+ webViewHelper.webView()->resize(WebSize(640, 480));
+ runPendingTasks();
+
+ const char* kFindString = "a";
+ const int kFindIdentifier = 7777;
+ const int kActiveIndex = 1;
+
+ WebFindOptions options;
+ WebString searchText = WebString::fromUTF8(kFindString);
+ WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame());
+ EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0));
+ mainFrame->resetMatchCount();
+
+ for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
+ frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText, options, true);
+
+ runPendingTasks();
+ EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0));
+ mainFrame->stopFinding(true);
+
+ for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
+ frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText, options, true);
+
+ runPendingTasks();
+ EXPECT_TRUE(client.findResultsAreReady());
+ EXPECT_EQ(kActiveIndex, client.activeIndex());
+
+ const char* kFindStringNew = "e";
+ WebString searchTextNew = WebString::fromUTF8(kFindStringNew);
+
+ EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchTextNew, options, false, 0));
+ mainFrame->resetMatchCount();
+
+ for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
+ frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchTextNew, options, true);
+
+ runPendingTasks();
+ EXPECT_TRUE(client.findResultsAreReady());
+ EXPECT_EQ(kActiveIndex, client.activeIndex());
+}
+
TEST_P(ParameterizedWebFrameTest, FindInPageSkipsHiddenFrames)
{
registerMockedHttpURLLoad("find_in_hidden_frame.html");
« no previous file with comments | « third_party/WebKit/Source/web/TextFinder.cpp ('k') | third_party/WebKit/Source/web/tests/data/find_match_count.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698