| 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/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 ASSERT_TRUE(ExecuteScript(shell(), script)); | 312 ASSERT_TRUE(ExecuteScript(shell(), script)); |
| 313 delegate()->WaitForNextReply(); | 313 delegate()->WaitForNextReply(); |
| 314 | 314 |
| 315 // The number of matches should update automatically to include the matches | 315 // The number of matches should update automatically to include the matches |
| 316 // from the newly added frame. | 316 // from the newly added frame. |
| 317 results = delegate()->GetFindResults(); | 317 results = delegate()->GetFindResults(); |
| 318 EXPECT_EQ(26, results.number_of_matches); | 318 EXPECT_EQ(26, results.number_of_matches); |
| 319 EXPECT_EQ(5, results.active_match_ordinal); | 319 EXPECT_EQ(5, results.active_match_ordinal); |
| 320 } | 320 } |
| 321 | 321 |
| 322 IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(RemoveFrame)) { |
| 323 LoadAndWait("/find_with_frame_removal.html"); |
| 324 |
| 325 blink::WebFindOptions options; |
| 326 Find("hello", options); |
| 327 delegate()->WaitForFinalReply(); |
| 328 FindResults results = delegate()->GetFindResults(); |
| 329 |
| 330 EXPECT_EQ(last_request_id(), results.request_id); |
| 331 EXPECT_EQ(2, results.number_of_matches); |
| 332 EXPECT_EQ(1, results.active_match_ordinal); |
| 333 |
| 334 // Remove the iframe. Make sure search results are updated, but that it's |
| 335 // noted that the update was due to a frame removal so that we don't beep. |
| 336 // See https://crbug.com/682299. |
| 337 std::string script( |
| 338 "var iframes = document.getElementsByTagName('iframe');\n" |
| 339 "for (var i = 0; i < iframes.length; i++)\n" |
| 340 " iframes[i].parentNode.removeChild(iframes[i]);"); |
| 341 delegate()->MarkNextReply(); |
| 342 ASSERT_TRUE(ExecuteScript(shell(), script)); |
| 343 delegate()->WaitForNextReply(); |
| 344 |
| 345 results = delegate()->GetFindResults(); |
| 346 EXPECT_EQ(1, results.number_of_matches); |
| 347 EXPECT_EQ(1, results.active_match_ordinal); |
| 348 EXPECT_TRUE(results.was_frame_removal); |
| 349 } |
| 350 |
| 322 // Tests adding a frame during a find session where there were previously no | 351 // Tests adding a frame during a find session where there were previously no |
| 323 // matches. | 352 // matches. |
| 324 IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(AddFrameAfterNoMatches)) { | 353 IN_PROC_BROWSER_TEST_F(FindRequestManagerTest, MAYBE(AddFrameAfterNoMatches)) { |
| 325 TestNavigationObserver navigation_observer(contents()); | 354 TestNavigationObserver navigation_observer(contents()); |
| 326 NavigateToURL(shell(), GURL("about:blank")); | 355 NavigateToURL(shell(), GURL("about:blank")); |
| 327 EXPECT_TRUE(navigation_observer.last_navigation_succeeded()); | 356 EXPECT_TRUE(navigation_observer.last_navigation_succeeded()); |
| 328 | 357 |
| 329 blink::WebFindOptions default_options; | 358 blink::WebFindOptions default_options; |
| 330 Find("result", default_options); | 359 Find("result", default_options); |
| 331 delegate()->WaitForFinalReply(); | 360 delegate()->WaitForFinalReply(); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 delegate()->MarkNextReply(); | 637 delegate()->MarkNextReply(); |
| 609 contents()->ActivateNearestFindResult( | 638 contents()->ActivateNearestFindResult( |
| 610 rects[order[i]].CenterPoint().x(), rects[order[i]].CenterPoint().y()); | 639 rects[order[i]].CenterPoint().x(), rects[order[i]].CenterPoint().y()); |
| 611 delegate()->WaitForNextReply(); | 640 delegate()->WaitForNextReply(); |
| 612 EXPECT_EQ(order[i] + 1, delegate()->GetFindResults().active_match_ordinal); | 641 EXPECT_EQ(order[i] + 1, delegate()->GetFindResults().active_match_ordinal); |
| 613 } | 642 } |
| 614 } | 643 } |
| 615 #endif // defined(OS_ANDROID) | 644 #endif // defined(OS_ANDROID) |
| 616 | 645 |
| 617 } // namespace content | 646 } // namespace content |
| OLD | NEW |