| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/keyboard_codes.h" | 5 #include "base/keyboard_codes.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
| 8 #include "chrome/browser/browser_window.h" | 8 #include "chrome/browser/browser_window.h" |
| 9 #include "chrome/browser/find_bar.h" | 9 #include "chrome/browser/find_bar.h" |
| 10 #include "chrome/browser/find_bar_controller.h" | 10 #include "chrome/browser/find_bar_controller.h" |
| 11 #include "chrome/browser/find_notification_details.h" | 11 #include "chrome/browser/find_notification_details.h" |
| 12 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
| 13 #include "chrome/browser/renderer_host/render_view_host.h" | 13 #include "chrome/browser/renderer_host/render_view_host.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents_view.h" | 15 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 16 #include "chrome/common/notification_service.h" | 16 #include "chrome/common/notification_service.h" |
| 17 #include "chrome/test/in_process_browser_test.h" | 17 #include "chrome/test/in_process_browser_test.h" |
| 18 #include "chrome/test/ui_test_utils.h" | 18 #include "chrome/test/ui_test_utils.h" |
| 19 | 19 |
| 20 #if defined(TOOLKIT_VIEWS) | 20 #if defined(TOOLKIT_VIEWS) |
| 21 #include "chrome/browser/views/find_bar_host.h" | 21 #include "chrome/browser/views/find_bar_host.h" |
| 22 #include "views/focus/focus_manager.h" | 22 #include "views/focus/focus_manager.h" |
| 23 #elif defined(TOOLKIT_GTK) | 23 #elif defined(TOOLKIT_GTK) |
| 24 #include "chrome/browser/gtk/slide_animator_gtk.h" | 24 #include "chrome/browser/gtk/slide_animator_gtk.h" |
| 25 #elif defined(OS_MACOSX) | 25 #elif defined(OS_MACOSX) |
| 26 #include "chrome/browser/cocoa/find_bar_bridge.h" | 26 #include "chrome/browser/cocoa/find_bar_bridge.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 const std::wstring kSimplePage = L"404_is_enough_for_us.html"; | 29 const std::string kSimplePage = "404_is_enough_for_us.html"; |
| 30 const std::wstring kFramePage = L"files/find_in_page/frames.html"; | 30 const std::string kFramePage = "files/find_in_page/frames.html"; |
| 31 const std::wstring kFrameData = L"files/find_in_page/framedata_general.html"; | 31 const std::string kFrameData = "files/find_in_page/framedata_general.html"; |
| 32 const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html"; | 32 const std::string kUserSelectPage = "files/find_in_page/user-select.html"; |
| 33 const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; | 33 const std::string kCrashPage = "files/find_in_page/crash_1341577.html"; |
| 34 const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html"; | 34 const std::string kTooFewMatchesPage = "files/find_in_page/bug_1155639.html"; |
| 35 const std::wstring kEndState = L"files/find_in_page/end_state.html"; | 35 const std::string kEndState = "files/find_in_page/end_state.html"; |
| 36 const std::wstring kPrematureEnd = L"files/find_in_page/premature_end.html"; | 36 const std::string kPrematureEnd = "files/find_in_page/premature_end.html"; |
| 37 const std::wstring kMoveIfOver = L"files/find_in_page/move_if_obscuring.html"; | 37 const std::string kMoveIfOver = "files/find_in_page/move_if_obscuring.html"; |
| 38 const std::wstring kBitstackCrash = L"files/find_in_page/crash_14491.html"; | 38 const std::string kBitstackCrash = "files/find_in_page/crash_14491.html"; |
| 39 const std::wstring kSelectChangesOrdinal = | 39 const std::string kSelectChangesOrdinal = |
| 40 L"files/find_in_page/select_changes_ordinal.html"; | 40 "files/find_in_page/select_changes_ordinal.html"; |
| 41 const std::wstring kSimple = L"files/find_in_page/simple.html"; | 41 const std::string kSimple = "files/find_in_page/simple.html"; |
| 42 const std::wstring kLinkPage = L"files/find_in_page/link.html"; | 42 const std::string kLinkPage = "files/find_in_page/link.html"; |
| 43 | 43 |
| 44 const bool kBack = false; | 44 const bool kBack = false; |
| 45 const bool kFwd = true; | 45 const bool kFwd = true; |
| 46 | 46 |
| 47 const bool kIgnoreCase = false; | 47 const bool kIgnoreCase = false; |
| 48 const bool kCaseSensitive = true; | 48 const bool kCaseSensitive = true; |
| 49 | 49 |
| 50 const int kMoveIterations = 30; | 50 const int kMoveIterations = 30; |
| 51 | 51 |
| 52 class FindInPageControllerTest : public InProcessBrowserTest { | 52 class FindInPageControllerTest : public InProcessBrowserTest { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 tab, WideToUTF16(std::wstring(search_str)), | 110 tab, WideToUTF16(std::wstring(search_str)), |
| 111 forward, case_sensitive, ordinal); | 111 forward, case_sensitive, ordinal); |
| 112 } | 112 } |
| 113 | 113 |
| 114 // This test loads a page with frames and starts FindInPage requests. | 114 // This test loads a page with frames and starts FindInPage requests. |
| 115 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFrames) { | 115 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFrames) { |
| 116 HTTPTestServer* server = StartHTTPServer(); | 116 HTTPTestServer* server = StartHTTPServer(); |
| 117 ASSERT_TRUE(server); | 117 ASSERT_TRUE(server); |
| 118 | 118 |
| 119 // First we navigate to our frames page. | 119 // First we navigate to our frames page. |
| 120 GURL url = server->TestServerPageW(kFramePage); | 120 GURL url = server->TestServerPage(kFramePage); |
| 121 ui_test_utils::NavigateToURL(browser(), url); | 121 ui_test_utils::NavigateToURL(browser(), url); |
| 122 | 122 |
| 123 // Try incremental search (mimicking user typing in). | 123 // Try incremental search (mimicking user typing in). |
| 124 int ordinal = 0; | 124 int ordinal = 0; |
| 125 TabContents* tab = browser()->GetSelectedTabContents(); | 125 TabContents* tab = browser()->GetSelectedTabContents(); |
| 126 EXPECT_EQ(18, FindInPageWchar(tab, L"g", | 126 EXPECT_EQ(18, FindInPageWchar(tab, L"g", |
| 127 kFwd, kIgnoreCase, &ordinal)); | 127 kFwd, kIgnoreCase, &ordinal)); |
| 128 EXPECT_EQ(1, ordinal); | 128 EXPECT_EQ(1, ordinal); |
| 129 EXPECT_EQ(11, FindInPageWchar(tab, L"go", | 129 EXPECT_EQ(11, FindInPageWchar(tab, L"go", |
| 130 kFwd, kIgnoreCase, &ordinal)); | 130 kFwd, kIgnoreCase, &ordinal)); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 203 } |
| 204 | 204 |
| 205 // This tests the FindInPage end-state, in other words: what is focused when you | 205 // This tests the FindInPage end-state, in other words: what is focused when you |
| 206 // close the Find box (ie. if you find within a link the link should be | 206 // close the Find box (ie. if you find within a link the link should be |
| 207 // focused). | 207 // focused). |
| 208 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) { | 208 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) { |
| 209 HTTPTestServer* server = StartHTTPServer(); | 209 HTTPTestServer* server = StartHTTPServer(); |
| 210 ASSERT_TRUE(server); | 210 ASSERT_TRUE(server); |
| 211 | 211 |
| 212 // First we navigate to our special focus tracking page. | 212 // First we navigate to our special focus tracking page. |
| 213 GURL url = server->TestServerPageW(kEndState); | 213 GURL url = server->TestServerPage(kEndState); |
| 214 ui_test_utils::NavigateToURL(browser(), url); | 214 ui_test_utils::NavigateToURL(browser(), url); |
| 215 | 215 |
| 216 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 216 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 217 ASSERT_TRUE(NULL != tab_contents); | 217 ASSERT_TRUE(NULL != tab_contents); |
| 218 | 218 |
| 219 // Verify that nothing has focus. | 219 // Verify that nothing has focus. |
| 220 ASSERT_STREQ("{nothing focused}", FocusedOnPage(tab_contents).c_str()); | 220 ASSERT_STREQ("{nothing focused}", FocusedOnPage(tab_contents).c_str()); |
| 221 | 221 |
| 222 // Search for a text that exists within a link on the page. | 222 // Search for a text that exists within a link on the page. |
| 223 int ordinal = 0; | 223 int ordinal = 0; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 251 EXPECT_STREQ("", FocusedOnPage(tab_contents).c_str()); | 251 EXPECT_STREQ("", FocusedOnPage(tab_contents).c_str()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 // This test loads a single-frame page and makes sure the ordinal returned makes | 254 // This test loads a single-frame page and makes sure the ordinal returned makes |
| 255 // sense as we FindNext over all the items. | 255 // sense as we FindNext over all the items. |
| 256 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) { | 256 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) { |
| 257 HTTPTestServer* server = StartHTTPServer(); | 257 HTTPTestServer* server = StartHTTPServer(); |
| 258 ASSERT_TRUE(server); | 258 ASSERT_TRUE(server); |
| 259 | 259 |
| 260 // First we navigate to our page. | 260 // First we navigate to our page. |
| 261 GURL url = server->TestServerPageW(kFrameData); | 261 GURL url = server->TestServerPage(kFrameData); |
| 262 ui_test_utils::NavigateToURL(browser(), url); | 262 ui_test_utils::NavigateToURL(browser(), url); |
| 263 | 263 |
| 264 // Search for 'o', which should make the first item active and return | 264 // Search for 'o', which should make the first item active and return |
| 265 // '1 in 3' (1st ordinal of a total of 3 matches). | 265 // '1 in 3' (1st ordinal of a total of 3 matches). |
| 266 TabContents* tab = browser()->GetSelectedTabContents(); | 266 TabContents* tab = browser()->GetSelectedTabContents(); |
| 267 int ordinal = 0; | 267 int ordinal = 0; |
| 268 EXPECT_EQ(3, FindInPageWchar(tab, L"o", | 268 EXPECT_EQ(3, FindInPageWchar(tab, L"o", |
| 269 kFwd, kIgnoreCase, &ordinal)); | 269 kFwd, kIgnoreCase, &ordinal)); |
| 270 EXPECT_EQ(1, ordinal); | 270 EXPECT_EQ(1, ordinal); |
| 271 EXPECT_EQ(3, FindInPageWchar(tab, L"o", | 271 EXPECT_EQ(3, FindInPageWchar(tab, L"o", |
| (...skipping 19 matching lines...) Expand all Loading... |
| 291 EXPECT_EQ(3, ordinal); | 291 EXPECT_EQ(3, ordinal); |
| 292 } | 292 } |
| 293 | 293 |
| 294 // This tests that the ordinal is correctly adjusted after a selection | 294 // This tests that the ordinal is correctly adjusted after a selection |
| 295 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 295 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 296 SelectChangesOrdinal_Issue20883) { | 296 SelectChangesOrdinal_Issue20883) { |
| 297 HTTPTestServer* server = StartHTTPServer(); | 297 HTTPTestServer* server = StartHTTPServer(); |
| 298 ASSERT_TRUE(server); | 298 ASSERT_TRUE(server); |
| 299 | 299 |
| 300 // First we navigate to our test content. | 300 // First we navigate to our test content. |
| 301 GURL url = server->TestServerPageW(kSelectChangesOrdinal); | 301 GURL url = server->TestServerPage(kSelectChangesOrdinal); |
| 302 ui_test_utils::NavigateToURL(browser(), url); | 302 ui_test_utils::NavigateToURL(browser(), url); |
| 303 | 303 |
| 304 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 304 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 305 ASSERT_TRUE(NULL != tab_contents); | 305 ASSERT_TRUE(NULL != tab_contents); |
| 306 | 306 |
| 307 // Search for a text that exists within a link on the page. | 307 // Search for a text that exists within a link on the page. |
| 308 TabContents* tab = browser()->GetSelectedTabContents(); | 308 TabContents* tab = browser()->GetSelectedTabContents(); |
| 309 int ordinal = 0; | 309 int ordinal = 0; |
| 310 EXPECT_EQ(4, FindInPageWchar(tab_contents, | 310 EXPECT_EQ(4, FindInPageWchar(tab_contents, |
| 311 L"google", | 311 L"google", |
| (...skipping 19 matching lines...) Expand all Loading... |
| 331 tab_contents->StopFinding(FindBarController::kKeepSelection); | 331 tab_contents->StopFinding(FindBarController::kKeepSelection); |
| 332 } | 332 } |
| 333 | 333 |
| 334 // This test loads a page with frames and makes sure the ordinal returned makes | 334 // This test loads a page with frames and makes sure the ordinal returned makes |
| 335 // sense. | 335 // sense. |
| 336 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageMultiFramesOrdinal) { | 336 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageMultiFramesOrdinal) { |
| 337 HTTPTestServer* server = StartHTTPServer(); | 337 HTTPTestServer* server = StartHTTPServer(); |
| 338 ASSERT_TRUE(server); | 338 ASSERT_TRUE(server); |
| 339 | 339 |
| 340 // First we navigate to our page. | 340 // First we navigate to our page. |
| 341 GURL url = server->TestServerPageW(kFramePage); | 341 GURL url = server->TestServerPage(kFramePage); |
| 342 ui_test_utils::NavigateToURL(browser(), url); | 342 ui_test_utils::NavigateToURL(browser(), url); |
| 343 | 343 |
| 344 // Search for 'a', which should make the first item active and return | 344 // Search for 'a', which should make the first item active and return |
| 345 // '1 in 7' (1st ordinal of a total of 7 matches). | 345 // '1 in 7' (1st ordinal of a total of 7 matches). |
| 346 TabContents* tab = browser()->GetSelectedTabContents(); | 346 TabContents* tab = browser()->GetSelectedTabContents(); |
| 347 int ordinal = 0; | 347 int ordinal = 0; |
| 348 EXPECT_EQ(7, | 348 EXPECT_EQ(7, |
| 349 FindInPageWchar(tab, L"a", kFwd, kIgnoreCase, &ordinal)); | 349 FindInPageWchar(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 350 EXPECT_EQ(1, ordinal); | 350 EXPECT_EQ(1, ordinal); |
| 351 EXPECT_EQ(7, | 351 EXPECT_EQ(7, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 EXPECT_EQ(7, ordinal); | 383 EXPECT_EQ(7, ordinal); |
| 384 } | 384 } |
| 385 | 385 |
| 386 // We could get ordinals out of whack when restarting search in subframes. | 386 // We could get ordinals out of whack when restarting search in subframes. |
| 387 // See http://crbug.com/5132. | 387 // See http://crbug.com/5132. |
| 388 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPage_Issue5132) { | 388 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPage_Issue5132) { |
| 389 HTTPTestServer* server = StartHTTPServer(); | 389 HTTPTestServer* server = StartHTTPServer(); |
| 390 ASSERT_TRUE(server); | 390 ASSERT_TRUE(server); |
| 391 | 391 |
| 392 // First we navigate to our page. | 392 // First we navigate to our page. |
| 393 GURL url = server->TestServerPageW(kFramePage); | 393 GURL url = server->TestServerPage(kFramePage); |
| 394 ui_test_utils::NavigateToURL(browser(), url); | 394 ui_test_utils::NavigateToURL(browser(), url); |
| 395 | 395 |
| 396 // Search for 'goa' three times (6 matches on page). | 396 // Search for 'goa' three times (6 matches on page). |
| 397 int ordinal = 0; | 397 int ordinal = 0; |
| 398 TabContents* tab = browser()->GetSelectedTabContents(); | 398 TabContents* tab = browser()->GetSelectedTabContents(); |
| 399 EXPECT_EQ(6, FindInPageWchar(tab, L"goa", | 399 EXPECT_EQ(6, FindInPageWchar(tab, L"goa", |
| 400 kFwd, kIgnoreCase, &ordinal)); | 400 kFwd, kIgnoreCase, &ordinal)); |
| 401 EXPECT_EQ(1, ordinal); | 401 EXPECT_EQ(1, ordinal); |
| 402 EXPECT_EQ(6, FindInPageWchar(tab, L"goa", | 402 EXPECT_EQ(6, FindInPageWchar(tab, L"goa", |
| 403 kFwd, kIgnoreCase, &ordinal)); | 403 kFwd, kIgnoreCase, &ordinal)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 414 kFwd, kIgnoreCase, &ordinal)); | 414 kFwd, kIgnoreCase, &ordinal)); |
| 415 EXPECT_EQ(3, ordinal); | 415 EXPECT_EQ(3, ordinal); |
| 416 } | 416 } |
| 417 | 417 |
| 418 // Load a page with no selectable text and make sure we don't crash. | 418 // Load a page with no selectable text and make sure we don't crash. |
| 419 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindUnSelectableText) { | 419 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindUnSelectableText) { |
| 420 HTTPTestServer* server = StartHTTPServer(); | 420 HTTPTestServer* server = StartHTTPServer(); |
| 421 ASSERT_TRUE(server); | 421 ASSERT_TRUE(server); |
| 422 | 422 |
| 423 // First we navigate to our page. | 423 // First we navigate to our page. |
| 424 GURL url = server->TestServerPageW(kUserSelectPage); | 424 GURL url = server->TestServerPage(kUserSelectPage); |
| 425 ui_test_utils::NavigateToURL(browser(), url); | 425 ui_test_utils::NavigateToURL(browser(), url); |
| 426 | 426 |
| 427 int ordinal = 0; | 427 int ordinal = 0; |
| 428 TabContents* tab = browser()->GetSelectedTabContents(); | 428 TabContents* tab = browser()->GetSelectedTabContents(); |
| 429 EXPECT_EQ(0, FindInPageWchar(tab, L"text", | 429 EXPECT_EQ(0, FindInPageWchar(tab, L"text", |
| 430 kFwd, kIgnoreCase, &ordinal)); | 430 kFwd, kIgnoreCase, &ordinal)); |
| 431 EXPECT_EQ(-1, ordinal); // Nothing is selected. | 431 EXPECT_EQ(-1, ordinal); // Nothing is selected. |
| 432 EXPECT_EQ(0, FindInPageWchar(tab, L"Non-existing string", | 432 EXPECT_EQ(0, FindInPageWchar(tab, L"Non-existing string", |
| 433 kFwd, kIgnoreCase, &ordinal)); | 433 kFwd, kIgnoreCase, &ordinal)); |
| 434 EXPECT_EQ(0, ordinal); | 434 EXPECT_EQ(0, ordinal); |
| 435 } | 435 } |
| 436 | 436 |
| 437 // Try to reproduce the crash seen in issue 1341577. | 437 // Try to reproduce the crash seen in issue 1341577. |
| 438 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue1341577) { | 438 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue1341577) { |
| 439 HTTPTestServer* server = StartHTTPServer(); | 439 HTTPTestServer* server = StartHTTPServer(); |
| 440 ASSERT_TRUE(server); | 440 ASSERT_TRUE(server); |
| 441 | 441 |
| 442 // First we navigate to our page. | 442 // First we navigate to our page. |
| 443 GURL url = server->TestServerPageW(kCrashPage); | 443 GURL url = server->TestServerPage(kCrashPage); |
| 444 ui_test_utils::NavigateToURL(browser(), url); | 444 ui_test_utils::NavigateToURL(browser(), url); |
| 445 | 445 |
| 446 // This would crash the tab. These must be the first two find requests issued | 446 // This would crash the tab. These must be the first two find requests issued |
| 447 // against the frame, otherwise an active frame pointer is set and it wont | 447 // against the frame, otherwise an active frame pointer is set and it wont |
| 448 // produce the crash. | 448 // produce the crash. |
| 449 // We used to check the return value and |ordinal|. With ICU 4.2, FiP does | 449 // We used to check the return value and |ordinal|. With ICU 4.2, FiP does |
| 450 // not find a stand-alone dependent vowel sign of Indic scripts. So, the | 450 // not find a stand-alone dependent vowel sign of Indic scripts. So, the |
| 451 // exptected values are all 0. To make this test pass regardless of | 451 // exptected values are all 0. To make this test pass regardless of |
| 452 // ICU version, we just call FiP and see if there's any crash. | 452 // ICU version, we just call FiP and see if there's any crash. |
| 453 // TODO(jungshik): According to a native Malayalam speaker, it's ok not | 453 // TODO(jungshik): According to a native Malayalam speaker, it's ok not |
| (...skipping 12 matching lines...) Expand all Loading... |
| 466 EXPECT_EQ(0, ordinal); | 466 EXPECT_EQ(0, ordinal); |
| 467 } | 467 } |
| 468 | 468 |
| 469 // Try to reproduce the crash seen in http://crbug.com/14491, where an assert | 469 // Try to reproduce the crash seen in http://crbug.com/14491, where an assert |
| 470 // hits in the BitStack size comparison in WebKit. | 470 // hits in the BitStack size comparison in WebKit. |
| 471 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue14491) { | 471 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue14491) { |
| 472 HTTPTestServer* server = StartHTTPServer(); | 472 HTTPTestServer* server = StartHTTPServer(); |
| 473 ASSERT_TRUE(server); | 473 ASSERT_TRUE(server); |
| 474 | 474 |
| 475 // First we navigate to our page. | 475 // First we navigate to our page. |
| 476 GURL url = server->TestServerPageW(kBitstackCrash); | 476 GURL url = server->TestServerPage(kBitstackCrash); |
| 477 ui_test_utils::NavigateToURL(browser(), url); | 477 ui_test_utils::NavigateToURL(browser(), url); |
| 478 | 478 |
| 479 // This used to crash the tab. | 479 // This used to crash the tab. |
| 480 int ordinal = 0; | 480 int ordinal = 0; |
| 481 EXPECT_EQ(0, FindInPageWchar(browser()->GetSelectedTabContents(), | 481 EXPECT_EQ(0, FindInPageWchar(browser()->GetSelectedTabContents(), |
| 482 L"s", kFwd, kIgnoreCase, &ordinal)); | 482 L"s", kFwd, kIgnoreCase, &ordinal)); |
| 483 EXPECT_EQ(0, ordinal); | 483 EXPECT_EQ(0, ordinal); |
| 484 } | 484 } |
| 485 | 485 |
| 486 // Test to make sure Find does the right thing when restarting from a timeout. | 486 // Test to make sure Find does the right thing when restarting from a timeout. |
| 487 // We used to have a problem where we'd stop finding matches when all of the | 487 // We used to have a problem where we'd stop finding matches when all of the |
| 488 // following conditions were true: | 488 // following conditions were true: |
| 489 // 1) The page has a lot of text to search. | 489 // 1) The page has a lot of text to search. |
| 490 // 2) The page contains more than one match. | 490 // 2) The page contains more than one match. |
| 491 // 3) It takes longer than the time-slice given to each Find operation (100 | 491 // 3) It takes longer than the time-slice given to each Find operation (100 |
| 492 // ms) to find one or more of those matches (so Find times out and has to try | 492 // ms) to find one or more of those matches (so Find times out and has to try |
| 493 // again from where it left off). | 493 // again from where it left off). |
| 494 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindRestarts_Issue1155639) { | 494 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindRestarts_Issue1155639) { |
| 495 HTTPTestServer* server = StartHTTPServer(); | 495 HTTPTestServer* server = StartHTTPServer(); |
| 496 ASSERT_TRUE(server); | 496 ASSERT_TRUE(server); |
| 497 | 497 |
| 498 // First we navigate to our page. | 498 // First we navigate to our page. |
| 499 GURL url = server->TestServerPageW(kTooFewMatchesPage); | 499 GURL url = server->TestServerPage(kTooFewMatchesPage); |
| 500 ui_test_utils::NavigateToURL(browser(), url); | 500 ui_test_utils::NavigateToURL(browser(), url); |
| 501 | 501 |
| 502 // This string appears 5 times at the bottom of a long page. If Find restarts | 502 // This string appears 5 times at the bottom of a long page. If Find restarts |
| 503 // properly after a timeout, it will find 5 matches, not just 1. | 503 // properly after a timeout, it will find 5 matches, not just 1. |
| 504 int ordinal = 0; | 504 int ordinal = 0; |
| 505 EXPECT_EQ(5, FindInPageWchar(browser()->GetSelectedTabContents(), | 505 EXPECT_EQ(5, FindInPageWchar(browser()->GetSelectedTabContents(), |
| 506 L"008.xml", | 506 L"008.xml", |
| 507 kFwd, kIgnoreCase, &ordinal)); | 507 kFwd, kIgnoreCase, &ordinal)); |
| 508 EXPECT_EQ(1, ordinal); | 508 EXPECT_EQ(1, ordinal); |
| 509 } | 509 } |
| 510 | 510 |
| 511 // This tests bug 11761: FindInPage terminates search prematurely. | 511 // This tests bug 11761: FindInPage terminates search prematurely. |
| 512 // This test will be enabled once the bug is fixed. | 512 // This test will be enabled once the bug is fixed. |
| 513 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 513 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 514 DISABLED_FindInPagePrematureEnd) { | 514 DISABLED_FindInPagePrematureEnd) { |
| 515 HTTPTestServer* server = StartHTTPServer(); | 515 HTTPTestServer* server = StartHTTPServer(); |
| 516 ASSERT_TRUE(server); | 516 ASSERT_TRUE(server); |
| 517 | 517 |
| 518 // First we navigate to our special focus tracking page. | 518 // First we navigate to our special focus tracking page. |
| 519 GURL url = server->TestServerPageW(kPrematureEnd); | 519 GURL url = server->TestServerPage(kPrematureEnd); |
| 520 ui_test_utils::NavigateToURL(browser(), url); | 520 ui_test_utils::NavigateToURL(browser(), url); |
| 521 | 521 |
| 522 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 522 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 523 ASSERT_TRUE(NULL != tab_contents); | 523 ASSERT_TRUE(NULL != tab_contents); |
| 524 | 524 |
| 525 // Search for a text that exists within a link on the page. | 525 // Search for a text that exists within a link on the page. |
| 526 int ordinal = 0; | 526 int ordinal = 0; |
| 527 EXPECT_EQ(2, FindInPageWchar(tab_contents, L"html ", | 527 EXPECT_EQ(2, FindInPageWchar(tab_contents, L"html ", |
| 528 kFwd, kIgnoreCase, &ordinal)); | 528 kFwd, kIgnoreCase, &ordinal)); |
| 529 EXPECT_EQ(1, ordinal); | 529 EXPECT_EQ(1, ordinal); |
| 530 } | 530 } |
| 531 | 531 |
| 532 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) { | 532 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) { |
| 533 HTTPTestServer* server = StartHTTPServer(); | 533 HTTPTestServer* server = StartHTTPServer(); |
| 534 ASSERT_TRUE(server); | 534 ASSERT_TRUE(server); |
| 535 | 535 |
| 536 // First we navigate to our special focus tracking page. | 536 // First we navigate to our special focus tracking page. |
| 537 GURL url = server->TestServerPageW(kSimplePage); | 537 GURL url = server->TestServerPage(kSimplePage); |
| 538 GURL url2 = server->TestServerPageW(kFramePage); | 538 GURL url2 = server->TestServerPage(kFramePage); |
| 539 ui_test_utils::NavigateToURL(browser(), url); | 539 ui_test_utils::NavigateToURL(browser(), url); |
| 540 | 540 |
| 541 browser()->ShowFindBar(); | 541 browser()->ShowFindBar(); |
| 542 | 542 |
| 543 gfx::Point position; | 543 gfx::Point position; |
| 544 bool fully_visible = false; | 544 bool fully_visible = false; |
| 545 | 545 |
| 546 // Make sure it is open. | 546 // Make sure it is open. |
| 547 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 547 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 548 EXPECT_TRUE(fully_visible); | 548 EXPECT_TRUE(fully_visible); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 562 } | 562 } |
| 563 | 563 |
| 564 // Make sure Find box disappears when History/Downloads page is opened, and | 564 // Make sure Find box disappears when History/Downloads page is opened, and |
| 565 // when a New Tab is opened. | 565 // when a New Tab is opened. |
| 566 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 566 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 567 FindDisappearOnNewTabAndHistory) { | 567 FindDisappearOnNewTabAndHistory) { |
| 568 HTTPTestServer* server = StartHTTPServer(); | 568 HTTPTestServer* server = StartHTTPServer(); |
| 569 ASSERT_TRUE(server); | 569 ASSERT_TRUE(server); |
| 570 | 570 |
| 571 // First we navigate to our special focus tracking page. | 571 // First we navigate to our special focus tracking page. |
| 572 GURL url = server->TestServerPageW(kSimplePage); | 572 GURL url = server->TestServerPage(kSimplePage); |
| 573 ui_test_utils::NavigateToURL(browser(), url); | 573 ui_test_utils::NavigateToURL(browser(), url); |
| 574 | 574 |
| 575 browser()->ShowFindBar(); | 575 browser()->ShowFindBar(); |
| 576 | 576 |
| 577 gfx::Point position; | 577 gfx::Point position; |
| 578 bool fully_visible = false; | 578 bool fully_visible = false; |
| 579 | 579 |
| 580 // Make sure it is open. | 580 // Make sure it is open. |
| 581 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 581 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 582 EXPECT_TRUE(fully_visible); | 582 EXPECT_TRUE(fully_visible); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 612 #define MAYBE_FindMovesWhenObscuring FLAKY_FindMovesWhenObscuring | 612 #define MAYBE_FindMovesWhenObscuring FLAKY_FindMovesWhenObscuring |
| 613 #else | 613 #else |
| 614 #define MAYBE_FindMovesWhenObscuring FindMovesWhenObscuring | 614 #define MAYBE_FindMovesWhenObscuring FindMovesWhenObscuring |
| 615 #endif | 615 #endif |
| 616 | 616 |
| 617 // Make sure Find box moves out of the way if it is obscuring the active match. | 617 // Make sure Find box moves out of the way if it is obscuring the active match. |
| 618 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FindMovesWhenObscuring) { | 618 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FindMovesWhenObscuring) { |
| 619 HTTPTestServer* server = StartHTTPServer(); | 619 HTTPTestServer* server = StartHTTPServer(); |
| 620 ASSERT_TRUE(server); | 620 ASSERT_TRUE(server); |
| 621 | 621 |
| 622 GURL url = server->TestServerPageW(kMoveIfOver); | 622 GURL url = server->TestServerPage(kMoveIfOver); |
| 623 ui_test_utils::NavigateToURL(browser(), url); | 623 ui_test_utils::NavigateToURL(browser(), url); |
| 624 | 624 |
| 625 browser()->ShowFindBar(); | 625 browser()->ShowFindBar(); |
| 626 | 626 |
| 627 // This is needed on GTK because the reposition operation is asynchronous. | 627 // This is needed on GTK because the reposition operation is asynchronous. |
| 628 MessageLoop::current()->RunAllPending(); | 628 MessageLoop::current()->RunAllPending(); |
| 629 | 629 |
| 630 gfx::Point start_position; | 630 gfx::Point start_position; |
| 631 gfx::Point position; | 631 gfx::Point position; |
| 632 bool fully_visible = false; | 632 bool fully_visible = false; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 EXPECT_EQ(position.x(), start_position.x()); | 666 EXPECT_EQ(position.x(), start_position.x()); |
| 667 } | 667 } |
| 668 | 668 |
| 669 // Make sure F3 in a new tab works if Find has previous string to search for. | 669 // Make sure F3 in a new tab works if Find has previous string to search for. |
| 670 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 670 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 671 FindNextInNewTabUsesPrepopulate) { | 671 FindNextInNewTabUsesPrepopulate) { |
| 672 HTTPTestServer* server = StartHTTPServer(); | 672 HTTPTestServer* server = StartHTTPServer(); |
| 673 ASSERT_TRUE(server); | 673 ASSERT_TRUE(server); |
| 674 | 674 |
| 675 // First we navigate to any page. | 675 // First we navigate to any page. |
| 676 GURL url = server->TestServerPageW(kSimplePage); | 676 GURL url = server->TestServerPage(kSimplePage); |
| 677 ui_test_utils::NavigateToURL(browser(), url); | 677 ui_test_utils::NavigateToURL(browser(), url); |
| 678 | 678 |
| 679 // Search for 'no_match'. No matches should be found. | 679 // Search for 'no_match'. No matches should be found. |
| 680 int ordinal = 0; | 680 int ordinal = 0; |
| 681 TabContents* tab = browser()->GetSelectedTabContents(); | 681 TabContents* tab = browser()->GetSelectedTabContents(); |
| 682 EXPECT_EQ(0, FindInPageWchar(tab, L"no_match", | 682 EXPECT_EQ(0, FindInPageWchar(tab, L"no_match", |
| 683 kFwd, kIgnoreCase, &ordinal)); | 683 kFwd, kIgnoreCase, &ordinal)); |
| 684 EXPECT_EQ(0, ordinal); | 684 EXPECT_EQ(0, ordinal); |
| 685 | 685 |
| 686 // Open another tab (tab B). | 686 // Open another tab (tab B). |
| (...skipping 26 matching lines...) Expand all Loading... |
| 713 // behavior. See http://crbug.com/26870. | 713 // behavior. See http://crbug.com/26870. |
| 714 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 714 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 715 DISABLED_AcceleratorRestoring) { | 715 DISABLED_AcceleratorRestoring) { |
| 716 #else | 716 #else |
| 717 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) { | 717 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) { |
| 718 #endif | 718 #endif |
| 719 HTTPTestServer* server = StartHTTPServer(); | 719 HTTPTestServer* server = StartHTTPServer(); |
| 720 ASSERT_TRUE(server); | 720 ASSERT_TRUE(server); |
| 721 | 721 |
| 722 // First we navigate to any page. | 722 // First we navigate to any page. |
| 723 GURL url = server->TestServerPageW(kSimplePage); | 723 GURL url = server->TestServerPage(kSimplePage); |
| 724 ui_test_utils::NavigateToURL(browser(), url); | 724 ui_test_utils::NavigateToURL(browser(), url); |
| 725 | 725 |
| 726 #if defined(OS_WIN) | 726 #if defined(OS_WIN) |
| 727 // TODO(oshima): Windows code assumes that NativeView is | 727 // TODO(oshima): Windows code assumes that NativeView is |
| 728 // assignable from NativeWindow, which is not true on other platforms. | 728 // assignable from NativeWindow, which is not true on other platforms. |
| 729 // This has to be fixed, probably by having explicit | 729 // This has to be fixed, probably by having explicit |
| 730 // GetNativeView / GetNativewWindow methods on BrowserWindow. | 730 // GetNativeView / GetNativewWindow methods on BrowserWindow. |
| 731 // See http://crbug.com/26873. | 731 // See http://crbug.com/26873. |
| 732 gfx::NativeView browser_view = browser()->window()->GetNativeHandle(); | 732 gfx::NativeView browser_view = browser()->window()->GetNativeHandle(); |
| 733 #elif defined(OS_LINUX) | 733 #elif defined(OS_LINUX) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 } | 766 } |
| 767 #endif // TOOLKIT_VIEWS | 767 #endif // TOOLKIT_VIEWS |
| 768 | 768 |
| 769 // Make sure Find box does not become UI-inactive when no text is in the box as | 769 // Make sure Find box does not become UI-inactive when no text is in the box as |
| 770 // we switch to a tab contents with an empty find string. See issue 13570. | 770 // we switch to a tab contents with an empty find string. See issue 13570. |
| 771 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) { | 771 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) { |
| 772 HTTPTestServer* server = StartHTTPServer(); | 772 HTTPTestServer* server = StartHTTPServer(); |
| 773 ASSERT_TRUE(server); | 773 ASSERT_TRUE(server); |
| 774 | 774 |
| 775 // First we navigate to any page. | 775 // First we navigate to any page. |
| 776 GURL url = server->TestServerPageW(kSimplePage); | 776 GURL url = server->TestServerPage(kSimplePage); |
| 777 ui_test_utils::NavigateToURL(browser(), url); | 777 ui_test_utils::NavigateToURL(browser(), url); |
| 778 | 778 |
| 779 browser()->ShowFindBar(); | 779 browser()->ShowFindBar(); |
| 780 | 780 |
| 781 // Simulate a user clearing the search string. Ideally, we should be | 781 // Simulate a user clearing the search string. Ideally, we should be |
| 782 // simulating keypresses here for searching for something and pressing | 782 // simulating keypresses here for searching for something and pressing |
| 783 // backspace, but that's been proven flaky in the past, so we go straight to | 783 // backspace, but that's been proven flaky in the past, so we go straight to |
| 784 // tab_contents. | 784 // tab_contents. |
| 785 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 785 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 786 // Stop the (non-existing) find operation, and clear the selection (which | 786 // Stop the (non-existing) find operation, and clear the selection (which |
| 787 // signals the UI is still active). | 787 // signals the UI is still active). |
| 788 tab_contents->StopFinding(FindBarController::kClearSelection); | 788 tab_contents->StopFinding(FindBarController::kClearSelection); |
| 789 // Make sure the Find UI flag hasn't been cleared, it must be so that the UI | 789 // Make sure the Find UI flag hasn't been cleared, it must be so that the UI |
| 790 // still responds to browser window resizing. | 790 // still responds to browser window resizing. |
| 791 ASSERT_TRUE(tab_contents->find_ui_active()); | 791 ASSERT_TRUE(tab_contents->find_ui_active()); |
| 792 } | 792 } |
| 793 | 793 |
| 794 // Make sure F3 works after you FindNext a couple of times and end the Find | 794 // Make sure F3 works after you FindNext a couple of times and end the Find |
| 795 // session. See issue http://crbug.com/28306. | 795 // session. See issue http://crbug.com/28306. |
| 796 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, RestartSearchFromF3) { | 796 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, RestartSearchFromF3) { |
| 797 HTTPTestServer* server = StartHTTPServer(); | 797 HTTPTestServer* server = StartHTTPServer(); |
| 798 ASSERT_TRUE(server); | 798 ASSERT_TRUE(server); |
| 799 | 799 |
| 800 // First we navigate to a simple page. | 800 // First we navigate to a simple page. |
| 801 GURL url = server->TestServerPageW(kSimple); | 801 GURL url = server->TestServerPage(kSimple); |
| 802 ui_test_utils::NavigateToURL(browser(), url); | 802 ui_test_utils::NavigateToURL(browser(), url); |
| 803 | 803 |
| 804 // Search for 'page'. Should have 1 match. | 804 // Search for 'page'. Should have 1 match. |
| 805 int ordinal = 0; | 805 int ordinal = 0; |
| 806 TabContents* tab = browser()->GetSelectedTabContents(); | 806 TabContents* tab = browser()->GetSelectedTabContents(); |
| 807 EXPECT_EQ(1, FindInPageWchar(tab, L"page", kFwd, kIgnoreCase, &ordinal)); | 807 EXPECT_EQ(1, FindInPageWchar(tab, L"page", kFwd, kIgnoreCase, &ordinal)); |
| 808 EXPECT_EQ(1, ordinal); | 808 EXPECT_EQ(1, ordinal); |
| 809 | 809 |
| 810 // Simulate what happens when you press F3 for FindNext. Still should show | 810 // Simulate what happens when you press F3 for FindNext. Still should show |
| 811 // one match. This cleared the pre-populate string at one point (see bug). | 811 // one match. This cleared the pre-populate string at one point (see bug). |
| (...skipping 14 matching lines...) Expand all Loading... |
| 826 // with the last search from the same tab rather than the last overall search. | 826 // with the last search from the same tab rather than the last overall search. |
| 827 // http://crbug.com/30006 | 827 // http://crbug.com/30006 |
| 828 #if defined(OS_CHROMEOS) | 828 #if defined(OS_CHROMEOS) |
| 829 #define PreferPreviousSearch FLAKY_PreferPreviousSearch | 829 #define PreferPreviousSearch FLAKY_PreferPreviousSearch |
| 830 #endif | 830 #endif |
| 831 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) { | 831 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) { |
| 832 HTTPTestServer* server = StartHTTPServer(); | 832 HTTPTestServer* server = StartHTTPServer(); |
| 833 ASSERT_TRUE(server); | 833 ASSERT_TRUE(server); |
| 834 | 834 |
| 835 // First we navigate to any page. | 835 // First we navigate to any page. |
| 836 GURL url = server->TestServerPageW(kSimplePage); | 836 GURL url = server->TestServerPage(kSimplePage); |
| 837 ui_test_utils::NavigateToURL(browser(), url); | 837 ui_test_utils::NavigateToURL(browser(), url); |
| 838 | 838 |
| 839 // Find "Default". | 839 // Find "Default". |
| 840 int ordinal = 0; | 840 int ordinal = 0; |
| 841 TabContents* tab1 = browser()->GetSelectedTabContents(); | 841 TabContents* tab1 = browser()->GetSelectedTabContents(); |
| 842 EXPECT_EQ(1, FindInPageWchar(tab1, L"Default", kFwd, kIgnoreCase, &ordinal)); | 842 EXPECT_EQ(1, FindInPageWchar(tab1, L"Default", kFwd, kIgnoreCase, &ordinal)); |
| 843 | 843 |
| 844 // Create a second tab. | 844 // Create a second tab. |
| 845 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, | 845 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, |
| 846 Browser::ADD_SELECTED, NULL, std::string()); | 846 Browser::ADD_SELECTED, NULL, std::string()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 865 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateSameTab) { | 865 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateSameTab) { |
| 866 #if defined(OS_MACOSX) | 866 #if defined(OS_MACOSX) |
| 867 // FindInPage on Mac doesn't use prepopulated values. Search there is global. | 867 // FindInPage on Mac doesn't use prepopulated values. Search there is global. |
| 868 return; | 868 return; |
| 869 #endif | 869 #endif |
| 870 | 870 |
| 871 HTTPTestServer* server = StartHTTPServer(); | 871 HTTPTestServer* server = StartHTTPServer(); |
| 872 ASSERT_TRUE(server); | 872 ASSERT_TRUE(server); |
| 873 | 873 |
| 874 // First we navigate to any page. | 874 // First we navigate to any page. |
| 875 GURL url = server->TestServerPageW(kSimple); | 875 GURL url = server->TestServerPage(kSimple); |
| 876 ui_test_utils::NavigateToURL(browser(), url); | 876 ui_test_utils::NavigateToURL(browser(), url); |
| 877 | 877 |
| 878 // Search for the word "page". | 878 // Search for the word "page". |
| 879 int ordinal = 0; | 879 int ordinal = 0; |
| 880 TabContents* tab1 = browser()->GetSelectedTabContents(); | 880 TabContents* tab1 = browser()->GetSelectedTabContents(); |
| 881 EXPECT_EQ(1, FindInPageWchar(tab1, L"page", kFwd, kIgnoreCase, &ordinal)); | 881 EXPECT_EQ(1, FindInPageWchar(tab1, L"page", kFwd, kIgnoreCase, &ordinal)); |
| 882 | 882 |
| 883 // Open the Find box. | 883 // Open the Find box. |
| 884 EnsureFindBoxOpen(); | 884 EnsureFindBoxOpen(); |
| 885 | 885 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 903 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateInNewTab) { | 903 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateInNewTab) { |
| 904 #if defined(OS_MACOSX) | 904 #if defined(OS_MACOSX) |
| 905 // FindInPage on Mac doesn't use prepopulated values. Search there is global. | 905 // FindInPage on Mac doesn't use prepopulated values. Search there is global. |
| 906 return; | 906 return; |
| 907 #endif | 907 #endif |
| 908 | 908 |
| 909 HTTPTestServer* server = StartHTTPServer(); | 909 HTTPTestServer* server = StartHTTPServer(); |
| 910 ASSERT_TRUE(server); | 910 ASSERT_TRUE(server); |
| 911 | 911 |
| 912 // First we navigate to any page. | 912 // First we navigate to any page. |
| 913 GURL url = server->TestServerPageW(kSimple); | 913 GURL url = server->TestServerPage(kSimple); |
| 914 ui_test_utils::NavigateToURL(browser(), url); | 914 ui_test_utils::NavigateToURL(browser(), url); |
| 915 | 915 |
| 916 // Search for the word "page". | 916 // Search for the word "page". |
| 917 int ordinal = 0; | 917 int ordinal = 0; |
| 918 TabContents* tab1 = browser()->GetSelectedTabContents(); | 918 TabContents* tab1 = browser()->GetSelectedTabContents(); |
| 919 EXPECT_EQ(1, FindInPageWchar(tab1, L"page", kFwd, kIgnoreCase, &ordinal)); | 919 EXPECT_EQ(1, FindInPageWchar(tab1, L"page", kFwd, kIgnoreCase, &ordinal)); |
| 920 | 920 |
| 921 // Now create a second tab and load the same page. | 921 // Now create a second tab and load the same page. |
| 922 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, | 922 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, |
| 923 Browser::ADD_SELECTED, NULL, std::string()); | 923 Browser::ADD_SELECTED, NULL, std::string()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 939 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) { | 939 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) { |
| 940 #if defined(OS_MACOSX) | 940 #if defined(OS_MACOSX) |
| 941 // FindInPage on Mac doesn't use prepopulated values. Search there is global. | 941 // FindInPage on Mac doesn't use prepopulated values. Search there is global. |
| 942 return; | 942 return; |
| 943 #endif | 943 #endif |
| 944 | 944 |
| 945 HTTPTestServer* server = StartHTTPServer(); | 945 HTTPTestServer* server = StartHTTPServer(); |
| 946 ASSERT_TRUE(server); | 946 ASSERT_TRUE(server); |
| 947 | 947 |
| 948 // First we navigate to any page. | 948 // First we navigate to any page. |
| 949 GURL url = server->TestServerPageW(kSimple); | 949 GURL url = server->TestServerPage(kSimple); |
| 950 ui_test_utils::NavigateToURL(browser(), url); | 950 ui_test_utils::NavigateToURL(browser(), url); |
| 951 | 951 |
| 952 // Search for the word "page". | 952 // Search for the word "page". |
| 953 int ordinal = 0; | 953 int ordinal = 0; |
| 954 TabContents* tab1 = browser()->GetSelectedTabContents(); | 954 TabContents* tab1 = browser()->GetSelectedTabContents(); |
| 955 EXPECT_EQ(1, FindInPageWchar(tab1, L"page", kFwd, kIgnoreCase, &ordinal)); | 955 EXPECT_EQ(1, FindInPageWchar(tab1, L"page", kFwd, kIgnoreCase, &ordinal)); |
| 956 | 956 |
| 957 // Open the Find box. | 957 // Open the Find box. |
| 958 EnsureFindBoxOpen(); | 958 EnsureFindBoxOpen(); |
| 959 | 959 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) { | 1012 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) { |
| 1013 #if defined(OS_MACOSX) | 1013 #if defined(OS_MACOSX) |
| 1014 // FindInPage on Mac doesn't use prepopulated values. Search there is global. | 1014 // FindInPage on Mac doesn't use prepopulated values. Search there is global. |
| 1015 return; | 1015 return; |
| 1016 #endif | 1016 #endif |
| 1017 | 1017 |
| 1018 HTTPTestServer* server = StartHTTPServer(); | 1018 HTTPTestServer* server = StartHTTPServer(); |
| 1019 ASSERT_TRUE(server); | 1019 ASSERT_TRUE(server); |
| 1020 | 1020 |
| 1021 // First we navigate to the "simple" test page. | 1021 // First we navigate to the "simple" test page. |
| 1022 GURL url = server->TestServerPageW(kSimple); | 1022 GURL url = server->TestServerPage(kSimple); |
| 1023 ui_test_utils::NavigateToURL(browser(), url); | 1023 ui_test_utils::NavigateToURL(browser(), url); |
| 1024 | 1024 |
| 1025 // Search for the word "page" in the normal browser tab. | 1025 // Search for the word "page" in the normal browser tab. |
| 1026 int ordinal = 0; | 1026 int ordinal = 0; |
| 1027 TabContents* tab1 = browser()->GetSelectedTabContents(); | 1027 TabContents* tab1 = browser()->GetSelectedTabContents(); |
| 1028 EXPECT_EQ(1, FindInPageWchar(tab1, L"page", kFwd, kIgnoreCase, &ordinal)); | 1028 EXPECT_EQ(1, FindInPageWchar(tab1, L"page", kFwd, kIgnoreCase, &ordinal)); |
| 1029 | 1029 |
| 1030 // Open the Find box. | 1030 // Open the Find box. |
| 1031 EnsureFindBoxOpenForBrowser(browser()); | 1031 EnsureFindBoxOpenForBrowser(browser()); |
| 1032 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); | 1032 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 EnsureFindBoxOpenForBrowser(browser()); | 1070 EnsureFindBoxOpenForBrowser(browser()); |
| 1071 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); | 1071 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 // This makes sure that dismissing the find bar with kActivateSelection works. | 1074 // This makes sure that dismissing the find bar with kActivateSelection works. |
| 1075 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, ActivateLinkNavigatesPage) { | 1075 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, ActivateLinkNavigatesPage) { |
| 1076 HTTPTestServer* server = StartHTTPServer(); | 1076 HTTPTestServer* server = StartHTTPServer(); |
| 1077 ASSERT_TRUE(server); | 1077 ASSERT_TRUE(server); |
| 1078 | 1078 |
| 1079 // First we navigate to our test content. | 1079 // First we navigate to our test content. |
| 1080 GURL url = server->TestServerPageW(kLinkPage); | 1080 GURL url = server->TestServerPage(kLinkPage); |
| 1081 ui_test_utils::NavigateToURL(browser(), url); | 1081 ui_test_utils::NavigateToURL(browser(), url); |
| 1082 | 1082 |
| 1083 TabContents* tab = browser()->GetSelectedTabContents(); | 1083 TabContents* tab = browser()->GetSelectedTabContents(); |
| 1084 int ordinal = 0; | 1084 int ordinal = 0; |
| 1085 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); | 1085 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); |
| 1086 EXPECT_EQ(ordinal, 1); | 1086 EXPECT_EQ(ordinal, 1); |
| 1087 | 1087 |
| 1088 // End the find session, click on the link. | 1088 // End the find session, click on the link. |
| 1089 tab->StopFinding(FindBarController::kActivateSelection); | 1089 tab->StopFinding(FindBarController::kActivateSelection); |
| 1090 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 1090 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
| 1091 } | 1091 } |
| OLD | NEW |