Index: Source/modules/indexeddb/IDBDatabase.cpp |
diff --git a/Source/modules/indexeddb/IDBDatabase.cpp b/Source/modules/indexeddb/IDBDatabase.cpp |
index 186bf64ba4e5b84aed26c334b82f17a9b06f43aa..237e62404f3007cac5c0f01b5e857271033e892a 100644 |
--- a/Source/modules/indexeddb/IDBDatabase.cpp |
+++ b/Source/modules/indexeddb/IDBDatabase.cpp |
@@ -48,7 +48,18 @@ |
namespace WebCore { |
-const char IDBDatabase::notFoundErrorMessage[] = "An operation failed because the requested database object could not be found."; |
+const char IDBDatabase::indexDeletedMessage[] = "The index or its object store has been deleted."; |
+const char IDBDatabase::isKeyCursorMessage[] = "The cursor is a key cursor."; |
+const char IDBDatabase::noKeyOrKeyRangeMessage[] = "No key or key range specified."; |
+const char IDBDatabase::noSuchIndexMessage[] = "The specified index was not be found."; |
arv (Not doing code reviews)
2013/07/12 17:43:08
Bad grammar of message
jsbell
2013/07/12 17:53:14
Done.
|
+const char IDBDatabase::noSuchObjectStoreMessage[] = "The specified object store was not found."; |
+const char IDBDatabase::notGotValueMessage[] = "The cursor is being iterated or has iterated past its end."; |
+const char IDBDatabase::notValidKeyMessage[] = "The parameter is not a valid key."; |
+const char IDBDatabase::notVersionChangeTransactionMessage[] = "The database is not running a version change transaction."; |
+const char IDBDatabase::objectStoreDeletedMessage[] = "The object store has been deleted."; |
+const char IDBDatabase::requestNotFinishedMessage[] = "The request has not finished."; |
+const char IDBDatabase::sourceDeletedMessage[] = "The cursor's source or effective object store has been deleted."; |
+const char IDBDatabase::transactionFinishedMessage[] = "The transaction has finished."; |
PassRefPtr<IDBDatabase> IDBDatabase::create(ScriptExecutionContext* context, PassRefPtr<IDBDatabaseBackendInterface> database, PassRefPtr<IDBDatabaseCallbacks> callbacks) |
{ |
@@ -176,7 +187,11 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co |
IDB_TRACE("IDBDatabase::createObjectStore"); |
HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBCreateObjectStoreCall, IDBMethodsMax); |
if (!m_versionChangeTransaction) { |
- es.throwDOMException(InvalidStateError); |
+ es.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTransactionMessage); |
+ return 0; |
+ } |
+ if (m_versionChangeTransaction->isFinished()) { |
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedMessage); |
return 0; |
} |
if (!m_versionChangeTransaction->isActive()) { |
@@ -185,17 +200,17 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co |
} |
if (containsObjectStore(name)) { |
- es.throwDOMException(ConstraintError); |
+ es.throwDOMException(ConstraintError, "An object store with the specified name already exists."); |
return 0; |
} |
if (!keyPath.isNull() && !keyPath.isValid()) { |
- es.throwDOMException(SyntaxError); |
+ es.throwDOMException(SyntaxError, "The keyPath option is not a valid key path."); |
return 0; |
} |
if (autoIncrement && ((keyPath.type() == IDBKeyPath::StringType && keyPath.string().isEmpty()) || keyPath.type() == IDBKeyPath::ArrayType)) { |
- es.throwDOMException(InvalidAccessError); |
+ es.throwDOMException(InvalidAccessError, "The autoIncrement option was set but the keyPath option was not a non-empty string."); |
arv (Not doing code reviews)
2013/07/12 17:43:08
Double negation. Maybe?
but the keyPath option wa
jsbell
2013/07/12 17:53:14
Went with "but the keyPath option was empty or an
|
return 0; |
} |
@@ -216,7 +231,11 @@ void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& es) |
IDB_TRACE("IDBDatabase::deleteObjectStore"); |
HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBDeleteObjectStoreCall, IDBMethodsMax); |
if (!m_versionChangeTransaction) { |
- es.throwDOMException(InvalidStateError); |
+ es.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTransactionMessage); |
+ return; |
+ } |
+ if (m_versionChangeTransaction->isFinished()) { |
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedMessage); |
return; |
} |
if (!m_versionChangeTransaction->isActive()) { |
@@ -226,7 +245,7 @@ void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& es) |
int64_t objectStoreId = findObjectStoreId(name); |
if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { |
- es.throwDOMException(NotFoundError, IDBDatabase::notFoundErrorMessage); |
+ es.throwDOMException(NotFoundError, "The specified object store was not found."); |
return; |
} |
@@ -240,7 +259,7 @@ PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont |
IDB_TRACE("IDBDatabase::transaction"); |
HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBTransactionCall, IDBMethodsMax); |
if (!scope.size()) { |
- es.throwDOMException(InvalidAccessError); |
+ es.throwDOMException(InvalidAccessError, "The storeNames parameter was empty."); |
return 0; |
} |
@@ -248,8 +267,13 @@ PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont |
if (es.hadException()) |
return 0; |
- if (m_versionChangeTransaction || m_closePending) { |
- es.throwDOMException(InvalidStateError); |
+ if (m_versionChangeTransaction) { |
+ es.throwDOMException(InvalidStateError, "A version change transaction is running."); |
+ return 0; |
+ } |
+ |
+ if (m_closePending) { |
+ es.throwDOMException(InvalidStateError, "The database connection is closing."); |
return 0; |
} |
@@ -257,7 +281,7 @@ PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont |
for (size_t i = 0; i < scope.size(); ++i) { |
int64_t objectStoreId = findObjectStoreId(scope[i]); |
if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { |
- es.throwDOMException(NotFoundError, IDBDatabase::notFoundErrorMessage); |
+ es.throwDOMException(NotFoundError, "One of the specified object stores was not found."); |
return 0; |
} |
objectStoreIds.append(objectStoreId); |