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

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

Issue 2399243002: Revert of Make ResourceFetcher return Resources with LoadError instead of nullptrs. (patchset #8 id… (Closed)
Patch Set: Created 4 years, 2 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
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 CachePolicy m_policy; 109 CachePolicy m_policy;
110 std::unique_ptr<scheduler::FakeWebTaskRunner> m_runner; 110 std::unique_ptr<scheduler::FakeWebTaskRunner> m_runner;
111 bool m_complete; 111 bool m_complete;
112 long long m_transferSize; 112 long long m_transferSize;
113 }; 113 };
114 114
115 class ResourceFetcherTest : public ::testing::Test {}; 115 class ResourceFetcherTest : public ::testing::Test {};
116 116
117 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) { 117 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) {
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, and a resource in an error 119 // Try to request a url. The request should fail, no resource should be
120 // state should be returned, and no resource should be present in the cache. 120 // returned, and no resource should be present in the cache.
121 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); 121 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr);
122 ResourceRequest resourceRequest(secureURL); 122 ResourceRequest resourceRequest(secureURL);
123 resourceRequest.setRequestContext(WebURLRequest::RequestContextInternal); 123 resourceRequest.setRequestContext(WebURLRequest::RequestContextInternal);
124 FetchRequest fetchRequest = 124 FetchRequest fetchRequest =
125 FetchRequest(resourceRequest, FetchInitiatorInfo()); 125 FetchRequest(resourceRequest, FetchInitiatorInfo());
126 Resource* resource = RawResource::fetch(fetchRequest, fetcher); 126 Resource* resource = RawResource::fetch(fetchRequest, fetcher);
127 ASSERT_TRUE(resource); 127 EXPECT_FALSE(resource);
128 EXPECT_TRUE(resource->errorOccurred());
129 EXPECT_TRUE(resource->resourceError().isAccessCheck());
130 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); 128 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL));
131 129
132 // Start by calling startLoad() directly, rather than via requestResource(). 130 // Start by calling startLoad() directly, rather than via requestResource().
133 // This shouldn't crash. 131 // This shouldn't crash.
134 fetcher->startLoad(RawResource::create(secureURL, Resource::Raw)); 132 fetcher->startLoad(RawResource::create(secureURL, Resource::Raw));
135 } 133 }
136 134
137 TEST_F(ResourceFetcherTest, UseExistingResource) { 135 TEST_F(ResourceFetcherTest, UseExistingResource) {
138 ResourceFetcher* fetcher = 136 ResourceFetcher* fetcher =
139 ResourceFetcher::create(ResourceFetcherTestMockFetchContext::create()); 137 ResourceFetcher::create(ResourceFetcherTestMockFetchContext::create());
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 Platform::current()->getURLLoaderMockFactory()->registerURL( 708 Platform::current()->getURLLoaderMockFactory()->registerURL(
711 url, WebURLResponse(), ""); 709 url, WebURLResponse(), "");
712 Resource* newResource = RawResource::fetch(fetchRequest, fetcher); 710 Resource* newResource = RawResource::fetch(fetchRequest, fetcher);
713 fetcher->stopFetching(); 711 fetcher->stopFetching();
714 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); 712 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url);
715 713
716 EXPECT_NE(resource, newResource); 714 EXPECT_NE(resource, newResource);
717 } 715 }
718 716
719 } // namespace blink 717 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | third_party/WebKit/Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698