Chromium Code Reviews| 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 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1064 // current_browser(). | 1064 // current_browser(). |
| 1065 WebContents* GetActiveWebContents() const { | 1065 WebContents* GetActiveWebContents() const { |
| 1066 return current_browser()->tab_strip_model()->GetActiveWebContents(); | 1066 return current_browser()->tab_strip_model()->GetActiveWebContents(); |
| 1067 } | 1067 } |
| 1068 | 1068 |
| 1069 // Overload for a single expected final status | 1069 // Overload for a single expected final status |
| 1070 scoped_ptr<TestPrerender> PrerenderTestURL( | 1070 scoped_ptr<TestPrerender> PrerenderTestURL( |
| 1071 const std::string& html_file, | 1071 const std::string& html_file, |
| 1072 FinalStatus expected_final_status, | 1072 FinalStatus expected_final_status, |
| 1073 int expected_number_of_loads) { | 1073 int expected_number_of_loads) { |
| 1074 return PrerenderTestURL(html_file, | |
| 1075 expected_final_status, | |
| 1076 expected_number_of_loads, | |
| 1077 expected_number_of_loads); | |
| 1078 } | |
| 1079 | |
| 1080 scoped_ptr<TestPrerender> PrerenderTestURL( | |
| 1081 const std::string& html_file, | |
| 1082 FinalStatus expected_final_status, | |
| 1083 int expected_number_of_dom_content_loads, | |
| 1084 int expected_number_of_loads) { | |
| 1074 GURL url = test_server()->GetURL(html_file); | 1085 GURL url = test_server()->GetURL(html_file); |
| 1075 return PrerenderTestURL(url, | 1086 return PrerenderTestURL(url, |
| 1076 expected_final_status, | 1087 expected_final_status, |
| 1088 expected_number_of_dom_content_loads, | |
| 1077 expected_number_of_loads); | 1089 expected_number_of_loads); |
| 1078 } | 1090 } |
| 1079 | 1091 |
| 1080 ScopedVector<TestPrerender> PrerenderTestURL( | 1092 ScopedVector<TestPrerender> PrerenderTestURL( |
| 1081 const std::string& html_file, | 1093 const std::string& html_file, |
| 1082 const std::vector<FinalStatus>& expected_final_status_queue, | 1094 const std::vector<FinalStatus>& expected_final_status_queue, |
| 1083 int expected_number_of_loads) { | 1095 int expected_number_of_loads) { |
| 1084 GURL url = test_server()->GetURL(html_file); | 1096 GURL url = test_server()->GetURL(html_file); |
| 1085 return PrerenderTestURLImpl(url, | 1097 return PrerenderTestURLImpl(url, |
| 1086 expected_final_status_queue, | 1098 expected_final_status_queue, |
| 1099 expected_number_of_loads, | |
| 1087 expected_number_of_loads); | 1100 expected_number_of_loads); |
| 1088 } | 1101 } |
| 1089 | 1102 |
| 1090 scoped_ptr<TestPrerender> PrerenderTestURL( | 1103 scoped_ptr<TestPrerender> PrerenderTestURL( |
| 1091 const GURL& url, | 1104 const GURL& url, |
| 1092 FinalStatus expected_final_status, | 1105 FinalStatus expected_final_status, |
| 1093 int expected_number_of_loads) { | 1106 int expected_number_of_loads) { |
| 1107 return PrerenderTestURL(url, | |
| 1108 expected_final_status, | |
| 1109 expected_number_of_loads, | |
| 1110 expected_number_of_loads); | |
| 1111 } | |
| 1112 | |
| 1113 scoped_ptr<TestPrerender> PrerenderTestURL( | |
| 1114 const GURL& url, | |
| 1115 FinalStatus expected_final_status, | |
| 1116 int expected_number_of_dom_content_loads, | |
| 1117 int expected_number_of_loads) { | |
| 1094 std::vector<FinalStatus> expected_final_status_queue( | 1118 std::vector<FinalStatus> expected_final_status_queue( |
| 1095 1, expected_final_status); | 1119 1, expected_final_status); |
| 1096 std::vector<TestPrerender*> prerenders; | 1120 std::vector<TestPrerender*> prerenders; |
| 1097 PrerenderTestURLImpl(url, | 1121 PrerenderTestURLImpl(url, |
| 1098 expected_final_status_queue, | 1122 expected_final_status_queue, |
| 1123 expected_number_of_dom_content_loads, | |
| 1099 expected_number_of_loads).release(&prerenders); | 1124 expected_number_of_loads).release(&prerenders); |
| 1100 CHECK_EQ(1u, prerenders.size()); | 1125 CHECK_EQ(1u, prerenders.size()); |
| 1101 return scoped_ptr<TestPrerender>(prerenders[0]); | 1126 return scoped_ptr<TestPrerender>(prerenders[0]); |
| 1102 } | 1127 } |
| 1103 | 1128 |
| 1104 void NavigateToDestURL() const { | 1129 void NavigateToDestURL() const { |
| 1105 NavigateToDestURLWithDisposition(CURRENT_TAB, true); | 1130 NavigateToDestURLWithDisposition(CURRENT_TAB, true); |
| 1106 } | 1131 } |
| 1107 | 1132 |
| 1108 // Opens the url in a new tab, with no opener. | 1133 // Opens the url in a new tab, with no opener. |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1302 "window.domAutomationController.send(" | 1327 "window.domAutomationController.send(" |
| 1303 "receivedPrerenderLoadEvents[%d] || 0)", index); | 1328 "receivedPrerenderLoadEvents[%d] || 0)", index); |
| 1304 | 1329 |
| 1305 CHECK(content::ExecuteScriptAndExtractInt( | 1330 CHECK(content::ExecuteScriptAndExtractInt( |
| 1306 GetActiveWebContents(), | 1331 GetActiveWebContents(), |
| 1307 expression, | 1332 expression, |
| 1308 &load_event_count)); | 1333 &load_event_count)); |
| 1309 return load_event_count; | 1334 return load_event_count; |
| 1310 } | 1335 } |
| 1311 | 1336 |
| 1337 int GetPrerenderDomContentLoadedEventCountForLinkNumber(int index) const { | |
| 1338 int dom_content_loaded_event_count; | |
| 1339 std::string expression = base::StringPrintf( | |
| 1340 "window.domAutomationController.send(" | |
| 1341 "receivedPrerenderDomContentLoadedEvents[%d] || 0)", index); | |
| 1342 | |
| 1343 CHECK(content::ExecuteScriptAndExtractInt( | |
| 1344 GetActiveWebContents(), | |
| 1345 expression, | |
| 1346 &dom_content_loaded_event_count)); | |
| 1347 return dom_content_loaded_event_count; | |
| 1348 } | |
| 1349 | |
| 1312 bool DidReceivePrerenderStopEventForLinkNumber(int index) const { | 1350 bool DidReceivePrerenderStopEventForLinkNumber(int index) const { |
| 1313 bool received_prerender_stopped; | 1351 bool received_prerender_stopped; |
| 1314 std::string expression = base::StringPrintf( | 1352 std::string expression = base::StringPrintf( |
| 1315 "window.domAutomationController.send(Boolean(" | 1353 "window.domAutomationController.send(Boolean(" |
| 1316 "receivedPrerenderStopEvents[%d]))", index); | 1354 "receivedPrerenderStopEvents[%d]))", index); |
| 1317 | 1355 |
| 1318 CHECK(content::ExecuteScriptAndExtractBool( | 1356 CHECK(content::ExecuteScriptAndExtractBool( |
| 1319 GetActiveWebContents(), | 1357 GetActiveWebContents(), |
| 1320 expression, | 1358 expression, |
| 1321 &received_prerender_stopped)); | 1359 &received_prerender_stopped)); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1462 private: | 1500 private: |
| 1463 // TODO(davidben): Remove this altogether so the tests don't globally assume | 1501 // TODO(davidben): Remove this altogether so the tests don't globally assume |
| 1464 // only one prerender. | 1502 // only one prerender. |
| 1465 TestPrerenderContents* GetPrerenderContents() const { | 1503 TestPrerenderContents* GetPrerenderContents() const { |
| 1466 return GetPrerenderContentsFor(dest_url_); | 1504 return GetPrerenderContentsFor(dest_url_); |
| 1467 } | 1505 } |
| 1468 | 1506 |
| 1469 ScopedVector<TestPrerender> PrerenderTestURLImpl( | 1507 ScopedVector<TestPrerender> PrerenderTestURLImpl( |
| 1470 const GURL& prerender_url, | 1508 const GURL& prerender_url, |
| 1471 const std::vector<FinalStatus>& expected_final_status_queue, | 1509 const std::vector<FinalStatus>& expected_final_status_queue, |
| 1510 int expected_number_of_dom_content_loads, | |
| 1472 int expected_number_of_loads) { | 1511 int expected_number_of_loads) { |
| 1473 dest_url_ = prerender_url; | 1512 dest_url_ = prerender_url; |
| 1474 | 1513 |
| 1475 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 1514 std::vector<net::SpawnedTestServer::StringPair> replacement_text; |
| 1476 replacement_text.push_back( | 1515 replacement_text.push_back( |
| 1477 make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec())); | 1516 make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec())); |
| 1478 std::string replacement_path; | 1517 std::string replacement_path; |
| 1479 CHECK(net::SpawnedTestServer::GetFilePathWithReplacements( | 1518 CHECK(net::SpawnedTestServer::GetFilePathWithReplacements( |
| 1480 loader_path_, | 1519 loader_path_, |
| 1481 replacement_text, | 1520 replacement_text, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1526 if (call_javascript_) { | 1565 if (call_javascript_) { |
| 1527 // Check if page behaves as expected while in prerendered state. | 1566 // Check if page behaves as expected while in prerendered state. |
| 1528 EXPECT_TRUE(DidPrerenderPass(prerender_contents->prerender_contents())); | 1567 EXPECT_TRUE(DidPrerenderPass(prerender_contents->prerender_contents())); |
| 1529 } | 1568 } |
| 1530 } | 1569 } |
| 1531 | 1570 |
| 1532 // Test that the referring page received the right start and load events. | 1571 // Test that the referring page received the right start and load events. |
| 1533 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0)); | 1572 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0)); |
| 1534 if (check_load_events_) { | 1573 if (check_load_events_) { |
| 1535 EXPECT_EQ(expected_number_of_loads, prerenders[0]->number_of_loads()); | 1574 EXPECT_EQ(expected_number_of_loads, prerenders[0]->number_of_loads()); |
| 1575 // expected_number_of_dom_content_loads can differ from | |
| 1576 // expected_number_of_loads, when prerender aborts between | |
| 1577 // 'DOMContentLoaded' and 'load'. | |
| 1578 EXPECT_EQ(expected_number_of_dom_content_loads, | |
| 1579 GetPrerenderDomContentLoadedEventCountForLinkNumber(0)); | |
| 1536 EXPECT_EQ(expected_number_of_loads, | 1580 EXPECT_EQ(expected_number_of_loads, |
| 1537 GetPrerenderLoadEventCountForLinkNumber(0)); | 1581 GetPrerenderLoadEventCountForLinkNumber(0)); |
| 1538 } | 1582 } |
| 1539 EXPECT_FALSE(HadPrerenderEventErrors()); | 1583 EXPECT_FALSE(HadPrerenderEventErrors()); |
| 1540 | 1584 |
| 1541 return prerenders.Pass(); | 1585 return prerenders.Pass(); |
| 1542 } | 1586 } |
| 1543 | 1587 |
| 1544 void NavigateToURLImpl(const content::OpenURLParams& params, | 1588 void NavigateToURLImpl(const content::OpenURLParams& params, |
| 1545 bool expect_swap_to_succeed) const { | 1589 bool expect_swap_to_succeed) const { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1610 std::string loader_query_and_fragment_; | 1654 std::string loader_query_and_fragment_; |
| 1611 Browser* explicitly_set_browser_; | 1655 Browser* explicitly_set_browser_; |
| 1612 }; | 1656 }; |
| 1613 | 1657 |
| 1614 // Checks that a page is correctly prerendered in the case of a | 1658 // Checks that a page is correctly prerendered in the case of a |
| 1615 // <link rel=prerender> tag and then loaded into a tab in response to a | 1659 // <link rel=prerender> tag and then loaded into a tab in response to a |
| 1616 // navigation. | 1660 // navigation. |
| 1617 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { | 1661 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { |
| 1618 UMAHistogramHelper histograms; | 1662 UMAHistogramHelper histograms; |
| 1619 | 1663 |
| 1620 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 1664 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
|
davidben
2014/02/11 17:04:33
Maybe a manual assertion after this line to test t
ksimbili
2014/02/11 20:05:57
Done.
| |
| 1621 histograms.Fetch(); | 1665 histograms.Fetch(); |
| 1622 histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); | 1666 histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| 1623 histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); | 1667 histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| 1624 histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); | 1668 histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| 1625 histograms.ExpectTotalCount("Prerender.websame_PrerenderNotSwappedInPLT", 1); | 1669 histograms.ExpectTotalCount("Prerender.websame_PrerenderNotSwappedInPLT", 1); |
| 1626 | 1670 |
| 1627 ChannelDestructionWatcher channel_close_watcher; | 1671 ChannelDestructionWatcher channel_close_watcher; |
| 1628 channel_close_watcher.WatchChannel( | 1672 channel_close_watcher.WatchChannel( |
| 1629 GetActiveWebContents()->GetRenderProcessHost()); | 1673 GetActiveWebContents()->GetRenderProcessHost()); |
| 1630 NavigateToDestURL(); | 1674 NavigateToDestURL(); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1954 1); | 1998 1); |
| 1955 NavigateToDestURL(); | 1999 NavigateToDestURL(); |
| 1956 } | 2000 } |
| 1957 | 2001 |
| 1958 // Renders a page that contains a prerender link to a page that contains an | 2002 // Renders a page that contains a prerender link to a page that contains an |
| 1959 // iframe with a source that requires http authentication. This should not | 2003 // iframe with a source that requires http authentication. This should not |
| 1960 // prerender successfully. | 2004 // prerender successfully. |
| 1961 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHttpAuthentication) { | 2005 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHttpAuthentication) { |
| 1962 PrerenderTestURL("files/prerender/prerender_http_auth_container.html", | 2006 PrerenderTestURL("files/prerender/prerender_http_auth_container.html", |
| 1963 FINAL_STATUS_AUTH_NEEDED, | 2007 FINAL_STATUS_AUTH_NEEDED, |
| 2008 1, | |
| 1964 0); | 2009 0); |
| 1965 } | 2010 } |
| 1966 | 2011 |
| 1967 // Checks that client-issued redirects work with prerendering. | 2012 // Checks that client-issued redirects work with prerendering. |
| 1968 // This version navigates to the page which issues the redirection, rather | 2013 // This version navigates to the page which issues the redirection, rather |
| 1969 // than the final destination page. | 2014 // than the final destination page. |
| 1970 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2015 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 1971 PrerenderClientRedirectNavigateToFirst) { | 2016 PrerenderClientRedirectNavigateToFirst) { |
| 1972 PrerenderTestURL(CreateClientRedirect("files/prerender/prerender_page.html"), | 2017 PrerenderTestURL(CreateClientRedirect("files/prerender/prerender_page.html"), |
| 1973 FINAL_STATUS_USED, | 2018 FINAL_STATUS_USED, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2106 std::string redirect_path = CreateClientRedirect( | 2151 std::string redirect_path = CreateClientRedirect( |
| 2107 "/files/prerender/prerender_embedded_content.html"); | 2152 "/files/prerender/prerender_embedded_content.html"); |
| 2108 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 2153 std::vector<net::SpawnedTestServer::StringPair> replacement_text; |
| 2109 replacement_text.push_back( | 2154 replacement_text.push_back( |
| 2110 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path)); | 2155 std::make_pair("REPLACE_WITH_URL", "/" + redirect_path)); |
| 2111 std::string replacement_path; | 2156 std::string replacement_path; |
| 2112 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( | 2157 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( |
| 2113 "files/prerender/prerender_with_iframe.html", | 2158 "files/prerender/prerender_with_iframe.html", |
| 2114 replacement_text, | 2159 replacement_text, |
| 2115 &replacement_path)); | 2160 &replacement_path)); |
| 2116 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 2); | 2161 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1, 2); |
| 2117 EXPECT_FALSE(UrlIsInPrerenderManager( | 2162 EXPECT_FALSE(UrlIsInPrerenderManager( |
| 2118 "files/prerender/prerender_embedded_content.html")); | 2163 "files/prerender/prerender_embedded_content.html")); |
| 2119 NavigateToDestURL(); | 2164 NavigateToDestURL(); |
| 2120 } | 2165 } |
| 2121 | 2166 |
| 2122 // Checks that server-issued redirects work with prerendering. | 2167 // Checks that server-issued redirects work with prerendering. |
| 2123 // This version navigates to the page which issues the redirection, rather | 2168 // This version navigates to the page which issues the redirection, rather |
| 2124 // than the final destination page. | 2169 // than the final destination page. |
| 2125 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2170 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 2126 PrerenderServerRedirectNavigateToFirst) { | 2171 PrerenderServerRedirectNavigateToFirst) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2171 EXPECT_FALSE(UrlIsInPrerenderManager( | 2216 EXPECT_FALSE(UrlIsInPrerenderManager( |
| 2172 "files/prerender/prerender_embedded_content.html")); | 2217 "files/prerender/prerender_embedded_content.html")); |
| 2173 NavigateToDestURL(); | 2218 NavigateToDestURL(); |
| 2174 } | 2219 } |
| 2175 | 2220 |
| 2176 // Prerenders a page that contains an automatic download triggered through an | 2221 // Prerenders a page that contains an automatic download triggered through an |
| 2177 // iframe. This should not prerender successfully. | 2222 // iframe. This should not prerender successfully. |
| 2178 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadIframe) { | 2223 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadIframe) { |
| 2179 PrerenderTestURL("files/prerender/prerender_download_iframe.html", | 2224 PrerenderTestURL("files/prerender/prerender_download_iframe.html", |
| 2180 FINAL_STATUS_DOWNLOAD, | 2225 FINAL_STATUS_DOWNLOAD, |
| 2226 1, | |
| 2181 0); | 2227 0); |
| 2182 } | 2228 } |
| 2183 | 2229 |
| 2184 // Prerenders a page that contains an automatic download triggered through | 2230 // Prerenders a page that contains an automatic download triggered through |
| 2185 // Javascript changing the window.location. This should not prerender | 2231 // Javascript changing the window.location. This should not prerender |
| 2186 // successfully | 2232 // successfully |
| 2187 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadLocation) { | 2233 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDownloadLocation) { |
| 2188 PrerenderTestURL(CreateClientRedirect("files/download-test1.lib"), | 2234 PrerenderTestURL(CreateClientRedirect("files/download-test1.lib"), |
| 2189 FINAL_STATUS_DOWNLOAD, | 2235 FINAL_STATUS_DOWNLOAD, |
| 2190 1); | 2236 1); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2238 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) { | 2284 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) { |
| 2239 PrerenderTestURL("files/prerender/prerender_popup.html", | 2285 PrerenderTestURL("files/prerender/prerender_popup.html", |
| 2240 FINAL_STATUS_CREATE_NEW_WINDOW, | 2286 FINAL_STATUS_CREATE_NEW_WINDOW, |
| 2241 0); | 2287 0); |
| 2242 } | 2288 } |
| 2243 | 2289 |
| 2244 // Checks that registering a protocol handler causes cancellation. | 2290 // Checks that registering a protocol handler causes cancellation. |
| 2245 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderRegisterProtocolHandler) { | 2291 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderRegisterProtocolHandler) { |
| 2246 PrerenderTestURL("files/prerender/prerender_register_protocol_handler.html", | 2292 PrerenderTestURL("files/prerender/prerender_register_protocol_handler.html", |
| 2247 FINAL_STATUS_REGISTER_PROTOCOL_HANDLER, | 2293 FINAL_STATUS_REGISTER_PROTOCOL_HANDLER, |
| 2294 1, | |
| 2248 0); | 2295 0); |
| 2249 } | 2296 } |
| 2250 | 2297 |
| 2251 // Checks that renderers using excessive memory will be terminated. | 2298 // Checks that renderers using excessive memory will be terminated. |
| 2252 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderExcessiveMemory) { | 2299 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderExcessiveMemory) { |
| 2253 ASSERT_TRUE(GetPrerenderManager()); | 2300 ASSERT_TRUE(GetPrerenderManager()); |
| 2254 GetPrerenderManager()->mutable_config().max_bytes = 30 * 1024 * 1024; | 2301 GetPrerenderManager()->mutable_config().max_bytes = 30 * 1024 * 1024; |
| 2255 // The excessive memory kill may happen before or after the load event as it | 2302 // The excessive memory kill may happen before or after the load event as it |
| 2256 // happens asynchronously with IPC calls. Even if the test does not start | 2303 // happens asynchronously with IPC calls. Even if the test does not start |
| 2257 // allocating until after load, the browser process might notice before the | 2304 // allocating until after load, the browser process might notice before the |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2777 replacement_text, | 2824 replacement_text, |
| 2778 &replacement_path)); | 2825 &replacement_path)); |
| 2779 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1); | 2826 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1); |
| 2780 NavigateToDestURL(); | 2827 NavigateToDestURL(); |
| 2781 } | 2828 } |
| 2782 | 2829 |
| 2783 // Checks that we cancel correctly when window.print() is called. | 2830 // Checks that we cancel correctly when window.print() is called. |
| 2784 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) { | 2831 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) { |
| 2785 PrerenderTestURL("files/prerender/prerender_print.html", | 2832 PrerenderTestURL("files/prerender/prerender_print.html", |
| 2786 FINAL_STATUS_WINDOW_PRINT, | 2833 FINAL_STATUS_WINDOW_PRINT, |
| 2834 1, | |
| 2787 0); | 2835 0); |
| 2788 } | 2836 } |
| 2789 | 2837 |
| 2790 // Checks that if a page is opened in a new window by javascript and both the | 2838 // Checks that if a page is opened in a new window by javascript and both the |
| 2791 // pages are in the same domain, the prerendered page is not used, due to | 2839 // pages are in the same domain, the prerendered page is not used, due to |
| 2792 // window.opener. | 2840 // window.opener. |
| 2793 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2841 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 2794 PrerenderSameDomainWindowOpenerWindowOpen) { | 2842 PrerenderSameDomainWindowOpenerWindowOpen) { |
| 2795 PrerenderTestURL("files/prerender/prerender_page.html", | 2843 PrerenderTestURL("files/prerender/prerender_page.html", |
| 2796 FINAL_STATUS_WINDOW_OPENER, | 2844 FINAL_STATUS_WINDOW_OPENER, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2865 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 2913 std::vector<net::SpawnedTestServer::StringPair> replacement_text; |
| 2866 replacement_text.push_back( | 2914 replacement_text.push_back( |
| 2867 std::make_pair("REPLACE_WITH_IMAGE_URL", https_url.spec())); | 2915 std::make_pair("REPLACE_WITH_IMAGE_URL", https_url.spec())); |
| 2868 std::string replacement_path; | 2916 std::string replacement_path; |
| 2869 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( | 2917 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( |
| 2870 "files/prerender/prerender_with_image.html", | 2918 "files/prerender/prerender_with_image.html", |
| 2871 replacement_text, | 2919 replacement_text, |
| 2872 &replacement_path)); | 2920 &replacement_path)); |
| 2873 PrerenderTestURL(replacement_path, | 2921 PrerenderTestURL(replacement_path, |
| 2874 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, | 2922 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, |
| 2923 1, | |
| 2875 0); | 2924 0); |
| 2876 } | 2925 } |
| 2877 | 2926 |
| 2878 // Checks that an SSL Client Certificate request that originates from an | 2927 // Checks that an SSL Client Certificate request that originates from an |
| 2879 // iframe will cancel the prerendered page. | 2928 // iframe will cancel the prerendered page. |
| 2880 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLClientCertIframe) { | 2929 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLClientCertIframe) { |
| 2881 ProfileIOData::FromResourceContext( | 2930 ProfileIOData::FromResourceContext( |
| 2882 current_browser()->profile()->GetResourceContext())-> | 2931 current_browser()->profile()->GetResourceContext())-> |
| 2883 set_client_cert_store_factory_for_testing( | 2932 set_client_cert_store_factory_for_testing( |
| 2884 base::Bind(&CreateCertStore)); | 2933 base::Bind(&CreateCertStore)); |
| 2885 net::SpawnedTestServer::SSLOptions ssl_options; | 2934 net::SpawnedTestServer::SSLOptions ssl_options; |
| 2886 ssl_options.request_client_certificate = true; | 2935 ssl_options.request_client_certificate = true; |
| 2887 net::SpawnedTestServer https_server( | 2936 net::SpawnedTestServer https_server( |
| 2888 net::SpawnedTestServer::TYPE_HTTPS, ssl_options, | 2937 net::SpawnedTestServer::TYPE_HTTPS, ssl_options, |
| 2889 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 2938 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
| 2890 ASSERT_TRUE(https_server.Start()); | 2939 ASSERT_TRUE(https_server.Start()); |
| 2891 GURL https_url = https_server.GetURL( | 2940 GURL https_url = https_server.GetURL( |
| 2892 "files/prerender/prerender_embedded_content.html"); | 2941 "files/prerender/prerender_embedded_content.html"); |
| 2893 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 2942 std::vector<net::SpawnedTestServer::StringPair> replacement_text; |
| 2894 replacement_text.push_back( | 2943 replacement_text.push_back( |
| 2895 std::make_pair("REPLACE_WITH_URL", https_url.spec())); | 2944 std::make_pair("REPLACE_WITH_URL", https_url.spec())); |
| 2896 std::string replacement_path; | 2945 std::string replacement_path; |
| 2897 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( | 2946 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( |
| 2898 "files/prerender/prerender_with_iframe.html", | 2947 "files/prerender/prerender_with_iframe.html", |
| 2899 replacement_text, | 2948 replacement_text, |
| 2900 &replacement_path)); | 2949 &replacement_path)); |
| 2901 PrerenderTestURL(replacement_path, | 2950 PrerenderTestURL(replacement_path, |
| 2902 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, | 2951 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, |
| 2952 1, | |
| 2903 0); | 2953 0); |
| 2904 } | 2954 } |
| 2905 | 2955 |
| 2906 #if defined(FULL_SAFE_BROWSING) | 2956 #if defined(FULL_SAFE_BROWSING) |
| 2907 // Ensures that we do not prerender pages with a safe browsing | 2957 // Ensures that we do not prerender pages with a safe browsing |
| 2908 // interstitial. | 2958 // interstitial. |
| 2909 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSafeBrowsingTopLevel) { | 2959 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSafeBrowsingTopLevel) { |
| 2910 GURL url = test_server()->GetURL("files/prerender/prerender_page.html"); | 2960 GURL url = test_server()->GetURL("files/prerender/prerender_page.html"); |
| 2911 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl( | 2961 GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl( |
| 2912 url, SB_THREAT_TYPE_URL_MALWARE); | 2962 url, SB_THREAT_TYPE_URL_MALWARE); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3511 GURL image_url = test_server()->GetURL( | 3561 GURL image_url = test_server()->GetURL( |
| 3512 CreateServerRedirect("invalidscheme://www.google.com/test.jpg")); | 3562 CreateServerRedirect("invalidscheme://www.google.com/test.jpg")); |
| 3513 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 3563 std::vector<net::SpawnedTestServer::StringPair> replacement_text; |
| 3514 replacement_text.push_back( | 3564 replacement_text.push_back( |
| 3515 std::make_pair("REPLACE_WITH_IMAGE_URL", image_url.spec())); | 3565 std::make_pair("REPLACE_WITH_IMAGE_URL", image_url.spec())); |
| 3516 std::string replacement_path; | 3566 std::string replacement_path; |
| 3517 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( | 3567 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( |
| 3518 "files/prerender/prerender_with_image.html", | 3568 "files/prerender/prerender_with_image.html", |
| 3519 replacement_text, | 3569 replacement_text, |
| 3520 &replacement_path)); | 3570 &replacement_path)); |
| 3521 PrerenderTestURL(replacement_path, FINAL_STATUS_UNSUPPORTED_SCHEME, 0); | 3571 PrerenderTestURL(replacement_path, FINAL_STATUS_UNSUPPORTED_SCHEME, 1, 0); |
| 3522 } | 3572 } |
| 3523 | 3573 |
| 3524 // Checks that chrome-extension subresource does not cancel the prerender. | 3574 // Checks that chrome-extension subresource does not cancel the prerender. |
| 3525 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 3575 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| 3526 PrerenderKeepSubresourceExtensionScheme) { | 3576 PrerenderKeepSubresourceExtensionScheme) { |
| 3527 GURL image_url = GURL("chrome-extension://abcdefg/test.jpg"); | 3577 GURL image_url = GURL("chrome-extension://abcdefg/test.jpg"); |
| 3528 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 3578 std::vector<net::SpawnedTestServer::StringPair> replacement_text; |
| 3529 replacement_text.push_back( | 3579 replacement_text.push_back( |
| 3530 std::make_pair("REPLACE_WITH_IMAGE_URL", image_url.spec())); | 3580 std::make_pair("REPLACE_WITH_IMAGE_URL", image_url.spec())); |
| 3531 std::string replacement_path; | 3581 std::string replacement_path; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3651 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDeferredImage) { | 3701 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDeferredImage) { |
| 3652 DisableJavascriptCalls(); | 3702 DisableJavascriptCalls(); |
| 3653 UMAHistogramHelper histograms; | 3703 UMAHistogramHelper histograms; |
| 3654 | 3704 |
| 3655 // The prerender will not completely load until after the swap, so wait for a | 3705 // The prerender will not completely load until after the swap, so wait for a |
| 3656 // title change before calling DidPrerenderPass. | 3706 // title change before calling DidPrerenderPass. |
| 3657 scoped_ptr<TestPrerender> prerender = | 3707 scoped_ptr<TestPrerender> prerender = |
| 3658 PrerenderTestURL( | 3708 PrerenderTestURL( |
| 3659 "files/prerender/prerender_deferred_image.html", | 3709 "files/prerender/prerender_deferred_image.html", |
| 3660 FINAL_STATUS_USED, 0); | 3710 FINAL_STATUS_USED, 0); |
| 3661 WaitForASCIITitle(prerender->contents()->prerender_contents(), kReadyTitle); | 3711 WaitForASCIITitle(prerender->contents()->prerender_contents(), kReadyTitle); |
|
davidben
2014/02/11 17:04:33
This would be a pretty good place to assert DOMCon
ksimbili
2014/02/11 20:05:57
Added test here. I'll add WaitForDomContentLoads,
| |
| 3662 EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents())); | 3712 EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents())); |
| 3663 EXPECT_EQ(0, prerender->number_of_loads()); | 3713 EXPECT_EQ(0, prerender->number_of_loads()); |
| 3664 histograms.Fetch(); | 3714 histograms.Fetch(); |
| 3665 histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); | 3715 histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| 3666 histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); | 3716 histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| 3667 histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); | 3717 histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| 3668 histograms.ExpectTotalCount("Prerender.websame_PrerenderNotSwappedInPLT", 0); | 3718 histograms.ExpectTotalCount("Prerender.websame_PrerenderNotSwappedInPLT", 0); |
| 3669 | 3719 |
| 3670 // Swap. | 3720 // Swap. |
| 3671 NavigationOrSwapObserver swap_observer(current_browser()->tab_strip_model(), | 3721 NavigationOrSwapObserver swap_observer(current_browser()->tab_strip_model(), |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4047 } | 4097 } |
| 4048 }; | 4098 }; |
| 4049 | 4099 |
| 4050 // Checks that prerendering works in incognito mode. | 4100 // Checks that prerendering works in incognito mode. |
| 4051 IN_PROC_BROWSER_TEST_F(PrerenderIncognitoBrowserTest, PrerenderIncognito) { | 4101 IN_PROC_BROWSER_TEST_F(PrerenderIncognitoBrowserTest, PrerenderIncognito) { |
| 4052 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 4102 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
| 4053 NavigateToDestURL(); | 4103 NavigateToDestURL(); |
| 4054 } | 4104 } |
| 4055 | 4105 |
| 4056 } // namespace prerender | 4106 } // namespace prerender |
| OLD | NEW |