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

Unified Diff: Source/core/fetch/MemoryCacheTest.cpp

Issue 214773004: Fix crash in MemoryCache::replace. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/fetch/MemoryCache.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/MemoryCacheTest.cpp
diff --git a/Source/core/fetch/MemoryCacheTest.cpp b/Source/core/fetch/MemoryCacheTest.cpp
index 3302b630755236ffca7f51d34ba981970a3b90d0..5a10bb68a41a0c35991525e6b1c7485ef00e3193 100644
--- a/Source/core/fetch/MemoryCacheTest.cpp
+++ b/Source/core/fetch/MemoryCacheTest.cpp
@@ -383,4 +383,27 @@ TEST_F(MemoryCacheTest, MultipleReplace)
EXPECT_FALSE(memoryCache()->contains(resource2.get()));
}
+TEST_F(MemoryCacheTest, RemoveDuringRevalidation)
+{
+ ResourcePtr<FakeResource> resource1 = new FakeResource(ResourceRequest(""), Resource::Raw);
+ memoryCache()->add(resource1.get());
+
+ ResourcePtr<FakeResource> resource2 = new FakeResource(ResourceRequest(""), Resource::Raw);
+ memoryCache()->remove(resource1.get());
+ memoryCache()->add(resource2.get());
+ EXPECT_TRUE(memoryCache()->contains(resource2.get()));
+ EXPECT_FALSE(memoryCache()->contains(resource1.get()));
+
+ ResourcePtr<FakeResource> resource3 = new FakeResource(ResourceRequest(""), Resource::Raw);
+ memoryCache()->remove(resource2.get());
+ memoryCache()->add(resource3.get());
+ EXPECT_TRUE(memoryCache()->contains(resource3.get()));
+ EXPECT_FALSE(memoryCache()->contains(resource2.get()));
+
+ memoryCache()->replace(resource1.get(), resource2.get());
+ EXPECT_TRUE(memoryCache()->contains(resource1.get()));
+ EXPECT_FALSE(memoryCache()->contains(resource2.get()));
+ EXPECT_FALSE(memoryCache()->contains(resource3.get()));
+}
+
} // namespace
« no previous file with comments | « Source/core/fetch/MemoryCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698