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

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

Issue 49003011: Handle should_replace_current_entry in prerender. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: content::kAboutBlankURL Created 7 years 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
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_manager.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 <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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "chrome/common/chrome_switches.h" 47 #include "chrome/common/chrome_switches.h"
48 #include "chrome/common/extensions/extension_constants.h" 48 #include "chrome/common/extensions/extension_constants.h"
49 #include "chrome/common/pref_names.h" 49 #include "chrome/common/pref_names.h"
50 #include "chrome/test/base/in_process_browser_test.h" 50 #include "chrome/test/base/in_process_browser_test.h"
51 #include "chrome/test/base/test_switches.h" 51 #include "chrome/test/base/test_switches.h"
52 #include "chrome/test/base/ui_test_utils.h" 52 #include "chrome/test/base/ui_test_utils.h"
53 #include "content/public/browser/browser_message_filter.h" 53 #include "content/public/browser/browser_message_filter.h"
54 #include "content/public/browser/devtools_agent_host.h" 54 #include "content/public/browser/devtools_agent_host.h"
55 #include "content/public/browser/devtools_client_host.h" 55 #include "content/public/browser/devtools_client_host.h"
56 #include "content/public/browser/devtools_manager.h" 56 #include "content/public/browser/devtools_manager.h"
57 #include "content/public/browser/navigation_controller.h"
58 #include "content/public/browser/navigation_entry.h"
57 #include "content/public/browser/notification_service.h" 59 #include "content/public/browser/notification_service.h"
58 #include "content/public/browser/render_process_host.h" 60 #include "content/public/browser/render_process_host.h"
59 #include "content/public/browser/render_view_host.h" 61 #include "content/public/browser/render_view_host.h"
60 #include "content/public/browser/site_instance.h" 62 #include "content/public/browser/site_instance.h"
61 #include "content/public/browser/web_contents.h" 63 #include "content/public/browser/web_contents.h"
62 #include "content/public/common/url_constants.h" 64 #include "content/public/common/url_constants.h"
63 #include "content/public/test/browser_test_utils.h" 65 #include "content/public/test/browser_test_utils.h"
64 #include "content/public/test/test_navigation_observer.h" 66 #include "content/public/test/test_navigation_observer.h"
65 #include "content/public/test/test_utils.h" 67 #include "content/public/test/test_utils.h"
66 #include "content/test/net/url_request_mock_http_job.h" 68 #include "content/test/net/url_request_mock_http_job.h"
(...skipping 27 matching lines...) Expand all
94 // 96 //
95 // The prerendered page is then displayed on a tab. The Javascript function 97 // The prerendered page is then displayed on a tab. The Javascript function
96 // DidDisplayPass() is called, and returns true if the page behaved as it 98 // DidDisplayPass() is called, and returns true if the page behaved as it
97 // should while being displayed. 99 // should while being displayed.
98 100
99 namespace prerender { 101 namespace prerender {
100 102
101 namespace { 103 namespace {
102 104
103 // Constants used in the test HTML files. 105 // Constants used in the test HTML files.
104 static const char* kReadyTitle = "READY"; 106 const char* kReadyTitle = "READY";
105 static const char* kPassTitle = "PASS"; 107 const char* kPassTitle = "PASS";
106 108
107 std::string CreateClientRedirect(const std::string& dest_url) { 109 std::string CreateClientRedirect(const std::string& dest_url) {
108 const char* const kClientRedirectBase = "client-redirect?"; 110 const char* const kClientRedirectBase = "client-redirect?";
109 return kClientRedirectBase + net::EscapeQueryParamValue(dest_url, false); 111 return kClientRedirectBase + net::EscapeQueryParamValue(dest_url, false);
110 } 112 }
111 113
112 std::string CreateServerRedirect(const std::string& dest_url) { 114 std::string CreateServerRedirect(const std::string& dest_url) {
113 const char* const kServerRedirectBase = "server-redirect?"; 115 const char* const kServerRedirectBase = "server-redirect?";
114 return kServerRedirectBase + net::EscapeQueryParamValue(dest_url, false); 116 return kServerRedirectBase + net::EscapeQueryParamValue(dest_url, false);
115 } 117 }
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 false); 824 false);
823 } 825 }
824 826
825 void NavigateToDestURL() const { 827 void NavigateToDestURL() const {
826 NavigateToDestURLWithDisposition(CURRENT_TAB, true); 828 NavigateToDestURLWithDisposition(CURRENT_TAB, true);
827 } 829 }
828 830
829 void NavigateToDestURLInNewTab() const { 831 void NavigateToDestURLInNewTab() const {
830 // First, open a new tab. 832 // First, open a new tab.
831 current_browser()->OpenURL( 833 current_browser()->OpenURL(
832 content::OpenURLParams(GURL("chrome://blank"), Referrer(), 834 content::OpenURLParams(GURL(content::kAboutBlankURL), Referrer(),
833 NEW_FOREGROUND_TAB, 835 NEW_FOREGROUND_TAB,
834 content::PAGE_TRANSITION_TYPED, false)); 836 content::PAGE_TRANSITION_TYPED, false));
835 // Next, navigate to the destination URL. The swap-in will not succeed, 837 // Next, navigate to the destination URL. The swap-in will not succeed,
836 // due to session storage namespace mismatch. The merge is only kicked off 838 // due to session storage namespace mismatch. The merge is only kicked off
837 // asynchronously. 839 // asynchronously.
838 NavigateToDestURLWithDisposition(CURRENT_TAB, false); 840 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
839 // Run the message loop, waiting for the merge to complete, the swapin to 841 // Run the message loop, waiting for the merge to complete, the swapin to
840 // be reattempted, and to eventually succeed. 842 // be reattempted, and to eventually succeed.
841 content::RunMessageLoop(); 843 content::RunMessageLoop();
842 } 844 }
(...skipping 2498 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 1); 3343 1);
3342 } 3344 }
3343 3345
3344 // Attempt a swap-in in a new tab, verifying that session storage namespace 3346 // Attempt a swap-in in a new tab, verifying that session storage namespace
3345 // merging works. 3347 // merging works.
3346 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageNewTab) { 3348 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageNewTab) {
3347 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); 3349 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
3348 NavigateToDestURLInNewTab(); 3350 NavigateToDestURLInNewTab();
3349 } 3351 }
3350 3352
3353 // Checks that prerenders honor |should_replace_current_entry|.
3354 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReplaceCurrentEntry) {
3355 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
3356
3357 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB,
3358 content::PAGE_TRANSITION_TYPED, false);
3359 params.should_replace_current_entry = true;
3360 NavigateToURLWithParams(params, false);
3361
3362 WebContents* web_contents =
3363 current_browser()->tab_strip_model()->GetActiveWebContents();
3364 const NavigationController& controller = web_contents->GetController();
3365 // First entry is about:blank, second is prerender_page.html.
3366 EXPECT_TRUE(controller.GetPendingEntry() == NULL);
3367 EXPECT_EQ(2, controller.GetEntryCount());
3368 EXPECT_EQ(GURL(content::kAboutBlankURL),
3369 controller.GetEntryAtIndex(0)->GetURL());
3370 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL());
3371 }
3372
3351 } // namespace prerender 3373 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698