mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
LibWeb/IDB: Use helper method for checking transaction state
This commit is contained in:
parent
4c7c7845d3
commit
c8e1b24864
Notes:
github-actions[bot]
2025-05-14 15:18:37 +00:00
Author: https://github.com/stelar7
Commit: c8e1b24864
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4727
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/shannonbooth
5 changed files with 31 additions and 28 deletions
|
@ -116,7 +116,7 @@ WebIDL::ExceptionOr<void> IDBCursor::continue_(JS::Value key)
|
|||
auto transaction = this->transaction();
|
||||
|
||||
// 2. If transaction’s 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 transaction’s 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 this’s 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 transaction’s 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.
|
||||
|
@ -349,7 +349,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBCursor::update(JS::Value value)
|
|||
auto transaction = this->transaction();
|
||||
|
||||
// 2. If transaction’s 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 transaction’s 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue