Index: content/browser/indexed_db/indexed_db_browsertest.cc |
diff --git a/content/browser/indexed_db/indexed_db_browsertest.cc b/content/browser/indexed_db/indexed_db_browsertest.cc |
index fbe35bf8499159e328f4c941901382773a70596f..d8a67c0abdba0f811fbbca4ea775d6c52040cef1 100644 |
--- a/content/browser/indexed_db/indexed_db_browsertest.cc |
+++ b/content/browser/indexed_db/indexed_db_browsertest.cc |
@@ -150,6 +150,22 @@ class IndexedDBBrowserTest : public ContentBrowserTest { |
return disk_usage_; |
} |
+ virtual int RequestBlobFileCount() { |
+ PostTaskAndReplyWithResult( |
+ GetContext()->TaskRunner(), FROM_HERE, |
+ base::Bind(&IndexedDBContext::GetOriginBlobFileCount, GetContext(), |
+ GURL("file:///")), |
+ base::Bind(&IndexedDBBrowserTest::DidGetBlobFileCount, this)); |
+ scoped_refptr<base::ThreadTestHelper> helper( |
+ new base::ThreadTestHelper(BrowserMainLoop::GetInstance() |
+ ->indexed_db_thread() |
+ ->message_loop_proxy())); |
+ EXPECT_TRUE(helper->Run()); |
+ // Wait for DidGetBlobFileCount to be called. |
+ base::MessageLoop::current()->RunUntilIdle(); |
+ return blob_file_count_; |
+ } |
+ |
private: |
static MockBrowserTestIndexedDBClassFactory* GetTestClassFactory() { |
static ::base::LazyInstance<MockBrowserTestIndexedDBClassFactory>::Leaky |
@@ -165,7 +181,10 @@ class IndexedDBBrowserTest : public ContentBrowserTest { |
disk_usage_ = bytes; |
} |
+ virtual void DidGetBlobFileCount(int count) { blob_file_count_ = count; } |
+ |
int64 disk_usage_; |
+ int blob_file_count_ = 0; |
DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTest); |
}; |
@@ -405,6 +424,20 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CanDeleteWhenOverQuotaTest) { |
SimpleTest(GetTestUrl("indexeddb", "delete_over_quota.html")); |
} |
+IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, EmptyBlob) { |
+ // First delete all IDB's for the test origin |
+ GetContext()->TaskRunner()->PostTask( |
jsbell
2015/03/03 22:38:07
Is this actually necessary? Is state persisted acr
cmumford
2015/03/03 23:01:35
Yes, it is necessary. Do you think this should be
jsbell
2015/03/03 23:37:56
SetUp would probably be better, but involve a new
|
+ FROM_HERE, base::Bind(&IndexedDBContextImpl::DeleteForOrigin, |
+ GetContext(), GURL("file:///"))); |
+ int64 original_count = RequestBlobFileCount(); |
+ EXPECT_EQ(0, original_count); // Start with no blob files. |
+ SimpleTest(GetTestUrl("indexeddb", "empty_blob.html")); |
+ int64 new_count = RequestBlobFileCount(); |
+ // The test creates/writes an empty blob, and file. It then deletes the one |
+ // file, so a single file should be left on disk. |
+ EXPECT_EQ(1, new_count); |
jsbell
2015/03/03 23:37:56
Is this still valid if the Blob is deleted too? (s
|
+} |
+ |
IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, BlobDidAck) { |
SimpleTest(GetTestUrl("indexeddb", "blob_did_ack.html")); |
// Wait for idle so that the blob ack has time to be received/processed by |