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

Unified Diff: content/browser/indexed_db/indexed_db_browsertest.cc

Issue 18660012: IndexedDB: Test for "close" event when connection is force-closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More context simplification Created 7 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 | « no previous file | content/test/data/indexeddb/force_close_event.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cecc98a113af5ac9dbadfc4fe3acb9171cb19a0e..a470d8eb1b051dc9c433e48631f4d1a0bc72fbcd 100644
--- a/content/browser/indexed_db/indexed_db_browsertest.cc
+++ b/content/browser/indexed_db/indexed_db_browsertest.cc
@@ -229,22 +229,20 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed,
}
static void CopyLevelDBToProfile(Shell* shell,
- scoped_refptr<IndexedDBContext> context,
+ scoped_refptr<IndexedDBContextImpl> context,
const std::string& test_directory) {
DCHECK(context->TaskRunner()->RunsTasksOnCurrentThread());
base::FilePath leveldb_dir(FILE_PATH_LITERAL("file__0.indexeddb.leveldb"));
base::FilePath test_data_dir =
GetTestFilePath("indexeddb", test_directory.c_str()).Append(leveldb_dir);
- IndexedDBContextImpl* context_impl =
jsbell 2013/07/11 00:17:09 Unrelated simplification.
- static_cast<IndexedDBContextImpl*>(context.get());
- base::FilePath dest = context_impl->data_path().Append(leveldb_dir);
+ base::FilePath dest = context->data_path().Append(leveldb_dir);
// If we don't create the destination directory first, the contents of the
// leveldb directory are copied directly into profile/IndexedDB instead of
// profile/IndexedDB/file__0.xxx/
ASSERT_TRUE(file_util::CreateDirectory(dest));
const bool kRecursive = true;
ASSERT_TRUE(base::CopyDirectory(test_data_dir,
- context_impl->data_path(),
+ context->data_path(),
kRecursive));
}
@@ -344,16 +342,10 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithMissingSSTFile,
IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, LevelDBLogFileTest) {
// Any page that opens an IndexedDB will work here.
SimpleTest(GetTestUrl("indexeddb", "database_test.html"));
- scoped_refptr<IndexedDBContext> context =
jsbell 2013/07/11 00:17:09 Unrelated simplification.
- BrowserContext::GetDefaultStoragePartition(
- shell()->web_contents()->GetBrowserContext())->
- GetIndexedDBContext();
- IndexedDBContextImpl* context_impl =
- static_cast<IndexedDBContextImpl*>(context.get());
base::FilePath leveldb_dir(FILE_PATH_LITERAL("file__0.indexeddb.leveldb"));
base::FilePath log_file(FILE_PATH_LITERAL("LOG"));
base::FilePath log_file_path =
- context_impl->data_path().Append(leveldb_dir).Append(log_file);
+ GetContext()->data_path().Append(leveldb_dir).Append(log_file);
int64 size;
EXPECT_TRUE(file_util::GetFileSize(log_file_path, &size));
EXPECT_GT(size, 0);
@@ -422,4 +414,21 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ConnectionsClosedOnTabClose) {
EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle());
}
+// Verify that a "close" event is fired at database connections when
+// the backing store is deleted.
+IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ForceCloseEventTest) {
+ NavigateAndWaitForTitle(shell(), "force_close_event.html", NULL,
+ "connection ready");
+
+ GetContext()->TaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&IndexedDBContextImpl::DeleteForOrigin,
+ GetContext(),
+ GURL("file:///")));
+
+ string16 expected_title16(ASCIIToUTF16("connection closed"));
+ TitleWatcher title_watcher(shell()->web_contents(), expected_title16);
+ EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle());
+}
+
} // namespace content
« no previous file with comments | « no previous file | content/test/data/indexeddb/force_close_event.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698