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

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

Issue 2141843003: Ensure |m_image| is (re-)created in ImageResource::didAddClient() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce ensureImage() Created 4 years, 5 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 | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | no next file » | 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 daf35bd190b5dc7fb3e7d2aa8af05bc32d68e32f..239564a918038758d5deca2b400df1257277affe 100644
--- a/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
+++ b/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
@@ -574,4 +574,41 @@ TEST(ImageResourceTest, FailedRevalidationSvgToSvg)
EXPECT_EQ(300, imageResource->getImage()->height());
}
+// Tests for pruning.
+
+TEST(ImageResourceTest, AddClientAfterPrune)
+{
+ KURL url(ParsedURLString, "http://127.0.0.1:8000/foo");
+ ImageResource* imageResource = ImageResource::create(ResourceRequest(url));
+
+ // Adds a ResourceClient but not ImageResourceObserver.
+ Persistent<MockResourceClient> client1 = new MockResourceClient(imageResource);
+
+ receiveResponse(imageResource, url, "image/jpeg", jpegImage());
+
+ EXPECT_FALSE(imageResource->errorOccurred());
+ ASSERT_TRUE(imageResource->hasImage());
+ EXPECT_FALSE(imageResource->getImage()->isNull());
+ EXPECT_EQ(1, imageResource->getImage()->width());
+ EXPECT_EQ(1, imageResource->getImage()->height());
+ EXPECT_TRUE(client1->notifyFinishedCalled());
+
+ client1->removeAsClient();
+
+ EXPECT_FALSE(imageResource->hasClientsOrObservers());
+
+ imageResource->prune();
+
+ EXPECT_FALSE(imageResource->hasImage());
+
+ // Re-adds a ResourceClient but not ImageResourceObserver.
+ Persistent<MockResourceClient> client2 = new MockResourceClient(imageResource);
+
+ ASSERT_TRUE(imageResource->hasImage());
+ EXPECT_FALSE(imageResource->getImage()->isNull());
+ EXPECT_EQ(1, imageResource->getImage()->width());
+ EXPECT_EQ(1, imageResource->getImage()->height());
+ EXPECT_TRUE(client2->notifyFinishedCalled());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698