blob: 05b452059204452e847d8d017f497246838f6ee3 [file] [log] [blame]
[email protected]b54649012009-04-17 17:00:121// Copyright (c) 2009 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]d9fde8d2009-10-08 19:59:305#include "build/build_config.h"
6
[email protected]8bcdec92009-02-25 16:15:187#include "base/message_loop.h"
[email protected]ece3c8b2009-03-27 16:55:398#include "base/ref_counted.h"
[email protected]8bcdec92009-02-25 16:15:189#include "chrome/browser/automation/ui_controls.h"
10#include "chrome/browser/browser.h"
[email protected]134c47b92009-08-19 03:33:4411#include "chrome/browser/browser_window.h"
12#include "chrome/browser/renderer_host/render_view_host.h"
[email protected]9e0c83a2009-05-06 19:44:3713#include "chrome/browser/renderer_host/render_widget_host_view.h"
14#include "chrome/browser/tab_contents/interstitial_page.h"
[email protected]186f13f2009-08-19 20:34:0015#include "chrome/browser/tab_contents/tab_contents.h"
16#include "chrome/browser/tab_contents/tab_contents_view.h"
initial.commit09911bf2008-07-26 23:55:2917#include "chrome/browser/view_ids.h"
[email protected]9e0c83a2009-05-06 19:44:3718#include "chrome/common/chrome_paths.h"
[email protected]8bcdec92009-02-25 16:15:1819#include "chrome/test/in_process_browser_test.h"
20#include "chrome/test/ui_test_utils.h"
[email protected]2362e4f2009-05-08 00:34:0521#include "views/focus/focus_manager.h"
22#include "views/view.h"
23#include "views/window/window.h"
initial.commit09911bf2008-07-26 23:55:2924
[email protected]134c47b92009-08-19 03:33:4425#if defined(TOOLKIT_VIEWS)
26#include "chrome/browser/views/frame/browser_view.h"
27#include "chrome/browser/views/location_bar_view.h"
28#include "chrome/browser/views/tab_contents/tab_contents_container.h"
29#endif
30
[email protected]b9821882009-08-17 22:25:1731#if defined(OS_LINUX)
32#include "chrome/browser/gtk/view_id_util.h"
33#endif
34
[email protected]fc2e0872009-08-21 22:14:4135#if defined(OS_LINUX)
36// For some reason we hit an external DNS lookup in this test in Linux but not
37// on Windows. TODO(estade): investigate.
38#define MAYBE_FocusTraversalOnInterstitial DISABLED_FocusTraversalOnInterstitial
[email protected]cb7e2542009-12-14 22:02:3539// TODO(jcampan): http://crbug.com/23683
40#define MAYBE_TabsRememberFocusFindInPage DISABLED_TabsRememberFocusFindInPage
[email protected]fc2e0872009-08-21 22:14:4141#else
[email protected]e4f4e0b2009-10-13 19:58:2142#define MAYBE_FocusTraversalOnInterstitial FocusTraversalOnInterstitial
[email protected]cb7e2542009-12-14 22:02:3543#define MAYBE_TabsRememberFocusFindInPage TabsRememberFocusFindInPage
[email protected]fc2e0872009-08-21 22:14:4144#endif
45
initial.commit09911bf2008-07-26 23:55:2946namespace {
47
[email protected]8bcdec92009-02-25 16:15:1848// The delay waited in some cases where we don't have a notifications for an
49// action we take.
initial.commit09911bf2008-07-26 23:55:2950const int kActionDelayMs = 500;
51
initial.commit09911bf2008-07-26 23:55:2952const wchar_t kSimplePage[] = L"files/focus/page_with_focus.html";
53const wchar_t kStealFocusPage[] = L"files/focus/page_steals_focus.html";
54const wchar_t kTypicalPage[] = L"files/focus/typical_page.html";
[email protected]b65de8b92009-09-14 19:36:3155const char kTypicalPageName[] = "typical_page.html";
initial.commit09911bf2008-07-26 23:55:2956
[email protected]8bcdec92009-02-25 16:15:1857class BrowserFocusTest : public InProcessBrowserTest {
initial.commit09911bf2008-07-26 23:55:2958 public:
59 BrowserFocusTest() {
[email protected]8bcdec92009-02-25 16:15:1860 set_show_window(true);
61 EnableDOMAutomation();
initial.commit09911bf2008-07-26 23:55:2962 }
[email protected]b9821882009-08-17 22:25:1763
[email protected]21abcc742009-10-23 02:52:0664 bool IsViewFocused(ViewID vid) {
65 return ui_test_utils::IsViewFocused(browser(), vid);
[email protected]b9821882009-08-17 22:25:1766 }
67
[email protected]fc2e0872009-08-21 22:14:4168 void ClickOnView(ViewID vid) {
[email protected]21abcc742009-10-23 02:52:0669 ui_test_utils::ClickOnView(browser(), vid);
[email protected]fc2e0872009-08-21 22:14:4170 }
71
[email protected]186f13f2009-08-19 20:34:0072 static void HideNativeWindow(gfx::NativeWindow window) {
73#if defined(OS_WIN)
74 // TODO(jcampan): retrieve the WidgetWin and show/hide on it instead of
75 // using Windows API.
76 ::ShowWindow(window, SW_HIDE);
77#elif defined(OS_LINUX)
78 gtk_widget_hide(GTK_WIDGET(window));
79#else
80 NOTIMPLEMENTED();
81#endif
82 }
83
84 static void ShowNativeWindow(gfx::NativeWindow window) {
85#if defined(OS_WIN)
86 // TODO(jcampan): retrieve the WidgetWin and show/hide on it instead of
87 // using Windows API.
88 ::ShowWindow(window, SW_SHOW);
89#elif defined(OS_LINUX)
90 gtk_widget_hide(GTK_WIDGET(window));
91#else
92 NOTIMPLEMENTED();
93#endif
94 }
initial.commit09911bf2008-07-26 23:55:2995};
96
[email protected]9e0c83a2009-05-06 19:44:3797class TestInterstitialPage : public InterstitialPage {
98 public:
99 TestInterstitialPage(TabContents* tab, bool new_navigation, const GURL& url)
100 : InterstitialPage(tab, new_navigation, url),
[email protected]130efb02009-09-18 18:54:35101 waiting_for_dom_response_(false),
102 waiting_for_focus_change_(false) {
[email protected]b65de8b92009-09-14 19:36:31103 FilePath file_path;
[email protected]9e0c83a2009-05-06 19:44:37104 bool r = PathService::Get(chrome::DIR_TEST_DATA, &file_path);
105 EXPECT_TRUE(r);
[email protected]b65de8b92009-09-14 19:36:31106 file_path = file_path.AppendASCII("focus");
107 file_path = file_path.AppendASCII(kTypicalPageName);
[email protected]9e0c83a2009-05-06 19:44:37108 r = file_util::ReadFileToString(file_path, &html_contents_);
109 EXPECT_TRUE(r);
110 }
111
112 virtual std::string GetHTMLContents() {
113 return html_contents_;
114 }
115
116 virtual void DomOperationResponse(const std::string& json_string,
117 int automation_id) {
118 if (waiting_for_dom_response_) {
119 dom_response_ = json_string;
120 waiting_for_dom_response_ = false;
121 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
122 return;
123 }
124 InterstitialPage::DomOperationResponse(json_string, automation_id);
125 }
126
127 std::string GetFocusedElement() {
128 std::wstring script = L"window.domAutomationController.setAutomationId(0);"
129 L"window.domAutomationController.send(getFocusedElement());";
130
131 render_view_host()->ExecuteJavascriptInWebFrame(L"", script);
132 DCHECK(!waiting_for_dom_response_);
133 waiting_for_dom_response_ = true;
134 ui_test_utils::RunMessageLoop();
135 // Remove the JSON extra quotes.
136 if (dom_response_.size() >= 2 && dom_response_[0] == '"' &&
137 dom_response_[dom_response_.size() - 1] == '"') {
138 dom_response_ = dom_response_.substr(1, dom_response_.size() - 2);
139 }
140 return dom_response_;
141 }
142
143 bool HasFocus() {
144 return render_view_host()->view()->HasFocus();
145 }
146
[email protected]130efb02009-09-18 18:54:35147 void WaitForFocusChange() {
148 waiting_for_focus_change_ = true;
149 ui_test_utils::RunMessageLoop();
150 }
151
152 protected:
153 virtual void FocusedNodeChanged() {
154 if (!waiting_for_focus_change_)
155 return;
156
157 waiting_for_focus_change_= false;
158 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
159 }
160
[email protected]9e0c83a2009-05-06 19:44:37161 private:
162 std::string html_contents_;
163
164 bool waiting_for_dom_response_;
[email protected]130efb02009-09-18 18:54:35165 bool waiting_for_focus_change_;
[email protected]9e0c83a2009-05-06 19:44:37166 std::string dom_response_;
[email protected]9e0c83a2009-05-06 19:44:37167};
[email protected]b9821882009-08-17 22:25:17168
initial.commit09911bf2008-07-26 23:55:29169} // namespace
170
[email protected]e4f4e0b2009-10-13 19:58:21171IN_PROC_BROWSER_TEST_F(BrowserFocusTest, ClickingMovesFocus) {
[email protected]fc2e0872009-08-21 22:14:41172#if defined(OS_LINUX)
173 // It seems we have to wait a little bit for the widgets to spin up before
174 // we can start clicking on them.
175 MessageLoop::current()->PostDelayedTask(FROM_HERE,
176 new MessageLoop::QuitTask(),
177 kActionDelayMs);
178 ui_test_utils::RunMessageLoop();
179#endif
180
[email protected]21abcc742009-10-23 02:52:06181 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]186f13f2009-08-19 20:34:00182
[email protected]fc2e0872009-08-21 22:14:41183 ClickOnView(VIEW_ID_TAB_CONTAINER);
[email protected]21abcc742009-10-23 02:52:06184 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]186f13f2009-08-19 20:34:00185
[email protected]fc2e0872009-08-21 22:14:41186 ClickOnView(VIEW_ID_LOCATION_BAR);
[email protected]21abcc742009-10-23 02:52:06187 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]186f13f2009-08-19 20:34:00188}
[email protected]186f13f2009-08-19 20:34:00189
[email protected]e4f4e0b2009-10-13 19:58:21190IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BrowsersRememberFocus) {
[email protected]8bcdec92009-02-25 16:15:18191 HTTPTestServer* server = StartHTTPServer();
initial.commit09911bf2008-07-26 23:55:29192
193 // First we navigate to our test page.
[email protected]dd265012009-01-08 20:45:27194 GURL url = server->TestServerPageW(kSimplePage);
[email protected]8bcdec92009-02-25 16:15:18195 ui_test_utils::NavigateToURL(browser(), url);
initial.commit09911bf2008-07-26 23:55:29196
[email protected]186f13f2009-08-19 20:34:00197 gfx::NativeWindow window = browser()->window()->GetNativeHandle();
198
initial.commit09911bf2008-07-26 23:55:29199 // The focus should be on the Tab contents.
[email protected]21abcc742009-10-23 02:52:06200 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
initial.commit09911bf2008-07-26 23:55:29201 // Now hide the window, show it again, the focus should not have changed.
[email protected]186f13f2009-08-19 20:34:00202 HideNativeWindow(window);
203 ShowNativeWindow(window);
[email protected]21abcc742009-10-23 02:52:06204 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
initial.commit09911bf2008-07-26 23:55:29205
[email protected]186f13f2009-08-19 20:34:00206 browser()->FocusLocationBar();
[email protected]21abcc742009-10-23 02:52:06207 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
initial.commit09911bf2008-07-26 23:55:29208 // Hide the window, show it again, the focus should not have changed.
[email protected]186f13f2009-08-19 20:34:00209 HideNativeWindow(window);
210 ShowNativeWindow(window);
[email protected]21abcc742009-10-23 02:52:06211 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
initial.commit09911bf2008-07-26 23:55:29212
[email protected]186f13f2009-08-19 20:34:00213 // The rest of this test does not make sense on Linux because the behavior
214 // of Activate() is not well defined and can vary by window manager.
215#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29216 // Open a new browser window.
[email protected]8bcdec92009-02-25 16:15:18217 Browser* browser2 = Browser::Create(browser()->profile());
218 ASSERT_TRUE(browser2);
[email protected]e0c7c262009-04-23 23:09:43219 browser2->tabstrip_model()->delegate()->AddBlankTab(true);
[email protected]8bcdec92009-02-25 16:15:18220 browser2->window()->Show();
221 ui_test_utils::NavigateToURL(browser2, url);
initial.commit09911bf2008-07-26 23:55:29222
[email protected]8bcdec92009-02-25 16:15:18223 HWND hwnd2 = reinterpret_cast<HWND>(browser2->window()->GetNativeHandle());
[email protected]4a507a62009-05-28 00:10:00224 BrowserView* browser_view2 =
225 BrowserView::GetBrowserViewForNativeWindow(hwnd2);
[email protected]8bcdec92009-02-25 16:15:18226 ASSERT_TRUE(browser_view2);
227 views::FocusManager* focus_manager2 =
[email protected]82166b62009-06-30 18:48:00228 views::FocusManager::GetFocusManagerForNativeView(hwnd2);
[email protected]8bcdec92009-02-25 16:15:18229 ASSERT_TRUE(focus_manager2);
[email protected]7e383692009-06-12 19:14:54230 EXPECT_EQ(browser_view2->GetTabContentsContainerView(),
[email protected]610d36a2009-05-22 23:00:38231 focus_manager2->GetFocusedView());
initial.commit09911bf2008-07-26 23:55:29232
233 // Switch to the 1st browser window, focus should still be on the location
234 // bar and the second browser should have nothing focused.
[email protected]8bcdec92009-02-25 16:15:18235 browser()->window()->Activate();
[email protected]21abcc742009-10-23 02:52:06236 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]8bcdec92009-02-25 16:15:18237 EXPECT_EQ(NULL, focus_manager2->GetFocusedView());
initial.commit09911bf2008-07-26 23:55:29238
239 // Switch back to the second browser, focus should still be on the page.
[email protected]8bcdec92009-02-25 16:15:18240 browser2->window()->Activate();
[email protected]186f13f2009-08-19 20:34:00241 EXPECT_EQ(NULL,
242 views::FocusManager::GetFocusManagerForNativeView(
243 browser()->window()->GetNativeHandle())->GetFocusedView());
[email protected]7e383692009-06-12 19:14:54244 EXPECT_EQ(browser_view2->GetTabContentsContainerView(),
[email protected]610d36a2009-05-22 23:00:38245 focus_manager2->GetFocusedView());
[email protected]8bcdec92009-02-25 16:15:18246
247 // Close the 2nd browser to avoid a DCHECK().
248 browser_view2->Close();
[email protected]186f13f2009-08-19 20:34:00249#endif
initial.commit09911bf2008-07-26 23:55:29250}
251
252// Tabs remember focus.
[email protected]e4f4e0b2009-10-13 19:58:21253IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) {
[email protected]8bcdec92009-02-25 16:15:18254 HTTPTestServer* server = StartHTTPServer();
initial.commit09911bf2008-07-26 23:55:29255
256 // First we navigate to our test page.
[email protected]dd265012009-01-08 20:45:27257 GURL url = server->TestServerPageW(kSimplePage);
[email protected]8bcdec92009-02-25 16:15:18258 ui_test_utils::NavigateToURL(browser(), url);
259
initial.commit09911bf2008-07-26 23:55:29260 // Create several tabs.
[email protected]22735af62009-04-07 21:09:58261 for (int i = 0; i < 4; ++i) {
[email protected]82166b62009-06-30 18:48:00262 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, -1,
263 false, NULL);
[email protected]22735af62009-04-07 21:09:58264 }
initial.commit09911bf2008-07-26 23:55:29265
266 // Alternate focus for the tab.
267 const bool kFocusPage[3][5] = {
268 { true, true, true, true, false },
269 { false, false, false, false, false },
270 { false, true, false, true, false }
271 };
272
273 for (int i = 1; i < 3; i++) {
274 for (int j = 0; j < 5; j++) {
[email protected]8bcdec92009-02-25 16:15:18275 // Activate the tab.
276 browser()->SelectTabContentsAt(j, true);
initial.commit09911bf2008-07-26 23:55:29277
278 // Activate the location bar or the page.
[email protected]7e383692009-06-12 19:14:54279 if (kFocusPage[i][j]) {
[email protected]186f13f2009-08-19 20:34:00280 browser()->GetTabContentsAt(j)->view()->Focus();
[email protected]7e383692009-06-12 19:14:54281 } else {
[email protected]186f13f2009-08-19 20:34:00282 browser()->FocusLocationBar();
[email protected]7e383692009-06-12 19:14:54283 }
initial.commit09911bf2008-07-26 23:55:29284 }
285
286 // Now come back to the tab and check the right view is focused.
287 for (int j = 0; j < 5; j++) {
[email protected]8bcdec92009-02-25 16:15:18288 // Activate the tab.
289 browser()->SelectTabContentsAt(j, true);
initial.commit09911bf2008-07-26 23:55:29290
[email protected]186f13f2009-08-19 20:34:00291 ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW :
292 VIEW_ID_LOCATION_BAR;
[email protected]21abcc742009-10-23 02:52:06293 ASSERT_TRUE(IsViewFocused(vid));
initial.commit09911bf2008-07-26 23:55:29294 }
[email protected]cb7e2542009-12-14 22:02:35295
296 gfx::NativeWindow window = browser()->window()->GetNativeHandle();
297 browser()->SelectTabContentsAt(0, true);
298 // Try the above, but with ctrl+tab. Since tab normally changes focus,
299 // this has regressed in the past. Loop through several times to be sure.
300 for (int j = 0; j < 15; j++) {
301 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW :
302 VIEW_ID_LOCATION_BAR;
303 ASSERT_TRUE(IsViewFocused(vid));
304
305 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_TAB, true,
306 false, false,
307 new MessageLoop::QuitTask());
308 ui_test_utils::RunMessageLoop();
309 }
310
311 // As above, but with ctrl+shift+tab.
312 browser()->SelectTabContentsAt(4, true);
313 for (int j = 14; j >= 0; --j) {
314 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW :
315 VIEW_ID_LOCATION_BAR;
316 ASSERT_TRUE(IsViewFocused(vid));
317
318 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_TAB, true,
319 true, false,
320 new MessageLoop::QuitTask());
321 ui_test_utils::RunMessageLoop();
322 }
initial.commit09911bf2008-07-26 23:55:29323 }
324}
325
[email protected]ae40b572009-10-02 21:17:45326// Tabs remember focus with find-in-page box.
[email protected]cb7e2542009-12-14 22:02:35327IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) {
[email protected]ae40b572009-10-02 21:17:45328 HTTPTestServer* server = StartHTTPServer();
329
330 // First we navigate to our test page.
331 GURL url = server->TestServerPageW(kSimplePage);
332 ui_test_utils::NavigateToURL(browser(), url);
333
334 browser()->Find();
335 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(),
336 ASCIIToUTF16("a"), true, false, NULL);
[email protected]21abcc742009-10-23 02:52:06337 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
[email protected]ae40b572009-10-02 21:17:45338
339 // Focus the location bar.
340 browser()->FocusLocationBar();
341
342 // Create a 2nd tab.
343 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, -1,
344 false, NULL);
345
346 // Focus should be on the recently opened tab page.
[email protected]21abcc742009-10-23 02:52:06347 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]ae40b572009-10-02 21:17:45348
349 // Select 1st tab, focus should still be on the location-bar.
350 // (bug http://crbug.com/23296)
351 browser()->SelectTabContentsAt(0, true);
[email protected]21abcc742009-10-23 02:52:06352 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]ae40b572009-10-02 21:17:45353
354 // Now open the find box again, switch to another tab and come back, the focus
355 // should return to the find box.
356 browser()->Find();
[email protected]21abcc742009-10-23 02:52:06357 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
[email protected]ae40b572009-10-02 21:17:45358 browser()->SelectTabContentsAt(1, true);
[email protected]21abcc742009-10-23 02:52:06359 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]ae40b572009-10-02 21:17:45360 browser()->SelectTabContentsAt(0, true);
[email protected]21abcc742009-10-23 02:52:06361 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
[email protected]ae40b572009-10-02 21:17:45362}
363
initial.commit09911bf2008-07-26 23:55:29364// Background window does not steal focus.
[email protected]e4f4e0b2009-10-13 19:58:21365IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) {
[email protected]8bcdec92009-02-25 16:15:18366 HTTPTestServer* server = StartHTTPServer();
initial.commit09911bf2008-07-26 23:55:29367
368 // First we navigate to our test page.
[email protected]8bcdec92009-02-25 16:15:18369 GURL url = server->TestServerPageW(kSimplePage);
370 ui_test_utils::NavigateToURL(browser(), url);
initial.commit09911bf2008-07-26 23:55:29371
372 // Open a new browser window.
[email protected]8bcdec92009-02-25 16:15:18373 Browser* browser2 = Browser::Create(browser()->profile());
374 ASSERT_TRUE(browser2);
[email protected]e0c7c262009-04-23 23:09:43375 browser2->tabstrip_model()->delegate()->AddBlankTab(true);
[email protected]8bcdec92009-02-25 16:15:18376 browser2->window()->Show();
[email protected]186f13f2009-08-19 20:34:00377
[email protected]ed179ee2009-10-03 21:02:51378 Browser* focused_browser = NULL;
379 Browser* unfocused_browser = NULL;
[email protected]186f13f2009-08-19 20:34:00380#if defined(OS_LINUX)
381 // On Linux, calling Activate() is not guaranteed to move focus, so we have
382 // to figure out which browser does have focus.
383 if (browser2->window()->IsActive()) {
384 focused_browser = browser2;
385 unfocused_browser = browser();
386 } else if (browser()->window()->IsActive()) {
387 focused_browser = browser();
388 unfocused_browser = browser2;
389 } else {
390 ASSERT_TRUE(false);
391 }
392#elif defined(OS_WIN)
393 focused_browser = browser();
394 unfocused_browser = browser2;
395#endif
396
[email protected]1e187af2009-02-25 02:02:46397 GURL steal_focus_url = server->TestServerPageW(kStealFocusPage);
[email protected]186f13f2009-08-19 20:34:00398 ui_test_utils::NavigateToURL(unfocused_browser, steal_focus_url);
[email protected]1e187af2009-02-25 02:02:46399
[email protected]8bcdec92009-02-25 16:15:18400 // Activate the first browser.
[email protected]186f13f2009-08-19 20:34:00401 focused_browser->window()->Activate();
initial.commit09911bf2008-07-26 23:55:29402
403 // Wait for the focus to be stolen by the other browser.
[email protected]186f13f2009-08-19 20:34:00404 PlatformThread::Sleep(2000);
initial.commit09911bf2008-07-26 23:55:29405
[email protected]8bcdec92009-02-25 16:15:18406 // Make sure the first browser is still active.
[email protected]186f13f2009-08-19 20:34:00407 EXPECT_TRUE(focused_browser->window()->IsActive());
[email protected]8bcdec92009-02-25 16:15:18408
409 // Close the 2nd browser to avoid a DCHECK().
[email protected]186f13f2009-08-19 20:34:00410 browser2->window()->Close();
initial.commit09911bf2008-07-26 23:55:29411}
412
413// Page cannot steal focus when focus is on location bar.
[email protected]e4f4e0b2009-10-13 19:58:21414IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) {
[email protected]8bcdec92009-02-25 16:15:18415 HTTPTestServer* server = StartHTTPServer();
initial.commit09911bf2008-07-26 23:55:29416
417 // Open the page that steals focus.
[email protected]dd265012009-01-08 20:45:27418 GURL url = server->TestServerPageW(kStealFocusPage);
[email protected]8bcdec92009-02-25 16:15:18419 ui_test_utils::NavigateToURL(browser(), url);
initial.commit09911bf2008-07-26 23:55:29420
[email protected]186f13f2009-08-19 20:34:00421 browser()->FocusLocationBar();
initial.commit09911bf2008-07-26 23:55:29422
423 // Wait for the page to steal focus.
[email protected]186f13f2009-08-19 20:34:00424 PlatformThread::Sleep(2000);
initial.commit09911bf2008-07-26 23:55:29425
426 // Make sure the location bar is still focused.
[email protected]21abcc742009-10-23 02:52:06427 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
initial.commit09911bf2008-07-26 23:55:29428}
429
[email protected]9e0c83a2009-05-06 19:44:37430// Focus traversal on a regular page.
[email protected]130efb02009-09-18 18:54:35431// Note that this test relies on a notification from the renderer that the
432// focus has changed in the page. The notification in the renderer may change
433// at which point this test would fail (see comment in
434// RenderWidget::didFocus()).
[email protected]e4f4e0b2009-10-13 19:58:21435IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) {
[email protected]8bcdec92009-02-25 16:15:18436 HTTPTestServer* server = StartHTTPServer();
initial.commit09911bf2008-07-26 23:55:29437
[email protected]8bcdec92009-02-25 16:15:18438 // First we navigate to our test page.
[email protected]dd265012009-01-08 20:45:27439 GURL url = server->TestServerPageW(kTypicalPage);
[email protected]8bcdec92009-02-25 16:15:18440 ui_test_utils::NavigateToURL(browser(), url);
initial.commit09911bf2008-07-26 23:55:29441
[email protected]186f13f2009-08-19 20:34:00442 browser()->FocusLocationBar();
initial.commit09911bf2008-07-26 23:55:29443
[email protected]8bcdec92009-02-25 16:15:18444 const char* kExpElementIDs[] = {
445 "", // Initially no element in the page should be focused
446 // (the location bar is focused).
447 "textEdit", "searchButton", "luckyButton", "googleLink", "gmailLink",
448 "gmapLink"
initial.commit09911bf2008-07-26 23:55:29449 };
450
[email protected]186f13f2009-08-19 20:34:00451 gfx::NativeWindow window = browser()->window()->GetNativeHandle();
452
initial.commit09911bf2008-07-26 23:55:29453 // Test forward focus traversal.
454 for (int i = 0; i < 3; ++i) {
455 // Location bar should be focused.
[email protected]21abcc742009-10-23 02:52:06456 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
initial.commit09911bf2008-07-26 23:55:29457
458 // Now let's press tab to move the focus.
[email protected]130efb02009-09-18 18:54:35459 for (size_t j = 0; j < arraysize(kExpElementIDs); ++j) {
initial.commit09911bf2008-07-26 23:55:29460 // Let's make sure the focus is on the expected element in the page.
[email protected]45671612009-04-29 22:24:01461 std::string actual;
462 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
[email protected]17c4f3c2009-07-04 16:36:25463 browser()->GetSelectedTabContents()->render_view_host(),
[email protected]8bcdec92009-02-25 16:15:18464 L"",
[email protected]45671612009-04-29 22:24:01465 L"window.domAutomationController.send(getFocusedElement());",
466 &actual));
initial.commit09911bf2008-07-26 23:55:29467 ASSERT_STREQ(kExpElementIDs[j], actual.c_str());
468
[email protected]130efb02009-09-18 18:54:35469 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB,
470 false, false, false));
471
472 if (j < arraysize(kExpElementIDs) - 1) {
473 ui_test_utils::WaitForFocusChange(browser()->GetSelectedTabContents()->
474 render_view_host());
475 } else {
476 // On the last tab key press, the focus returns to the browser.
477 ui_test_utils::WaitForFocusInBrowser(browser());
478 }
initial.commit09911bf2008-07-26 23:55:29479 }
[email protected]8bcdec92009-02-25 16:15:18480
481 // At this point the renderer has sent us a message asking to advance the
482 // focus (as the end of the focus loop was reached in the renderer).
483 // We need to run the message loop to process it.
[email protected]130efb02009-09-18 18:54:35484 MessageLoop::current()->RunAllPending();
initial.commit09911bf2008-07-26 23:55:29485 }
486
487 // Now let's try reverse focus traversal.
488 for (int i = 0; i < 3; ++i) {
489 // Location bar should be focused.
[email protected]21abcc742009-10-23 02:52:06490 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
initial.commit09911bf2008-07-26 23:55:29491
[email protected]8bcdec92009-02-25 16:15:18492 // Now let's press shift-tab to move the focus in reverse.
[email protected]130efb02009-09-18 18:54:35493 for (size_t j = 0; j < 7; ++j) {
494 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB,
495 false, true, false));
496
497 if (j < arraysize(kExpElementIDs) - 1) {
498 ui_test_utils::WaitForFocusChange(browser()->GetSelectedTabContents()->
499 render_view_host());
500 } else {
501 // On the last tab key press, the focus returns to the browser.
502 ui_test_utils::WaitForFocusInBrowser(browser());
503 }
initial.commit09911bf2008-07-26 23:55:29504
505 // Let's make sure the focus is on the expected element in the page.
[email protected]45671612009-04-29 22:24:01506 std::string actual;
507 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
[email protected]17c4f3c2009-07-04 16:36:25508 browser()->GetSelectedTabContents()->render_view_host(),
[email protected]8bcdec92009-02-25 16:15:18509 L"",
[email protected]45671612009-04-29 22:24:01510 L"window.domAutomationController.send(getFocusedElement());",
511 &actual));
initial.commit09911bf2008-07-26 23:55:29512 ASSERT_STREQ(kExpElementIDs[6 - j], actual.c_str());
513 }
[email protected]8bcdec92009-02-25 16:15:18514
515 // At this point the renderer has sent us a message asking to advance the
516 // focus (as the end of the focus loop was reached in the renderer).
517 // We need to run the message loop to process it.
[email protected]130efb02009-09-18 18:54:35518 MessageLoop::current()->RunAllPending();
initial.commit09911bf2008-07-26 23:55:29519 }
520}
521
[email protected]9e0c83a2009-05-06 19:44:37522// Focus traversal while an interstitial is showing.
[email protected]fc2e0872009-08-21 22:14:41523IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
[email protected]9e0c83a2009-05-06 19:44:37524 HTTPTestServer* server = StartHTTPServer();
525
526 // First we navigate to our test page.
527 GURL url = server->TestServerPageW(kSimplePage);
528 ui_test_utils::NavigateToURL(browser(), url);
529
[email protected]9e0c83a2009-05-06 19:44:37530 // Focus should be on the page.
[email protected]21abcc742009-10-23 02:52:06531 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]9e0c83a2009-05-06 19:44:37532
533 // Let's show an interstitial.
534 TestInterstitialPage* interstitial_page =
535 new TestInterstitialPage(browser()->GetSelectedTabContents(),
536 true, GURL("http://interstitial.com"));
537 interstitial_page->Show();
538 // Give some time for the interstitial to show.
539 MessageLoop::current()->PostDelayedTask(FROM_HERE,
540 new MessageLoop::QuitTask(),
541 1000);
542 ui_test_utils::RunMessageLoop();
543
[email protected]fc2e0872009-08-21 22:14:41544 browser()->FocusLocationBar();
[email protected]9e0c83a2009-05-06 19:44:37545
546 const char* kExpElementIDs[] = {
547 "", // Initially no element in the page should be focused
548 // (the location bar is focused).
549 "textEdit", "searchButton", "luckyButton", "googleLink", "gmailLink",
550 "gmapLink"
551 };
552
[email protected]fc2e0872009-08-21 22:14:41553 gfx::NativeWindow window = browser()->window()->GetNativeHandle();
554
[email protected]9e0c83a2009-05-06 19:44:37555 // Test forward focus traversal.
556 for (int i = 0; i < 2; ++i) {
557 // Location bar should be focused.
[email protected]21abcc742009-10-23 02:52:06558 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]9e0c83a2009-05-06 19:44:37559
560 // Now let's press tab to move the focus.
[email protected]130efb02009-09-18 18:54:35561 for (size_t j = 0; j < 7; ++j) {
[email protected]9e0c83a2009-05-06 19:44:37562 // Let's make sure the focus is on the expected element in the page.
563 std::string actual = interstitial_page->GetFocusedElement();
564 ASSERT_STREQ(kExpElementIDs[j], actual.c_str());
565
[email protected]130efb02009-09-18 18:54:35566 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB,
567 false, false, false));
568
569 if (j < arraysize(kExpElementIDs) - 1) {
570 interstitial_page->WaitForFocusChange();
571 } else {
572 // On the last tab key press, the focus returns to the browser.
573 ui_test_utils::WaitForFocusInBrowser(browser());
574 }
[email protected]9e0c83a2009-05-06 19:44:37575 }
576
577 // At this point the renderer has sent us a message asking to advance the
578 // focus (as the end of the focus loop was reached in the renderer).
579 // We need to run the message loop to process it.
[email protected]130efb02009-09-18 18:54:35580 MessageLoop::current()->RunAllPending();
[email protected]9e0c83a2009-05-06 19:44:37581 }
582
583 // Now let's try reverse focus traversal.
584 for (int i = 0; i < 2; ++i) {
585 // Location bar should be focused.
[email protected]21abcc742009-10-23 02:52:06586 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]9e0c83a2009-05-06 19:44:37587
588 // Now let's press shift-tab to move the focus in reverse.
[email protected]130efb02009-09-18 18:54:35589 for (size_t j = 0; j < 7; ++j) {
590 ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB,
591 false, true, false));
592
593 if (j < arraysize(kExpElementIDs) - 1) {
594 interstitial_page->WaitForFocusChange();
595 } else {
596 // On the last tab key press, the focus returns to the browser.
597 ui_test_utils::WaitForFocusInBrowser(browser());
598 }
[email protected]9e0c83a2009-05-06 19:44:37599
600 // Let's make sure the focus is on the expected element in the page.
601 std::string actual = interstitial_page->GetFocusedElement();
602 ASSERT_STREQ(kExpElementIDs[6 - j], actual.c_str());
603 }
604
605 // At this point the renderer has sent us a message asking to advance the
606 // focus (as the end of the focus loop was reached in the renderer).
607 // We need to run the message loop to process it.
[email protected]130efb02009-09-18 18:54:35608 MessageLoop::current()->RunAllPending();
[email protected]9e0c83a2009-05-06 19:44:37609 }
610}
611
612// Focus stays on page with interstitials.
[email protected]e4f4e0b2009-10-13 19:58:21613IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) {
[email protected]9e0c83a2009-05-06 19:44:37614 HTTPTestServer* server = StartHTTPServer();
615
616 // First we navigate to our test page.
617 GURL url = server->TestServerPageW(kSimplePage);
618 ui_test_utils::NavigateToURL(browser(), url);
619
[email protected]9e0c83a2009-05-06 19:44:37620 // Page should have focus.
[email protected]21abcc742009-10-23 02:52:06621 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]9e0c83a2009-05-06 19:44:37622 EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()->
623 HasFocus());
624
[email protected]9d8a4642009-07-29 17:25:30625 // Let's show an interstitial.
[email protected]9e0c83a2009-05-06 19:44:37626 TestInterstitialPage* interstitial_page =
627 new TestInterstitialPage(browser()->GetSelectedTabContents(),
628 true, GURL("http://interstitial.com"));
629 interstitial_page->Show();
630 // Give some time for the interstitial to show.
631 MessageLoop::current()->PostDelayedTask(FROM_HERE,
632 new MessageLoop::QuitTask(),
633 1000);
634 ui_test_utils::RunMessageLoop();
635
636 // The interstitial should have focus now.
[email protected]21abcc742009-10-23 02:52:06637 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]9e0c83a2009-05-06 19:44:37638 EXPECT_TRUE(interstitial_page->HasFocus());
639
640 // Hide the interstitial.
641 interstitial_page->DontProceed();
642
643 // Focus should be back on the original page.
[email protected]21abcc742009-10-23 02:52:06644 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]9e0c83a2009-05-06 19:44:37645}
646
[email protected]9bd491ee2008-12-10 22:31:07647// Make sure Find box can request focus, even when it is already open.
[email protected]e4f4e0b2009-10-13 19:58:21648IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
[email protected]8bcdec92009-02-25 16:15:18649 HTTPTestServer* server = StartHTTPServer();
license.botbf09a502008-08-24 00:55:55650
[email protected]9bd491ee2008-12-10 22:31:07651 // Open some page (any page that doesn't steal focus).
[email protected]dd265012009-01-08 20:45:27652 GURL url = server->TestServerPageW(kTypicalPage);
[email protected]8bcdec92009-02-25 16:15:18653 ui_test_utils::NavigateToURL(browser(), url);
[email protected]9bd491ee2008-12-10 22:31:07654
[email protected]fc2e0872009-08-21 22:14:41655 gfx::NativeWindow window = browser()->window()->GetNativeHandle();
[email protected]9bd491ee2008-12-10 22:31:07656
657 // Press Ctrl+F, which will make the Find box open and request focus.
[email protected]fc2e0872009-08-21 22:14:41658 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true,
[email protected]22cdd932009-08-18 02:16:21659 false, false,
[email protected]8bcdec92009-02-25 16:15:18660 new MessageLoop::QuitTask());
661 ui_test_utils::RunMessageLoop();
662
663 // Ideally, we wouldn't sleep here and instead would intercept the
664 // RenderViewHostDelegate::HandleKeyboardEvent() callback. To do that, we
665 // could create a RenderViewHostDelegate wrapper and hook-it up by either:
666 // - creating a factory used to create the delegate
667 // - making the test a private and overwriting the delegate member directly.
[email protected]fc2e0872009-08-21 22:14:41668 MessageLoop::current()->PostDelayedTask(
669 FROM_HERE, new MessageLoop::QuitTask(), kActionDelayMs);
[email protected]8bcdec92009-02-25 16:15:18670 ui_test_utils::RunMessageLoop();
671
[email protected]21abcc742009-10-23 02:52:06672 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
[email protected]9bd491ee2008-12-10 22:31:07673
[email protected]fc2e0872009-08-21 22:14:41674 browser()->FocusLocationBar();
[email protected]21abcc742009-10-23 02:52:06675 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]9bd491ee2008-12-10 22:31:07676
677 // Now press Ctrl+F again and focus should move to the Find box.
[email protected]fc2e0872009-08-21 22:14:41678 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true,
[email protected]22cdd932009-08-18 02:16:21679 false, false,
[email protected]8bcdec92009-02-25 16:15:18680 new MessageLoop::QuitTask());
681 ui_test_utils::RunMessageLoop();
[email protected]21abcc742009-10-23 02:52:06682 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
[email protected]9bd491ee2008-12-10 22:31:07683
684 // Set focus to the page.
[email protected]fc2e0872009-08-21 22:14:41685 ClickOnView(VIEW_ID_TAB_CONTAINER);
[email protected]21abcc742009-10-23 02:52:06686 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]9bd491ee2008-12-10 22:31:07687
688 // Now press Ctrl+F again and focus should move to the Find box.
[email protected]fc2e0872009-08-21 22:14:41689 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, false,
[email protected]22cdd932009-08-18 02:16:21690 false, new MessageLoop::QuitTask());
[email protected]8bcdec92009-02-25 16:15:18691 ui_test_utils::RunMessageLoop();
692
693 // See remark above on why we wait.
[email protected]fc2e0872009-08-21 22:14:41694 MessageLoop::current()->PostDelayedTask(
695 FROM_HERE, new MessageLoop::QuitTask(), kActionDelayMs);
[email protected]8bcdec92009-02-25 16:15:18696 ui_test_utils::RunMessageLoop();
[email protected]21abcc742009-10-23 02:52:06697 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
[email protected]9bd491ee2008-12-10 22:31:07698}
[email protected]401513c2009-03-12 00:21:28699
700// Makes sure the focus is in the right location when opening the different
701// types of tabs.
[email protected]e4f4e0b2009-10-13 19:58:21702IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) {
[email protected]401513c2009-03-12 00:21:28703 // Open the history tab, focus should be on the tab contents.
704 browser()->ShowHistoryTab();
[email protected]21abcc742009-10-23 02:52:06705 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]401513c2009-03-12 00:21:28706
707 // Open the new tab, focus should be on the location bar.
708 browser()->NewTab();
[email protected]21abcc742009-10-23 02:52:06709 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]401513c2009-03-12 00:21:28710
711 // Open the download tab, focus should be on the tab contents.
712 browser()->ShowDownloadsTab();
[email protected]21abcc742009-10-23 02:52:06713 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]3e3f0eb2009-06-22 18:33:43714
715 // Open about:blank, focus should be on the location bar.
716 browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK,
717 true, -1, false, NULL);
[email protected]21abcc742009-10-23 02:52:06718 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]401513c2009-03-12 00:21:28719}
[email protected]9d8a4642009-07-29 17:25:30720
721// Tests that focus goes where expected when using reload.
[email protected]e4f4e0b2009-10-13 19:58:21722IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
[email protected]9d8a4642009-07-29 17:25:30723 HTTPTestServer* server = StartHTTPServer();
724
[email protected]9d8a4642009-07-29 17:25:30725 // Open the new tab, reload.
726 browser()->NewTab();
[email protected]b7a20d32009-08-15 00:02:40727 browser()->Reload();
728 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
[email protected]9d8a4642009-07-29 17:25:30729 // Focus should stay on the location bar.
[email protected]21abcc742009-10-23 02:52:06730 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]9d8a4642009-07-29 17:25:30731
732 // Open a regular page, focus the location bar, reload.
733 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage));
[email protected]fc2e0872009-08-21 22:14:41734 browser()->FocusLocationBar();
[email protected]21abcc742009-10-23 02:52:06735 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
[email protected]b7a20d32009-08-15 00:02:40736 browser()->Reload();
737 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
[email protected]9d8a4642009-07-29 17:25:30738 // Focus should now be on the tab contents.
[email protected]fc2e0872009-08-21 22:14:41739 browser()->ShowDownloadsTab();
[email protected]21abcc742009-10-23 02:52:06740 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]9d8a4642009-07-29 17:25:30741}
742
743// Tests that focus goes where expected when using reload on a crashed tab.
[email protected]e4f4e0b2009-10-13 19:58:21744IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReloadCrashedTab) {
[email protected]9d8a4642009-07-29 17:25:30745 HTTPTestServer* server = StartHTTPServer();
746
[email protected]9d8a4642009-07-29 17:25:30747 // Open a regular page, crash, reload.
748 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage));
749 ui_test_utils::CrashTab(browser()->GetSelectedTabContents());
[email protected]b7a20d32009-08-15 00:02:40750 browser()->Reload();
751 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
[email protected]9d8a4642009-07-29 17:25:30752 // Focus should now be on the tab contents.
[email protected]fc2e0872009-08-21 22:14:41753 browser()->ShowDownloadsTab();
[email protected]21abcc742009-10-23 02:52:06754 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
[email protected]9d8a4642009-07-29 17:25:30755}