OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 const char kScriptDocumentWritePath[] = "/predictors/document_write.js"; | 65 const char kScriptDocumentWritePath[] = "/predictors/document_write.js"; |
66 const char kHtmlAppendChildPath[] = "/predictors/append_child.html"; | 66 const char kHtmlAppendChildPath[] = "/predictors/append_child.html"; |
67 const char kScriptAppendChildPath[] = "/predictors/append_child.js"; | 67 const char kScriptAppendChildPath[] = "/predictors/append_child.js"; |
68 const char kHtmlInnerHtmlPath[] = "/predictors/inner_html.html"; | 68 const char kHtmlInnerHtmlPath[] = "/predictors/inner_html.html"; |
69 const char kScriptInnerHtmlPath[] = "/predictors/inner_html.js"; | 69 const char kScriptInnerHtmlPath[] = "/predictors/inner_html.js"; |
70 const char kHtmlXHRPath[] = "/predictors/xhr.html"; | 70 const char kHtmlXHRPath[] = "/predictors/xhr.html"; |
71 const char kScriptXHRPath[] = "/predictors/xhr.js"; | 71 const char kScriptXHRPath[] = "/predictors/xhr.js"; |
72 const char kHtmlIframePath[] = "/predictors/html_iframe.html"; | 72 const char kHtmlIframePath[] = "/predictors/html_iframe.html"; |
73 const char kHtmlJavascriptRedirectPath[] = | 73 const char kHtmlJavascriptRedirectPath[] = |
74 "/predictors/javascript_redirect.html"; | 74 "/predictors/javascript_redirect.html"; |
| 75 const char kHtmlFcpOrderPath[] = "/predictors/subresource_fcp_order.html"; |
75 | 76 |
76 // Host, path. | 77 // Host, path. |
77 const char* kScript[2] = {kFooHost, kScriptPath}; | 78 const char* kScript[2] = {kFooHost, kScriptPath}; |
78 const char* kImage[2] = {kBarHost, kImagePath}; | 79 const char* kImage[2] = {kBarHost, kImagePath}; |
79 const char* kFont[2] = {kFooHost, kFontPath}; | 80 const char* kFont[2] = {kFooHost, kFontPath}; |
80 const char* kStyle[2] = {kBazHost, kStylePath}; | 81 const char* kStyle[2] = {kBazHost, kStylePath}; |
81 | 82 |
82 struct ResourceSummary { | 83 struct ResourceSummary { |
83 ResourceSummary() | 84 ResourceSummary() |
84 : version(0), | 85 : version(0), |
85 is_no_store(false), | 86 is_no_store(false), |
86 is_external(false), | 87 is_external(false), |
87 is_observable(true), | 88 is_observable(true), |
88 is_prohibited(false) {} | 89 is_prohibited(false) { |
| 90 request.before_first_contentful_paint = true; |
| 91 } |
89 | 92 |
90 ResourcePrefetchPredictor::URLRequestSummary request; | 93 ResourcePrefetchPredictor::URLRequestSummary request; |
91 // Allows to update HTTP ETag. | 94 // Allows to update HTTP ETag. |
92 size_t version; | 95 size_t version; |
93 // True iff "Cache-control: no-store" header is present. | 96 // True iff "Cache-control: no-store" header is present. |
94 bool is_no_store; | 97 bool is_no_store; |
95 // True iff a request for this resource must be ignored by the custom handler. | 98 // True iff a request for this resource must be ignored by the custom handler. |
96 bool is_external; | 99 bool is_external; |
97 // True iff the LearningObserver must observe this resource. | 100 // True iff the LearningObserver must observe this resource. |
98 bool is_observable; | 101 bool is_observable; |
99 // A request with |is_prohibited| set to true makes the test that originates | 102 // A request with |is_prohibited| set to true makes the test that originates |
100 // the request fail. | 103 // the request fail. |
101 bool is_prohibited; | 104 bool is_prohibited; |
| 105 // If set, the HTTP request handler will sleep for this long before |
| 106 // responding. |
| 107 base::TimeDelta delay; |
102 }; | 108 }; |
103 | 109 |
104 struct RedirectEdge { | 110 struct RedirectEdge { |
105 // This response code should be returned by previous url in the chain. | 111 // This response code should be returned by previous url in the chain. |
106 net::HttpStatusCode code; | 112 net::HttpStatusCode code; |
107 GURL url; | 113 GURL url; |
108 bool is_client_side; | 114 bool is_client_side; |
109 }; | 115 }; |
110 | 116 |
111 // Helper class to track and allow waiting for ResourcePrefetchPredictor | 117 // Helper class to track and allow waiting for ResourcePrefetchPredictor |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 168 } |
163 | 169 |
164 // Fill a NavigationID with "empty" data that does not trigger | 170 // Fill a NavigationID with "empty" data that does not trigger |
165 // the is_valid DCHECK(). Allows comparing. | 171 // the is_valid DCHECK(). Allows comparing. |
166 void SetValidNavigationID(NavigationID* navigation_id) { | 172 void SetValidNavigationID(NavigationID* navigation_id) { |
167 navigation_id->tab_id = 0; | 173 navigation_id->tab_id = 0; |
168 navigation_id->main_frame_url = GURL("http://127.0.0.1"); | 174 navigation_id->main_frame_url = GURL("http://127.0.0.1"); |
169 } | 175 } |
170 | 176 |
171 void ModifySubresourceForComparison(URLRequestSummary* subresource, | 177 void ModifySubresourceForComparison(URLRequestSummary* subresource, |
172 bool match_navigation_id) { | 178 bool match_navigation_id, |
| 179 bool match_before_first_contentful_paint) { |
173 if (!match_navigation_id) | 180 if (!match_navigation_id) |
174 SetValidNavigationID(&subresource->navigation_id); | 181 SetValidNavigationID(&subresource->navigation_id); |
| 182 if (!match_before_first_contentful_paint) |
| 183 subresource->before_first_contentful_paint = true; |
175 if (subresource->resource_type == content::RESOURCE_TYPE_IMAGE && | 184 if (subresource->resource_type == content::RESOURCE_TYPE_IMAGE && |
176 subresource->priority == net::LOWEST) { | 185 subresource->priority == net::LOWEST) { |
177 // Fuzzy comparison for images because an image priority can be | 186 // Fuzzy comparison for images because an image priority can be |
178 // boosted during layout via | 187 // boosted during layout via |
179 // ResourceFetcher::updateAllImageResourcePriorities(). | 188 // ResourceFetcher::updateAllImageResourcePriorities(). |
180 subresource->priority = net::MEDIUM; | 189 subresource->priority = net::MEDIUM; |
181 } | 190 } |
182 } | 191 } |
183 | 192 |
184 // Does a custom comparison of subresources of URLRequestSummary | 193 // Does a custom comparison of subresources of URLRequestSummary |
185 // and fail the test if the expectation is not met. | 194 // and fail the test if the expectation is not met. |
186 void CompareSubresources(std::vector<URLRequestSummary> actual_subresources, | 195 void CompareSubresources(std::vector<URLRequestSummary> actual_subresources, |
187 std::vector<URLRequestSummary> expected_subresources, | 196 std::vector<URLRequestSummary> expected_subresources, |
188 bool match_navigation_id) { | 197 bool match_navigation_id, |
| 198 bool match_before_first_contentful_paint) { |
189 // Duplicate resources can be observed in a single navigation but | 199 // Duplicate resources can be observed in a single navigation but |
190 // ResourcePrefetchPredictor only cares about the first occurrence of each. | 200 // ResourcePrefetchPredictor only cares about the first occurrence of each. |
191 RemoveDuplicateSubresources(&actual_subresources); | 201 RemoveDuplicateSubresources(&actual_subresources); |
192 | 202 |
193 for (auto& subresource : actual_subresources) | 203 for (auto& subresource : actual_subresources) |
194 ModifySubresourceForComparison(&subresource, match_navigation_id); | 204 ModifySubresourceForComparison(&subresource, match_navigation_id, |
| 205 match_before_first_contentful_paint); |
195 for (auto& subresource : expected_subresources) | 206 for (auto& subresource : expected_subresources) |
196 ModifySubresourceForComparison(&subresource, match_navigation_id); | 207 ModifySubresourceForComparison(&subresource, match_navigation_id, |
| 208 match_before_first_contentful_paint); |
197 | 209 |
198 EXPECT_THAT(actual_subresources, | 210 EXPECT_THAT(actual_subresources, |
199 testing::UnorderedElementsAreArray(expected_subresources)); | 211 testing::UnorderedElementsAreArray(expected_subresources)); |
200 } | 212 } |
201 | 213 |
202 std::string CreateVersionedETag(size_t version, const std::string& path) { | 214 std::string CreateVersionedETag(size_t version, const std::string& path) { |
203 return base::StringPrintf("'%zu%s'", version, path.c_str()); | 215 return base::StringPrintf("'%zu%s'", version, path.c_str()); |
204 } | 216 } |
205 | 217 |
206 GURL GetRequestURL(const net::test_server::HttpRequest& request) { | 218 GURL GetRequestURL(const net::test_server::HttpRequest& request) { |
(...skipping 19 matching lines...) Expand all Loading... |
226 // Helper class to track and allow waiting for a single OnNavigationLearned | 238 // Helper class to track and allow waiting for a single OnNavigationLearned |
227 // event. The information provided by this event is also used to verify that | 239 // event. The information provided by this event is also used to verify that |
228 // ResourcePrefetchPredictor works as expected. | 240 // ResourcePrefetchPredictor works as expected. |
229 class LearningObserver : public TestObserver { | 241 class LearningObserver : public TestObserver { |
230 public: | 242 public: |
231 using PageRequestSummary = ResourcePrefetchPredictor::PageRequestSummary; | 243 using PageRequestSummary = ResourcePrefetchPredictor::PageRequestSummary; |
232 | 244 |
233 LearningObserver(ResourcePrefetchPredictor* predictor, | 245 LearningObserver(ResourcePrefetchPredictor* predictor, |
234 const size_t expected_url_visit_count, | 246 const size_t expected_url_visit_count, |
235 const PageRequestSummary& expected_summary, | 247 const PageRequestSummary& expected_summary, |
236 bool match_navigation_id) | 248 bool match_navigation_id, |
| 249 bool match_before_first_contentful_paint) |
237 : TestObserver(predictor), | 250 : TestObserver(predictor), |
238 url_visit_count_(expected_url_visit_count), | 251 url_visit_count_(expected_url_visit_count), |
239 summary_(expected_summary), | 252 summary_(expected_summary), |
240 match_navigation_id_(match_navigation_id) {} | 253 match_navigation_id_(match_navigation_id), |
| 254 match_before_first_contentful_paint_( |
| 255 match_before_first_contentful_paint) {} |
241 | 256 |
242 // TestObserver: | 257 // TestObserver: |
243 void OnNavigationLearned(size_t url_visit_count, | 258 void OnNavigationLearned(size_t url_visit_count, |
244 const PageRequestSummary& summary) override { | 259 const PageRequestSummary& summary) override { |
245 EXPECT_EQ(url_visit_count, url_visit_count_); | 260 EXPECT_EQ(url_visit_count, url_visit_count_); |
246 EXPECT_EQ(summary.main_frame_url, summary_.main_frame_url); | 261 EXPECT_EQ(summary.main_frame_url, summary_.main_frame_url); |
247 EXPECT_EQ(summary.initial_url, summary_.initial_url); | 262 EXPECT_EQ(summary.initial_url, summary_.initial_url); |
248 for (const auto& resource : summary.subresource_requests) | 263 for (const auto& resource : summary.subresource_requests) |
249 current_navigation_ids_.insert(resource.navigation_id); | 264 current_navigation_ids_.insert(resource.navigation_id); |
250 CompareSubresources(summary.subresource_requests, | 265 CompareSubresources(summary.subresource_requests, |
251 summary_.subresource_requests, match_navigation_id_); | 266 summary_.subresource_requests, match_navigation_id_, |
| 267 match_before_first_contentful_paint_); |
252 run_loop_.Quit(); | 268 run_loop_.Quit(); |
253 } | 269 } |
254 | 270 |
255 void Wait() { run_loop_.Run(); } | 271 void Wait() { run_loop_.Run(); } |
256 | 272 |
257 std::set<NavigationID>& current_navigation_ids() { | 273 std::set<NavigationID>& current_navigation_ids() { |
258 return current_navigation_ids_; | 274 return current_navigation_ids_; |
259 } | 275 } |
260 | 276 |
261 private: | 277 private: |
262 base::RunLoop run_loop_; | 278 base::RunLoop run_loop_; |
263 size_t url_visit_count_; | 279 size_t url_visit_count_; |
264 PageRequestSummary summary_; | 280 PageRequestSummary summary_; |
265 bool match_navigation_id_; | 281 bool match_navigation_id_; |
| 282 bool match_before_first_contentful_paint_; |
266 std::set<NavigationID> current_navigation_ids_; | 283 std::set<NavigationID> current_navigation_ids_; |
267 | 284 |
268 DISALLOW_COPY_AND_ASSIGN(LearningObserver); | 285 DISALLOW_COPY_AND_ASSIGN(LearningObserver); |
269 }; | 286 }; |
270 | 287 |
271 // Helper class to track and allow waiting for a single OnPrefetchingFinished | 288 // Helper class to track and allow waiting for a single OnPrefetchingFinished |
272 // event. Checks also that {Start,Stop}Prefetching are called with the right | 289 // event. Checks also that {Start,Stop}Prefetching are called with the right |
273 // argument. | 290 // argument. |
274 class PrefetchingObserver : public TestObserver { | 291 class PrefetchingObserver : public TestObserver { |
275 public: | 292 public: |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // URLs from the test server contain a port number. | 370 // URLs from the test server contain a port number. |
354 ResourcePrefetchPredictor::SetAllowPortInUrlsForTesting(true); | 371 ResourcePrefetchPredictor::SetAllowPortInUrlsForTesting(true); |
355 EnsurePredictorInitialized(); | 372 EnsurePredictorInitialized(); |
356 histogram_tester_.reset(new base::HistogramTester()); | 373 histogram_tester_.reset(new base::HistogramTester()); |
357 } | 374 } |
358 | 375 |
359 void TearDownOnMainThread() override { | 376 void TearDownOnMainThread() override { |
360 ResourcePrefetchPredictor::SetAllowPortInUrlsForTesting(false); | 377 ResourcePrefetchPredictor::SetAllowPortInUrlsForTesting(false); |
361 } | 378 } |
362 | 379 |
363 void TestLearningAndPrefetching(const GURL& main_frame_url) { | 380 void TestLearningAndPrefetching( |
| 381 const GURL& main_frame_url, |
| 382 bool match_before_first_contentful_paint = false) { |
364 // Navigate to |main_frame_url| and check all the expectations. | 383 // Navigate to |main_frame_url| and check all the expectations. |
365 NavigateToURLAndCheckSubresources(main_frame_url); | 384 NavigateToURLAndCheckSubresources(main_frame_url, |
| 385 WindowOpenDisposition::CURRENT_TAB, |
| 386 match_before_first_contentful_paint); |
366 ClearCache(); | 387 ClearCache(); |
367 // It is needed to have at least two resource hits to trigger prefetch. | 388 // It is needed to have at least two resource hits to trigger prefetch. |
368 NavigateToURLAndCheckSubresources(main_frame_url); | 389 NavigateToURLAndCheckSubresources(main_frame_url, |
| 390 WindowOpenDisposition::CURRENT_TAB, |
| 391 match_before_first_contentful_paint); |
369 ClearCache(); | 392 ClearCache(); |
370 // Prefetch all needed resources and change expectations so that all | 393 // Prefetch all needed resources and change expectations so that all |
371 // cacheable resources should be served from cache next navigation. | 394 // cacheable resources should be served from cache next navigation. |
372 PrefetchURL(main_frame_url); | 395 PrefetchURL(main_frame_url); |
373 // To be sure that the browser send no requests to the server after | 396 // To be sure that the browser send no requests to the server after |
374 // prefetching. | 397 // prefetching. |
375 NavigateToURLAndCheckSubresourcesAllCached(main_frame_url); | 398 NavigateToURLAndCheckSubresourcesAllCached(main_frame_url); |
376 } | 399 } |
377 | 400 |
378 void NavigateToURLAndCheckSubresourcesAllCached(const GURL& navigation_url) { | 401 void NavigateToURLAndCheckSubresourcesAllCached(const GURL& navigation_url) { |
379 for (auto& kv : resources_) { | 402 for (auto& kv : resources_) { |
380 if (kv.second.is_observable) | 403 if (kv.second.is_observable) |
381 kv.second.is_prohibited = true; | 404 kv.second.is_prohibited = true; |
382 } | 405 } |
383 NavigateToURLAndCheckSubresources(navigation_url); | 406 NavigateToURLAndCheckSubresources(navigation_url); |
384 for (auto& kv : resources_) { | 407 for (auto& kv : resources_) { |
385 if (kv.second.is_observable) | 408 if (kv.second.is_observable) |
386 kv.second.is_prohibited = false; | 409 kv.second.is_prohibited = false; |
387 } | 410 } |
388 } | 411 } |
389 | 412 |
390 void NavigateToURLAndCheckSubresources( | 413 void NavigateToURLAndCheckSubresources( |
391 const GURL& navigation_url, | 414 const GURL& navigation_url, |
392 WindowOpenDisposition disposition = WindowOpenDisposition::CURRENT_TAB) { | 415 WindowOpenDisposition disposition = WindowOpenDisposition::CURRENT_TAB, |
| 416 bool match_before_first_contentful_paint = false) { |
393 GURL initial_url = GetLastClientSideRedirectEndpoint(navigation_url); | 417 GURL initial_url = GetLastClientSideRedirectEndpoint(navigation_url); |
394 GURL main_frame_url = GetRedirectEndpoint(navigation_url); | 418 GURL main_frame_url = GetRedirectEndpoint(navigation_url); |
395 std::vector<URLRequestSummary> url_request_summaries; | 419 std::vector<URLRequestSummary> url_request_summaries; |
396 for (const auto& kv : resources_) { | 420 for (const auto& kv : resources_) { |
397 if (kv.second.is_observable) { | 421 if (kv.second.is_observable) { |
398 url_request_summaries.push_back( | 422 url_request_summaries.push_back( |
399 GetURLRequestSummaryForResource(main_frame_url, kv.second)); | 423 GetURLRequestSummaryForResource(main_frame_url, kv.second)); |
400 } | 424 } |
401 } | 425 } |
402 | 426 |
403 bool match_navigation_id = | 427 bool match_navigation_id = |
404 disposition == WindowOpenDisposition::CURRENT_TAB; | 428 disposition == WindowOpenDisposition::CURRENT_TAB; |
405 | 429 |
406 LearningObserver observer( | 430 LearningObserver observer( |
407 predictor_, UpdateAndGetVisitCount(initial_url), | 431 predictor_, UpdateAndGetVisitCount(initial_url), |
408 CreatePageRequestSummary(main_frame_url.spec(), initial_url.spec(), | 432 CreatePageRequestSummary(main_frame_url.spec(), initial_url.spec(), |
409 url_request_summaries), | 433 url_request_summaries), |
410 match_navigation_id); | 434 match_navigation_id, match_before_first_contentful_paint); |
411 ui_test_utils::NavigateToURLWithDisposition( | 435 ui_test_utils::NavigateToURLWithDisposition( |
412 browser(), navigation_url, disposition, | 436 browser(), navigation_url, disposition, |
413 ui_test_utils::BROWSER_TEST_NONE); | 437 ui_test_utils::BROWSER_TEST_NONE); |
414 observer.Wait(); | 438 observer.Wait(); |
415 | 439 |
416 for (auto& kv : resources_) { | 440 for (auto& kv : resources_) { |
417 if (kv.second.is_observable) | 441 if (kv.second.is_observable) |
418 kv.second.request.was_cached = true; | 442 kv.second.request.was_cached = true; |
419 } | 443 } |
420 for (const auto& nav : observer.current_navigation_ids()) | 444 for (const auto& nav : observer.current_navigation_ids()) |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 689 } |
666 if (summary.request.always_revalidate) | 690 if (summary.request.always_revalidate) |
667 http_response->AddCustomHeader("Cache-Control", "no-cache"); | 691 http_response->AddCustomHeader("Cache-Control", "no-cache"); |
668 else | 692 else |
669 http_response->AddCustomHeader("Cache-Control", "max-age=2147483648"); | 693 http_response->AddCustomHeader("Cache-Control", "max-age=2147483648"); |
670 | 694 |
671 // Add some content, otherwise the prefetch size histogram rounds down to | 695 // Add some content, otherwise the prefetch size histogram rounds down to |
672 // 0kB. | 696 // 0kB. |
673 http_response->set_content(std::string(1024, ' ')); | 697 http_response->set_content(std::string(1024, ' ')); |
674 | 698 |
| 699 if (!summary.delay.is_zero()) |
| 700 base::PlatformThread::Sleep(summary.delay); |
| 701 |
675 return std::move(http_response); | 702 return std::move(http_response); |
676 } | 703 } |
677 | 704 |
678 // The custom handler for redirect requests from the browser to an | 705 // The custom handler for redirect requests from the browser to an |
679 // EmbeddedTestServer. Running on the EmbeddedTestServer IO thread. | 706 // EmbeddedTestServer. Running on the EmbeddedTestServer IO thread. |
680 // Finds the data to serve requests in |redirects_| map keyed by a request | 707 // Finds the data to serve requests in |redirects_| map keyed by a request |
681 // URL. | 708 // URL. |
682 std::unique_ptr<net::test_server::HttpResponse> HandleRedirectRequest( | 709 std::unique_ptr<net::test_server::HttpResponse> HandleRedirectRequest( |
683 const net::test_server::HttpRequest& request) const { | 710 const net::test_server::HttpRequest& request) const { |
684 std::map<GURL, RedirectEdge>::const_iterator redirect_it = | 711 std::map<GURL, RedirectEdge>::const_iterator redirect_it = |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 histogram_tester_->ExpectBucketCount( | 762 histogram_tester_->ExpectBucketCount( |
736 internal::kResourcePrefetchPredictorPrefetchHitsCountNotCached, 4, 1); | 763 internal::kResourcePrefetchPredictorPrefetchHitsCountNotCached, 4, 1); |
737 | 764 |
738 histogram_tester_->ExpectBucketCount( | 765 histogram_tester_->ExpectBucketCount( |
739 internal::kResourcePrefetchPredictorPrefetchMissesSize, 0, 1); | 766 internal::kResourcePrefetchPredictorPrefetchMissesSize, 0, 1); |
740 // Each request is ~1k, see HandleResourceRequest() above. | 767 // Each request is ~1k, see HandleResourceRequest() above. |
741 histogram_tester_->ExpectBucketCount( | 768 histogram_tester_->ExpectBucketCount( |
742 internal::kResourcePrefetchPredictorPrefetchHitsSize, 4, 1); | 769 internal::kResourcePrefetchPredictorPrefetchHitsSize, 4, 1); |
743 } | 770 } |
744 | 771 |
| 772 IN_PROC_BROWSER_TEST_F(ResourcePrefetchPredictorBrowserTest, |
| 773 SubresourceFcpOrder) { |
| 774 AddResource(GetURL(kStylePath), content::RESOURCE_TYPE_STYLESHEET, |
| 775 net::HIGHEST); |
| 776 AddResource(GetURL(kScriptPath), content::RESOURCE_TYPE_SCRIPT, net::MEDIUM); |
| 777 |
| 778 ResourceSummary* image = AddResource( |
| 779 GetURL(kImagePath), content::RESOURCE_TYPE_IMAGE, net::LOWEST); |
| 780 // Delay HTTP response to ensure enough time to receive notice of |
| 781 // firstContentfulPaint. |
| 782 image->delay = base::TimeDelta::FromMilliseconds(1500); |
| 783 image->request.before_first_contentful_paint = false; |
| 784 |
| 785 TestLearningAndPrefetching(GetURL(kHtmlFcpOrderPath), true); |
| 786 } |
| 787 |
745 IN_PROC_BROWSER_TEST_F(ResourcePrefetchPredictorBrowserTest, Redirect) { | 788 IN_PROC_BROWSER_TEST_F(ResourcePrefetchPredictorBrowserTest, Redirect) { |
746 GURL initial_url = GetURLWithHost(kFooHost, kRedirectPath); | 789 GURL initial_url = GetURLWithHost(kFooHost, kRedirectPath); |
747 GURL redirected_url = | 790 GURL redirected_url = |
748 GetPageURLWithReplacements(kBarHost, kHtmlSubresourcesPath); | 791 GetPageURLWithReplacements(kBarHost, kHtmlSubresourcesPath); |
749 AddRedirectChain(initial_url, | 792 AddRedirectChain(initial_url, |
750 {{net::HTTP_MOVED_PERMANENTLY, redirected_url}}); | 793 {{net::HTTP_MOVED_PERMANENTLY, redirected_url}}); |
751 AddResourcesFromSubresourceHtml(); | 794 AddResourcesFromSubresourceHtml(); |
752 TestLearningAndPrefetching(initial_url); | 795 TestLearningAndPrefetching(initial_url); |
753 } | 796 } |
754 | 797 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 AddResourcesFromSubresourceHtml(); | 1005 AddResourcesFromSubresourceHtml(); |
963 | 1006 |
964 NavigateToURLAndCheckSubresources(initial_url); | 1007 NavigateToURLAndCheckSubresources(initial_url); |
965 ClearCache(); | 1008 ClearCache(); |
966 NavigateToURLAndCheckSubresources(initial_url); | 1009 NavigateToURLAndCheckSubresources(initial_url); |
967 ClearCache(); | 1010 ClearCache(); |
968 NavigateToURLAndCheckPrefetching(initial_url); | 1011 NavigateToURLAndCheckPrefetching(initial_url); |
969 } | 1012 } |
970 | 1013 |
971 } // namespace predictors | 1014 } // namespace predictors |
OLD | NEW |