Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp

Issue 1805653002: Add regression test for crbug.com/594072 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/fetch/ResourceFetcher.h" 31 #include "core/fetch/ResourceFetcher.h"
32 32
33 #include "core/fetch/FetchInitiatorInfo.h" 33 #include "core/fetch/FetchInitiatorInfo.h"
34 #include "core/fetch/FetchInitiatorTypeNames.h" 34 #include "core/fetch/FetchInitiatorTypeNames.h"
35 #include "core/fetch/FetchRequest.h" 35 #include "core/fetch/FetchRequest.h"
36 #include "core/fetch/MemoryCache.h" 36 #include "core/fetch/MemoryCache.h"
37 #include "core/fetch/RawResource.h"
37 #include "core/fetch/ResourceLoader.h" 38 #include "core/fetch/ResourceLoader.h"
38 #include "platform/exported/WrappedResourceResponse.h" 39 #include "platform/exported/WrappedResourceResponse.h"
39 #include "platform/heap/Handle.h" 40 #include "platform/heap/Handle.h"
40 #include "platform/network/ResourceRequest.h" 41 #include "platform/network/ResourceRequest.h"
41 #include "platform/testing/URLTestHelpers.h" 42 #include "platform/testing/URLTestHelpers.h"
42 #include "platform/weborigin/KURL.h" 43 #include "platform/weborigin/KURL.h"
43 #include "public/platform/Platform.h" 44 #include "public/platform/Platform.h"
44 #include "public/platform/WebURLResponse.h" 45 #include "public/platform/WebURLResponse.h"
45 #include "public/platform/WebUnitTestSupport.h" 46 #include "public/platform/WebUnitTestSupport.h"
46 #include "testing/gtest/include/gtest/gtest.h" 47 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 ResourceRequest request(KURL(ParsedURLString, "data:text/html,foo")); 231 ResourceRequest request(KURL(ParsedURLString, "data:text/html,foo"));
231 ResourceLoaderOptions options; 232 ResourceLoaderOptions options;
232 options.dataBufferingPolicy = DoNotBufferData; 233 options.dataBufferingPolicy = DoNotBufferData;
233 FetchRequest fetchRequest = FetchRequest(request, FetchInitiatorTypeNames::i nternal, options); 234 FetchRequest fetchRequest = FetchRequest(request, FetchInitiatorTypeNames::i nternal, options);
234 RefPtrWillBeRawPtr<Resource> resource1 = fetcher->requestResource(fetchReque st, TestResourceFactory(Resource::Media)); 235 RefPtrWillBeRawPtr<Resource> resource1 = fetcher->requestResource(fetchReque st, TestResourceFactory(Resource::Media));
235 RefPtrWillBeRawPtr<Resource> resource2 = fetcher->requestResource(fetchReque st, TestResourceFactory(Resource::Media)); 236 RefPtrWillBeRawPtr<Resource> resource2 = fetcher->requestResource(fetchReque st, TestResourceFactory(Resource::Media));
236 EXPECT_NE(resource1.get(), resource2.get()); 237 EXPECT_NE(resource1.get(), resource2.get());
237 memoryCache()->remove(resource2.get()); 238 memoryCache()->remove(resource2.get());
238 } 239 }
239 240
241 class ServeRequestsOnCompleteClient : public RawResourceClient {
242 public:
243 void notifyFinished(Resource*) override
244 {
245 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests( );
246 }
247
hiroshige 2016/03/15 21:52:34 In addition to the RELEASE_ASSERT, how about addin
Nate Chapin 2016/03/16 17:04:03 Done.
248 String debugName() const override { return "ServeRequestsOnCompleteClient"; }
249 };
250
251 TEST_F(ResourceFetcherTest, ResponseOnCancel)
hiroshige 2016/03/15 21:52:34 How about adding comments that have - link to Issu
Nate Chapin 2016/03/16 17:04:03 Done.
252 {
253 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html");
254 ResourceResponse response;
255 response.setURL(url);
256 response.setHTTPStatusCode(200);
257 URLTestHelpers::registerMockedURLLoadWithCustomResponse(url, "white-1x1.png" , WebString::fromUTF8(""), WrappedResourceResponse(response));
258
259 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe tchContext::create());
260 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo());
261 RefPtrWillBeRawPtr<Resource> resource = fetcher->requestResource(fetchReques t, TestResourceFactory(Resource::Raw));
262 ServeRequestsOnCompleteClient client;
263 resource->addClient(&client);
264 resource->loader()->cancel();
265 Platform::current()->unitTestSupport()->unregisterMockedURL(url);
266 }
267
240 } // namespace blink 268 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698