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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 case FINAL_STATUS_APP_TERMINATING: | 156 case FINAL_STATUS_APP_TERMINATING: |
157 case FINAL_STATUS_PROFILE_DESTROYED: | 157 case FINAL_STATUS_PROFILE_DESTROYED: |
158 case FINAL_STATUS_CACHE_OR_HISTORY_CLEARED: | 158 case FINAL_STATUS_CACHE_OR_HISTORY_CLEARED: |
159 // We'll crash the renderer after it's loaded. | 159 // We'll crash the renderer after it's loaded. |
160 case FINAL_STATUS_RENDERER_CRASHED: | 160 case FINAL_STATUS_RENDERER_CRASHED: |
161 case FINAL_STATUS_CANCELLED: | 161 case FINAL_STATUS_CANCELLED: |
162 case FINAL_STATUS_DEVTOOLS_ATTACHED: | 162 case FINAL_STATUS_DEVTOOLS_ATTACHED: |
163 case FINAL_STATUS_PAGE_BEING_CAPTURED: | 163 case FINAL_STATUS_PAGE_BEING_CAPTURED: |
164 case FINAL_STATUS_NAVIGATION_UNCOMMITTED: | 164 case FINAL_STATUS_NAVIGATION_UNCOMMITTED: |
165 case FINAL_STATUS_WOULD_HAVE_BEEN_USED: | 165 case FINAL_STATUS_WOULD_HAVE_BEEN_USED: |
| 166 case FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE: |
166 return false; | 167 return false; |
167 default: | 168 default: |
168 return true; | 169 return true; |
169 } | 170 } |
170 } | 171 } |
171 | 172 |
172 // Convenience function to wait for a title. Handles the case when the | 173 // Convenience function to wait for a title. Handles the case when the |
173 // WebContents already has the expected title. | 174 // WebContents already has the expected title. |
174 void WaitForASCIITitle(WebContents* web_contents, | 175 void WaitForASCIITitle(WebContents* web_contents, |
175 const char* expected_title_ascii) { | 176 const char* expected_title_ascii) { |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 | 1191 |
1191 void OpenDestURLViaClickNewBackgroundTab() const { | 1192 void OpenDestURLViaClickNewBackgroundTab() const { |
1192 #if defined(OS_MACOSX) | 1193 #if defined(OS_MACOSX) |
1193 OpenURLWithJSImpl("MetaClick", dest_url_, GURL(), true); | 1194 OpenURLWithJSImpl("MetaClick", dest_url_, GURL(), true); |
1194 #else | 1195 #else |
1195 OpenURLWithJSImpl("CtrlClick", dest_url_, GURL(), true); | 1196 OpenURLWithJSImpl("CtrlClick", dest_url_, GURL(), true); |
1196 #endif | 1197 #endif |
1197 } | 1198 } |
1198 | 1199 |
1199 void OpenDestURLViaWindowOpen() const { | 1200 void OpenDestURLViaWindowOpen() const { |
1200 OpenURLWithJSImpl("WindowOpen", dest_url_, GURL(), true); | 1201 OpenURLViaWindowOpen(dest_url_); |
| 1202 } |
| 1203 |
| 1204 void OpenURLViaWindowOpen(const GURL& url) const { |
| 1205 OpenURLWithJSImpl("WindowOpen", url, GURL(), true); |
1201 } | 1206 } |
1202 | 1207 |
1203 void RemoveLinkElement(int i) const { | 1208 void RemoveLinkElement(int i) const { |
1204 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScript( | 1209 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScript( |
1205 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i))); | 1210 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i))); |
1206 } | 1211 } |
1207 | 1212 |
1208 void ClickToNextPageAfterPrerender() { | 1213 void ClickToNextPageAfterPrerender() { |
1209 TestNavigationObserver nav_observer(GetActiveWebContents()); | 1214 TestNavigationObserver nav_observer(GetActiveWebContents()); |
1210 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame(); | 1215 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame(); |
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2845 // Checks that we cancel correctly when window.print() is called. | 2850 // Checks that we cancel correctly when window.print() is called. |
2846 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) { | 2851 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) { |
2847 DisableLoadEventCheck(); | 2852 DisableLoadEventCheck(); |
2848 PrerenderTestURL("files/prerender/prerender_print.html", | 2853 PrerenderTestURL("files/prerender/prerender_print.html", |
2849 FINAL_STATUS_WINDOW_PRINT, | 2854 FINAL_STATUS_WINDOW_PRINT, |
2850 0); | 2855 0); |
2851 } | 2856 } |
2852 | 2857 |
2853 // Checks that if a page is opened in a new window by javascript and both the | 2858 // Checks that if a page is opened in a new window by javascript and both the |
2854 // pages are in the same domain, the prerendered page is not used, due to | 2859 // pages are in the same domain, the prerendered page is not used, due to |
2855 // window.opener. | 2860 // there being other tabs in the same browsing instance. |
2856 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2861 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2857 PrerenderSameDomainWindowOpenerWindowOpen) { | 2862 PrerenderSameDomainWindowOpenerWindowOpen) { |
2858 PrerenderTestURL("files/prerender/prerender_page.html", | 2863 PrerenderTestURL("files/prerender/prerender_page.html", |
2859 FINAL_STATUS_WINDOW_OPENER, | 2864 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE, |
2860 1); | 2865 1); |
2861 OpenDestURLViaWindowOpen(); | 2866 OpenDestURLViaWindowOpen(); |
2862 } | 2867 } |
2863 | 2868 |
2864 // Checks that if a page is opened due to click on a href with target="_blank" | 2869 // Checks that if a page is opened due to click on a href with target="_blank" |
2865 // and both pages are in the same domain the prerendered page is not used, due | 2870 // and both pages are in the same domain the prerendered page is not used, due |
2866 // to window.opener. | 2871 // there being other tabs in the same browsing instance. |
2867 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2872 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2868 PrerenderSameDomainWindowOpenerClickTarget) { | 2873 PrerenderSameDomainWindowOpenerClickTarget) { |
2869 PrerenderTestURL("files/prerender/prerender_page.html", | 2874 PrerenderTestURL("files/prerender/prerender_page.html", |
2870 FINAL_STATUS_WINDOW_OPENER, | 2875 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE, |
2871 1); | 2876 1); |
2872 OpenDestURLViaClickTarget(); | 2877 OpenDestURLViaClickTarget(); |
2873 } | 2878 } |
2874 | 2879 |
| 2880 // Checks that prerenders do not get swapped into target pages that have opened |
| 2881 // a popup, even if the target page itself does not have an opener. |
| 2882 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTargetHasPopup) { |
| 2883 PrerenderTestURL("files/prerender/prerender_page.html", |
| 2884 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE, |
| 2885 1); |
| 2886 OpenURLViaWindowOpen(GURL(content::kAboutBlankURL)); |
| 2887 NavigateToDestURLWithDisposition(CURRENT_TAB, false); |
| 2888 } |
| 2889 |
2875 class TestClientCertStore : public net::ClientCertStore { | 2890 class TestClientCertStore : public net::ClientCertStore { |
2876 public: | 2891 public: |
2877 TestClientCertStore() {} | 2892 TestClientCertStore() {} |
2878 virtual ~TestClientCertStore() {} | 2893 virtual ~TestClientCertStore() {} |
2879 | 2894 |
2880 // net::ClientCertStore: | 2895 // net::ClientCertStore: |
2881 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, | 2896 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, |
2882 net::CertificateList* selected_certs, | 2897 net::CertificateList* selected_certs, |
2883 const base::Closure& callback) OVERRIDE { | 2898 const base::Closure& callback) OVERRIDE { |
2884 *selected_certs = net::CertificateList( | 2899 *selected_certs = net::CertificateList( |
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4258 | 4273 |
4259 // Navigate to the URL entered. | 4274 // Navigate to the URL entered. |
4260 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); | 4275 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); |
4261 | 4276 |
4262 // Prerender should be running, but abandoned. | 4277 // Prerender should be running, but abandoned. |
4263 EXPECT_TRUE( | 4278 EXPECT_TRUE( |
4264 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); | 4279 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); |
4265 } | 4280 } |
4266 | 4281 |
4267 } // namespace prerender | 4282 } // namespace prerender |
OLD | NEW |