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

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

Issue 257083002: Check BrowsingInstance before swapping prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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 | « no previous file | chrome/browser/prerender/prerender_final_status.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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 case FINAL_STATUS_APP_TERMINATING: 159 case FINAL_STATUS_APP_TERMINATING:
160 case FINAL_STATUS_PROFILE_DESTROYED: 160 case FINAL_STATUS_PROFILE_DESTROYED:
161 case FINAL_STATUS_CACHE_OR_HISTORY_CLEARED: 161 case FINAL_STATUS_CACHE_OR_HISTORY_CLEARED:
162 // We'll crash the renderer after it's loaded. 162 // We'll crash the renderer after it's loaded.
163 case FINAL_STATUS_RENDERER_CRASHED: 163 case FINAL_STATUS_RENDERER_CRASHED:
164 case FINAL_STATUS_CANCELLED: 164 case FINAL_STATUS_CANCELLED:
165 case FINAL_STATUS_DEVTOOLS_ATTACHED: 165 case FINAL_STATUS_DEVTOOLS_ATTACHED:
166 case FINAL_STATUS_PAGE_BEING_CAPTURED: 166 case FINAL_STATUS_PAGE_BEING_CAPTURED:
167 case FINAL_STATUS_NAVIGATION_UNCOMMITTED: 167 case FINAL_STATUS_NAVIGATION_UNCOMMITTED:
168 case FINAL_STATUS_WOULD_HAVE_BEEN_USED: 168 case FINAL_STATUS_WOULD_HAVE_BEEN_USED:
169 case FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE:
169 return false; 170 return false;
170 default: 171 default:
171 return true; 172 return true;
172 } 173 }
173 } 174 }
174 175
175 // Convenience function to wait for a title. Handles the case when the 176 // Convenience function to wait for a title. Handles the case when the
176 // WebContents already has the expected title. 177 // WebContents already has the expected title.
177 void WaitForASCIITitle(WebContents* web_contents, 178 void WaitForASCIITitle(WebContents* web_contents,
178 const char* expected_title_ascii) { 179 const char* expected_title_ascii) {
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 1200
1200 void OpenDestURLViaClickNewBackgroundTab() const { 1201 void OpenDestURLViaClickNewBackgroundTab() const {
1201 #if defined(OS_MACOSX) 1202 #if defined(OS_MACOSX)
1202 OpenURLWithJSImpl("MetaClick", dest_url_, GURL(), true); 1203 OpenURLWithJSImpl("MetaClick", dest_url_, GURL(), true);
1203 #else 1204 #else
1204 OpenURLWithJSImpl("CtrlClick", dest_url_, GURL(), true); 1205 OpenURLWithJSImpl("CtrlClick", dest_url_, GURL(), true);
1205 #endif 1206 #endif
1206 } 1207 }
1207 1208
1208 void OpenDestURLViaWindowOpen() const { 1209 void OpenDestURLViaWindowOpen() const {
1209 OpenURLWithJSImpl("WindowOpen", dest_url_, GURL(), true); 1210 OpenURLViaWindowOpen(dest_url_);
1211 }
1212
1213 void OpenURLViaWindowOpen(const GURL& url) const {
1214 OpenURLWithJSImpl("WindowOpen", url, GURL(), true);
1210 } 1215 }
1211 1216
1212 void RemoveLinkElement(int i) const { 1217 void RemoveLinkElement(int i) const {
1213 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScript( 1218 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScript(
1214 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i))); 1219 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i)));
1215 } 1220 }
1216 1221
1217 void ClickToNextPageAfterPrerender() { 1222 void ClickToNextPageAfterPrerender() {
1218 TestNavigationObserver nav_observer(GetActiveWebContents()); 1223 TestNavigationObserver nav_observer(GetActiveWebContents());
1219 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame(); 1224 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame();
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after
2870 // Checks that we cancel correctly when window.print() is called. 2875 // Checks that we cancel correctly when window.print() is called.
2871 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) { 2876 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) {
2872 DisableLoadEventCheck(); 2877 DisableLoadEventCheck();
2873 PrerenderTestURL("files/prerender/prerender_print.html", 2878 PrerenderTestURL("files/prerender/prerender_print.html",
2874 FINAL_STATUS_WINDOW_PRINT, 2879 FINAL_STATUS_WINDOW_PRINT,
2875 0); 2880 0);
2876 } 2881 }
2877 2882
2878 // Checks that if a page is opened in a new window by javascript and both the 2883 // Checks that if a page is opened in a new window by javascript and both the
2879 // pages are in the same domain, the prerendered page is not used, due to 2884 // pages are in the same domain, the prerendered page is not used, due to
2880 // window.opener. 2885 // there being other tabs in the same browsing instance.
2881 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 2886 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
2882 PrerenderSameDomainWindowOpenerWindowOpen) { 2887 PrerenderSameDomainWindowOpenerWindowOpen) {
2883 PrerenderTestURL("files/prerender/prerender_page.html", 2888 PrerenderTestURL("files/prerender/prerender_page.html",
2884 FINAL_STATUS_WINDOW_OPENER, 2889 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE,
2885 1); 2890 1);
2886 OpenDestURLViaWindowOpen(); 2891 OpenDestURLViaWindowOpen();
2887 } 2892 }
2888 2893
2889 // Checks that if a page is opened due to click on a href with target="_blank" 2894 // Checks that if a page is opened due to click on a href with target="_blank"
2890 // and both pages are in the same domain the prerendered page is not used, due 2895 // and both pages are in the same domain the prerendered page is not used, due
2891 // to window.opener. 2896 // there being other tabs in the same browsing instance.
2892 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 2897 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
2893 PrerenderSameDomainWindowOpenerClickTarget) { 2898 PrerenderSameDomainWindowOpenerClickTarget) {
2894 PrerenderTestURL("files/prerender/prerender_page.html", 2899 PrerenderTestURL("files/prerender/prerender_page.html",
2895 FINAL_STATUS_WINDOW_OPENER, 2900 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE,
2896 1); 2901 1);
2897 OpenDestURLViaClickTarget(); 2902 OpenDestURLViaClickTarget();
2898 } 2903 }
2899 2904
2905 // Checks that prerenders do not get swapped into target pages that have opened
2906 // a popup, even if the target page itself does not have an opener.
2907 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTargetHasPopup) {
2908 PrerenderTestURL("files/prerender/prerender_page.html",
2909 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE,
2910 1);
2911 OpenURLViaWindowOpen(GURL(content::kAboutBlankURL));
2912 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
2913 }
2914
2900 class TestClientCertStore : public net::ClientCertStore { 2915 class TestClientCertStore : public net::ClientCertStore {
2901 public: 2916 public:
2902 TestClientCertStore() {} 2917 TestClientCertStore() {}
2903 virtual ~TestClientCertStore() {} 2918 virtual ~TestClientCertStore() {}
2904 2919
2905 // net::ClientCertStore: 2920 // net::ClientCertStore:
2906 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, 2921 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info,
2907 net::CertificateList* selected_certs, 2922 net::CertificateList* selected_certs,
2908 const base::Closure& callback) OVERRIDE { 2923 const base::Closure& callback) OVERRIDE {
2909 *selected_certs = net::CertificateList( 2924 *selected_certs = net::CertificateList(
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after
4397 4412
4398 // Navigate to the URL entered. 4413 // Navigate to the URL entered.
4399 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); 4414 omnibox_view->model()->AcceptInput(CURRENT_TAB, false);
4400 4415
4401 // Prerender should be running, but abandoned. 4416 // Prerender should be running, but abandoned.
4402 EXPECT_TRUE( 4417 EXPECT_TRUE(
4403 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); 4418 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting());
4404 } 4419 }
4405 4420
4406 } // namespace prerender 4421 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_final_status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698