summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcmumford@chromium.org <cmumford@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 17:15:20 +0000
committercmumford@chromium.org <cmumford@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 17:15:20 +0000
commitf186e514fe186d2013d5a984cf54f660c66c8861 (patch)
treeb1f05e84b3373e804f01779d4568effdbf0e5853
parent8aa5588cc6c29b8bc9ee38375ead5129c86d570e (diff)
downloadchromium_src-f186e514fe186d2013d5a984cf54f660c66c8861.zip
chromium_src-f186e514fe186d2013d5a984cf54f660c66c8861.tar.gz
chromium_src-f186e514fe186d2013d5a984cf54f660c66c8861.tar.bz2
Properly deal with a corrupt IndexedDB db in indexedDB.webkitGetDatabaseNames
Would previously silently fail and leave the corrupted database intact. BUG=382676 Review URL: https://codereview.chromium.org/356593004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280032 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/indexed_db/indexed_db_backing_store.cc2
-rw-r--r--content/browser/indexed_db/indexed_db_browsertest.cc1
-rw-r--r--content/browser/indexed_db/indexed_db_factory.cc9
-rw-r--r--content/test/data/indexeddb/corrupted_open_db_detection.html18
4 files changed, 28 insertions, 2 deletions
diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc
index 5ef25a5..b99c98e 100644
--- a/content/browser/indexed_db/indexed_db_backing_store.cc
+++ b/content/browser/indexed_db/indexed_db_backing_store.cc
@@ -1177,7 +1177,7 @@ std::vector<base::string16> IndexedDBBackingStore::GetDatabaseNames(
}
if (!s->ok())
- INTERNAL_READ_ERROR_UNTESTED(GET_DATABASE_NAMES);
+ INTERNAL_READ_ERROR(GET_DATABASE_NAMES);
return found_names;
}
diff --git a/content/browser/indexed_db/indexed_db_browsertest.cc b/content/browser/indexed_db/indexed_db_browsertest.cc
index 898cf7b..4483750 100644
--- a/content/browser/indexed_db/indexed_db_browsertest.cc
+++ b/content/browser/indexed_db/indexed_db_browsertest.cc
@@ -615,6 +615,7 @@ INSTANTIATE_TEST_CASE_P(IndexedDBBrowserCorruptionTestInstantiation,
IndexedDBBrowserCorruptionTest,
::testing::Values("failGetBlobJournal",
"get",
+ "failWebkitGetDatabaseNames",
"iterate",
"failTransactionCommit",
"clearObjectStore"));
diff --git a/content/browser/indexed_db/indexed_db_factory.cc b/content/browser/indexed_db/indexed_db_factory.cc
index 9cb77c5..9c32c76 100644
--- a/content/browser/indexed_db/indexed_db_factory.cc
+++ b/content/browser/indexed_db/indexed_db_factory.cc
@@ -201,8 +201,15 @@ void IndexedDBFactory::GetDatabaseNames(
std::vector<base::string16> names = backing_store->GetDatabaseNames(&s);
if (!s.ok()) {
- // TODO(cmumford): Handle this error
DLOG(ERROR) << "Internal error getting database names";
+ IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
+ "Internal error opening backing store for "
+ "indexedDB.webkitGetDatabaseNames.");
+ callbacks->OnError(error);
+ backing_store = NULL;
+ if (s.IsCorruption())
+ HandleBackingStoreCorruption(origin_url, error);
+ return;
}
callbacks->OnSuccess(names);
backing_store = NULL;
diff --git a/content/test/data/indexeddb/corrupted_open_db_detection.html b/content/test/data/indexeddb/corrupted_open_db_detection.html
index 76c5de5..ce45690 100644
--- a/content/test/data/indexeddb/corrupted_open_db_detection.html
+++ b/content/test/data/indexeddb/corrupted_open_db_detection.html
@@ -131,6 +131,24 @@ var tests = {
request.onerror = requestError;
});
},
+ failWebkitGetDatabaseNames: function() {
+ tests.testCommon('readonly');
+ gotRequestError = 0;
+ db.onclose = function(event) {
+ shouldBe("numTransactionErrors", "0");
+ shouldBe("numTransactionAborts", "1");
+ shouldBe("gotRequestError", "1");
+
+ done("Closed as expected");
+ };
+ testXhr("/corrupt/test/fail?class=LevelDBIterator&method=Seek", function() {
+ request = window.indexedDB.webkitGetDatabaseNames();
+ request.onsuccess = unexpectedSuccessCallback;
+ request.onerror = function(evt) {
+ gotRequestError += 1;
+ };
+ });
+ },
iterate: function() {
testXhr("/corrupt/test/corruptdb?storeName", function() {
tests.testCommon('readonly');