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

Unified Diff: content/browser/cache_storage/cache_storage_manager_unittest.cc

Issue 2186433004: [CacheStorage] Deleting a cache could delete the wrong directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix1
Patch Set: Rebase 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 | « content/browser/cache_storage/cache_storage.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/cache_storage/cache_storage_manager_unittest.cc
diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc
index 1cb0439ccff6d6bc63ea8beb5fd271a20f5a3b52..abb071486c7116ece2993a05eca0d279d9e11e11 100644
--- a/content/browser/cache_storage/cache_storage_manager_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc
@@ -555,7 +555,6 @@ TEST_P(CacheStorageManagerTestP, DropRefAfterNewCacheWithSameNameCreated) {
// 1. Create cache A and hang onto the handle
const GURL kTestURL = GURL("http://example.com/foo");
EXPECT_TRUE(Open(origin1_, "foo"));
- EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL));
std::unique_ptr<CacheStorageCacheHandle> cache_handle =
std::move(callback_cache_handle_);
@@ -564,7 +563,6 @@ TEST_P(CacheStorageManagerTestP, DropRefAfterNewCacheWithSameNameCreated) {
// 3. Create cache B (with the same name)
EXPECT_TRUE(Open(origin1_, "foo"));
- EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL));
// 4. Drop handle to A
cache_handle.reset();
@@ -573,6 +571,32 @@ TEST_P(CacheStorageManagerTestP, DropRefAfterNewCacheWithSameNameCreated) {
EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL));
}
+TEST_P(CacheStorageManagerTestP, DeleteCorrectDirectory) {
+ // This test reproduces crbug.com/630036.
+ // 1. Cache A with name "foo" is created
+ const GURL kTestURL = GURL("http://example.com/foo");
+ EXPECT_TRUE(Open(origin1_, "foo"));
+ std::unique_ptr<CacheStorageCacheHandle> cache_handle =
+ std::move(callback_cache_handle_);
+
+ // 2. Cache A is doomed, but js hangs onto the handle.
+ EXPECT_TRUE(Delete(origin1_, "foo"));
+
+ // 3. Cache B with name "foo" is created
+ EXPECT_TRUE(Open(origin1_, "foo"));
+
+ // 4. Cache B is doomed, and both handles are reset.
+ EXPECT_TRUE(Delete(origin1_, "foo"));
+ cache_handle.reset();
+ callback_cache_handle_.reset();
+
+ // Do some busy work on a different cache to move the cache pool threads
+ // along and trigger the bug.
+ EXPECT_TRUE(Open(origin1_, "bar"));
+ EXPECT_TRUE(CachePut(callback_cache_handle_->value(), kTestURL));
+ EXPECT_TRUE(CacheMatch(callback_cache_handle_->value(), kTestURL));
+}
+
TEST_P(CacheStorageManagerTestP, StorageMatchAllEntryExistsTwice) {
EXPECT_TRUE(Open(origin1_, "foo"));
EXPECT_TRUE(CachePutWithStatusCode(callback_cache_handle_->value(),
« no previous file with comments | « content/browser/cache_storage/cache_storage.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698