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

Unified Diff: third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp

Issue 1893673004: Ensure RemoteFontFaceSource doesn't try to start a load in a detached document (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp b/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
index e7765ce3f8239b1753ff6d56c9a1117106ac96b3..3d39d8737d391f68043f6776251ddd4512aa5179 100644
--- a/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
+++ b/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
@@ -80,9 +80,43 @@ static Vector<unsigned char> jpegImage()
return jpeg;
}
+namespace {
+
+class MockTaskRunner : public blink::WebTaskRunner {
+ void postTask(const WebTraceLocation&, Task*) override { }
+ void postDelayedTask(const WebTraceLocation&, Task*, double) override { }
+ WebTaskRunner* clone() override { return nullptr; }
+ double virtualTimeSeconds() const override { return 0.0; }
+ double monotonicallyIncreasingVirtualTimeSeconds() const override { return 0.0; }
+};
+
+}
+
+class ImageResourceTestMockFetchContext : public FetchContext {
+public:
+ static ImageResourceTestMockFetchContext* create()
+ {
+ return new ImageResourceTestMockFetchContext;
+ }
+
+ virtual ~ImageResourceTestMockFetchContext() { }
+
+ bool allowImage(bool imagesEnabled, const KURL&) const override { return true; }
+ bool canRequest(Resource::Type, const ResourceRequest&, const KURL&, const ResourceLoaderOptions&, bool forPreload, FetchRequest::OriginRestriction) const override { return true; }
+ bool shouldLoadNewResource(Resource::Type) const override { return true; }
+ WebTaskRunner* loadingTaskRunner() const override { return m_runner.get(); }
+
+private:
+ ImageResourceTestMockFetchContext()
+ : m_runner(adoptPtr(new MockTaskRunner))
+ { }
+
+ OwnPtr<MockTaskRunner> m_runner;
+};
+
TEST(ImageResourceTest, MultipartImage)
{
- ResourceFetcher* fetcher = ResourceFetcher::create(nullptr);
+ ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html");
@@ -148,7 +182,7 @@ TEST(ImageResourceTest, CancelOnDetach)
KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html");
- ResourceFetcher* fetcher = ResourceFetcher::create(nullptr);
+ ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
// Emulate starting a real load.
ImageResource* cachedImage = ImageResource::create(ResourceRequest(testURL));
@@ -234,7 +268,7 @@ TEST(ImageResourceTest, ReloadIfLoFi)
cachedImage->setStatus(Resource::Pending);
MockImageResourceClient client(cachedImage);
- ResourceFetcher* fetcher = ResourceFetcher::create(nullptr);
+ ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
// Send the image response.
Vector<unsigned char> jpeg = jpegImage();
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698