OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/web_contents/web_contents_impl.h" | 7 #include "content/browser/web_contents/web_contents_impl.h" |
8 #include "content/public/browser/notification_types.h" | 8 #include "content/public/browser/notification_types.h" |
9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
10 #include "content/public/test/content_browser_test.h" | 10 #include "content/public/test/content_browser_test.h" |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 // across the frame boundary should not cause the frame to be re-scoped. If | 546 // across the frame boundary should not cause the frame to be re-scoped. If |
547 // the re-scope occurs, then we will see the number of matches change in one | 547 // the re-scope occurs, then we will see the number of matches change in one |
548 // of the recorded find replies. | 548 // of the recorded find replies. |
549 for (auto& reply : delegate()->GetReplyRecord()) { | 549 for (auto& reply : delegate()->GetReplyRecord()) { |
550 EXPECT_EQ(last_request_id(), reply.request_id); | 550 EXPECT_EQ(last_request_id(), reply.request_id); |
551 EXPECT_TRUE(reply.number_of_matches == kInvalidId || | 551 EXPECT_TRUE(reply.number_of_matches == kInvalidId || |
552 reply.number_of_matches == results.number_of_matches); | 552 reply.number_of_matches == results.number_of_matches); |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
| 556 IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(FindInPage_Issue644448)) { |
| 557 TestNavigationObserver navigation_observer(contents()); |
| 558 NavigateToURL(shell(), GURL("about:blank")); |
| 559 EXPECT_TRUE(navigation_observer.last_navigation_succeeded()); |
| 560 |
| 561 blink::WebFindOptions default_options; |
| 562 Find("result", default_options); |
| 563 delegate()->WaitForFinalReply(); |
| 564 |
| 565 // Initially, there are no matches on the page. |
| 566 FindResults results = delegate()->GetFindResults(); |
| 567 EXPECT_EQ(last_request_id(), results.request_id); |
| 568 EXPECT_EQ(0, results.number_of_matches); |
| 569 EXPECT_EQ(0, results.active_match_ordinal); |
| 570 |
| 571 // Load a page with matches. |
| 572 LoadAndWait("/find_in_simple_page.html"); |
| 573 |
| 574 Find("result", default_options); |
| 575 delegate()->WaitForFinalReply(); |
| 576 |
| 577 // There should now be matches found. When the bug was present, there were |
| 578 // still no matches found. |
| 579 results = delegate()->GetFindResults(); |
| 580 EXPECT_EQ(last_request_id(), results.request_id); |
| 581 EXPECT_EQ(5, results.number_of_matches); |
| 582 EXPECT_EQ(1, results.active_match_ordinal); |
| 583 } |
| 584 |
556 #if defined(OS_ANDROID) | 585 #if defined(OS_ANDROID) |
557 // Tests requesting find match rects. | 586 // Tests requesting find match rects. |
558 IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(FindMatchRects)) { | 587 IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(FindMatchRects)) { |
559 LoadAndWait("/find_in_page.html"); | 588 LoadAndWait("/find_in_page.html"); |
560 | 589 |
561 blink::WebFindOptions default_options; | 590 blink::WebFindOptions default_options; |
562 Find("result", default_options); | 591 Find("result", default_options); |
563 delegate()->WaitForFinalReply(); | 592 delegate()->WaitForFinalReply(); |
564 EXPECT_EQ(19, delegate()->GetFindResults().number_of_matches); | 593 EXPECT_EQ(19, delegate()->GetFindResults().number_of_matches); |
565 | 594 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 delegate()->MarkNextReply(); | 688 delegate()->MarkNextReply(); |
660 contents()->ActivateNearestFindResult( | 689 contents()->ActivateNearestFindResult( |
661 rects[order[i]].CenterPoint().x(), rects[order[i]].CenterPoint().y()); | 690 rects[order[i]].CenterPoint().x(), rects[order[i]].CenterPoint().y()); |
662 delegate()->WaitForNextReply(); | 691 delegate()->WaitForNextReply(); |
663 EXPECT_EQ(order[i] + 1, delegate()->GetFindResults().active_match_ordinal); | 692 EXPECT_EQ(order[i] + 1, delegate()->GetFindResults().active_match_ordinal); |
664 } | 693 } |
665 } | 694 } |
666 #endif // defined(OS_ANDROID) | 695 #endif // defined(OS_ANDROID) |
667 | 696 |
668 } // namespace content | 697 } // namespace content |
OLD | NEW |