OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/file_util.h" |
5 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
6 #include "base/string16.h" | 7 #include "base/string16.h" |
7 #include "base/string_util.h" | 8 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/cancelable_request.h" |
| 11 #include "chrome/browser/history/history.h" |
| 12 #include "chrome/browser/history/history_service_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
12 #include "chrome/browser/ui/browser_navigator.h" | 16 #include "chrome/browser/ui/browser_navigator.h" |
13 #include "chrome/browser/ui/browser_tabstrip.h" | 17 #include "chrome/browser/ui/browser_tabstrip.h" |
14 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/chrome_pages.h" | 19 #include "chrome/browser/ui/chrome_pages.h" |
16 #include "chrome/browser/ui/find_bar/find_bar.h" | 20 #include "chrome/browser/ui/find_bar/find_bar.h" |
17 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 21 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
18 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 22 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
19 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 23 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
20 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
23 #include "chrome/test/base/in_process_browser_test.h" | 27 #include "chrome/test/base/in_process_browser_test.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 28 #include "chrome/test/base/ui_test_utils.h" |
| 29 #include "content/public/browser/download_manager.h" |
25 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
26 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
27 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
28 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
29 #include "content/public/browser/web_contents_view.h" | 34 #include "content/public/browser/web_contents_view.h" |
30 #include "content/public/test/browser_test_utils.h" | 35 #include "content/public/test/browser_test_utils.h" |
| 36 #include "content/public/test/download_test_observer.h" |
| 37 #include "net/base/net_util.h" |
31 #include "ui/base/accelerators/accelerator.h" | 38 #include "ui/base/accelerators/accelerator.h" |
32 #include "ui/base/keycodes/keyboard_codes.h" | 39 #include "ui/base/keycodes/keyboard_codes.h" |
33 | 40 |
34 #if defined(TOOLKIT_VIEWS) | 41 #if defined(TOOLKIT_VIEWS) |
35 #include "chrome/browser/ui/views/find_bar_host.h" | 42 #include "chrome/browser/ui/views/find_bar_host.h" |
36 #include "ui/views/focus/focus_manager.h" | 43 #include "ui/views/focus/focus_manager.h" |
37 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
38 #elif defined(TOOLKIT_GTK) | 45 #elif defined(TOOLKIT_GTK) |
39 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" | 46 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" |
40 #elif defined(OS_MACOSX) | 47 #elif defined(OS_MACOSX) |
(...skipping 20 matching lines...) Expand all Loading... |
61 const std::string kLinkPage = "link.html"; | 68 const std::string kLinkPage = "link.html"; |
62 | 69 |
63 const bool kBack = false; | 70 const bool kBack = false; |
64 const bool kFwd = true; | 71 const bool kFwd = true; |
65 | 72 |
66 const bool kIgnoreCase = false; | 73 const bool kIgnoreCase = false; |
67 const bool kCaseSensitive = true; | 74 const bool kCaseSensitive = true; |
68 | 75 |
69 const int kMoveIterations = 30; | 76 const int kMoveIterations = 30; |
70 | 77 |
| 78 namespace { |
| 79 |
| 80 void HistoryServiceQueried(int) { |
| 81 MessageLoop::current()->Quit(); |
| 82 } |
| 83 |
| 84 } // namespace |
| 85 |
71 class FindInPageControllerTest : public InProcessBrowserTest { | 86 class FindInPageControllerTest : public InProcessBrowserTest { |
72 public: | 87 public: |
73 FindInPageControllerTest() { | 88 FindInPageControllerTest() { |
74 #if defined(TOOLKIT_VIEWS) | 89 #if defined(TOOLKIT_VIEWS) |
75 DropdownBarHost::disable_animations_during_testing_ = true; | 90 DropdownBarHost::disable_animations_during_testing_ = true; |
76 #elif defined(TOOLKIT_GTK) | 91 #elif defined(TOOLKIT_GTK) |
77 SlideAnimatorGtk::SetAnimationsForTesting(false); | 92 SlideAnimatorGtk::SetAnimationsForTesting(false); |
78 #elif defined(OS_MACOSX) | 93 #elif defined(OS_MACOSX) |
79 FindBarBridge::disable_animations_during_testing_ = true; | 94 FindBarBridge::disable_animations_during_testing_ = true; |
80 #endif | 95 #endif |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return position.x(); | 182 return position.x(); |
168 } | 183 } |
169 return start_x_position; | 184 return start_x_position; |
170 } | 185 } |
171 | 186 |
172 GURL GetURL(const std::string filename) { | 187 GURL GetURL(const std::string filename) { |
173 return ui_test_utils::GetTestUrl( | 188 return ui_test_utils::GetTestUrl( |
174 FilePath().AppendASCII("find_in_page"), | 189 FilePath().AppendASCII("find_in_page"), |
175 FilePath().AppendASCII(filename)); | 190 FilePath().AppendASCII(filename)); |
176 } | 191 } |
| 192 |
| 193 void FlushHistoryService() { |
| 194 CancelableRequestConsumer history_consumer; |
| 195 HistoryServiceFactory::GetForProfile( |
| 196 browser()->profile(), Profile::IMPLICIT_ACCESS)-> |
| 197 GetNextDownloadId(&history_consumer, |
| 198 base::Bind(&HistoryServiceQueried)); |
| 199 content::RunMessageLoop(); |
| 200 } |
177 }; | 201 }; |
178 | 202 |
179 // This test loads a page with frames and starts FindInPage requests. | 203 // This test loads a page with frames and starts FindInPage requests. |
180 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFrames) { | 204 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFrames) { |
181 // First we navigate to our frames page. | 205 // First we navigate to our frames page. |
182 GURL url = GetURL(kFramePage); | 206 GURL url = GetURL(kFramePage); |
183 ui_test_utils::NavigateToURL(browser(), url); | 207 ui_test_utils::NavigateToURL(browser(), url); |
184 | 208 |
185 // Try incremental search (mimicking user typing in). | 209 // Try incremental search (mimicking user typing in). |
186 int ordinal = 0; | 210 int ordinal = 0; |
187 TabContents* tab = chrome::GetActiveTabContents(browser()); | 211 TabContents* tab = chrome::GetActiveTabContents(browser()); |
188 EXPECT_EQ(18, FindInPageWchar(tab, L"g", | 212 EXPECT_EQ(18, FindInPageWchar(tab, L"g", |
189 kFwd, kIgnoreCase, &ordinal)); | 213 kFwd, kIgnoreCase, &ordinal)); |
190 EXPECT_EQ(1, ordinal); | 214 EXPECT_EQ(1, ordinal); |
191 EXPECT_EQ(11, FindInPageWchar(tab, L"go", | 215 EXPECT_EQ(11, FindInPageWchar(tab, L"go", |
192 kFwd, kIgnoreCase, &ordinal)); | 216 kFwd, kIgnoreCase, &ordinal)); |
193 EXPECT_EQ(1, ordinal); | 217 EXPECT_EQ(1, ordinal); |
194 EXPECT_EQ(04, FindInPageWchar(tab, L"goo", | 218 EXPECT_EQ(4, FindInPageWchar(tab, L"goo", |
195 kFwd, kIgnoreCase, &ordinal)); | 219 kFwd, kIgnoreCase, &ordinal)); |
196 EXPECT_EQ(1, ordinal); | 220 EXPECT_EQ(1, ordinal); |
197 EXPECT_EQ(03, FindInPageWchar(tab, L"goog", | 221 EXPECT_EQ(3, FindInPageWchar(tab, L"goog", |
198 kFwd, kIgnoreCase, &ordinal)); | 222 kFwd, kIgnoreCase, &ordinal)); |
199 EXPECT_EQ(1, ordinal); | 223 EXPECT_EQ(1, ordinal); |
200 EXPECT_EQ(02, FindInPageWchar(tab, L"googl", | 224 EXPECT_EQ(2, FindInPageWchar(tab, L"googl", |
201 kFwd, kIgnoreCase, &ordinal)); | 225 kFwd, kIgnoreCase, &ordinal)); |
202 EXPECT_EQ(1, ordinal); | 226 EXPECT_EQ(1, ordinal); |
203 EXPECT_EQ(01, FindInPageWchar(tab, L"google", | 227 EXPECT_EQ(1, FindInPageWchar(tab, L"google", |
204 kFwd, kIgnoreCase, &ordinal)); | 228 kFwd, kIgnoreCase, &ordinal)); |
205 EXPECT_EQ(1, ordinal); | 229 EXPECT_EQ(1, ordinal); |
206 EXPECT_EQ(00, FindInPageWchar(tab, L"google!", | 230 EXPECT_EQ(0, FindInPageWchar(tab, L"google!", |
207 kFwd, kIgnoreCase, &ordinal)); | 231 kFwd, kIgnoreCase, &ordinal)); |
208 EXPECT_EQ(0, ordinal); | 232 EXPECT_EQ(0, ordinal); |
209 | 233 |
210 // Negative test (no matches should be found). | 234 // Negative test (no matches should be found). |
211 EXPECT_EQ(0, FindInPageWchar(tab, L"Non-existing string", | 235 EXPECT_EQ(0, FindInPageWchar(tab, L"Non-existing string", |
212 kFwd, kIgnoreCase, &ordinal)); | 236 kFwd, kIgnoreCase, &ordinal)); |
213 EXPECT_EQ(0, ordinal); | 237 EXPECT_EQ(0, ordinal); |
214 | 238 |
215 // 'horse' only exists in the three right frames. | 239 // 'horse' only exists in the three right frames. |
216 EXPECT_EQ(3, FindInPageWchar(tab, L"horse", | 240 EXPECT_EQ(3, FindInPageWchar(tab, L"horse", |
217 kFwd, kIgnoreCase, &ordinal)); | 241 kFwd, kIgnoreCase, &ordinal)); |
(...skipping 29 matching lines...) Expand all Loading... |
247 kFwd, kIgnoreCase, &ordinal)); | 271 kFwd, kIgnoreCase, &ordinal)); |
248 EXPECT_EQ(1, ordinal); | 272 EXPECT_EQ(1, ordinal); |
249 EXPECT_EQ(1, FindInPageWchar(tab, L"Hreggvi\u00F0ur", | 273 EXPECT_EQ(1, FindInPageWchar(tab, L"Hreggvi\u00F0ur", |
250 kFwd, kCaseSensitive, &ordinal)); | 274 kFwd, kCaseSensitive, &ordinal)); |
251 EXPECT_EQ(1, ordinal); | 275 EXPECT_EQ(1, ordinal); |
252 EXPECT_EQ(0, FindInPageWchar(tab, L"hreggvi\u00F0ur", | 276 EXPECT_EQ(0, FindInPageWchar(tab, L"hreggvi\u00F0ur", |
253 kFwd, kCaseSensitive, &ordinal)); | 277 kFwd, kCaseSensitive, &ordinal)); |
254 EXPECT_EQ(0, ordinal); | 278 EXPECT_EQ(0, ordinal); |
255 } | 279 } |
256 | 280 |
| 281 // Verify search for text within various forms and text areas. |
| 282 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFormsTextAreas) { |
| 283 std::vector<GURL> urls; |
| 284 urls.push_back(GetURL("textintextarea.html")); |
| 285 urls.push_back(GetURL("smalltextarea.html")); |
| 286 urls.push_back(GetURL("populatedform.html")); |
| 287 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 288 |
| 289 for (size_t i = 0; i < urls.size(); ++i) { |
| 290 ui_test_utils::NavigateToURL(browser(), urls[i]); |
| 291 EXPECT_EQ(1, FindInPageWchar(tab, L"cat", kFwd, kIgnoreCase, NULL)); |
| 292 EXPECT_EQ(0, FindInPageWchar(tab, L"bat", kFwd, kIgnoreCase, NULL)); |
| 293 } |
| 294 } |
| 295 |
| 296 // Verify search for text within special URLs such as chrome:history, |
| 297 // chrome://downloads, data directory |
| 298 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindNextAndPrevious) { |
| 299 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 300 |
| 301 FilePath data_dir = ui_test_utils::GetTestFilePath(FilePath(), FilePath()); |
| 302 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(data_dir)); |
| 303 EXPECT_EQ(1, FindInPageWchar(tab, L"downloads", kFwd, kIgnoreCase, NULL)); |
| 304 |
| 305 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); |
| 306 |
| 307 // The history page does an async request to the history service and then |
| 308 // updates the renderer. So we make a query as well, and by the time it comes |
| 309 // back we know the data is on its way to the renderer. |
| 310 FlushHistoryService(); |
| 311 |
| 312 string16 query(data_dir.LossyDisplayName()); |
| 313 EXPECT_EQ(1, |
| 314 ui_test_utils::FindInPage(tab, query, kFwd, kIgnoreCase, NULL, |
| 315 NULL)); |
| 316 |
| 317 // Start a download. |
| 318 content::DownloadManager* download_manager = |
| 319 content::BrowserContext::GetDownloadManager(browser()->profile()); |
| 320 scoped_ptr<content::DownloadTestObserver> observer( |
| 321 new content::DownloadTestObserverTerminal( |
| 322 download_manager, 1, |
| 323 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); |
| 324 |
| 325 GURL download_url = ui_test_utils::GetTestUrl( |
| 326 FilePath().AppendASCII("downloads"), |
| 327 FilePath().AppendASCII("a_zip_file.zip")); |
| 328 ui_test_utils::NavigateToURL(browser(), download_url); |
| 329 observer->WaitForFinished(); |
| 330 |
| 331 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); |
| 332 FlushHistoryService(); |
| 333 EXPECT_EQ(1, |
| 334 FindInPageWchar(tab, L"a_zip_file.zip", kFwd, kIgnoreCase, NULL)); |
| 335 } |
| 336 |
| 337 // Verify search selection coordinates. The data file used is set-up such that |
| 338 // the text occurs on the same line, and we verify their positions by verifying |
| 339 // their relative positions. |
| 340 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageSpecialURLs) { |
| 341 std::wstring search_string(L"\u5728\u897f\u660c\u536b\u661f\u53d1"); |
| 342 gfx::Rect first, second, first_reverse; |
| 343 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 344 ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html")); |
| 345 ui_test_utils::FindInPage( |
| 346 tab, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, &first); |
| 347 ui_test_utils::FindInPage( |
| 348 tab, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, &second); |
| 349 |
| 350 // We have search occurrence in the same row, so top-bottom coordinates should |
| 351 // be the same even for second search. |
| 352 ASSERT_EQ(first.y(), second.y()); |
| 353 ASSERT_EQ(first.bottom(), second.bottom()); |
| 354 ASSERT_LT(first.x(), second.x()); |
| 355 ASSERT_LT(first.right(), second.right()); |
| 356 |
| 357 ui_test_utils::FindInPage( |
| 358 tab, WideToUTF16(search_string), kBack, kIgnoreCase, NULL, |
| 359 &first_reverse); |
| 360 // We find next and we go back so find coordinates should be the same as |
| 361 // previous ones. |
| 362 ASSERT_EQ(first, first_reverse); |
| 363 } |
| 364 |
| 365 // Verifies that comments and meta data are not searchable. |
| 366 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 367 CommentsAndMetaDataNotSearchable) { |
| 368 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 369 ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html")); |
| 370 |
| 371 std::wstring search_string = |
| 372 L"\u4e2d\u65b0\u793e\u8bb0\u8005\u5b8b\u5409\u6cb3\u6444\u4e2d\u65b0\u7f51
"; |
| 373 EXPECT_EQ(0, ui_test_utils::FindInPage( |
| 374 tab, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, NULL)); |
| 375 } |
| 376 |
| 377 // Verifies that span and lists are searchable. |
| 378 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SpanAndListsSearchable) { |
| 379 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 380 ui_test_utils::NavigateToURL(browser(), GetURL("FindRandomTests.html")); |
| 381 |
| 382 std::wstring search_string = L"has light blue eyes and my father has dark"; |
| 383 EXPECT_EQ(1, ui_test_utils::FindInPage( |
| 384 tab, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, NULL)); |
| 385 |
| 386 search_string = L"Google\nApple\nandroid"; |
| 387 EXPECT_EQ(1, ui_test_utils::FindInPage( |
| 388 tab, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, NULL)); |
| 389 } |
| 390 |
| 391 // Find in a very large page |
| 392 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, LargePage) { |
| 393 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 394 ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html")); |
| 395 |
| 396 std::wstring search_string = L"daughter of Prince"; |
| 397 EXPECT_EQ(373, |
| 398 FindInPageWchar(tab, search_string.c_str(), kFwd, kIgnoreCase, |
| 399 NULL)); |
| 400 } |
| 401 |
| 402 // Find a very long string in a large page. |
| 403 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindLongString) { |
| 404 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 405 ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html")); |
| 406 |
| 407 FilePath path = ui_test_utils::GetTestFilePath( |
| 408 FilePath().AppendASCII("find_in_page"), |
| 409 FilePath().AppendASCII("LongFind.txt")); |
| 410 std::string query; |
| 411 file_util::ReadFileToString(path, &query); |
| 412 std::wstring search_string = UTF8ToWide(query); |
| 413 EXPECT_EQ(1, |
| 414 FindInPageWchar(tab, search_string.c_str(), kFwd, kIgnoreCase, |
| 415 NULL)); |
| 416 } |
| 417 |
| 418 // Find a big font string in a page. |
| 419 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, BigString) { |
| 420 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 421 ui_test_utils::NavigateToURL(browser(), GetURL("BigText.html")); |
| 422 EXPECT_EQ(1, |
| 423 FindInPageWchar(tab, L"SomeLargeString", kFwd, kIgnoreCase, NULL)); |
| 424 } |
| 425 |
| 426 // Search Back and Forward on a single occurrence. |
| 427 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SingleOccurrence) { |
| 428 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 429 ui_test_utils::NavigateToURL(browser(), GetURL("FindRandomTests.html")); |
| 430 |
| 431 gfx::Rect first_rect; |
| 432 EXPECT_EQ(1, |
| 433 ui_test_utils::FindInPage(tab, ASCIIToUTF16("2010 Pro Bowl"), kFwd, |
| 434 kIgnoreCase, NULL, &first_rect)); |
| 435 |
| 436 gfx::Rect second_rect; |
| 437 EXPECT_EQ(1, |
| 438 ui_test_utils::FindInPage(tab, ASCIIToUTF16("2010 Pro Bowl"), kFwd, |
| 439 kIgnoreCase, NULL, &second_rect)); |
| 440 |
| 441 // Doing a fake find so we have no previous search. |
| 442 ui_test_utils::FindInPage(tab, ASCIIToUTF16("ghgfjgfh201232rere"), kFwd, |
| 443 kIgnoreCase, NULL, NULL); |
| 444 |
| 445 ASSERT_EQ(first_rect, second_rect); |
| 446 |
| 447 EXPECT_EQ(1, |
| 448 ui_test_utils::FindInPage(tab, ASCIIToUTF16("2010 Pro Bowl"), kFwd, |
| 449 kIgnoreCase, NULL, &first_rect)); |
| 450 EXPECT_EQ(1, |
| 451 ui_test_utils::FindInPage(tab, ASCIIToUTF16("2010 Pro Bowl"), kBack, |
| 452 kIgnoreCase, NULL, &second_rect)); |
| 453 ASSERT_EQ(first_rect, second_rect); |
| 454 } |
| 455 |
| 456 // Find the whole text file page and find count should be 1. |
| 457 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindWholeFileContent) { |
| 458 TabContents* tab = chrome::GetActiveTabContents(browser()); |
| 459 |
| 460 FilePath path = ui_test_utils::GetTestFilePath( |
| 461 FilePath().AppendASCII("find_in_page"), |
| 462 FilePath().AppendASCII("find_test.txt")); |
| 463 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(path)); |
| 464 |
| 465 std::string query; |
| 466 file_util::ReadFileToString(path, &query); |
| 467 std::wstring search_string = UTF8ToWide(query); |
| 468 EXPECT_EQ(1, |
| 469 FindInPageWchar(tab, search_string.c_str(), false, false, NULL)); |
| 470 } |
| 471 |
257 // Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute. | 472 // Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute. |
258 bool FocusedOnPage(WebContents* web_contents, std::string* result) | 473 bool FocusedOnPage(WebContents* web_contents, std::string* result) |
259 WARN_UNUSED_RESULT; | 474 WARN_UNUSED_RESULT; |
260 | 475 |
261 bool FocusedOnPage(WebContents* web_contents, std::string* result) { | 476 bool FocusedOnPage(WebContents* web_contents, std::string* result) { |
262 return content::ExecuteJavaScriptAndExtractString( | 477 return content::ExecuteJavaScriptAndExtractString( |
263 web_contents->GetRenderViewHost(), | 478 web_contents->GetRenderViewHost(), |
264 L"", | 479 L"", |
265 L"window.domAutomationController.send(getFocusedElement());", | 480 L"window.domAutomationController.send(getFocusedElement());", |
266 result); | 481 result); |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 content::RunAllPendingInMessageLoop(); // Needed on Linux. | 1468 content::RunAllPendingInMessageLoop(); // Needed on Linux. |
1254 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); | 1469 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); |
1255 | 1470 |
1256 ui_test_utils::NavigateToURLWithDisposition( | 1471 ui_test_utils::NavigateToURLWithDisposition( |
1257 browser(), url, NEW_FOREGROUND_TAB, | 1472 browser(), url, NEW_FOREGROUND_TAB, |
1258 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1473 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1259 chrome::CloseTab(browser()); | 1474 chrome::CloseTab(browser()); |
1260 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); | 1475 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); |
1261 EXPECT_EQ(position, position2); | 1476 EXPECT_EQ(position, position2); |
1262 } | 1477 } |
OLD | NEW |