| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <deque> | 6 #include <deque> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 site_instance->GetBrowserContext()) | 505 site_instance->GetBrowserContext()) |
| 506 ->CancelAllPrerenders(); | 506 ->CancelAllPrerenders(); |
| 507 return ChromeContentBrowserClient::ShouldAllowOpenURL(site_instance, | 507 return ChromeContentBrowserClient::ShouldAllowOpenURL(site_instance, |
| 508 url); | 508 url); |
| 509 } | 509 } |
| 510 | 510 |
| 511 private: | 511 private: |
| 512 DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient); | 512 DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient); |
| 513 }; | 513 }; |
| 514 | 514 |
| 515 // A ContentBrowserClient that forces cross-process navigations. | |
| 516 class SwapProcessesContentBrowserClient : public ChromeContentBrowserClient { | |
| 517 public: | |
| 518 SwapProcessesContentBrowserClient() {} | |
| 519 ~SwapProcessesContentBrowserClient() override {} | |
| 520 | |
| 521 // ChromeContentBrowserClient: | |
| 522 bool ShouldSwapProcessesForRedirect( | |
| 523 content::BrowserContext* browser_context, | |
| 524 const GURL& current_url, | |
| 525 const GURL& new_url) override { | |
| 526 return true; | |
| 527 } | |
| 528 | |
| 529 private: | |
| 530 DISALLOW_COPY_AND_ASSIGN(SwapProcessesContentBrowserClient); | |
| 531 }; | |
| 532 | |
| 533 base::FilePath GetTestPath(const std::string& file_name) { | 515 base::FilePath GetTestPath(const std::string& file_name) { |
| 534 return ui_test_utils::GetTestFilePath( | 516 return ui_test_utils::GetTestFilePath( |
| 535 base::FilePath(FILE_PATH_LITERAL("prerender")), | 517 base::FilePath(FILE_PATH_LITERAL("prerender")), |
| 536 base::FilePath().AppendASCII(file_name)); | 518 base::FilePath().AppendASCII(file_name)); |
| 537 } | 519 } |
| 538 | 520 |
| 539 page_load_metrics::PageLoadExtraInfo GenericPageLoadExtraInfo( | 521 page_load_metrics::PageLoadExtraInfo GenericPageLoadExtraInfo( |
| 540 const GURL& dest_url) { | 522 const GURL& dest_url) { |
| 541 return page_load_metrics::PageLoadExtraInfo::CreateForTesting( | 523 return page_load_metrics::PageLoadExtraInfo::CreateForTesting( |
| 542 dest_url, false /* started_in_foreground */); | 524 dest_url, false /* started_in_foreground */); |
| (...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2941 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCapturedWebContents) { | 2923 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCapturedWebContents) { |
| 2942 PrerenderTestURL("/prerender/prerender_page.html", | 2924 PrerenderTestURL("/prerender/prerender_page.html", |
| 2943 FINAL_STATUS_PAGE_BEING_CAPTURED, 1); | 2925 FINAL_STATUS_PAGE_BEING_CAPTURED, 1); |
| 2944 WebContents* web_contents = GetActiveWebContents(); | 2926 WebContents* web_contents = GetActiveWebContents(); |
| 2945 web_contents->IncrementCapturerCount(gfx::Size()); | 2927 web_contents->IncrementCapturerCount(gfx::Size()); |
| 2946 NavigateToDestURLWithDisposition(WindowOpenDisposition::CURRENT_TAB, false); | 2928 NavigateToDestURLWithDisposition(WindowOpenDisposition::CURRENT_TAB, false); |
| 2947 web_contents->DecrementCapturerCount(); | 2929 web_contents->DecrementCapturerCount(); |
| 2948 } | 2930 } |
| 2949 | 2931 |
| 2950 // Checks that prerenders are aborted on cross-process navigation from | 2932 // Checks that prerenders are aborted on cross-process navigation from |
| 2951 // a server redirect. | |
| 2952 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | |
| 2953 PrerenderCrossProcessServerRedirect) { | |
| 2954 // Cross-process navigations don't happen for prerendering with PlzNavigate, | |
| 2955 // since we decide on a process after redirects are followed. | |
| 2956 if (content::IsBrowserSideNavigationEnabled()) | |
| 2957 return; | |
| 2958 | |
| 2959 // Force everything to be a process swap. | |
| 2960 SwapProcessesContentBrowserClient test_browser_client; | |
| 2961 content::ContentBrowserClient* original_browser_client = | |
| 2962 content::SetBrowserClientForTesting(&test_browser_client); | |
| 2963 | |
| 2964 PrerenderTestURL(CreateServerRedirect("/prerender/prerender_page.html"), | |
| 2965 FINAL_STATUS_OPEN_URL, 0); | |
| 2966 | |
| 2967 content::SetBrowserClientForTesting(original_browser_client); | |
| 2968 } | |
| 2969 | |
| 2970 // Checks that URLRequests for prerenders being aborted on cross-process | |
| 2971 // navigation from a server redirect are cleaned up, so they don't keep cache | |
| 2972 // entries locked. | |
| 2973 // See http://crbug.com/341134 | |
| 2974 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | |
| 2975 PrerenderCrossProcessServerRedirectNoHang) { | |
| 2976 // Cross-process navigations don't happen for prerendering with PlzNavigate, | |
| 2977 // since we decide on a process after redirects are followed. | |
| 2978 if (content::IsBrowserSideNavigationEnabled()) | |
| 2979 return; | |
| 2980 | |
| 2981 const char kDestPath[] = "/prerender/prerender_page.html"; | |
| 2982 // Force everything to be a process swap. | |
| 2983 SwapProcessesContentBrowserClient test_browser_client; | |
| 2984 content::ContentBrowserClient* original_browser_client = | |
| 2985 content::SetBrowserClientForTesting(&test_browser_client); | |
| 2986 | |
| 2987 PrerenderTestURL(CreateServerRedirect(kDestPath), FINAL_STATUS_OPEN_URL, 0); | |
| 2988 | |
| 2989 ui_test_utils::NavigateToURL(browser(), | |
| 2990 embedded_test_server()->GetURL(kDestPath)); | |
| 2991 | |
| 2992 content::SetBrowserClientForTesting(original_browser_client); | |
| 2993 } | |
| 2994 | |
| 2995 // Checks that prerenders are aborted on cross-process navigation from | |
| 2996 // a client redirect. | 2933 // a client redirect. |
| 2997 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2934 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 2998 PrerenderCrossProcessClientRedirect) { | 2935 PrerenderCrossProcessClientRedirect) { |
| 2999 // Cross-process navigation logic for renderer-initiated navigations | 2936 // Cross-process navigation logic for renderer-initiated navigations |
| 3000 // is partially controlled by the renderer, namely | 2937 // is partially controlled by the renderer, namely |
| 3001 // ChromeContentRendererClient. This test instead relies on the Web | 2938 // ChromeContentRendererClient. This test instead relies on the Web |
| 3002 // Store triggering such navigations. | 2939 // Store triggering such navigations. |
| 3003 GURL webstore_url = extension_urls::GetWebstoreLaunchURL(); | 2940 GURL webstore_url = extension_urls::GetWebstoreLaunchURL(); |
| 3004 | 2941 |
| 3005 // Mock out requests to the Web Store. | 2942 // Mock out requests to the Web Store. |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3921 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, | 3858 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, |
| 3922 "DidDisplayReallyPass()", | 3859 "DidDisplayReallyPass()", |
| 3923 &display_test_result)); | 3860 &display_test_result)); |
| 3924 ASSERT_TRUE(display_test_result); | 3861 ASSERT_TRUE(display_test_result); |
| 3925 } | 3862 } |
| 3926 #endif // !defined(DISABLE_NACL) | 3863 #endif // !defined(DISABLE_NACL) |
| 3927 | 3864 |
| 3928 } // namespace prerender | 3865 } // namespace prerender |
| 3929 | 3866 |
| 3930 #endif // !defined(OS_MACOSX) || !defined(ADDRESS_SANITIZER) | 3867 #endif // !defined(OS_MACOSX) || !defined(ADDRESS_SANITIZER) |
| OLD | NEW |