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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 Resource* create(const ResourceRequest& request, const ResourceLoaderOptions
& options, const String& charset) const override | 111 Resource* create(const ResourceRequest& request, const ResourceLoaderOptions
& options, const String& charset) const override |
112 { | 112 { |
113 return Resource::create(request, type(), options); | 113 return Resource::create(request, type(), options); |
114 } | 114 } |
115 }; | 115 }; |
116 | 116 |
117 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) | 117 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) |
118 { | 118 { |
119 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); | 119 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); |
120 // Try to request a url. The request should fail, no resource should be retu
rned, | 120 // Try to request a url. The request should fail, and a resource in an error
state |
121 // and no resource should be present in the cache. | 121 // should be returned, and no resource should be present in the cache. |
122 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); | 122 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); |
123 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn
itiatorInfo()); | 123 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn
itiatorInfo()); |
124 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact
ory()); | 124 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact
ory()); |
125 EXPECT_FALSE(resource); | 125 ASSERT_TRUE(resource); |
| 126 EXPECT_TRUE(resource->errorOccurred()); |
| 127 EXPECT_TRUE(resource->resourceError().isAccessCheck()); |
126 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); | 128 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); |
127 | 129 |
128 // Start by calling startLoad() directly, rather than via requestResource(). | 130 // Start by calling startLoad() directly, rather than via requestResource(). |
129 // This shouldn't crash. | 131 // This shouldn't crash. |
130 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); | 132 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); |
131 } | 133 } |
132 | 134 |
133 TEST_F(ResourceFetcherTest, UseExistingResource) | 135 TEST_F(ResourceFetcherTest, UseExistingResource) |
134 { | 136 { |
135 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe
tchContext::create()); | 137 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe
tchContext::create()); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 EXPECT_TRUE(memoryCache()->contains(resource)); | 657 EXPECT_TRUE(memoryCache()->contains(resource)); |
656 EXPECT_TRUE(resource->isPreloaded()); | 658 EXPECT_TRUE(resource->isPreloaded()); |
657 | 659 |
658 // DCL reached on second fetcher | 660 // DCL reached on second fetcher |
659 fetcher2->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads); | 661 fetcher2->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads); |
660 EXPECT_TRUE(memoryCache()->contains(resource)); | 662 EXPECT_TRUE(memoryCache()->contains(resource)); |
661 EXPECT_FALSE(resource->isPreloaded()); | 663 EXPECT_FALSE(resource->isPreloaded()); |
662 } | 664 } |
663 | 665 |
664 } // namespace blink | 666 } // namespace blink |
OLD | NEW |