| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) | 116 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) |
| 117 { | 117 { |
| 118 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); | 118 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); |
| 119 // Try to request a url. The request should fail, no resource should be retu
rned, | 119 // Try to request a url. The request should fail, no resource should be retu
rned, |
| 120 // and no resource should be present in the cache. | 120 // and no resource should be present in the cache. |
| 121 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); | 121 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); |
| 122 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn
itiatorInfo()); | 122 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn
itiatorInfo()); |
| 123 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact
ory()); | 123 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact
ory()); |
| 124 EXPECT_EQ(resource, static_cast<Resource*>(nullptr)); | 124 EXPECT_FALSE(resource); |
| 125 EXPECT_EQ(memoryCache()->resourceForURL(secureURL), static_cast<Resource*>(n
ullptr)); | 125 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); |
| 126 | 126 |
| 127 // Start by calling startLoad() directly, rather than via requestResource(). | 127 // Start by calling startLoad() directly, rather than via requestResource(). |
| 128 // This shouldn't crash. | 128 // This shouldn't crash. |
| 129 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); | 129 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 TEST_F(ResourceFetcherTest, UseExistingResource) | 132 TEST_F(ResourceFetcherTest, UseExistingResource) |
| 133 { | 133 { |
| 134 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe
tchContext::create()); | 134 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe
tchContext::create()); |
| 135 | 135 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 USING_GARBAGE_COLLECTED_MIXIN(RequestSameResourceOnComplete); | 230 USING_GARBAGE_COLLECTED_MIXIN(RequestSameResourceOnComplete); |
| 231 public: | 231 public: |
| 232 explicit RequestSameResourceOnComplete(Resource* resource) | 232 explicit RequestSameResourceOnComplete(Resource* resource) |
| 233 : m_resource(resource) | 233 : m_resource(resource) |
| 234 , m_notifyFinishedCalled(false) | 234 , m_notifyFinishedCalled(false) |
| 235 { | 235 { |
| 236 } | 236 } |
| 237 | 237 |
| 238 void notifyFinished(Resource* resource) override | 238 void notifyFinished(Resource* resource) override |
| 239 { | 239 { |
| 240 ASSERT_EQ(m_resource, resource); | 240 EXPECT_EQ(m_resource, resource); |
| 241 ResourceFetcherTestMockFetchContext* context = ResourceFetcherTestMockFe
tchContext::create(); | 241 ResourceFetcherTestMockFetchContext* context = ResourceFetcherTestMockFe
tchContext::create(); |
| 242 context->setCachePolicy(CachePolicyRevalidate); | 242 context->setCachePolicy(CachePolicyRevalidate); |
| 243 ResourceFetcher* fetcher2 = ResourceFetcher::create(context); | 243 ResourceFetcher* fetcher2 = ResourceFetcher::create(context); |
| 244 FetchRequest fetchRequest2(m_resource->url(), FetchInitiatorInfo()); | 244 FetchRequest fetchRequest2(m_resource->url(), FetchInitiatorInfo()); |
| 245 Resource* resource2 = fetcher2->requestResource(fetchRequest2, TestResou
rceFactory(Resource::Image)); | 245 Resource* resource2 = fetcher2->requestResource(fetchRequest2, TestResou
rceFactory(Resource::Image)); |
| 246 EXPECT_EQ(m_resource, resource2); | 246 EXPECT_EQ(m_resource, resource2); |
| 247 m_notifyFinishedCalled = true; | 247 m_notifyFinishedCalled = true; |
| 248 } | 248 } |
| 249 bool notifyFinishedCalled() const { return m_notifyFinishedCalled; } | 249 bool notifyFinishedCalled() const { return m_notifyFinishedCalled; } |
| 250 | 250 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 FetchRequest request(url, FetchInitiatorInfo()); | 510 FetchRequest request(url, FetchInitiatorInfo()); |
| 511 request.makeSynchronous(); | 511 request.makeSynchronous(); |
| 512 Resource* resource = fetcher->requestResource(request, TestResourceFactory()
); | 512 Resource* resource = fetcher->requestResource(request, TestResourceFactory()
); |
| 513 EXPECT_TRUE(resource->isLoaded()); | 513 EXPECT_TRUE(resource->isLoaded()); |
| 514 EXPECT_EQ(ResourceLoadPriorityHighest, resource->resourceRequest().priority(
)); | 514 EXPECT_EQ(ResourceLoadPriorityHighest, resource->resourceRequest().priority(
)); |
| 515 | 515 |
| 516 memoryCache()->remove(resource); | 516 memoryCache()->remove(resource); |
| 517 } | 517 } |
| 518 | 518 |
| 519 } // namespace blink | 519 } // namespace blink |
| OLD | NEW |