| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // the PrerenderRendererCrash test. | 169 // the PrerenderRendererCrash test. |
| 170 if (url.spec() != chrome::kAboutCrashURL) | 170 if (url.spec() != chrome::kAboutCrashURL) |
| 171 return PrerenderContents::AddAliasURL(url); | 171 return PrerenderContents::AddAliasURL(url); |
| 172 return true; | 172 return true; |
| 173 } | 173 } |
| 174 | 174 |
| 175 virtual void DidStopLoading() OVERRIDE { | 175 virtual void DidStopLoading() OVERRIDE { |
| 176 PrerenderContents::DidStopLoading(); | 176 PrerenderContents::DidStopLoading(); |
| 177 ++number_of_loads_; | 177 ++number_of_loads_; |
| 178 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status_) && | 178 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status_) && |
| 179 number_of_loads_ >= expected_number_of_loads_) { | 179 number_of_loads_ == expected_number_of_loads_) { |
| 180 MessageLoopForUI::current()->Quit(); | 180 MessageLoopForUI::current()->Quit(); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 // For tests that open the prerender in a new background tab, the RenderView | 184 // For tests that open the prerender in a new background tab, the RenderView |
| 185 // will not have been made visible when the PrerenderContents is destroyed | 185 // will not have been made visible when the PrerenderContents is destroyed |
| 186 // even though it is used. | 186 // even though it is used. |
| 187 void set_should_be_shown(bool value) { should_be_shown_ = value; } | 187 void set_should_be_shown(bool value) { should_be_shown_ = value; } |
| 188 | 188 |
| 189 // Some of the ui_test_utils calls that we use assume that no one will quit | 189 // Some of the ui_test_utils calls that we use assume that no one will quit |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 ASSERT_TRUE(https_server.Start()); | 883 ASSERT_TRUE(https_server.Start()); |
| 884 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html"); | 884 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html"); |
| 885 PrerenderTestURL(CreateClientRedirect(https_url.spec()), | 885 PrerenderTestURL(CreateClientRedirect(https_url.spec()), |
| 886 FINAL_STATUS_USED, | 886 FINAL_STATUS_USED, |
| 887 2); | 887 2); |
| 888 NavigateToDestURL(); | 888 NavigateToDestURL(); |
| 889 } | 889 } |
| 890 | 890 |
| 891 // Checks that client-issued redirects within an iframe in a prerendered | 891 // Checks that client-issued redirects within an iframe in a prerendered |
| 892 // page will not count as an "alias" for the prerendered page. | 892 // page will not count as an "alias" for the prerendered page. |
| 893 // Test flaky due to http://crbug.com/88973. | 893 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClientRedirectInIframe) { |
| 894 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | |
| 895 FLAKY_PrerenderClientRedirectInIframe) { | |
| 896 std::string redirect_path = CreateClientRedirect( | 894 std::string redirect_path = CreateClientRedirect( |
| 897 "/files/prerender/prerender_embedded_content.html"); | 895 "/files/prerender/prerender_embedded_content.html"); |
| 898 std::vector<net::TestServer::StringPair> replacement_text; | 896 std::vector<net::TestServer::StringPair> replacement_text; |
| 899 replacement_text.push_back( | 897 replacement_text.push_back( |
| 900 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path)); | 898 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path)); |
| 901 std::string replacement_path; | 899 std::string replacement_path; |
| 902 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements( | 900 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements( |
| 903 "files/prerender/prerender_with_iframe.html", | 901 "files/prerender/prerender_with_iframe.html", |
| 904 replacement_text, | 902 replacement_text, |
| 905 &replacement_path)); | 903 &replacement_path)); |
| 906 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1); | 904 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 2); |
| 907 EXPECT_FALSE(UrlIsInPrerenderManager( | 905 EXPECT_FALSE(UrlIsInPrerenderManager( |
| 908 "files/prerender/prerender_embedded_content.html")); | 906 "files/prerender/prerender_embedded_content.html")); |
| 909 NavigateToDestURL(); | 907 NavigateToDestURL(); |
| 910 } | 908 } |
| 911 | 909 |
| 912 // Checks that client-issued redirects within an iframe in a prerendered | 910 // Checks that client-issued redirects within an iframe in a prerendered |
| 913 // page to an https page will not cancel the prerender, nor will it | 911 // page to an https page will not cancel the prerender, nor will it |
| 914 // count as an "alias" for the prerendered page. | 912 // count as an "alias" for the prerendered page. |
| 915 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 913 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 916 PrerenderClientRedirectToHttpsInIframe) { | 914 PrerenderClientRedirectToHttpsInIframe) { |
| 917 net::TestServer https_server(net::TestServer::TYPE_HTTPS, | 915 net::TestServer https_server(net::TestServer::TYPE_HTTPS, |
| 918 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 916 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
| 919 ASSERT_TRUE(https_server.Start()); | 917 ASSERT_TRUE(https_server.Start()); |
| 920 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html"); | 918 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html"); |
| 921 std::string redirect_path = CreateClientRedirect(https_url.spec()); | 919 std::string redirect_path = CreateClientRedirect(https_url.spec()); |
| 922 std::vector<net::TestServer::StringPair> replacement_text; | 920 std::vector<net::TestServer::StringPair> replacement_text; |
| 923 replacement_text.push_back( | 921 replacement_text.push_back( |
| 924 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path)); | 922 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path)); |
| 925 std::string replacement_path; | 923 std::string replacement_path; |
| 926 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements( | 924 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements( |
| 927 "files/prerender/prerender_with_iframe.html", | 925 "files/prerender/prerender_with_iframe.html", |
| 928 replacement_text, | 926 replacement_text, |
| 929 &replacement_path)); | 927 &replacement_path)); |
| 930 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1); | 928 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 2); |
| 931 EXPECT_FALSE(UrlIsInPrerenderManager(https_url)); | 929 EXPECT_FALSE(UrlIsInPrerenderManager(https_url)); |
| 932 NavigateToDestURL(); | 930 NavigateToDestURL(); |
| 933 } | 931 } |
| 934 | 932 |
| 935 // Checks that server-issued redirects work with prerendering. | 933 // Checks that server-issued redirects work with prerendering. |
| 936 // This version navigates to the page which issues the redirection, rather | 934 // This version navigates to the page which issues the redirection, rather |
| 937 // than the final destination page. | 935 // than the final destination page. |
| 938 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 936 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 939 PrerenderServerRedirectNavigateToFirst) { | 937 PrerenderServerRedirectNavigateToFirst) { |
| 940 PrerenderTestURL(CreateServerRedirect("files/prerender/prerender_page.html"), | 938 PrerenderTestURL(CreateServerRedirect("files/prerender/prerender_page.html"), |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 1); | 1796 1); |
| 1799 OpenDestURLViaClickNewBackgroundTab(); | 1797 OpenDestURLViaClickNewBackgroundTab(); |
| 1800 // SelectNextTab completes synchronously, in terms of | 1798 // SelectNextTab completes synchronously, in terms of |
| 1801 // updating the active index. | 1799 // updating the active index. |
| 1802 browser()->SelectNextTab(); | 1800 browser()->SelectNextTab(); |
| 1803 ClickToNextPageAfterPrerender(browser()); | 1801 ClickToNextPageAfterPrerender(browser()); |
| 1804 GoBackToPrerender(browser()); | 1802 GoBackToPrerender(browser()); |
| 1805 } | 1803 } |
| 1806 | 1804 |
| 1807 } // namespace prerender | 1805 } // namespace prerender |
| OLD | NEW |