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/web_contents_modal_dialog_manager_delegate.h" | 14 #include "chrome/browser/ui/web_contents_modal_dialog_manager_delegate.h" |
15 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 15 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/native_web_keyboard_event.h" | 19 #include "content/public/browser/native_web_keyboard_event.h" |
| 20 #include "content/public/browser/navigation_controller.h" |
20 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
22 #include "content/public/browser/web_contents_view.h" | 23 #include "content/public/browser/web_contents_view.h" |
23 #include "ipc/ipc_message.h" | 24 #include "ipc/ipc_message.h" |
24 #include "ui/base/accelerators/accelerator.h" | 25 #include "ui/base/accelerators/accelerator.h" |
25 #include "ui/views/controls/textfield/textfield.h" | 26 #include "ui/views/controls/textfield/textfield.h" |
26 #include "ui/views/focus/focus_manager.h" | 27 #include "ui/views/focus/focus_manager.h" |
27 #include "ui/views/layout/fill_layout.h" | 28 #include "ui/views/layout/fill_layout.h" |
28 #include "ui/views/test/test_widget_observer.h" | 29 #include "ui/views/test/test_widget_observer.h" |
29 #include "ui/views/window/dialog_delegate.h" | 30 #include "ui/views/window/dialog_delegate.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 ui_test_utils::NavigateToURL(browser(), new_tab_url); | 323 ui_test_utils::NavigateToURL(browser(), new_tab_url); |
323 GURL about_url(chrome::kChromeUIAboutURL); | 324 GURL about_url(chrome::kChromeUIAboutURL); |
324 ui_test_utils::NavigateToURL(browser(), about_url); | 325 ui_test_utils::NavigateToURL(browser(), about_url); |
325 | 326 |
326 ConstrainedWebDialogDelegate* cwdd = CreateConstrainedWebDialog( | 327 ConstrainedWebDialogDelegate* cwdd = CreateConstrainedWebDialog( |
327 browser()->profile(), | 328 browser()->profile(), |
328 new ui::test::TestWebDialogDelegate(about_url), | 329 new ui::test::TestWebDialogDelegate(about_url), |
329 NULL, | 330 NULL, |
330 web_contents); | 331 web_contents); |
331 | 332 |
| 333 content::WindowedNotificationObserver back_observer( |
| 334 content::NOTIFICATION_LOAD_STOP, |
| 335 content::Source<content::NavigationController>( |
| 336 &web_contents->GetController())); |
332 content::RenderViewHost* render_view_host = | 337 content::RenderViewHost* render_view_host = |
333 cwdd->GetWebContents()->GetRenderViewHost(); | 338 cwdd->GetWebContents()->GetRenderViewHost(); |
334 ForwardKeyEvent(render_view_host, ui::VKEY_BACK); | 339 ForwardKeyEvent(render_view_host, ui::VKEY_BACK); |
335 | 340 |
336 // Backspace is not processed as accelerator before it's sent to web contents. | 341 // Backspace is not processed as accelerator before it's sent to web contents. |
| 342 EXPECT_FALSE(web_contents->GetController().GetPendingEntry()); |
337 EXPECT_EQ(about_url.spec(), web_contents->GetURL().spec()); | 343 EXPECT_EQ(about_url.spec(), web_contents->GetURL().spec()); |
338 | 344 |
| 345 // Backspace is processed as accelerator after it's sent to web contents. |
339 content::RunAllPendingInMessageLoop(); | 346 content::RunAllPendingInMessageLoop(); |
| 347 EXPECT_TRUE(web_contents->GetController().GetPendingEntry()); |
340 | 348 |
341 // Backspace is processed as accelerator after it's sent to web contents. | 349 // Wait for the navigation to commit, since the URL will not be visible |
| 350 // until then. |
| 351 back_observer.Wait(); |
342 EXPECT_EQ(new_tab_url.spec(), web_contents->GetURL().spec()); | 352 EXPECT_EQ(new_tab_url.spec(), web_contents->GetURL().spec()); |
343 } | 353 } |
344 | 354 |
345 // Fails flakily (once per 10-20 runs) on Win Aura only. http://crbug.com/177482 | 355 // Fails flakily (once per 10-20 runs) on Win Aura only. http://crbug.com/177482 |
346 // Also fails on CrOS. | 356 // Also fails on CrOS. |
347 #if defined(OS_WIN) || defined(OS_CHROMEOS) | 357 #if defined(OS_WIN) || defined(OS_CHROMEOS) |
348 #define MAYBE_EscapeCloseConstrainedWindow DISABLED_EscapeCloseConstrainedWindow | 358 #define MAYBE_EscapeCloseConstrainedWindow DISABLED_EscapeCloseConstrainedWindow |
349 #else | 359 #else |
350 #define MAYBE_EscapeCloseConstrainedWindow EscapeCloseConstrainedWindow | 360 #define MAYBE_EscapeCloseConstrainedWindow EscapeCloseConstrainedWindow |
351 #endif | 361 #endif |
(...skipping 24 matching lines...) Expand all Loading... |
376 // Escape is not processed as accelerator before it's sent to web contents. | 386 // Escape is not processed as accelerator before it's sent to web contents. |
377 EXPECT_FALSE(observer.widget_closed()); | 387 EXPECT_FALSE(observer.widget_closed()); |
378 | 388 |
379 content::RunAllPendingInMessageLoop(); | 389 content::RunAllPendingInMessageLoop(); |
380 | 390 |
381 // Escape is processed as accelerator after it's sent to web contents. | 391 // Escape is processed as accelerator after it's sent to web contents. |
382 EXPECT_TRUE(observer.widget_closed()); | 392 EXPECT_TRUE(observer.widget_closed()); |
383 } | 393 } |
384 | 394 |
385 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11)) | 395 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11)) |
OLD | NEW |