From e292fca9e47cba237bb5b2d885f900eddecd70c5 Mon Sep 17 00:00:00 2001 From: "finnur@google.com" Date: Mon, 8 Dec 2008 20:29:43 +0000 Subject: Fixing 5132: Find-in-page reports wrong ordinal when restarting search in sub-frame ReportFindInPageSelection calls OrdinalOfFirstMatchForFrame internally, so we don't need to do it again at the call site. Added a test to catch this in the future. Review URL: http://codereview.chromium.org/13190 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6532 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/views/find_bar_win_uitest.cc | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'chrome') diff --git a/chrome/browser/views/find_bar_win_uitest.cc b/chrome/browser/views/find_bar_win_uitest.cc index 1ce49f5..7350779 100644 --- a/chrome/browser/views/find_bar_win_uitest.cc +++ b/chrome/browser/views/find_bar_win_uitest.cc @@ -153,6 +153,36 @@ TEST_F(FindInPageControllerTest, FindInPageMultiFramesOrdinal) { EXPECT_EQ(7, ordinal); } +// We could get ordinals out of whack when restarting search in subframes. +// See http://crbug.com/5132 +TEST_F(FindInPageControllerTest, FindInPage_Issue5132) { + TestServer server(L"chrome/test/data"); + + // First we navigate to our frames page. + GURL url = server.TestServerPageW(kFramePage); + scoped_ptr tab(GetActiveTab()); + ASSERT_TRUE(tab->NavigateToURL(url)); + WaitUntilTabCount(1); + + // Search for 'goa' three times (6 matches on page). + int ordinal = 0; + EXPECT_EQ(6, tab->FindInPage(L"goa", FWD, IGNORE_CASE, false, &ordinal)); + EXPECT_EQ(1, ordinal); + // FindNext returns -1 for match count because it doesn't bother with + // recounting the number of matches. We don't care about the match count + // anyway in this case, we just want to check the ordinal. + EXPECT_EQ(-1, tab->FindInPage(L"goa", FWD, IGNORE_CASE, true, &ordinal)); + EXPECT_EQ(2, ordinal); + EXPECT_EQ(-1, tab->FindInPage(L"goa", FWD, IGNORE_CASE, true, &ordinal)); + EXPECT_EQ(3, ordinal); + // Add space to search (should result in no matches). + EXPECT_EQ(0, tab->FindInPage(L"goa ", FWD, IGNORE_CASE, false, &ordinal)); + EXPECT_EQ(-1, ordinal); + // Remove the space, should be back to '3 out of 6') + EXPECT_EQ(6, tab->FindInPage(L"goa", FWD, IGNORE_CASE, false, &ordinal)); + EXPECT_EQ(3, ordinal); +} + // Load a page with no selectable text and make sure we don't crash. TEST_F(FindInPageControllerTest, FindUnSelectableText) { TestServer server(L"chrome/test/data"); -- cgit v1.1