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

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 232463007: Don't leave aborted URLs in the omnibox unless we're on a new tab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 8 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
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | content/browser/frame_host/navigation_controller_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/sys_info.h" 13 #include "base/sys_info.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/chrome_content_browser_client.h" 15 #include "chrome/browser/chrome_content_browser_client.h"
16 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/command_updater.h" 17 #include "chrome/browser/command_updater.h"
18 #include "chrome/browser/content_settings/host_content_settings_map.h" 18 #include "chrome/browser/content_settings/host_content_settings_map.h"
19 #include "chrome/browser/defaults.h" 19 #include "chrome/browser/defaults.h"
20 #include "chrome/browser/extensions/extension_browsertest.h" 20 #include "chrome/browser/extensions/extension_browsertest.h"
21 #include "chrome/browser/extensions/extension_service.h" 21 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/tab_helper.h" 22 #include "chrome/browser/extensions/tab_helper.h"
23 #include "chrome/browser/first_run/first_run.h" 23 #include "chrome/browser/first_run/first_run.h"
24 #include "chrome/browser/lifetime/application_lifetime.h" 24 #include "chrome/browser/lifetime/application_lifetime.h"
25 #include "chrome/browser/prefs/incognito_mode_prefs.h" 25 #include "chrome/browser/prefs/incognito_mode_prefs.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/profiles/profile_manager.h" 27 #include "chrome/browser/profiles/profile_manager.h"
28 #include "chrome/browser/search/search.h"
28 #include "chrome/browser/sessions/session_backend.h" 29 #include "chrome/browser/sessions/session_backend.h"
29 #include "chrome/browser/sessions/session_service_factory.h" 30 #include "chrome/browser/sessions/session_service_factory.h"
30 #include "chrome/browser/translate/translate_tab_helper.h" 31 #include "chrome/browser/translate/translate_tab_helper.h"
31 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 32 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
32 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 33 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
33 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" 34 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
34 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 35 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
35 #include "chrome/browser/ui/browser.h" 36 #include "chrome/browser/ui/browser.h"
36 #include "chrome/browser/ui/browser_command_controller.h" 37 #include "chrome/browser/ui/browser_command_controller.h"
37 #include "chrome/browser/ui/browser_commands.h" 38 #include "chrome/browser/ui/browser_commands.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 #else 463 #else
463 25; 464 25;
464 #endif 465 #endif
465 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) { 466 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) {
466 EXPECT_GE(CountRenderProcessHosts(), kExpectedProcessCount); 467 EXPECT_GE(CountRenderProcessHosts(), kExpectedProcessCount);
467 } else { 468 } else {
468 EXPECT_LT(CountRenderProcessHosts(), kExpectedProcessCount); 469 EXPECT_LT(CountRenderProcessHosts(), kExpectedProcessCount);
469 } 470 }
470 } 471 }
471 472
473 // Test that a browser-initiated navigation to an aborted URL load leaves around
474 // a pending entry if we start from the NTP but not from a normal page.
475 // See http://crbug.com/355537.
476 IN_PROC_BROWSER_TEST_F(BrowserTest, ClearPendingOnFailUnlessNTP) {
477 ASSERT_TRUE(test_server()->Start());
478 WebContents* web_contents =
479 browser()->tab_strip_model()->GetActiveWebContents();
480 GURL ntp_url(chrome::GetNewTabPageURL(browser()->profile()));
481 ui_test_utils::NavigateToURL(browser(), ntp_url);
482
483 // Navigate to a 204 URL (aborts with no content) on the NTP and make sure it
484 // sticks around so that the user can edit it.
485 GURL abort_url(test_server()->GetURL("nocontent"));
486 {
487 content::WindowedNotificationObserver stop_observer(
488 content::NOTIFICATION_LOAD_STOP,
489 content::Source<NavigationController>(
490 &web_contents->GetController()));
491 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB,
492 content::PAGE_TRANSITION_TYPED, false));
493 stop_observer.Wait();
494 EXPECT_TRUE(web_contents->GetController().GetPendingEntry());
495 EXPECT_EQ(abort_url, web_contents->GetVisibleURL());
496 }
497
498 // Navigate to a real URL.
499 GURL real_url(test_server()->GetURL("title1.html"));
500 ui_test_utils::NavigateToURL(browser(), real_url);
501 EXPECT_EQ(real_url, web_contents->GetVisibleURL());
502
503 // Now navigating to a 204 URL should clear the pending entry.
504 {
505 content::WindowedNotificationObserver stop_observer(
506 content::NOTIFICATION_LOAD_STOP,
507 content::Source<NavigationController>(
508 &web_contents->GetController()));
509 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB,
510 content::PAGE_TRANSITION_TYPED, false));
511 stop_observer.Wait();
512 EXPECT_FALSE(web_contents->GetController().GetPendingEntry());
513 EXPECT_EQ(real_url, web_contents->GetVisibleURL());
514 }
515 }
516
472 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a 517 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a
473 // cross-process navigation is ready to commit. 518 // cross-process navigation is ready to commit.
474 IN_PROC_BROWSER_TEST_F(BrowserTest, CrossProcessNavCancelsDialogs) { 519 IN_PROC_BROWSER_TEST_F(BrowserTest, CrossProcessNavCancelsDialogs) {
475 ASSERT_TRUE(test_server()->Start()); 520 ASSERT_TRUE(test_server()->Start());
476 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 521 host_resolver()->AddRule("www.example.com", "127.0.0.1");
477 GURL url(test_server()->GetURL("empty.html")); 522 GURL url(test_server()->GetURL("empty.html"));
478 ui_test_utils::NavigateToURL(browser(), url); 523 ui_test_utils::NavigateToURL(browser(), url);
479 524
480 // Test this with multiple alert dialogs to ensure that we can navigate away 525 // Test this with multiple alert dialogs to ensure that we can navigate away
481 // even if the renderer tries to synchronously create more. 526 // even if the renderer tries to synchronously create more.
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 #endif 2649 #endif
2605 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2650 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2606 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2651 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2607 gfx::Size exp_final_size(initial_wcv_size); 2652 gfx::Size exp_final_size(initial_wcv_size);
2608 exp_final_size.Enlarge(wcv_resize_insets.width(), 2653 exp_final_size.Enlarge(wcv_resize_insets.width(),
2609 wcv_resize_insets.height() + height_inset); 2654 wcv_resize_insets.height() + height_inset);
2610 EXPECT_EQ(exp_final_size, 2655 EXPECT_EQ(exp_final_size,
2611 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2656 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2612 EXPECT_EQ(exp_final_size, web_contents->GetView()->GetContainerSize()); 2657 EXPECT_EQ(exp_final_size, web_contents->GetView()->GetContainerSize());
2613 } 2658 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | content/browser/frame_host/navigation_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698