Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Side by Side Diff: chrome/browser/ui/views/constrained_window_views_browsertest.cc

Issue 14283005: Allow showing pending URL for new tab navigations, but only if safe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/webui/constrained_web_dialog_ui.h" 13 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "components/web_modal/web_contents_modal_dialog_manager.h" 17 #include "components/web_modal/web_contents_modal_dialog_manager.h"
18 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 18 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 ui_test_utils::NavigateToURL(browser(), new_tab_url); 325 ui_test_utils::NavigateToURL(browser(), new_tab_url);
325 GURL about_url(chrome::kChromeUIAboutURL); 326 GURL about_url(chrome::kChromeUIAboutURL);
326 ui_test_utils::NavigateToURL(browser(), about_url); 327 ui_test_utils::NavigateToURL(browser(), about_url);
327 328
328 ConstrainedWebDialogDelegate* cwdd = CreateConstrainedWebDialog( 329 ConstrainedWebDialogDelegate* cwdd = CreateConstrainedWebDialog(
329 browser()->profile(), 330 browser()->profile(),
330 new ui::test::TestWebDialogDelegate(about_url), 331 new ui::test::TestWebDialogDelegate(about_url),
331 NULL, 332 NULL,
332 web_contents); 333 web_contents);
333 334
335 content::WindowedNotificationObserver back_observer(
336 content::NOTIFICATION_LOAD_STOP,
337 content::Source<content::NavigationController>(
338 &web_contents->GetController()));
334 content::RenderViewHost* render_view_host = 339 content::RenderViewHost* render_view_host =
335 cwdd->GetWebContents()->GetRenderViewHost(); 340 cwdd->GetWebContents()->GetRenderViewHost();
336 ForwardKeyEvent(render_view_host, ui::VKEY_BACK); 341 ForwardKeyEvent(render_view_host, ui::VKEY_BACK);
337 342
338 // Backspace is not processed as accelerator before it's sent to web contents. 343 // Backspace is not processed as accelerator before it's sent to web contents.
344 EXPECT_FALSE(web_contents->GetController().GetPendingEntry());
339 EXPECT_EQ(about_url.spec(), web_contents->GetURL().spec()); 345 EXPECT_EQ(about_url.spec(), web_contents->GetURL().spec());
340 346
347 // Backspace is processed as accelerator after it's sent to web contents.
341 content::RunAllPendingInMessageLoop(); 348 content::RunAllPendingInMessageLoop();
349 EXPECT_TRUE(web_contents->GetController().GetPendingEntry());
342 350
343 // Backspace is processed as accelerator after it's sent to web contents. 351 // Wait for the navigation to commit, since the URL will not be visible
352 // until then.
353 back_observer.Wait();
344 EXPECT_EQ(new_tab_url.spec(), web_contents->GetURL().spec()); 354 EXPECT_EQ(new_tab_url.spec(), web_contents->GetURL().spec());
345 } 355 }
346 356
347 // Fails flakily (once per 10-20 runs) on Win Aura only. http://crbug.com/177482 357 // Fails flakily (once per 10-20 runs) on Win Aura only. http://crbug.com/177482
348 // Also fails on CrOS. 358 // Also fails on CrOS.
349 #if defined(OS_WIN) || defined(OS_CHROMEOS) 359 #if defined(OS_WIN) || defined(OS_CHROMEOS)
350 #define MAYBE_EscapeCloseConstrainedWindow DISABLED_EscapeCloseConstrainedWindow 360 #define MAYBE_EscapeCloseConstrainedWindow DISABLED_EscapeCloseConstrainedWindow
351 #else 361 #else
352 #define MAYBE_EscapeCloseConstrainedWindow EscapeCloseConstrainedWindow 362 #define MAYBE_EscapeCloseConstrainedWindow EscapeCloseConstrainedWindow
353 #endif 363 #endif
(...skipping 24 matching lines...) Expand all
378 // Escape is not processed as accelerator before it's sent to web contents. 388 // Escape is not processed as accelerator before it's sent to web contents.
379 EXPECT_FALSE(observer.widget_closed()); 389 EXPECT_FALSE(observer.widget_closed());
380 390
381 content::RunAllPendingInMessageLoop(); 391 content::RunAllPendingInMessageLoop();
382 392
383 // Escape is processed as accelerator after it's sent to web contents. 393 // Escape is processed as accelerator after it's sent to web contents.
384 EXPECT_TRUE(observer.widget_closed()); 394 EXPECT_TRUE(observer.widget_closed());
385 } 395 }
386 396
387 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11)) 397 #endif // defined(OS_WIN) || (defined(USE_AURA) && defined(USE_X11))
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_navigator_browsertest.cc ('k') | content/browser/android/content_view_core_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698