LibWeb/IDB: Use helper method for checking transaction state

This commit is contained in:
stelar7 2025-05-13 23:14:02 +02:00 committed by Jelle Raaijmakers
parent 4c7c7845d3
commit c8e1b24864
Notes: github-actions[bot] 2025-05-14 15:18:37 +00:00
5 changed files with 31 additions and 28 deletions

View file

@ -116,7 +116,7 @@ WebIDL::ExceptionOr<void> IDBCursor::continue_(JS::Value key)
auto transaction = this->transaction();
// 2. If transactions state is not active, then throw a "TransactionInactiveError" DOMException.
if (transaction->state() != IDBTransaction::TransactionState::Active)
if (!transaction->is_active())
return WebIDL::TransactionInactiveError::create(realm, "Transaction is not active while continuing cursor"_string);
// FIXME: 3. If this's source or effective object store has been deleted, throw an "InvalidStateError" DOMException
@ -207,7 +207,7 @@ WebIDL::ExceptionOr<void> IDBCursor::advance(WebIDL::UnsignedLong count)
auto transaction = this->transaction();
// 3. If transactions state is not active, then throw a "TransactionInactiveError" DOMException.
if (transaction->state() != IDBTransaction::TransactionState::Active)
if (!transaction->is_active())
return WebIDL::TransactionInactiveError::create(realm, "Transaction is not active while advancing cursor"_string);
// FIXME: 4. If thiss source or effective object store has been deleted, throw an "InvalidStateError" DOMException.
@ -249,7 +249,7 @@ WebIDL::ExceptionOr<void> IDBCursor::continue_primary_key(JS::Value key_param, J
auto transaction = this->transaction();
// 2. If transactions state is not active, then throw a "TransactionInactiveError" DOMException.
if (transaction->state() != IDBTransaction::TransactionState::Active)
if (!transaction->is_active())
return WebIDL::TransactionInactiveError::create(realm, "Transaction is not active while continuing cursor"_string);
// FIXME: 3. If thiss source or effective object store has been deleted, throw an "InvalidStateError" DOMException.
@ -349,7 +349,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBCursor::update(JS::Value value)
auto transaction = this->transaction();
// 2. If transactions state is not active, then throw a "TransactionInactiveError" DOMException.
if (transaction->state() != IDBTransaction::TransactionState::Active)
if (!transaction->is_active())
return WebIDL::TransactionInactiveError::create(realm, "Transaction is not active while updating cursor"_string);
// 3. If transaction is a read-only transaction, throw a "ReadOnlyError" DOMException.
@ -415,7 +415,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBCursor::delete_()
auto transaction = this->transaction();
// 2. If transactions state is not active, then throw a "TransactionInactiveError" DOMException.
if (transaction->state() != IDBTransaction::TransactionState::Active)
if (!transaction->is_active())
return WebIDL::TransactionInactiveError::create(realm, "Transaction is not active while deleting cursor"_string);
// 3. If transaction is a read-only transaction, throw a "ReadOnlyError" DOMException.