| Index: third_party/WebKit/Source/modules/indexeddb/IDBCursor.cpp
|
| diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBCursor.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBCursor.cpp
|
| index e4ab0851f8b7212dd2b8c1a385d08d9dfa1e5201..4dbfded21c4fceef8d454d0918d93619b83c6600 100644
|
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBCursor.cpp
|
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBCursor.cpp
|
| @@ -93,18 +93,6 @@ IDBRequest* IDBCursor::update(ScriptState* scriptState, const ScriptValue& value
|
| {
|
| IDB_TRACE("IDBCursor::update");
|
|
|
| - if (!m_gotValue) {
|
| - exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
|
| - return nullptr;
|
| - }
|
| - if (isKeyCursor()) {
|
| - exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCursorErrorMessage);
|
| - return nullptr;
|
| - }
|
| - if (isDeleted()) {
|
| - exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
|
| - return nullptr;
|
| - }
|
| if (m_transaction->isFinished() || m_transaction->isFinishing()) {
|
| exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
|
| return nullptr;
|
| @@ -117,6 +105,18 @@ IDBRequest* IDBCursor::update(ScriptState* scriptState, const ScriptValue& value
|
| exceptionState.throwDOMException(ReadOnlyError, "The record may not be updated inside a read-only transaction.");
|
| return nullptr;
|
| }
|
| + if (isDeleted()) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
|
| + return nullptr;
|
| + }
|
| + if (!m_gotValue) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
|
| + return nullptr;
|
| + }
|
| + if (isKeyCursor()) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCursorErrorMessage);
|
| + return nullptr;
|
| + }
|
|
|
| IDBObjectStore* objectStore = effectiveObjectStore();
|
| return objectStore->put(scriptState, WebIDBPutModeCursorUpdate, IDBAny::create(this), value, m_primaryKey, exceptionState);
|
| @@ -137,14 +137,14 @@ void IDBCursor::advance(unsigned count, ExceptionState& exceptionState)
|
| exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
|
| return;
|
| }
|
| - if (!m_gotValue) {
|
| - exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
|
| - return;
|
| - }
|
| if (isDeleted()) {
|
| exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
|
| return;
|
| }
|
| + if (!m_gotValue) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
|
| + return;
|
| + }
|
|
|
| m_request->setPendingCursor(this);
|
| m_gotValue = false;
|
| @@ -154,6 +154,24 @@ void IDBCursor::advance(unsigned count, ExceptionState& exceptionState)
|
| void IDBCursor::continueFunction(ScriptState* scriptState, const ScriptValue& keyValue, ExceptionState& exceptionState)
|
| {
|
| IDB_TRACE("IDBCursor::continue");
|
| +
|
| + if (m_transaction->isFinished() || m_transaction->isFinishing()) {
|
| + exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
|
| + return;
|
| + }
|
| + if (!m_transaction->isActive()) {
|
| + exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
|
| + return;
|
| + }
|
| + if (!m_gotValue) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
|
| + return;
|
| + }
|
| + if (isDeleted()) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
|
| + return;
|
| + }
|
| +
|
| IDBKey* key = keyValue.isUndefined() || keyValue.isNull() ? nullptr : ScriptValue::to<IDBKey*>(scriptState->isolate(), keyValue, exceptionState);
|
| if (exceptionState.hadException())
|
| return;
|
| @@ -167,6 +185,24 @@ void IDBCursor::continueFunction(ScriptState* scriptState, const ScriptValue& ke
|
| void IDBCursor::continuePrimaryKey(ScriptState* scriptState, const ScriptValue& keyValue, const ScriptValue& primaryKeyValue, ExceptionState& exceptionState)
|
| {
|
| IDB_TRACE("IDBCursor::continuePrimaryKey");
|
| +
|
| + if (m_transaction->isFinished() || m_transaction->isFinishing()) {
|
| + exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
|
| + return;
|
| + }
|
| + if (!m_transaction->isActive()) {
|
| + exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
|
| + return;
|
| + }
|
| + if (!m_gotValue) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
|
| + return;
|
| + }
|
| + if (isDeleted()) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
|
| + return;
|
| + }
|
| +
|
| if (m_source->getType() != IDBAny::IDBIndexType) {
|
| exceptionState.throwDOMException(InvalidAccessError, "The cursor's source is not an index.");
|
| return;
|
| @@ -197,27 +233,11 @@ void IDBCursor::continuePrimaryKey(ScriptState* scriptState, const ScriptValue&
|
|
|
| void IDBCursor::continueFunction(IDBKey* key, IDBKey* primaryKey, ExceptionState& exceptionState)
|
| {
|
| + ASSERT(m_transaction->isActive());
|
| + ASSERT(m_gotValue);
|
| + ASSERT(!isDeleted());
|
| ASSERT(!primaryKey || (key && primaryKey));
|
|
|
| - if (m_transaction->isFinished() || m_transaction->isFinishing()) {
|
| - exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
|
| - return;
|
| - }
|
| - if (!m_transaction->isActive()) {
|
| - exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
|
| - return;
|
| - }
|
| -
|
| - if (!m_gotValue) {
|
| - exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
|
| - return;
|
| - }
|
| -
|
| - if (isDeleted()) {
|
| - exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
|
| - return;
|
| - }
|
| -
|
| if (key) {
|
| ASSERT(m_key);
|
| if (m_direction == WebIDBCursorDirectionNext || m_direction == WebIDBCursorDirectionNextNoDuplicate) {
|
| @@ -260,7 +280,10 @@ IDBRequest* IDBCursor::deleteFunction(ScriptState* scriptState, ExceptionState&
|
| exceptionState.throwDOMException(ReadOnlyError, "The record may not be deleted inside a read-only transaction.");
|
| return nullptr;
|
| }
|
| -
|
| + if (isDeleted()) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
|
| + return nullptr;
|
| + }
|
| if (!m_gotValue) {
|
| exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
|
| return nullptr;
|
| @@ -269,10 +292,6 @@ IDBRequest* IDBCursor::deleteFunction(ScriptState* scriptState, ExceptionState&
|
| exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCursorErrorMessage);
|
| return nullptr;
|
| }
|
| - if (isDeleted()) {
|
| - exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
|
| - return nullptr;
|
| - }
|
| if (!m_transaction->backendDB()) {
|
| exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage);
|
| return nullptr;
|
|
|