OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/ui/browser_finder.h" | 6 #include "chrome/browser/ui/browser_finder.h" |
7 #include "chrome/browser/ui/find_bar/find_bar.h" | 7 #include "chrome/browser/ui/find_bar/find_bar.h" |
8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
9 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 9 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 bool FocusedOnPage(WebContents* web_contents, std::string* result) { | 53 bool FocusedOnPage(WebContents* web_contents, std::string* result) { |
54 return content::ExecuteScriptAndExtractString( | 54 return content::ExecuteScriptAndExtractString( |
55 web_contents, | 55 web_contents, |
56 "window.domAutomationController.send(getFocusedElement());", | 56 "window.domAutomationController.send(getFocusedElement());", |
57 result); | 57 result); |
58 } | 58 } |
59 | 59 |
60 // This tests the FindInPage end-state, in other words: what is focused when you | 60 // This tests the FindInPage end-state, in other words: what is focused when you |
61 // close the Find box (ie. if you find within a link the link should be | 61 // close the Find box (ie. if you find within a link the link should be |
62 // focused). | 62 // focused). |
63 IN_PROC_BROWSER_TEST_F(FindInPageInteractiveTest, FindInPageEndState) { | 63 // Flaky on CrOS. |
| 64 #if defined(OS_CHROMEOS) |
| 65 #define MAYBE_FindInPageEndState DISABLED_FindInPageEndState |
| 66 #else |
| 67 #define MAYBE_FindInPageEndState FindInPageEndState |
| 68 #endif |
| 69 IN_PROC_BROWSER_TEST_F(FindInPageInteractiveTest, MAYBE_FindInPageEndState) { |
64 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 70 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
65 | 71 |
66 // Make sure Chrome is in the foreground, otherwise sending input | 72 // Make sure Chrome is in the foreground, otherwise sending input |
67 // won't do anything and the test will hang. | 73 // won't do anything and the test will hang. |
68 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 74 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
69 | 75 |
70 // First we navigate to our special focus tracking page. | 76 // First we navigate to our special focus tracking page. |
71 GURL url = embedded_test_server()->GetURL(kEndState); | 77 GURL url = embedded_test_server()->GetURL(kEndState); |
72 ui_test_utils::NavigateToURL(browser(), url); | 78 ui_test_utils::NavigateToURL(browser(), url); |
73 | 79 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 "window.domAutomationController.send(selectLink1());", | 112 "window.domAutomationController.send(selectLink1());", |
107 &result)); | 113 &result)); |
108 | 114 |
109 // End the find session. | 115 // End the find session. |
110 find_tab_helper->StopFinding(FindBarController::kKeepSelectionOnPage); | 116 find_tab_helper->StopFinding(FindBarController::kKeepSelectionOnPage); |
111 | 117 |
112 // Verify that link2 is not focused. | 118 // Verify that link2 is not focused. |
113 ASSERT_TRUE(FocusedOnPage(web_contents, &result)); | 119 ASSERT_TRUE(FocusedOnPage(web_contents, &result)); |
114 EXPECT_STREQ("", result.c_str()); | 120 EXPECT_STREQ("", result.c_str()); |
115 } | 121 } |
OLD | NEW |