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

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: 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
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 case FINAL_STATUS_APP_TERMINATING: 150 case FINAL_STATUS_APP_TERMINATING:
151 case FINAL_STATUS_PROFILE_DESTROYED: 151 case FINAL_STATUS_PROFILE_DESTROYED:
152 case FINAL_STATUS_CACHE_OR_HISTORY_CLEARED: 152 case FINAL_STATUS_CACHE_OR_HISTORY_CLEARED:
153 // We'll crash the renderer after it's loaded. 153 // We'll crash the renderer after it's loaded.
154 case FINAL_STATUS_RENDERER_CRASHED: 154 case FINAL_STATUS_RENDERER_CRASHED:
155 case FINAL_STATUS_CANCELLED: 155 case FINAL_STATUS_CANCELLED:
156 case FINAL_STATUS_DEVTOOLS_ATTACHED: 156 case FINAL_STATUS_DEVTOOLS_ATTACHED:
157 case FINAL_STATUS_PAGE_BEING_CAPTURED: 157 case FINAL_STATUS_PAGE_BEING_CAPTURED:
158 case FINAL_STATUS_NAVIGATION_UNCOMMITTED: 158 case FINAL_STATUS_NAVIGATION_UNCOMMITTED:
159 case FINAL_STATUS_WOULD_HAVE_BEEN_USED: 159 case FINAL_STATUS_WOULD_HAVE_BEEN_USED:
160 case FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE:
160 return false; 161 return false;
161 default: 162 default:
162 return true; 163 return true;
163 } 164 }
164 } 165 }
165 166
166 // Convenience function to wait for a title. Handles the case when the 167 // Convenience function to wait for a title. Handles the case when the
167 // WebContents already has the expected title. 168 // WebContents already has the expected title.
168 void WaitForASCIITitle(WebContents* web_contents, 169 void WaitForASCIITitle(WebContents* web_contents,
169 const char* expected_title_ascii) { 170 const char* expected_title_ascii) {
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 1185
1185 void OpenDestURLViaClickNewBackgroundTab() const { 1186 void OpenDestURLViaClickNewBackgroundTab() const {
1186 #if defined(OS_MACOSX) 1187 #if defined(OS_MACOSX)
1187 OpenURLWithJSImpl("MetaClick", dest_url_, GURL(), true); 1188 OpenURLWithJSImpl("MetaClick", dest_url_, GURL(), true);
1188 #else 1189 #else
1189 OpenURLWithJSImpl("CtrlClick", dest_url_, GURL(), true); 1190 OpenURLWithJSImpl("CtrlClick", dest_url_, GURL(), true);
1190 #endif 1191 #endif
1191 } 1192 }
1192 1193
1193 void OpenDestURLViaWindowOpen() const { 1194 void OpenDestURLViaWindowOpen() const {
1194 OpenURLWithJSImpl("WindowOpen", dest_url_, GURL(), true); 1195 OpenURLViaWindowOpen(dest_url_);
1196 }
1197
1198 void OpenURLViaWindowOpen(const GURL& url) const {
1199 OpenURLWithJSImpl("WindowOpen", url, GURL(), true);
1195 } 1200 }
1196 1201
1197 void RemoveLinkElement(int i) const { 1202 void RemoveLinkElement(int i) const {
1198 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScript( 1203 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScript(
1199 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i))); 1204 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i)));
1200 } 1205 }
1201 1206
1202 void ClickToNextPageAfterPrerender() { 1207 void ClickToNextPageAfterPrerender() {
1203 TestNavigationObserver nav_observer(GetActiveWebContents()); 1208 TestNavigationObserver nav_observer(GetActiveWebContents());
1204 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame(); 1209 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame();
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 2843
2839 // Checks that we cancel correctly when window.print() is called. 2844 // Checks that we cancel correctly when window.print() is called.
2840 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) { 2845 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) {
2841 PrerenderTestURL("files/prerender/prerender_print.html", 2846 PrerenderTestURL("files/prerender/prerender_print.html",
2842 FINAL_STATUS_WINDOW_PRINT, 2847 FINAL_STATUS_WINDOW_PRINT,
2843 0); 2848 0);
2844 } 2849 }
2845 2850
2846 // Checks that if a page is opened in a new window by javascript and both the 2851 // Checks that if a page is opened in a new window by javascript and both the
2847 // pages are in the same domain, the prerendered page is not used, due to 2852 // pages are in the same domain, the prerendered page is not used, due to
2848 // window.opener. 2853 // there being other tabs in the same browsing instance.
2849 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 2854 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
2850 PrerenderSameDomainWindowOpenerWindowOpen) { 2855 PrerenderSameDomainWindowOpenerWindowOpen) {
2851 PrerenderTestURL("files/prerender/prerender_page.html", 2856 PrerenderTestURL("files/prerender/prerender_page.html",
2852 FINAL_STATUS_WINDOW_OPENER, 2857 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE,
2853 1); 2858 1);
2854 OpenDestURLViaWindowOpen(); 2859 OpenDestURLViaWindowOpen();
2855 } 2860 }
2856 2861
2857 // Checks that if a page is opened due to click on a href with target="_blank" 2862 // Checks that if a page is opened due to click on a href with target="_blank"
2858 // and both pages are in the same domain the prerendered page is not used, due 2863 // and both pages are in the same domain the prerendered page is not used, due
2859 // to window.opener. 2864 // there being other tabs in the same browsing instance.
2860 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 2865 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
2861 PrerenderSameDomainWindowOpenerClickTarget) { 2866 PrerenderSameDomainWindowOpenerClickTarget) {
2862 PrerenderTestURL("files/prerender/prerender_page.html", 2867 PrerenderTestURL("files/prerender/prerender_page.html",
2863 FINAL_STATUS_WINDOW_OPENER, 2868 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE,
2864 1); 2869 1);
2865 OpenDestURLViaClickTarget(); 2870 OpenDestURLViaClickTarget();
2866 } 2871 }
2867 2872
2873 // Checks that prerenders do not get swapped into target pages that have opened
2874 // a popup, even if the target page itself does not have an opener.
2875 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTargetHasPopup) {
2876 PrerenderTestURL("files/prerender/prerender_page.html",
2877 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE,
2878 1);
2879 OpenURLViaWindowOpen(GURL(content::kAboutBlankURL));
2880 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
2881 }
2882
2868 class TestClientCertStore : public net::ClientCertStore { 2883 class TestClientCertStore : public net::ClientCertStore {
2869 public: 2884 public:
2870 TestClientCertStore() {} 2885 TestClientCertStore() {}
2871 virtual ~TestClientCertStore() {} 2886 virtual ~TestClientCertStore() {}
2872 2887
2873 // net::ClientCertStore: 2888 // net::ClientCertStore:
2874 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, 2889 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info,
2875 net::CertificateList* selected_certs, 2890 net::CertificateList* selected_certs,
2876 const base::Closure& callback) OVERRIDE { 2891 const base::Closure& callback) OVERRIDE {
2877 *selected_certs = net::CertificateList( 2892 *selected_certs = net::CertificateList(
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
4169 IN_PROC_BROWSER_TEST_F(PrerenderIncognitoBrowserTest, 4184 IN_PROC_BROWSER_TEST_F(PrerenderIncognitoBrowserTest,
4170 PrerenderIncognitoClosed) { 4185 PrerenderIncognitoClosed) {
4171 scoped_ptr<TestPrerender> prerender = 4186 scoped_ptr<TestPrerender> prerender =
4172 PrerenderTestURL("files/prerender/prerender_page.html", 4187 PrerenderTestURL("files/prerender/prerender_page.html",
4173 FINAL_STATUS_PROFILE_DESTROYED, 1); 4188 FINAL_STATUS_PROFILE_DESTROYED, 1);
4174 current_browser()->window()->Close(); 4189 current_browser()->window()->Close();
4175 prerender->WaitForStop(); 4190 prerender->WaitForStop();
4176 } 4191 }
4177 4192
4178 } // namespace prerender 4193 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_final_status.h » ('j') | chrome/browser/prerender/prerender_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698