Commit d3b32d5f authored by paulmeyer's avatar paulmeyer Committed by Commit bot

Fix find box bug after navigation.

The bug is that after searching for a string that is not on the page, if
you then navigate to a page that DOES contain that string, find-in-page
will still find no matches.

What is actually happening in the search after navigation is that even
though TextFinder::find() is returning true (to indicate that a match is
found), the field |m_lastFindRequestCompletedWithNoMatches| is still
false (from the last page, which had no matches). This prevents any
matches from being highlighted during the subsequent scoping effort.

The simple (and correct) fix is to set
|m_lastFindRequestCompletedWithNoMatches| to false if a match is found
in TextFinder::find() (since the find request no longer has no matches).

BUG=644448

Review-Url: https://codereview.chromium.org/2316203002
Cr-Commit-Position: refs/heads/master@{#417095}
parent 65033f1b
...@@ -553,6 +553,35 @@ IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(FindInPage_Issue627799)) { ...@@ -553,6 +553,35 @@ IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(FindInPage_Issue627799)) {
} }
} }
IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(FindInPage_Issue644448)) {
TestNavigationObserver navigation_observer(contents());
NavigateToURL(shell(), GURL("about:blank"));
EXPECT_TRUE(navigation_observer.last_navigation_succeeded());
blink::WebFindOptions default_options;
Find("result", default_options);
delegate()->WaitForFinalReply();
// Initially, there are no matches on the page.
FindResults results = delegate()->GetFindResults();
EXPECT_EQ(last_request_id(), results.request_id);
EXPECT_EQ(0, results.number_of_matches);
EXPECT_EQ(0, results.active_match_ordinal);
// Load a page with matches.
LoadAndWait("/find_in_simple_page.html");
Find("result", default_options);
delegate()->WaitForFinalReply();
// There should now be matches found. When the bug was present, there were
// still no matches found.
results = delegate()->GetFindResults();
EXPECT_EQ(last_request_id(), results.request_id);
EXPECT_EQ(5, results.number_of_matches);
EXPECT_EQ(1, results.active_match_ordinal);
}
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Tests requesting find match rects. // Tests requesting find match rects.
IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(FindMatchRects)) { IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(FindMatchRects)) {
......
<!DOCTYPE html>
<html>
<body>
This is a simple page with 5 matches for "result".
result Result RESULT rEsUlT
</body>
</html>
...@@ -200,6 +200,7 @@ bool TextFinder::find(int identifier, const WebString& searchText, const WebFind ...@@ -200,6 +200,7 @@ bool TextFinder::find(int identifier, const WebString& searchText, const WebFind
reportFindInPageSelection(selectionRect, m_activeMatchIndex + 1, identifier); reportFindInPageSelection(selectionRect, m_activeMatchIndex + 1, identifier);
} }
m_lastFindRequestCompletedWithNoMatches = false;
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment