diff options
author | finnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-04 19:32:49 +0000 |
---|---|---|
committer | finnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-04 19:32:49 +0000 |
commit | aedd85af7d7d0c90ed343ece4c66660db00841ec (patch) | |
tree | 8ba798b3932fbf2c1b5db69f39175326fd8745ab /chrome/test | |
parent | d5a94281a8df5b47a341e2dd71b4d5f8dafd5878 (diff) | |
download | chromium_src-aedd85af7d7d0c90ed343ece4c66660db00841ec.zip chromium_src-aedd85af7d7d0c90ed343ece4c66660db00841ec.tar.gz chromium_src-aedd85af7d7d0c90ed343ece4c66660db00841ec.tar.bz2 |
Fix issue 5079: Incorrect "Active match ordinal" count during Find-in-page
I introduced a regression in my reimplemenation of Find-in-page. The active match ordinal in Find-in-page (also known as "the 7" in "7 of 9") would be just a little off on pages with frames.
Problem A: When you search for something in gmail, for example, the ordinal could start off slightly negative or be 0. I wasn't checking the last_match_count_ of a frame for negative numbers before adding it to the total (it starts off as -1 and remains that way if the frame is not deemed to be worthy of being scoped, i.e. if it is hidden).
Problem B: On pages with multiple matches spread across multiple frames the ordinal would not be subtracted correctly after pressing F3 and Shift-F3 to go back to the frame you were on. We shouldn't be increasing/decreasing the active_match_index for a given frame when FindNext/FindPrevious causes us to jump between frames. We should instead reset it.
I added two tests to catch this in the future. They test ordinal values as you use Find in page (including combinations of frames/no-frames & FindNext/FindPrevious).
Oh, and I also removed some traces that were supposed to expose why a test was flaky, but it turns out to have been something unrelated to the test.
Review URL: http://codereview.chromium.org/13130
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6369 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 15 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 13 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 6 |
3 files changed, 23 insertions, 11 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 3eb8498..b71457d 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -311,15 +311,15 @@ IPC_BEGIN_MESSAGES(Automation, 0) // (1=case sensitive, 0=case insensitive). If an error occurs, matches_found // will be -1. // - // NOTE: This message has been deprecated, please use the new message - // AutomationMsg_FindRequest below. + // NOTE: These two messages have been deprecated, please use the new messages + // AutomationMsg_FindRequest and AutomationMsg_FindInPageResponse2 below. // - IPC_MESSAGE_ROUTED4(AutomationMsg_FindInPageRequest, + IPC_MESSAGE_ROUTED4(AutomationMsg_FindInPageRequest, // DEPRECATED. int, /* tab_handle */ std::wstring, /* find_request */ int, /* forward */ int /* match_case */) - IPC_MESSAGE_ROUTED1(AutomationMsg_FindInPageResponse, + IPC_MESSAGE_ROUTED1(AutomationMsg_FindInPageResponse, // DEPRECATED. int /* matches_found */) // This message sends a inspect element request for a given tab. The response @@ -733,7 +733,7 @@ IPC_BEGIN_MESSAGES(Automation, 0) // This message starts a find within a tab corresponding to the supplied // tab handle. The parameter |request| specifies what to search for. // If an error occurs, |matches_found| will be -1 (see response message - // AutomationMsg_FindInPageResponse). + // AutomationMsg_FindInPageResponse2). // IPC_MESSAGE_ROUTED2(AutomationMsg_FindRequest, int, /* tab_handle */ @@ -807,4 +807,9 @@ IPC_BEGIN_MESSAGES(Automation, 0) IPC_MESSAGE_ROUTED1(AutomationMsg_ShowingAppModalDialogResponse, bool /* showing dialog */) + // Returns the ordinal and the number of matches found as a response to + // a AutomationMsg_FindRequest. + IPC_MESSAGE_ROUTED2(AutomationMsg_FindInPageResponse2, + int /* active_ordinal */, + int /* matches_found */) IPC_END_MESSAGES(Automation) diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 7668c19..0b87689 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -121,7 +121,8 @@ bool TabProxy::GetFindWindowLocation(int* x, int* y) { int TabProxy::FindInPage(const std::wstring& search_string, FindInPageDirection forward, FindInPageCase match_case, - bool find_next) { + bool find_next, + int* active_ordinal) { if (!is_valid()) return -1; @@ -136,14 +137,18 @@ int TabProxy::FindInPage(const std::wstring& search_string, bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_FindRequest(0, handle_, request), &response, - AutomationMsg_FindInPageResponse::ID); + AutomationMsg_FindInPageResponse2::ID); if (!succeeded) return -1; void* iter = NULL; + int ordinal; int matches_found; - AutomationMsg_FindInPageResponse::Read(response, &matches_found); - + response->ReadInt(&iter, &ordinal); + response->ReadInt(&iter, &matches_found); + if (active_ordinal) + *active_ordinal = ordinal; + delete response; return matches_found; } diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index a13e6a5..07e3617 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -178,9 +178,11 @@ class TabProxy : public AutomationResourceProxy { // specifies what string to search for, |forward| specifies whether to search // in forward direction, and |match_case| specifies case sensitivity // (true=case sensitive). |find_next| specifies whether this is a new search - // or a continuation of the old one. A return value of -1 indicates failure. + // or a continuation of the old one. |ordinal| is an optional parameter that + // returns the ordinal of the active match (also known as "the 7" part of + // "7 of 9"). A return value of -1 indicates failure. int FindInPage(const std::wstring& search_string, FindInPageDirection forward, - FindInPageCase match_case, bool find_next); + FindInPageCase match_case, bool find_next, int* ordinal); bool GetCookies(const GURL& url, std::string* cookies); bool GetCookieByName(const GURL& url, |