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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 325443002: Move about://-related constants from //content to //url (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android ifx Created 6 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 <deque> 5 #include <deque>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 2886 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 1); 2897 1);
2898 OpenDestURLViaClickTarget(); 2898 OpenDestURLViaClickTarget();
2899 } 2899 }
2900 2900
2901 // Checks that prerenders do not get swapped into target pages that have opened 2901 // Checks that prerenders do not get swapped into target pages that have opened
2902 // a popup, even if the target page itself does not have an opener. 2902 // a popup, even if the target page itself does not have an opener.
2903 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTargetHasPopup) { 2903 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTargetHasPopup) {
2904 PrerenderTestURL("files/prerender/prerender_page.html", 2904 PrerenderTestURL("files/prerender/prerender_page.html",
2905 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE, 2905 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE,
2906 1); 2906 1);
2907 OpenURLViaWindowOpen(GURL(content::kAboutBlankURL)); 2907 OpenURLViaWindowOpen(GURL(url::kAboutBlankURL));
2908 NavigateToDestURLWithDisposition(CURRENT_TAB, false); 2908 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
2909 } 2909 }
2910 2910
2911 class TestClientCertStore : public net::ClientCertStore { 2911 class TestClientCertStore : public net::ClientCertStore {
2912 public: 2912 public:
2913 TestClientCertStore() {} 2913 TestClientCertStore() {}
2914 virtual ~TestClientCertStore() {} 2914 virtual ~TestClientCertStore() {}
2915 2915
2916 // net::ClientCertStore: 2916 // net::ClientCertStore:
2917 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, 2917 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info,
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
4002 kTestURL, test_file, counter.AsWeakPtr())); 4002 kTestURL, test_file, counter.AsWeakPtr()));
4003 4003
4004 PrerenderTestURL(kTestURL, FINAL_STATUS_USED, 1); 4004 PrerenderTestURL(kTestURL, FINAL_STATUS_USED, 1);
4005 4005
4006 // Open a new tab to navigate in. 4006 // Open a new tab to navigate in.
4007 ui_test_utils::NavigateToURLWithDisposition( 4007 ui_test_utils::NavigateToURLWithDisposition(
4008 current_browser(), kInitURL, NEW_FOREGROUND_TAB, 4008 current_browser(), kInitURL, NEW_FOREGROUND_TAB,
4009 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 4009 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
4010 4010
4011 // Navigate to about:blank so the next navigation is cross-process. 4011 // Navigate to about:blank so the next navigation is cross-process.
4012 ui_test_utils::NavigateToURL(current_browser(), 4012 ui_test_utils::NavigateToURL(current_browser(), GURL(url::kAboutBlankURL));
4013 GURL(content::kAboutBlankURL));
4014 4013
4015 // Now navigate in the new tab. Set expect_swap_to_succeed to false because 4014 // Now navigate in the new tab. Set expect_swap_to_succeed to false because
4016 // the swap does not occur synchronously. 4015 // the swap does not occur synchronously.
4017 // 4016 //
4018 // TODO(davidben): When all swaps become asynchronous, remove the OpenURL 4017 // TODO(davidben): When all swaps become asynchronous, remove the OpenURL
4019 // return value assertion and let this go through the usual successful-swap 4018 // return value assertion and let this go through the usual successful-swap
4020 // codepath. 4019 // codepath.
4021 NavigateToDestURLWithDisposition(CURRENT_TAB, false); 4020 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
4022 4021
4023 // Verify DidDisplayPass manually since the previous call skipped it. 4022 // Verify DidDisplayPass manually since the previous call skipped it.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4056 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB, 4055 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB,
4057 content::PAGE_TRANSITION_TYPED, false); 4056 content::PAGE_TRANSITION_TYPED, false);
4058 params.should_replace_current_entry = true; 4057 params.should_replace_current_entry = true;
4059 NavigateToURLWithParams(params, false); 4058 NavigateToURLWithParams(params, false);
4060 4059
4061 const NavigationController& controller = 4060 const NavigationController& controller =
4062 GetActiveWebContents()->GetController(); 4061 GetActiveWebContents()->GetController();
4063 // First entry is about:blank, second is prerender_page.html. 4062 // First entry is about:blank, second is prerender_page.html.
4064 EXPECT_TRUE(controller.GetPendingEntry() == NULL); 4063 EXPECT_TRUE(controller.GetPendingEntry() == NULL);
4065 EXPECT_EQ(2, controller.GetEntryCount()); 4064 EXPECT_EQ(2, controller.GetEntryCount());
4066 EXPECT_EQ(GURL(content::kAboutBlankURL), 4065 EXPECT_EQ(GURL(url::kAboutBlankURL), controller.GetEntryAtIndex(0)->GetURL());
4067 controller.GetEntryAtIndex(0)->GetURL());
4068 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL()); 4066 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL());
4069 } 4067 }
4070 4068
4071 // Checks prerender does not hit DCHECKs and behaves properly if two pending 4069 // Checks prerender does not hit DCHECKs and behaves properly if two pending
4072 // swaps occur in a row. 4070 // swaps occur in a row.
4073 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDoublePendingSwap) { 4071 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDoublePendingSwap) {
4074 GetPrerenderManager()->mutable_config().max_link_concurrency = 2; 4072 GetPrerenderManager()->mutable_config().max_link_concurrency = 2;
4075 GetPrerenderManager()->mutable_config().max_link_concurrency_per_launcher = 2; 4073 GetPrerenderManager()->mutable_config().max_link_concurrency_per_launcher = 2;
4076 4074
4077 GURL url1 = test_server()->GetURL("files/prerender/prerender_page.html?1"); 4075 GURL url1 = test_server()->GetURL("files/prerender/prerender_page.html?1");
4078 scoped_ptr<TestPrerender> prerender1 = 4076 scoped_ptr<TestPrerender> prerender1 =
4079 PrerenderTestURL(url1, FINAL_STATUS_APP_TERMINATING, 1); 4077 PrerenderTestURL(url1, FINAL_STATUS_APP_TERMINATING, 1);
4080 4078
4081 GURL url2 = test_server()->GetURL("files/prerender/prerender_page.html?2"); 4079 GURL url2 = test_server()->GetURL("files/prerender/prerender_page.html?2");
4082 scoped_ptr<TestPrerender> prerender2 = ExpectPrerender(FINAL_STATUS_USED); 4080 scoped_ptr<TestPrerender> prerender2 = ExpectPrerender(FINAL_STATUS_USED);
4083 AddPrerender(url2, 1); 4081 AddPrerender(url2, 1);
4084 prerender2->WaitForStart(); 4082 prerender2->WaitForStart();
4085 prerender2->WaitForLoads(1); 4083 prerender2->WaitForLoads(1);
4086 4084
4087 // There's no reason the second prerender can't be used, but the swap races 4085 // There's no reason the second prerender can't be used, but the swap races
4088 // with didStartProvisionalLoad and didFailProvisionalLoad from the previous 4086 // with didStartProvisionalLoad and didFailProvisionalLoad from the previous
4089 // navigation. The current logic will conservatively fail to swap under such 4087 // navigation. The current logic will conservatively fail to swap under such
4090 // races. However, if the renderer is slow enough, it's possible for the 4088 // races. However, if the renderer is slow enough, it's possible for the
4091 // prerender to still be used, so don't program in either expectation. 4089 // prerender to still be used, so don't program in either expectation.
4092 ASSERT_TRUE(prerender2->contents()); 4090 ASSERT_TRUE(prerender2->contents());
4093 prerender2->contents()->set_skip_final_checks(true); 4091 prerender2->contents()->set_skip_final_checks(true);
4094 4092
4095 // Open a new tab to navigate in. 4093 // Open a new tab to navigate in.
4096 ui_test_utils::NavigateToURLWithDisposition( 4094 ui_test_utils::NavigateToURLWithDisposition(
4097 current_browser(), GURL(content::kAboutBlankURL), NEW_FOREGROUND_TAB, 4095 current_browser(),
4096 GURL(url::kAboutBlankURL),
4097 NEW_FOREGROUND_TAB,
4098 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 4098 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
4099 4099
4100 // Fire off two navigations, without running the event loop between them. 4100 // Fire off two navigations, without running the event loop between them.
4101 NavigationOrSwapObserver swap_observer( 4101 NavigationOrSwapObserver swap_observer(
4102 current_browser()->tab_strip_model(), 4102 current_browser()->tab_strip_model(),
4103 GetActiveWebContents(), 2); 4103 GetActiveWebContents(), 2);
4104 current_browser()->OpenURL(OpenURLParams( 4104 current_browser()->OpenURL(OpenURLParams(
4105 url1, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 4105 url1, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
4106 current_browser()->OpenURL(OpenURLParams( 4106 current_browser()->OpenURL(OpenURLParams(
4107 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 4107 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
4108 swap_observer.Wait(); 4108 swap_observer.Wait();
4109 4109
4110 // The WebContents should be on url2. There may be 2 or 3 entries, depending 4110 // The WebContents should be on url2. There may be 2 or 3 entries, depending
4111 // on whether the first one managed to complete. 4111 // on whether the first one managed to complete.
4112 // 4112 //
4113 // TODO(davidben): When http://crbug.com/335835 is fixed, the 3 entry case 4113 // TODO(davidben): When http://crbug.com/335835 is fixed, the 3 entry case
4114 // shouldn't be possible because it's throttled by the pending swap that 4114 // shouldn't be possible because it's throttled by the pending swap that
4115 // cannot complete. 4115 // cannot complete.
4116 const NavigationController& controller = 4116 const NavigationController& controller =
4117 GetActiveWebContents()->GetController(); 4117 GetActiveWebContents()->GetController();
4118 EXPECT_TRUE(controller.GetPendingEntry() == NULL); 4118 EXPECT_TRUE(controller.GetPendingEntry() == NULL);
4119 EXPECT_LE(2, controller.GetEntryCount()); 4119 EXPECT_LE(2, controller.GetEntryCount());
4120 EXPECT_GE(3, controller.GetEntryCount()); 4120 EXPECT_GE(3, controller.GetEntryCount());
4121 EXPECT_EQ(GURL(content::kAboutBlankURL), 4121 EXPECT_EQ(GURL(url::kAboutBlankURL), controller.GetEntryAtIndex(0)->GetURL());
4122 controller.GetEntryAtIndex(0)->GetURL());
4123 EXPECT_EQ(url2, controller.GetEntryAtIndex( 4122 EXPECT_EQ(url2, controller.GetEntryAtIndex(
4124 controller.GetEntryCount() - 1)->GetURL()); 4123 controller.GetEntryCount() - 1)->GetURL());
4125 } 4124 }
4126 4125
4127 // Verify that pending swaps get aborted on new navigations. 4126 // Verify that pending swaps get aborted on new navigations.
4128 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 4127 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
4129 PrerenderPendingSwapNewNavigation) { 4128 PrerenderPendingSwapNewNavigation) {
4130 PrerenderManager::HangSessionStorageMergesForTesting(); 4129 PrerenderManager::HangSessionStorageMergesForTesting();
4131 4130
4132 PrerenderTestURL("files/prerender/prerender_page.html", 4131 PrerenderTestURL("files/prerender/prerender_page.html",
4133 FINAL_STATUS_APP_TERMINATING, 1); 4132 FINAL_STATUS_APP_TERMINATING, 1);
4134 4133
4135 // Open a new tab to navigate in. 4134 // Open a new tab to navigate in.
4136 ui_test_utils::NavigateToURLWithDisposition( 4135 ui_test_utils::NavigateToURLWithDisposition(
4137 current_browser(), GURL(content::kAboutBlankURL), NEW_FOREGROUND_TAB, 4136 current_browser(),
4137 GURL(url::kAboutBlankURL),
4138 NEW_FOREGROUND_TAB,
4138 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 4139 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
4139 4140
4140 // Navigate to the URL. Wait for DidStartLoading, just so it's definitely 4141 // Navigate to the URL. Wait for DidStartLoading, just so it's definitely
4141 // progressed somewhere. 4142 // progressed somewhere.
4142 content::WindowedNotificationObserver page_load_observer( 4143 content::WindowedNotificationObserver page_load_observer(
4143 content::NOTIFICATION_LOAD_START, 4144 content::NOTIFICATION_LOAD_START,
4144 content::Source<NavigationController>( 4145 content::Source<NavigationController>(
4145 &GetActiveWebContents()->GetController())); 4146 &GetActiveWebContents()->GetController()));
4146 current_browser()->OpenURL(OpenURLParams( 4147 current_browser()->OpenURL(OpenURLParams(
4147 dest_url(), Referrer(), CURRENT_TAB, 4148 dest_url(), Referrer(), CURRENT_TAB,
4148 content::PAGE_TRANSITION_TYPED, false)); 4149 content::PAGE_TRANSITION_TYPED, false));
4149 page_load_observer.Wait(); 4150 page_load_observer.Wait();
4150 4151
4151 // Navigate somewhere else. This should succeed and abort the pending swap. 4152 // Navigate somewhere else. This should succeed and abort the pending swap.
4152 TestNavigationObserver nav_observer(GetActiveWebContents()); 4153 TestNavigationObserver nav_observer(GetActiveWebContents());
4153 current_browser()->OpenURL(OpenURLParams( 4154 current_browser()->OpenURL(OpenURLParams(GURL(url::kAboutBlankURL),
4154 GURL(content::kAboutBlankURL), Referrer(), CURRENT_TAB, 4155 Referrer(),
4155 content::PAGE_TRANSITION_TYPED, false)); 4156 CURRENT_TAB,
4157 content::PAGE_TRANSITION_TYPED,
4158 false));
4156 nav_observer.Wait(); 4159 nav_observer.Wait();
4157 } 4160 }
4158 4161
4159 // Checks that <a ping> requests are not dropped in prerender. 4162 // Checks that <a ping> requests are not dropped in prerender.
4160 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPing) { 4163 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPing) {
4161 // Count hits to a certain URL. 4164 // Count hits to a certain URL.
4162 const GURL kPingURL("http://prerender.test/ping"); 4165 const GURL kPingURL("http://prerender.test/ping");
4163 base::FilePath empty_file = ui_test_utils::GetTestFilePath( 4166 base::FilePath empty_file = ui_test_utils::GetTestFilePath(
4164 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("empty.html"))); 4167 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("empty.html")));
4165 RequestCounter ping_counter; 4168 RequestCounter ping_counter;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
4407 4410
4408 // Navigate to the URL entered. 4411 // Navigate to the URL entered.
4409 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); 4412 omnibox_view->model()->AcceptInput(CURRENT_TAB, false);
4410 4413
4411 // Prerender should be running, but abandoned. 4414 // Prerender should be running, but abandoned.
4412 EXPECT_TRUE( 4415 EXPECT_TRUE(
4413 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); 4416 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting());
4414 } 4417 }
4415 4418
4416 } // namespace prerender 4419 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/browser/prerender/prerender_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698