OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "chrome/browser/automation/ui_controls.h" | 9 #include "chrome/browser/automation/ui_controls.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const wchar_t kTypicalPage[] = L"files/focus/typical_page.html"; | 51 const wchar_t kTypicalPage[] = L"files/focus/typical_page.html"; |
52 const char kTypicalPageName[] = "typical_page.html"; | 52 const char kTypicalPageName[] = "typical_page.html"; |
53 | 53 |
54 class BrowserFocusTest : public InProcessBrowserTest { | 54 class BrowserFocusTest : public InProcessBrowserTest { |
55 public: | 55 public: |
56 BrowserFocusTest() { | 56 BrowserFocusTest() { |
57 set_show_window(true); | 57 set_show_window(true); |
58 EnableDOMAutomation(); | 58 EnableDOMAutomation(); |
59 } | 59 } |
60 | 60 |
61 void CheckViewHasFocus(ViewID vid) { | 61 bool IsViewFocused(ViewID vid) { |
62 BrowserWindow* browser_window = browser()->window(); | 62 return ui_test_utils::IsViewFocused(browser(), vid); |
63 ASSERT_TRUE(browser_window); | |
64 gfx::NativeWindow window = browser_window->GetNativeHandle(); | |
65 ASSERT_TRUE(window); | |
66 #if defined(OS_WIN) | |
67 views::FocusManager* focus_manager = | |
68 views::FocusManager::GetFocusManagerForNativeView(window); | |
69 ASSERT_TRUE(focus_manager); | |
70 EXPECT_EQ(vid, focus_manager->GetFocusedView()->GetID()) << | |
71 "For view id " << vid; | |
72 #elif defined(OS_LINUX) | |
73 GtkWidget* widget = ViewIDUtil::GetWidget(GTK_WIDGET(window), vid); | |
74 ASSERT_TRUE(widget); | |
75 EXPECT_TRUE(WidgetInFocusChain(GTK_WIDGET(window), widget)) << | |
76 "For view id " << vid; | |
77 #else | |
78 NOTIMPLEMENTED(); | |
79 #endif | |
80 } | 63 } |
81 | 64 |
82 void ClickOnView(ViewID vid) { | 65 void ClickOnView(ViewID vid) { |
83 BrowserWindow* browser_window = browser()->window(); | 66 ui_test_utils::ClickOnView(browser(), vid); |
84 ASSERT_TRUE(browser_window); | |
85 #if defined(TOOLKIT_VIEWS) | |
86 views::View* view = | |
87 reinterpret_cast<BrowserView*>(browser_window)->GetViewByID(vid); | |
88 #elif defined(OS_LINUX) | |
89 gfx::NativeWindow window = browser_window->GetNativeHandle(); | |
90 ASSERT_TRUE(window); | |
91 GtkWidget* view = ViewIDUtil::GetWidget(GTK_WIDGET(window), vid); | |
92 #endif | |
93 ASSERT_TRUE(view); | |
94 ui_controls::MoveMouseToCenterAndPress( | |
95 view, | |
96 ui_controls::LEFT, | |
97 ui_controls::DOWN | ui_controls::UP, | |
98 new MessageLoop::QuitTask()); | |
99 ui_test_utils::RunMessageLoop(); | |
100 } | 67 } |
101 | 68 |
102 static void HideNativeWindow(gfx::NativeWindow window) { | 69 static void HideNativeWindow(gfx::NativeWindow window) { |
103 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
104 // TODO(jcampan): retrieve the WidgetWin and show/hide on it instead of | 71 // TODO(jcampan): retrieve the WidgetWin and show/hide on it instead of |
105 // using Windows API. | 72 // using Windows API. |
106 ::ShowWindow(window, SW_HIDE); | 73 ::ShowWindow(window, SW_HIDE); |
107 #elif defined(OS_LINUX) | 74 #elif defined(OS_LINUX) |
108 gtk_widget_hide(GTK_WIDGET(window)); | 75 gtk_widget_hide(GTK_WIDGET(window)); |
109 #else | 76 #else |
110 NOTIMPLEMENTED(); | 77 NOTIMPLEMENTED(); |
111 #endif | 78 #endif |
112 } | 79 } |
113 | 80 |
114 static void ShowNativeWindow(gfx::NativeWindow window) { | 81 static void ShowNativeWindow(gfx::NativeWindow window) { |
115 #if defined(OS_WIN) | 82 #if defined(OS_WIN) |
116 // TODO(jcampan): retrieve the WidgetWin and show/hide on it instead of | 83 // TODO(jcampan): retrieve the WidgetWin and show/hide on it instead of |
117 // using Windows API. | 84 // using Windows API. |
118 ::ShowWindow(window, SW_SHOW); | 85 ::ShowWindow(window, SW_SHOW); |
119 #elif defined(OS_LINUX) | 86 #elif defined(OS_LINUX) |
120 gtk_widget_hide(GTK_WIDGET(window)); | 87 gtk_widget_hide(GTK_WIDGET(window)); |
121 #else | 88 #else |
122 NOTIMPLEMENTED(); | 89 NOTIMPLEMENTED(); |
123 #endif | 90 #endif |
124 } | 91 } |
125 | |
126 private: | |
127 #if defined(OS_LINUX) | |
128 // Check if the focused widget for |root| is |target| or a child of |target|. | |
129 static bool WidgetInFocusChain(GtkWidget* root, GtkWidget* target) { | |
130 GtkWidget* iter = root; | |
131 | |
132 while (iter) { | |
133 if (iter == target) | |
134 return true; | |
135 | |
136 if (!GTK_IS_CONTAINER(iter)) | |
137 return false; | |
138 | |
139 iter = GTK_CONTAINER(iter)->focus_child; | |
140 } | |
141 | |
142 return false; | |
143 } | |
144 #endif | |
145 }; | 92 }; |
146 | 93 |
147 class TestInterstitialPage : public InterstitialPage { | 94 class TestInterstitialPage : public InterstitialPage { |
148 public: | 95 public: |
149 TestInterstitialPage(TabContents* tab, bool new_navigation, const GURL& url) | 96 TestInterstitialPage(TabContents* tab, bool new_navigation, const GURL& url) |
150 : InterstitialPage(tab, new_navigation, url), | 97 : InterstitialPage(tab, new_navigation, url), |
151 waiting_for_dom_response_(false), | 98 waiting_for_dom_response_(false), |
152 waiting_for_focus_change_(false) { | 99 waiting_for_focus_change_(false) { |
153 FilePath file_path; | 100 FilePath file_path; |
154 bool r = PathService::Get(chrome::DIR_TEST_DATA, &file_path); | 101 bool r = PathService::Get(chrome::DIR_TEST_DATA, &file_path); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, ClickingMovesFocus) { | 168 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, ClickingMovesFocus) { |
222 #if defined(OS_LINUX) | 169 #if defined(OS_LINUX) |
223 // It seems we have to wait a little bit for the widgets to spin up before | 170 // It seems we have to wait a little bit for the widgets to spin up before |
224 // we can start clicking on them. | 171 // we can start clicking on them. |
225 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 172 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
226 new MessageLoop::QuitTask(), | 173 new MessageLoop::QuitTask(), |
227 kActionDelayMs); | 174 kActionDelayMs); |
228 ui_test_utils::RunMessageLoop(); | 175 ui_test_utils::RunMessageLoop(); |
229 #endif | 176 #endif |
230 | 177 |
231 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 178 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
232 | 179 |
233 ClickOnView(VIEW_ID_TAB_CONTAINER); | 180 ClickOnView(VIEW_ID_TAB_CONTAINER); |
234 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 181 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
235 | 182 |
236 ClickOnView(VIEW_ID_LOCATION_BAR); | 183 ClickOnView(VIEW_ID_LOCATION_BAR); |
237 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 184 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
238 } | 185 } |
239 | 186 |
240 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BrowsersRememberFocus) { | 187 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BrowsersRememberFocus) { |
241 HTTPTestServer* server = StartHTTPServer(); | 188 HTTPTestServer* server = StartHTTPServer(); |
242 | 189 |
243 // First we navigate to our test page. | 190 // First we navigate to our test page. |
244 GURL url = server->TestServerPageW(kSimplePage); | 191 GURL url = server->TestServerPageW(kSimplePage); |
245 ui_test_utils::NavigateToURL(browser(), url); | 192 ui_test_utils::NavigateToURL(browser(), url); |
246 | 193 |
247 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); | 194 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); |
248 | 195 |
249 // The focus should be on the Tab contents. | 196 // The focus should be on the Tab contents. |
250 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 197 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
251 // Now hide the window, show it again, the focus should not have changed. | 198 // Now hide the window, show it again, the focus should not have changed. |
252 HideNativeWindow(window); | 199 HideNativeWindow(window); |
253 ShowNativeWindow(window); | 200 ShowNativeWindow(window); |
254 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 201 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
255 | 202 |
256 browser()->FocusLocationBar(); | 203 browser()->FocusLocationBar(); |
257 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 204 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
258 // Hide the window, show it again, the focus should not have changed. | 205 // Hide the window, show it again, the focus should not have changed. |
259 HideNativeWindow(window); | 206 HideNativeWindow(window); |
260 ShowNativeWindow(window); | 207 ShowNativeWindow(window); |
261 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 208 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
262 | 209 |
263 // The rest of this test does not make sense on Linux because the behavior | 210 // The rest of this test does not make sense on Linux because the behavior |
264 // of Activate() is not well defined and can vary by window manager. | 211 // of Activate() is not well defined and can vary by window manager. |
265 #if defined(OS_WIN) | 212 #if defined(OS_WIN) |
266 // Open a new browser window. | 213 // Open a new browser window. |
267 Browser* browser2 = Browser::Create(browser()->profile()); | 214 Browser* browser2 = Browser::Create(browser()->profile()); |
268 ASSERT_TRUE(browser2); | 215 ASSERT_TRUE(browser2); |
269 browser2->tabstrip_model()->delegate()->AddBlankTab(true); | 216 browser2->tabstrip_model()->delegate()->AddBlankTab(true); |
270 browser2->window()->Show(); | 217 browser2->window()->Show(); |
271 ui_test_utils::NavigateToURL(browser2, url); | 218 ui_test_utils::NavigateToURL(browser2, url); |
272 | 219 |
273 HWND hwnd2 = reinterpret_cast<HWND>(browser2->window()->GetNativeHandle()); | 220 HWND hwnd2 = reinterpret_cast<HWND>(browser2->window()->GetNativeHandle()); |
274 BrowserView* browser_view2 = | 221 BrowserView* browser_view2 = |
275 BrowserView::GetBrowserViewForNativeWindow(hwnd2); | 222 BrowserView::GetBrowserViewForNativeWindow(hwnd2); |
276 ASSERT_TRUE(browser_view2); | 223 ASSERT_TRUE(browser_view2); |
277 views::FocusManager* focus_manager2 = | 224 views::FocusManager* focus_manager2 = |
278 views::FocusManager::GetFocusManagerForNativeView(hwnd2); | 225 views::FocusManager::GetFocusManagerForNativeView(hwnd2); |
279 ASSERT_TRUE(focus_manager2); | 226 ASSERT_TRUE(focus_manager2); |
280 EXPECT_EQ(browser_view2->GetTabContentsContainerView(), | 227 EXPECT_EQ(browser_view2->GetTabContentsContainerView(), |
281 focus_manager2->GetFocusedView()); | 228 focus_manager2->GetFocusedView()); |
282 | 229 |
283 // Switch to the 1st browser window, focus should still be on the location | 230 // Switch to the 1st browser window, focus should still be on the location |
284 // bar and the second browser should have nothing focused. | 231 // bar and the second browser should have nothing focused. |
285 browser()->window()->Activate(); | 232 browser()->window()->Activate(); |
286 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 233 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
287 EXPECT_EQ(NULL, focus_manager2->GetFocusedView()); | 234 EXPECT_EQ(NULL, focus_manager2->GetFocusedView()); |
288 | 235 |
289 // Switch back to the second browser, focus should still be on the page. | 236 // Switch back to the second browser, focus should still be on the page. |
290 browser2->window()->Activate(); | 237 browser2->window()->Activate(); |
291 EXPECT_EQ(NULL, | 238 EXPECT_EQ(NULL, |
292 views::FocusManager::GetFocusManagerForNativeView( | 239 views::FocusManager::GetFocusManagerForNativeView( |
293 browser()->window()->GetNativeHandle())->GetFocusedView()); | 240 browser()->window()->GetNativeHandle())->GetFocusedView()); |
294 EXPECT_EQ(browser_view2->GetTabContentsContainerView(), | 241 EXPECT_EQ(browser_view2->GetTabContentsContainerView(), |
295 focus_manager2->GetFocusedView()); | 242 focus_manager2->GetFocusedView()); |
296 | 243 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 } | 280 } |
334 } | 281 } |
335 | 282 |
336 // Now come back to the tab and check the right view is focused. | 283 // Now come back to the tab and check the right view is focused. |
337 for (int j = 0; j < 5; j++) { | 284 for (int j = 0; j < 5; j++) { |
338 // Activate the tab. | 285 // Activate the tab. |
339 browser()->SelectTabContentsAt(j, true); | 286 browser()->SelectTabContentsAt(j, true); |
340 | 287 |
341 ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW : | 288 ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW : |
342 VIEW_ID_LOCATION_BAR; | 289 VIEW_ID_LOCATION_BAR; |
343 CheckViewHasFocus(vid); | 290 ASSERT_TRUE(IsViewFocused(vid)); |
344 } | 291 } |
345 } | 292 } |
346 } | 293 } |
347 | 294 |
348 // Tabs remember focus with find-in-page box. | 295 // Tabs remember focus with find-in-page box. |
349 // TODO(jcampan): http://crbug.com/23683 Disabled because it fails on Linux. | 296 // TODO(jcampan): http://crbug.com/23683 Disabled because it fails on Linux. |
350 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocusFindInPage) { | 297 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocusFindInPage) { |
351 HTTPTestServer* server = StartHTTPServer(); | 298 HTTPTestServer* server = StartHTTPServer(); |
352 | 299 |
353 // First we navigate to our test page. | 300 // First we navigate to our test page. |
354 GURL url = server->TestServerPageW(kSimplePage); | 301 GURL url = server->TestServerPageW(kSimplePage); |
355 ui_test_utils::NavigateToURL(browser(), url); | 302 ui_test_utils::NavigateToURL(browser(), url); |
356 | 303 |
357 browser()->Find(); | 304 browser()->Find(); |
358 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), | 305 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), |
359 ASCIIToUTF16("a"), true, false, NULL); | 306 ASCIIToUTF16("a"), true, false, NULL); |
360 CheckViewHasFocus(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 307 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
361 | 308 |
362 // Focus the location bar. | 309 // Focus the location bar. |
363 browser()->FocusLocationBar(); | 310 browser()->FocusLocationBar(); |
364 | 311 |
365 // Create a 2nd tab. | 312 // Create a 2nd tab. |
366 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, -1, | 313 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, -1, |
367 false, NULL); | 314 false, NULL); |
368 | 315 |
369 // Focus should be on the recently opened tab page. | 316 // Focus should be on the recently opened tab page. |
370 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 317 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
371 | 318 |
372 // Select 1st tab, focus should still be on the location-bar. | 319 // Select 1st tab, focus should still be on the location-bar. |
373 // (bug http://crbug.com/23296) | 320 // (bug http://crbug.com/23296) |
374 browser()->SelectTabContentsAt(0, true); | 321 browser()->SelectTabContentsAt(0, true); |
375 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 322 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
376 | 323 |
377 // Now open the find box again, switch to another tab and come back, the focus | 324 // Now open the find box again, switch to another tab and come back, the focus |
378 // should return to the find box. | 325 // should return to the find box. |
379 browser()->Find(); | 326 browser()->Find(); |
380 CheckViewHasFocus(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 327 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
381 browser()->SelectTabContentsAt(1, true); | 328 browser()->SelectTabContentsAt(1, true); |
382 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 329 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
383 browser()->SelectTabContentsAt(0, true); | 330 browser()->SelectTabContentsAt(0, true); |
384 CheckViewHasFocus(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 331 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
385 } | 332 } |
386 | 333 |
387 // Background window does not steal focus. | 334 // Background window does not steal focus. |
388 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) { | 335 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) { |
389 HTTPTestServer* server = StartHTTPServer(); | 336 HTTPTestServer* server = StartHTTPServer(); |
390 | 337 |
391 // First we navigate to our test page. | 338 // First we navigate to our test page. |
392 GURL url = server->TestServerPageW(kSimplePage); | 339 GURL url = server->TestServerPageW(kSimplePage); |
393 ui_test_utils::NavigateToURL(browser(), url); | 340 ui_test_utils::NavigateToURL(browser(), url); |
394 | 341 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 // Open the page that steals focus. | 387 // Open the page that steals focus. |
441 GURL url = server->TestServerPageW(kStealFocusPage); | 388 GURL url = server->TestServerPageW(kStealFocusPage); |
442 ui_test_utils::NavigateToURL(browser(), url); | 389 ui_test_utils::NavigateToURL(browser(), url); |
443 | 390 |
444 browser()->FocusLocationBar(); | 391 browser()->FocusLocationBar(); |
445 | 392 |
446 // Wait for the page to steal focus. | 393 // Wait for the page to steal focus. |
447 PlatformThread::Sleep(2000); | 394 PlatformThread::Sleep(2000); |
448 | 395 |
449 // Make sure the location bar is still focused. | 396 // Make sure the location bar is still focused. |
450 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 397 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
451 } | 398 } |
452 | 399 |
453 // Focus traversal on a regular page. | 400 // Focus traversal on a regular page. |
454 // Note that this test relies on a notification from the renderer that the | 401 // Note that this test relies on a notification from the renderer that the |
455 // focus has changed in the page. The notification in the renderer may change | 402 // focus has changed in the page. The notification in the renderer may change |
456 // at which point this test would fail (see comment in | 403 // at which point this test would fail (see comment in |
457 // RenderWidget::didFocus()). | 404 // RenderWidget::didFocus()). |
458 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) { | 405 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) { |
459 HTTPTestServer* server = StartHTTPServer(); | 406 HTTPTestServer* server = StartHTTPServer(); |
460 | 407 |
461 // First we navigate to our test page. | 408 // First we navigate to our test page. |
462 GURL url = server->TestServerPageW(kTypicalPage); | 409 GURL url = server->TestServerPageW(kTypicalPage); |
463 ui_test_utils::NavigateToURL(browser(), url); | 410 ui_test_utils::NavigateToURL(browser(), url); |
464 | 411 |
465 browser()->FocusLocationBar(); | 412 browser()->FocusLocationBar(); |
466 | 413 |
467 const char* kExpElementIDs[] = { | 414 const char* kExpElementIDs[] = { |
468 "", // Initially no element in the page should be focused | 415 "", // Initially no element in the page should be focused |
469 // (the location bar is focused). | 416 // (the location bar is focused). |
470 "textEdit", "searchButton", "luckyButton", "googleLink", "gmailLink", | 417 "textEdit", "searchButton", "luckyButton", "googleLink", "gmailLink", |
471 "gmapLink" | 418 "gmapLink" |
472 }; | 419 }; |
473 | 420 |
474 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); | 421 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); |
475 | 422 |
476 // Test forward focus traversal. | 423 // Test forward focus traversal. |
477 for (int i = 0; i < 3; ++i) { | 424 for (int i = 0; i < 3; ++i) { |
478 // Location bar should be focused. | 425 // Location bar should be focused. |
479 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 426 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
480 | 427 |
481 // Now let's press tab to move the focus. | 428 // Now let's press tab to move the focus. |
482 for (size_t j = 0; j < arraysize(kExpElementIDs); ++j) { | 429 for (size_t j = 0; j < arraysize(kExpElementIDs); ++j) { |
483 // Let's make sure the focus is on the expected element in the page. | 430 // Let's make sure the focus is on the expected element in the page. |
484 std::string actual; | 431 std::string actual; |
485 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 432 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
486 browser()->GetSelectedTabContents()->render_view_host(), | 433 browser()->GetSelectedTabContents()->render_view_host(), |
487 L"", | 434 L"", |
488 L"window.domAutomationController.send(getFocusedElement());", | 435 L"window.domAutomationController.send(getFocusedElement());", |
489 &actual)); | 436 &actual)); |
(...skipping 13 matching lines...) Expand all Loading... |
503 | 450 |
504 // At this point the renderer has sent us a message asking to advance the | 451 // At this point the renderer has sent us a message asking to advance the |
505 // focus (as the end of the focus loop was reached in the renderer). | 452 // focus (as the end of the focus loop was reached in the renderer). |
506 // We need to run the message loop to process it. | 453 // We need to run the message loop to process it. |
507 MessageLoop::current()->RunAllPending(); | 454 MessageLoop::current()->RunAllPending(); |
508 } | 455 } |
509 | 456 |
510 // Now let's try reverse focus traversal. | 457 // Now let's try reverse focus traversal. |
511 for (int i = 0; i < 3; ++i) { | 458 for (int i = 0; i < 3; ++i) { |
512 // Location bar should be focused. | 459 // Location bar should be focused. |
513 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 460 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
514 | 461 |
515 // Now let's press shift-tab to move the focus in reverse. | 462 // Now let's press shift-tab to move the focus in reverse. |
516 for (size_t j = 0; j < 7; ++j) { | 463 for (size_t j = 0; j < 7; ++j) { |
517 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, | 464 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, |
518 false, true, false)); | 465 false, true, false)); |
519 | 466 |
520 if (j < arraysize(kExpElementIDs) - 1) { | 467 if (j < arraysize(kExpElementIDs) - 1) { |
521 ui_test_utils::WaitForFocusChange(browser()->GetSelectedTabContents()-> | 468 ui_test_utils::WaitForFocusChange(browser()->GetSelectedTabContents()-> |
522 render_view_host()); | 469 render_view_host()); |
523 } else { | 470 } else { |
(...skipping 20 matching lines...) Expand all Loading... |
544 | 491 |
545 // Focus traversal while an interstitial is showing. | 492 // Focus traversal while an interstitial is showing. |
546 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { | 493 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { |
547 HTTPTestServer* server = StartHTTPServer(); | 494 HTTPTestServer* server = StartHTTPServer(); |
548 | 495 |
549 // First we navigate to our test page. | 496 // First we navigate to our test page. |
550 GURL url = server->TestServerPageW(kSimplePage); | 497 GURL url = server->TestServerPageW(kSimplePage); |
551 ui_test_utils::NavigateToURL(browser(), url); | 498 ui_test_utils::NavigateToURL(browser(), url); |
552 | 499 |
553 // Focus should be on the page. | 500 // Focus should be on the page. |
554 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 501 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
555 | 502 |
556 // Let's show an interstitial. | 503 // Let's show an interstitial. |
557 TestInterstitialPage* interstitial_page = | 504 TestInterstitialPage* interstitial_page = |
558 new TestInterstitialPage(browser()->GetSelectedTabContents(), | 505 new TestInterstitialPage(browser()->GetSelectedTabContents(), |
559 true, GURL("http://interstitial.com")); | 506 true, GURL("http://interstitial.com")); |
560 interstitial_page->Show(); | 507 interstitial_page->Show(); |
561 // Give some time for the interstitial to show. | 508 // Give some time for the interstitial to show. |
562 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 509 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
563 new MessageLoop::QuitTask(), | 510 new MessageLoop::QuitTask(), |
564 1000); | 511 1000); |
565 ui_test_utils::RunMessageLoop(); | 512 ui_test_utils::RunMessageLoop(); |
566 | 513 |
567 browser()->FocusLocationBar(); | 514 browser()->FocusLocationBar(); |
568 | 515 |
569 const char* kExpElementIDs[] = { | 516 const char* kExpElementIDs[] = { |
570 "", // Initially no element in the page should be focused | 517 "", // Initially no element in the page should be focused |
571 // (the location bar is focused). | 518 // (the location bar is focused). |
572 "textEdit", "searchButton", "luckyButton", "googleLink", "gmailLink", | 519 "textEdit", "searchButton", "luckyButton", "googleLink", "gmailLink", |
573 "gmapLink" | 520 "gmapLink" |
574 }; | 521 }; |
575 | 522 |
576 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); | 523 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); |
577 | 524 |
578 // Test forward focus traversal. | 525 // Test forward focus traversal. |
579 for (int i = 0; i < 2; ++i) { | 526 for (int i = 0; i < 2; ++i) { |
580 // Location bar should be focused. | 527 // Location bar should be focused. |
581 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 528 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
582 | 529 |
583 // Now let's press tab to move the focus. | 530 // Now let's press tab to move the focus. |
584 for (size_t j = 0; j < 7; ++j) { | 531 for (size_t j = 0; j < 7; ++j) { |
585 // Let's make sure the focus is on the expected element in the page. | 532 // Let's make sure the focus is on the expected element in the page. |
586 std::string actual = interstitial_page->GetFocusedElement(); | 533 std::string actual = interstitial_page->GetFocusedElement(); |
587 ASSERT_STREQ(kExpElementIDs[j], actual.c_str()); | 534 ASSERT_STREQ(kExpElementIDs[j], actual.c_str()); |
588 | 535 |
589 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, | 536 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, |
590 false, false, false)); | 537 false, false, false)); |
591 | 538 |
592 if (j < arraysize(kExpElementIDs) - 1) { | 539 if (j < arraysize(kExpElementIDs) - 1) { |
593 interstitial_page->WaitForFocusChange(); | 540 interstitial_page->WaitForFocusChange(); |
594 } else { | 541 } else { |
595 // On the last tab key press, the focus returns to the browser. | 542 // On the last tab key press, the focus returns to the browser. |
596 ui_test_utils::WaitForFocusInBrowser(browser()); | 543 ui_test_utils::WaitForFocusInBrowser(browser()); |
597 } | 544 } |
598 } | 545 } |
599 | 546 |
600 // At this point the renderer has sent us a message asking to advance the | 547 // At this point the renderer has sent us a message asking to advance the |
601 // focus (as the end of the focus loop was reached in the renderer). | 548 // focus (as the end of the focus loop was reached in the renderer). |
602 // We need to run the message loop to process it. | 549 // We need to run the message loop to process it. |
603 MessageLoop::current()->RunAllPending(); | 550 MessageLoop::current()->RunAllPending(); |
604 } | 551 } |
605 | 552 |
606 // Now let's try reverse focus traversal. | 553 // Now let's try reverse focus traversal. |
607 for (int i = 0; i < 2; ++i) { | 554 for (int i = 0; i < 2; ++i) { |
608 // Location bar should be focused. | 555 // Location bar should be focused. |
609 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 556 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
610 | 557 |
611 // Now let's press shift-tab to move the focus in reverse. | 558 // Now let's press shift-tab to move the focus in reverse. |
612 for (size_t j = 0; j < 7; ++j) { | 559 for (size_t j = 0; j < 7; ++j) { |
613 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, | 560 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, |
614 false, true, false)); | 561 false, true, false)); |
615 | 562 |
616 if (j < arraysize(kExpElementIDs) - 1) { | 563 if (j < arraysize(kExpElementIDs) - 1) { |
617 interstitial_page->WaitForFocusChange(); | 564 interstitial_page->WaitForFocusChange(); |
618 } else { | 565 } else { |
619 // On the last tab key press, the focus returns to the browser. | 566 // On the last tab key press, the focus returns to the browser. |
(...skipping 14 matching lines...) Expand all Loading... |
634 | 581 |
635 // Focus stays on page with interstitials. | 582 // Focus stays on page with interstitials. |
636 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) { | 583 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) { |
637 HTTPTestServer* server = StartHTTPServer(); | 584 HTTPTestServer* server = StartHTTPServer(); |
638 | 585 |
639 // First we navigate to our test page. | 586 // First we navigate to our test page. |
640 GURL url = server->TestServerPageW(kSimplePage); | 587 GURL url = server->TestServerPageW(kSimplePage); |
641 ui_test_utils::NavigateToURL(browser(), url); | 588 ui_test_utils::NavigateToURL(browser(), url); |
642 | 589 |
643 // Page should have focus. | 590 // Page should have focus. |
644 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 591 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
645 EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()-> | 592 EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()-> |
646 HasFocus()); | 593 HasFocus()); |
647 | 594 |
648 // Let's show an interstitial. | 595 // Let's show an interstitial. |
649 TestInterstitialPage* interstitial_page = | 596 TestInterstitialPage* interstitial_page = |
650 new TestInterstitialPage(browser()->GetSelectedTabContents(), | 597 new TestInterstitialPage(browser()->GetSelectedTabContents(), |
651 true, GURL("http://interstitial.com")); | 598 true, GURL("http://interstitial.com")); |
652 interstitial_page->Show(); | 599 interstitial_page->Show(); |
653 // Give some time for the interstitial to show. | 600 // Give some time for the interstitial to show. |
654 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 601 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
655 new MessageLoop::QuitTask(), | 602 new MessageLoop::QuitTask(), |
656 1000); | 603 1000); |
657 ui_test_utils::RunMessageLoop(); | 604 ui_test_utils::RunMessageLoop(); |
658 | 605 |
659 // The interstitial should have focus now. | 606 // The interstitial should have focus now. |
660 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 607 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
661 EXPECT_TRUE(interstitial_page->HasFocus()); | 608 EXPECT_TRUE(interstitial_page->HasFocus()); |
662 | 609 |
663 // Hide the interstitial. | 610 // Hide the interstitial. |
664 interstitial_page->DontProceed(); | 611 interstitial_page->DontProceed(); |
665 | 612 |
666 // Focus should be back on the original page. | 613 // Focus should be back on the original page. |
667 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 614 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
668 } | 615 } |
669 | 616 |
670 // Make sure Find box can request focus, even when it is already open. | 617 // Make sure Find box can request focus, even when it is already open. |
671 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { | 618 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { |
672 HTTPTestServer* server = StartHTTPServer(); | 619 HTTPTestServer* server = StartHTTPServer(); |
673 | 620 |
674 // Open some page (any page that doesn't steal focus). | 621 // Open some page (any page that doesn't steal focus). |
675 GURL url = server->TestServerPageW(kTypicalPage); | 622 GURL url = server->TestServerPageW(kTypicalPage); |
676 ui_test_utils::NavigateToURL(browser(), url); | 623 ui_test_utils::NavigateToURL(browser(), url); |
677 | 624 |
678 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); | 625 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); |
679 | 626 |
680 // Press Ctrl+F, which will make the Find box open and request focus. | 627 // Press Ctrl+F, which will make the Find box open and request focus. |
681 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, | 628 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, |
682 false, false, | 629 false, false, |
683 new MessageLoop::QuitTask()); | 630 new MessageLoop::QuitTask()); |
684 ui_test_utils::RunMessageLoop(); | 631 ui_test_utils::RunMessageLoop(); |
685 | 632 |
686 // Ideally, we wouldn't sleep here and instead would intercept the | 633 // Ideally, we wouldn't sleep here and instead would intercept the |
687 // RenderViewHostDelegate::HandleKeyboardEvent() callback. To do that, we | 634 // RenderViewHostDelegate::HandleKeyboardEvent() callback. To do that, we |
688 // could create a RenderViewHostDelegate wrapper and hook-it up by either: | 635 // could create a RenderViewHostDelegate wrapper and hook-it up by either: |
689 // - creating a factory used to create the delegate | 636 // - creating a factory used to create the delegate |
690 // - making the test a private and overwriting the delegate member directly. | 637 // - making the test a private and overwriting the delegate member directly. |
691 MessageLoop::current()->PostDelayedTask( | 638 MessageLoop::current()->PostDelayedTask( |
692 FROM_HERE, new MessageLoop::QuitTask(), kActionDelayMs); | 639 FROM_HERE, new MessageLoop::QuitTask(), kActionDelayMs); |
693 ui_test_utils::RunMessageLoop(); | 640 ui_test_utils::RunMessageLoop(); |
694 | 641 |
695 CheckViewHasFocus(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 642 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
696 | 643 |
697 browser()->FocusLocationBar(); | 644 browser()->FocusLocationBar(); |
698 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 645 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
699 | 646 |
700 // Now press Ctrl+F again and focus should move to the Find box. | 647 // Now press Ctrl+F again and focus should move to the Find box. |
701 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, | 648 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, |
702 false, false, | 649 false, false, |
703 new MessageLoop::QuitTask()); | 650 new MessageLoop::QuitTask()); |
704 ui_test_utils::RunMessageLoop(); | 651 ui_test_utils::RunMessageLoop(); |
705 CheckViewHasFocus(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 652 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
706 | 653 |
707 // Set focus to the page. | 654 // Set focus to the page. |
708 ClickOnView(VIEW_ID_TAB_CONTAINER); | 655 ClickOnView(VIEW_ID_TAB_CONTAINER); |
709 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 656 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
710 | 657 |
711 // Now press Ctrl+F again and focus should move to the Find box. | 658 // Now press Ctrl+F again and focus should move to the Find box. |
712 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, false, | 659 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, false, |
713 false, new MessageLoop::QuitTask()); | 660 false, new MessageLoop::QuitTask()); |
714 ui_test_utils::RunMessageLoop(); | 661 ui_test_utils::RunMessageLoop(); |
715 | 662 |
716 // See remark above on why we wait. | 663 // See remark above on why we wait. |
717 MessageLoop::current()->PostDelayedTask( | 664 MessageLoop::current()->PostDelayedTask( |
718 FROM_HERE, new MessageLoop::QuitTask(), kActionDelayMs); | 665 FROM_HERE, new MessageLoop::QuitTask(), kActionDelayMs); |
719 ui_test_utils::RunMessageLoop(); | 666 ui_test_utils::RunMessageLoop(); |
720 CheckViewHasFocus(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 667 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
721 } | 668 } |
722 | 669 |
723 // Makes sure the focus is in the right location when opening the different | 670 // Makes sure the focus is in the right location when opening the different |
724 // types of tabs. | 671 // types of tabs. |
725 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) { | 672 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) { |
726 // Open the history tab, focus should be on the tab contents. | 673 // Open the history tab, focus should be on the tab contents. |
727 browser()->ShowHistoryTab(); | 674 browser()->ShowHistoryTab(); |
728 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 675 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
729 | 676 |
730 // Open the new tab, focus should be on the location bar. | 677 // Open the new tab, focus should be on the location bar. |
731 browser()->NewTab(); | 678 browser()->NewTab(); |
732 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 679 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
733 | 680 |
734 // Open the download tab, focus should be on the tab contents. | 681 // Open the download tab, focus should be on the tab contents. |
735 browser()->ShowDownloadsTab(); | 682 browser()->ShowDownloadsTab(); |
736 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 683 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
737 | 684 |
738 // Open about:blank, focus should be on the location bar. | 685 // Open about:blank, focus should be on the location bar. |
739 browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK, | 686 browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK, |
740 true, -1, false, NULL); | 687 true, -1, false, NULL); |
741 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 688 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
742 } | 689 } |
743 | 690 |
744 // Tests that focus goes where expected when using reload. | 691 // Tests that focus goes where expected when using reload. |
745 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { | 692 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { |
746 HTTPTestServer* server = StartHTTPServer(); | 693 HTTPTestServer* server = StartHTTPServer(); |
747 | 694 |
748 // Open the new tab, reload. | 695 // Open the new tab, reload. |
749 browser()->NewTab(); | 696 browser()->NewTab(); |
750 browser()->Reload(); | 697 browser()->Reload(); |
751 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 698 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
752 // Focus should stay on the location bar. | 699 // Focus should stay on the location bar. |
753 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 700 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
754 | 701 |
755 // Open a regular page, focus the location bar, reload. | 702 // Open a regular page, focus the location bar, reload. |
756 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage)); | 703 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage)); |
757 browser()->FocusLocationBar(); | 704 browser()->FocusLocationBar(); |
758 CheckViewHasFocus(VIEW_ID_LOCATION_BAR); | 705 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
759 browser()->Reload(); | 706 browser()->Reload(); |
760 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 707 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
761 // Focus should now be on the tab contents. | 708 // Focus should now be on the tab contents. |
762 browser()->ShowDownloadsTab(); | 709 browser()->ShowDownloadsTab(); |
763 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 710 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
764 } | 711 } |
765 | 712 |
766 // Tests that focus goes where expected when using reload on a crashed tab. | 713 // Tests that focus goes where expected when using reload on a crashed tab. |
767 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReloadCrashedTab) { | 714 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReloadCrashedTab) { |
768 HTTPTestServer* server = StartHTTPServer(); | 715 HTTPTestServer* server = StartHTTPServer(); |
769 | 716 |
770 // Open a regular page, crash, reload. | 717 // Open a regular page, crash, reload. |
771 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage)); | 718 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage)); |
772 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); | 719 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); |
773 browser()->Reload(); | 720 browser()->Reload(); |
774 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 721 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
775 // Focus should now be on the tab contents. | 722 // Focus should now be on the tab contents. |
776 browser()->ShowDownloadsTab(); | 723 browser()->ShowDownloadsTab(); |
777 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 724 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
778 } | 725 } |
OLD | NEW |