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/memory/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
6 #include "chrome/browser/platform_util.h" | 6 #include "chrome/browser/platform_util.h" |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/browser/ui/views/constrained_window_views.h" | 11 #include "chrome/browser/ui/views/constrained_window_views.h" |
12 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
13 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" | 13 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" |
14 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 14 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
18 #include "content/public/browser/native_web_keyboard_event.h" | 18 #include "content/public/browser/native_web_keyboard_event.h" |
| 19 #include "content/public/browser/navigation_controller.h" |
19 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
21 #include "content/public/browser/web_contents_view.h" | 22 #include "content/public/browser/web_contents_view.h" |
22 #include "ipc/ipc_message.h" | 23 #include "ipc/ipc_message.h" |
23 #include "ui/base/accelerators/accelerator.h" | 24 #include "ui/base/accelerators/accelerator.h" |
24 #include "ui/views/controls/textfield/textfield.h" | 25 #include "ui/views/controls/textfield/textfield.h" |
25 #include "ui/views/focus/focus_manager.h" | 26 #include "ui/views/focus/focus_manager.h" |
26 #include "ui/views/layout/fill_layout.h" | 27 #include "ui/views/layout/fill_layout.h" |
27 #include "ui/views/test/test_widget_observer.h" | 28 #include "ui/views/test/test_widget_observer.h" |
28 #include "ui/views/window/dialog_delegate.h" | 29 #include "ui/views/window/dialog_delegate.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 ui_test_utils::NavigateToURL(browser(), new_tab_url); | 314 ui_test_utils::NavigateToURL(browser(), new_tab_url); |
314 GURL about_url(chrome::kChromeUIAboutURL); | 315 GURL about_url(chrome::kChromeUIAboutURL); |
315 ui_test_utils::NavigateToURL(browser(), about_url); | 316 ui_test_utils::NavigateToURL(browser(), about_url); |
316 | 317 |
317 ConstrainedWebDialogDelegate* cwdd = CreateConstrainedWebDialog( | 318 ConstrainedWebDialogDelegate* cwdd = CreateConstrainedWebDialog( |
318 browser()->profile(), | 319 browser()->profile(), |
319 new ui::test::TestWebDialogDelegate(about_url), | 320 new ui::test::TestWebDialogDelegate(about_url), |
320 NULL, | 321 NULL, |
321 web_contents); | 322 web_contents); |
322 | 323 |
| 324 content::WindowedNotificationObserver back_observer( |
| 325 content::NOTIFICATION_LOAD_STOP, |
| 326 content::Source<content::NavigationController>( |
| 327 &web_contents->GetController())); |
323 content::RenderViewHost* render_view_host = | 328 content::RenderViewHost* render_view_host = |
324 cwdd->GetWebContents()->GetRenderViewHost(); | 329 cwdd->GetWebContents()->GetRenderViewHost(); |
325 ForwardKeyEvent(render_view_host, ui::VKEY_BACK); | 330 ForwardKeyEvent(render_view_host, ui::VKEY_BACK); |
326 | 331 |
327 // Backspace is not processed as accelerator before it's sent to web contents. | 332 // Backspace is not processed as accelerator before it's sent to web contents. |
| 333 EXPECT_FALSE(web_contents->GetController().GetPendingEntry()); |
328 EXPECT_EQ(about_url.spec(), web_contents->GetURL().spec()); | 334 EXPECT_EQ(about_url.spec(), web_contents->GetURL().spec()); |
329 | 335 |
| 336 // Backspace is processed as accelerator after it's sent to web contents. |
330 content::RunAllPendingInMessageLoop(); | 337 content::RunAllPendingInMessageLoop(); |
| 338 EXPECT_TRUE(web_contents->GetController().GetPendingEntry()); |
331 | 339 |
332 // Backspace is processed as accelerator after it's sent to web contents. | 340 // Wait for the navigation to commit, since the URL will not be visible |
| 341 // until then. |
| 342 back_observer.Wait(); |
333 EXPECT_EQ(new_tab_url.spec(), web_contents->GetURL().spec()); | 343 EXPECT_EQ(new_tab_url.spec(), web_contents->GetURL().spec()); |
334 } | 344 } |
335 | 345 |
336 // Fails flakily (once per 10-20 runs) on Win Aura only. http://crbug.com/177482 | 346 // Fails flakily (once per 10-20 runs) on Win Aura only. http://crbug.com/177482 |
337 #if defined(OS_WIN) | 347 #if defined(OS_WIN) |
338 #define MAYBE_EscapeCloseConstrainedWindow DISABLED_EscapeCloseConstrainedWindow | 348 #define MAYBE_EscapeCloseConstrainedWindow DISABLED_EscapeCloseConstrainedWindow |
339 #else | 349 #else |
340 #define MAYBE_EscapeCloseConstrainedWindow EscapeCloseConstrainedWindow | 350 #define MAYBE_EscapeCloseConstrainedWindow EscapeCloseConstrainedWindow |
341 #endif | 351 #endif |
342 | 352 |
(...skipping 23 matching lines...) Expand all Loading... |
366 // Escape is not processed as accelerator before it's sent to web contents. | 376 // Escape is not processed as accelerator before it's sent to web contents. |
367 EXPECT_FALSE(observer.widget_closed()); | 377 EXPECT_FALSE(observer.widget_closed()); |
368 | 378 |
369 content::RunAllPendingInMessageLoop(); | 379 content::RunAllPendingInMessageLoop(); |
370 | 380 |
371 // Escape is processed as accelerator after it's sent to web contents. | 381 // Escape is processed as accelerator after it's sent to web contents. |
372 EXPECT_TRUE(observer.widget_closed()); | 382 EXPECT_TRUE(observer.widget_closed()); |
373 } | 383 } |
374 | 384 |
375 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11)) | 385 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11)) |
OLD | NEW |