OLD | NEW |
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 Loading... |
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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 | 1194 |
1194 void OpenDestURLViaClickNewBackgroundTab() const { | 1195 void OpenDestURLViaClickNewBackgroundTab() const { |
1195 #if defined(OS_MACOSX) | 1196 #if defined(OS_MACOSX) |
1196 OpenURLWithJSImpl("MetaClick", dest_url_, GURL(), true); | 1197 OpenURLWithJSImpl("MetaClick", dest_url_, GURL(), true); |
1197 #else | 1198 #else |
1198 OpenURLWithJSImpl("CtrlClick", dest_url_, GURL(), true); | 1199 OpenURLWithJSImpl("CtrlClick", dest_url_, GURL(), true); |
1199 #endif | 1200 #endif |
1200 } | 1201 } |
1201 | 1202 |
1202 void OpenDestURLViaWindowOpen() const { | 1203 void OpenDestURLViaWindowOpen() const { |
1203 OpenURLWithJSImpl("WindowOpen", dest_url_, GURL(), true); | 1204 OpenURLViaWindowOpen(dest_url_); |
| 1205 } |
| 1206 |
| 1207 void OpenURLViaWindowOpen(const GURL& url) const { |
| 1208 OpenURLWithJSImpl("WindowOpen", url, GURL(), true); |
1204 } | 1209 } |
1205 | 1210 |
1206 void RemoveLinkElement(int i) const { | 1211 void RemoveLinkElement(int i) const { |
1207 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScript( | 1212 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScript( |
1208 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i))); | 1213 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i))); |
1209 } | 1214 } |
1210 | 1215 |
1211 void ClickToNextPageAfterPrerender() { | 1216 void ClickToNextPageAfterPrerender() { |
1212 TestNavigationObserver nav_observer(GetActiveWebContents()); | 1217 TestNavigationObserver nav_observer(GetActiveWebContents()); |
1213 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame(); | 1218 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame(); |
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2848 // Checks that we cancel correctly when window.print() is called. | 2853 // Checks that we cancel correctly when window.print() is called. |
2849 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) { | 2854 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) { |
2850 DisableLoadEventCheck(); | 2855 DisableLoadEventCheck(); |
2851 PrerenderTestURL("files/prerender/prerender_print.html", | 2856 PrerenderTestURL("files/prerender/prerender_print.html", |
2852 FINAL_STATUS_WINDOW_PRINT, | 2857 FINAL_STATUS_WINDOW_PRINT, |
2853 0); | 2858 0); |
2854 } | 2859 } |
2855 | 2860 |
2856 // Checks that if a page is opened in a new window by javascript and both the | 2861 // Checks that if a page is opened in a new window by javascript and both the |
2857 // pages are in the same domain, the prerendered page is not used, due to | 2862 // pages are in the same domain, the prerendered page is not used, due to |
2858 // window.opener. | 2863 // there being other tabs in the same browsing instance. |
2859 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2864 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2860 PrerenderSameDomainWindowOpenerWindowOpen) { | 2865 PrerenderSameDomainWindowOpenerWindowOpen) { |
2861 PrerenderTestURL("files/prerender/prerender_page.html", | 2866 PrerenderTestURL("files/prerender/prerender_page.html", |
2862 FINAL_STATUS_WINDOW_OPENER, | 2867 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE, |
2863 1); | 2868 1); |
2864 OpenDestURLViaWindowOpen(); | 2869 OpenDestURLViaWindowOpen(); |
2865 } | 2870 } |
2866 | 2871 |
2867 // Checks that if a page is opened due to click on a href with target="_blank" | 2872 // Checks that if a page is opened due to click on a href with target="_blank" |
2868 // and both pages are in the same domain the prerendered page is not used, due | 2873 // and both pages are in the same domain the prerendered page is not used, due |
2869 // to window.opener. | 2874 // there being other tabs in the same browsing instance. |
2870 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2875 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2871 PrerenderSameDomainWindowOpenerClickTarget) { | 2876 PrerenderSameDomainWindowOpenerClickTarget) { |
2872 PrerenderTestURL("files/prerender/prerender_page.html", | 2877 PrerenderTestURL("files/prerender/prerender_page.html", |
2873 FINAL_STATUS_WINDOW_OPENER, | 2878 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE, |
2874 1); | 2879 1); |
2875 OpenDestURLViaClickTarget(); | 2880 OpenDestURLViaClickTarget(); |
2876 } | 2881 } |
2877 | 2882 |
| 2883 // Checks that prerenders do not get swapped into target pages that have opened |
| 2884 // a popup, even if the target page itself does not have an opener. |
| 2885 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTargetHasPopup) { |
| 2886 PrerenderTestURL("files/prerender/prerender_page.html", |
| 2887 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE, |
| 2888 1); |
| 2889 OpenURLViaWindowOpen(GURL(content::kAboutBlankURL)); |
| 2890 NavigateToDestURLWithDisposition(CURRENT_TAB, false); |
| 2891 } |
| 2892 |
2878 class TestClientCertStore : public net::ClientCertStore { | 2893 class TestClientCertStore : public net::ClientCertStore { |
2879 public: | 2894 public: |
2880 TestClientCertStore() {} | 2895 TestClientCertStore() {} |
2881 virtual ~TestClientCertStore() {} | 2896 virtual ~TestClientCertStore() {} |
2882 | 2897 |
2883 // net::ClientCertStore: | 2898 // net::ClientCertStore: |
2884 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, | 2899 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, |
2885 net::CertificateList* selected_certs, | 2900 net::CertificateList* selected_certs, |
2886 const base::Closure& callback) OVERRIDE { | 2901 const base::Closure& callback) OVERRIDE { |
2887 *selected_certs = net::CertificateList( | 2902 *selected_certs = net::CertificateList( |
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4262 | 4277 |
4263 // Navigate to the URL entered. | 4278 // Navigate to the URL entered. |
4264 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); | 4279 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); |
4265 | 4280 |
4266 // Prerender should be running, but abandoned. | 4281 // Prerender should be running, but abandoned. |
4267 EXPECT_TRUE( | 4282 EXPECT_TRUE( |
4268 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); | 4283 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); |
4269 } | 4284 } |
4270 | 4285 |
4271 } // namespace prerender | 4286 } // namespace prerender |
OLD | NEW |