| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/loader/LinkLoader.h" | 5 #include "core/loader/LinkLoader.h" |
| 6 | 6 |
| 7 #include "core/frame/Settings.h" | 7 #include "core/frame/Settings.h" |
| 8 #include "core/html/LinkRelAttribute.h" | 8 #include "core/html/LinkRelAttribute.h" |
| 9 #include "core/loader/DocumentLoader.h" | 9 #include "core/loader/DocumentLoader.h" |
| 10 #include "core/loader/LinkLoaderClient.h" | 10 #include "core/loader/LinkLoaderClient.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 EXPECT_EQ(testCase.context, | 244 EXPECT_EQ(testCase.context, |
| 245 resource->resourceRequest().requestContext()); | 245 resource->resourceRequest().requestContext()); |
| 246 if (testCase.expectedReferrerPolicy != ReferrerPolicyDefault) { | 246 if (testCase.expectedReferrerPolicy != ReferrerPolicyDefault) { |
| 247 EXPECT_EQ(testCase.expectedReferrerPolicy, | 247 EXPECT_EQ(testCase.expectedReferrerPolicy, |
| 248 resource->resourceRequest().getReferrerPolicy()); | 248 resource->resourceRequest().getReferrerPolicy()); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 dummyPageHolder->document().fetcher()->clearPreloads(); | 252 dummyPageHolder->document().fetcher()->clearPreloads(); |
| 253 } | 253 } |
| 254 memoryCache()->evictResources(); | 254 Platform::current() |
| 255 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 255 ->getURLLoaderMockFactory() |
| 256 ->unregisterAllURLsAndClearMemoryCache(); |
| 256 } | 257 } |
| 257 } | 258 } |
| 258 | 259 |
| 259 TEST(LinkLoaderTest, Prefetch) { | 260 TEST(LinkLoaderTest, Prefetch) { |
| 260 struct TestCase { | 261 struct TestCase { |
| 261 const char* href; | 262 const char* href; |
| 262 // TODO(yoav): Add support for type and media crbug.com/662687 | 263 // TODO(yoav): Add support for type and media crbug.com/662687 |
| 263 const char* type; | 264 const char* type; |
| 264 const char* media; | 265 const char* media; |
| 265 const ReferrerPolicy referrerPolicy; | 266 const ReferrerPolicy referrerPolicy; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 296 EXPECT_TRUE(resource); | 297 EXPECT_TRUE(resource); |
| 297 } else { | 298 } else { |
| 298 EXPECT_FALSE(resource); | 299 EXPECT_FALSE(resource); |
| 299 } | 300 } |
| 300 if (resource) { | 301 if (resource) { |
| 301 if (testCase.expectedReferrerPolicy != ReferrerPolicyDefault) { | 302 if (testCase.expectedReferrerPolicy != ReferrerPolicyDefault) { |
| 302 EXPECT_EQ(testCase.expectedReferrerPolicy, | 303 EXPECT_EQ(testCase.expectedReferrerPolicy, |
| 303 resource->resourceRequest().getReferrerPolicy()); | 304 resource->resourceRequest().getReferrerPolicy()); |
| 304 } | 305 } |
| 305 } | 306 } |
| 306 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 307 Platform::current() |
| 308 ->getURLLoaderMockFactory() |
| 309 ->unregisterAllURLsAndClearMemoryCache(); |
| 307 } | 310 } |
| 308 } | 311 } |
| 309 | 312 |
| 310 TEST(LinkLoaderTest, DNSPrefetch) { | 313 TEST(LinkLoaderTest, DNSPrefetch) { |
| 311 struct { | 314 struct { |
| 312 const char* href; | 315 const char* href; |
| 313 const bool shouldLoad; | 316 const bool shouldLoad; |
| 314 } cases[] = { | 317 } cases[] = { |
| 315 {"http://example.com/", true}, | 318 {"http://example.com/", true}, |
| 316 {"https://example.com/", true}, | 319 {"https://example.com/", true}, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 loader->loadLink(LinkRelAttribute("preconnect"), testCase.crossOrigin, | 371 loader->loadLink(LinkRelAttribute("preconnect"), testCase.crossOrigin, |
| 369 String(), String(), String(), ReferrerPolicyDefault, | 372 String(), String(), String(), ReferrerPolicyDefault, |
| 370 hrefURL, dummyPageHolder->document(), networkHints); | 373 hrefURL, dummyPageHolder->document(), networkHints); |
| 371 EXPECT_EQ(testCase.shouldLoad, networkHints.didPreconnect()); | 374 EXPECT_EQ(testCase.shouldLoad, networkHints.didPreconnect()); |
| 372 EXPECT_EQ(testCase.isHTTPS, networkHints.isHTTPS()); | 375 EXPECT_EQ(testCase.isHTTPS, networkHints.isHTTPS()); |
| 373 EXPECT_EQ(testCase.isCrossOrigin, networkHints.isCrossOrigin()); | 376 EXPECT_EQ(testCase.isCrossOrigin, networkHints.isCrossOrigin()); |
| 374 } | 377 } |
| 375 } | 378 } |
| 376 | 379 |
| 377 } // namespace blink | 380 } // namespace blink |
| OLD | NEW |