Bug 769356: Calling transaction.abort() should leave transaction.error as null, but throwing exceptions should set transaction.error. r=sicking

This commit is contained in:
Kyle Huey 2012-06-29 09:48:34 -07:00
Родитель c0b8b36893
Коммит 4eb6d0f6d4
7 изменённых файлов: 30 добавлений и 14 удалений

Просмотреть файл

@ -438,7 +438,7 @@ AsyncConnectionHelper::OnSuccess()
if ((internalEvent->flags & NS_EVENT_FLAG_EXCEPTION_THROWN) &&
mTransaction &&
mTransaction->IsOpen()) {
rv = mTransaction->Abort();
rv = mTransaction->Abort(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -474,7 +474,7 @@ AsyncConnectionHelper::OnError()
if ((internalEvent->flags & NS_EVENT_FLAG_EXCEPTION_THROWN) &&
mTransaction &&
mTransaction->IsOpen() &&
NS_FAILED(mTransaction->Abort())) {
NS_FAILED(mTransaction->Abort(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR))) {
NS_WARNING("Failed to abort transaction!");
}

Просмотреть файл

@ -818,7 +818,7 @@ void
NoRequestDatabaseHelper::OnError()
{
NS_ASSERTION(IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
mTransaction->AbortWithCode(GetResultCode());
mTransaction->Abort(GetResultCode());
}
nsresult

Просмотреть файл

@ -2357,7 +2357,7 @@ void
NoRequestObjectStoreHelper::OnError()
{
NS_ASSERTION(IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
mTransaction->AbortWithCode(GetResultCode());
mTransaction->Abort(GetResultCode());
}
nsresult

Просмотреть файл

@ -498,10 +498,13 @@ IDBTransaction::ClearCreatedFileInfos()
}
nsresult
IDBTransaction::AbortWithCode(nsresult aAbortCode)
IDBTransaction::AbortInternal(nsresult aAbortCode,
already_AddRefed<nsIDOMDOMError> aError)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsCOMPtr<nsIDOMDOMError> error = aError;
if (IsFinished()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
}
@ -515,6 +518,7 @@ IDBTransaction::AbortWithCode(nsresult aAbortCode)
mAbortCode = aAbortCode;
mReadyState = IDBTransaction::DONE;
mError = error.forget();
if (GetMode() == IDBTransaction::VERSION_CHANGE) {
// If a version change transaction is aborted, we must revert the world
@ -566,9 +570,18 @@ IDBTransaction::Abort(IDBRequest* aRequest)
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(aRequest, "This is undesirable.");
aRequest->GetError(getter_AddRefs(mError));
nsCOMPtr<nsIDOMDOMError> error;
aRequest->GetError(getter_AddRefs(error));
return AbortWithCode(aRequest->GetErrorCode());
return AbortInternal(aRequest->GetErrorCode(), error.forget());
}
nsresult
IDBTransaction::Abort(nsresult aErrorCode)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return AbortInternal(aErrorCode, DOMError::CreateForNSResult(aErrorCode));
}
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBTransaction)
@ -747,7 +760,7 @@ NS_IMETHODIMP
IDBTransaction::Abort()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return AbortWithCode(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR);
return AbortInternal(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR, nsnull);
}
nsresult

Просмотреть файл

@ -193,10 +193,10 @@ public:
IDBObjectStore** _retval);
nsresult
AbortWithCode(nsresult aAbortCode);
Abort(IDBRequest* aRequest);
nsresult
Abort(IDBRequest* aRequest);
Abort(nsresult aAbortCode);
nsresult
GetAbortCode() const
@ -205,6 +205,9 @@ public:
}
private:
nsresult
AbortInternal(nsresult aAbortCode, already_AddRefed<nsIDOMDOMError> aError);
// Should only be called directly through IndexedDBDatabaseChild.
static already_AddRefed<IDBTransaction>
CreateInternal(IDBDatabase* aDatabase,

Просмотреть файл

@ -578,7 +578,7 @@ bool
IndexedDBTransactionParent::RecvAbort(const nsresult& aAbortCode)
{
MOZ_ASSERT(mTransaction);
mTransaction->AbortWithCode(aAbortCode);
mTransaction->Abort(aAbortCode);
return true;
}

Просмотреть файл

@ -68,7 +68,7 @@
let event = yield;
is(event.type, "abort",
"Throwing during an upgradeneeded event should abort the transaction.");
is(event.target.error, null, "Got null error object");
is(event.target.error.name, "AbortError", "Got AbortError object");
request.onerror = grabEventAndContinueHandler;
event = yield;
@ -112,7 +112,7 @@
event = yield;
is(event.type, "abort", "Got transaction abort event");
is(event.target.error, null, "Got null error object");
is(event.target.error.name, "AbortError", "Got AbortError object");
openrequest.onerror = grabEventAndContinueHandler;
event = yield;
@ -161,7 +161,7 @@
event = yield;
is(event.type, "abort", "Got transaction abort event");
is(event.target.error, null, "Got null error object");
is(event.target.error.name, "AbortError", "Got AbortError object");
openrequest.onerror = grabEventAndContinueHandler;
event = yield;