Chromium Code Reviews| Index: Source/modules/indexeddb/IDBCursor.cpp |
| diff --git a/Source/modules/indexeddb/IDBCursor.cpp b/Source/modules/indexeddb/IDBCursor.cpp |
| index a4eec9b77e80a6319f53fd698c72cce878a5c806..5b0d3c0f53ecaa09434d1dc34bfae2de407de819 100644 |
| --- a/Source/modules/indexeddb/IDBCursor.cpp |
| +++ b/Source/modules/indexeddb/IDBCursor.cpp |
| @@ -126,8 +126,20 @@ PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value, |
| { |
| IDB_TRACE("IDBCursor::update"); |
| - if (!m_gotValue || isKeyCursor() || isDeleted()) { |
| - es.throwDOMException(InvalidStateError); |
| + if (!m_gotValue) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::notGotValueMessage); |
|
arv (Not doing code reviews)
2013/07/12 17:43:08
maybe didntGetValueErrorMessage or noValueErrorMes
jsbell
2013/07/12 17:53:14
Yeah, that was contorted. I went with "noValueErro
|
| + return 0; |
| + } |
| + if (isKeyCursor()) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::isKeyCursorMessage); |
|
arv (Not doing code reviews)
2013/07/12 17:43:08
Can we name these *ErrorMessage?
jsbell
2013/07/12 17:53:14
Done (while you were typing this, actually!)
|
| + return 0; |
| + } |
| + if (isDeleted()) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedMessage); |
| + return 0; |
| + } |
| + if (m_transaction->isFinished()) { |
| + es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedMessage); |
| return 0; |
| } |
| if (!m_transaction->isActive()) { |
| @@ -145,7 +157,7 @@ PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value, |
| if (usesInLineKeys) { |
| RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(m_request->requestState(), value, keyPath); |
| if (!keyPathKey || !keyPathKey->isEqual(m_currentPrimaryKey.get())) { |
| - es.throwDOMException(DataError); |
| + es.throwDOMException(DataError, "The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key."); |
| return 0; |
| } |
| } |
| @@ -156,11 +168,19 @@ PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value, |
| void IDBCursor::advance(unsigned long count, ExceptionState& es) |
| { |
| IDB_TRACE("IDBCursor::advance"); |
| - if (!m_gotValue || isDeleted()) { |
| - es.throwDOMException(InvalidStateError); |
| + if (!m_gotValue) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::notGotValueMessage); |
| + return; |
| + } |
| + if (isDeleted()) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedMessage); |
| return; |
| } |
| + if (m_transaction->isFinished()) { |
| + es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedMessage); |
| + return; |
| + } |
| if (!m_transaction->isActive()) { |
| es.throwDOMException(TransactionInactiveError); |
| return; |
| @@ -187,17 +207,26 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& es) |
| { |
| IDB_TRACE("IDBCursor::continue"); |
| if (key && !key->isValid()) { |
| - es.throwDOMException(DataError); |
| + es.throwDOMException(DataError, IDBDatabase::notValidKeyMessage); |
| return; |
| } |
| + if (m_transaction->isFinished()) { |
| + es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedMessage); |
| + return; |
| + } |
| if (!m_transaction->isActive()) { |
| es.throwDOMException(TransactionInactiveError); |
| return; |
| } |
| - if (!m_gotValue || isDeleted()) { |
| - es.throwDOMException(InvalidStateError); |
| + if (!m_gotValue) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::notGotValueMessage); |
| + return; |
| + } |
| + |
| + if (isDeleted()) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedMessage); |
| return; |
| } |
| @@ -205,12 +234,12 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& es) |
| ASSERT(m_currentKey); |
| if (m_direction == IndexedDB::CursorNext || m_direction == IndexedDB::CursorNextNoDuplicate) { |
| if (!m_currentKey->isLessThan(key.get())) { |
| - es.throwDOMException(DataError); |
| + es.throwDOMException(DataError, "The parameter is less than or equal to this cursor's position."); |
| return; |
| } |
| } else { |
| if (!key->isLessThan(m_currentKey.get())) { |
| - es.throwDOMException(DataError); |
| + es.throwDOMException(DataError, "The parameter is greater than or equal to this cursor's position."); |
| return; |
| } |
| } |
| @@ -226,6 +255,10 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& es) |
| PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext* context, ExceptionState& es) |
| { |
| IDB_TRACE("IDBCursor::delete"); |
| + if (m_transaction->isFinished()) { |
| + es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedMessage); |
| + return 0; |
| + } |
| if (!m_transaction->isActive()) { |
| es.throwDOMException(TransactionInactiveError); |
| return 0; |
| @@ -235,8 +268,16 @@ PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext* context |
| return 0; |
| } |
| - if (!m_gotValue || isKeyCursor() || isDeleted()) { |
| - es.throwDOMException(InvalidStateError); |
| + if (!m_gotValue) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::notGotValueMessage); |
| + return 0; |
| + } |
| + if (isKeyCursor()) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::isKeyCursorMessage); |
| + return 0; |
| + } |
| + if (isDeleted()) { |
| + es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedMessage); |
| return 0; |
| } |