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

@@ -108,7 +108,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBObjectStore>> IDBDatabase::create_object_store(St
return WebIDL::InvalidStateError::create(realm, "Upgrade transaction is null"_string);
// 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 creating object store"_string);
// 4. Let keyPath be optionss keyPath member if it is not undefined or null, or null otherwise.
@@ -170,7 +170,7 @@ WebIDL::ExceptionOr<void> IDBDatabase::delete_object_store(String const& name)
return WebIDL::InvalidStateError::create(realm, "Upgrade transaction is null"_string);
// 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 deleting object store"_string);
// 4. Let store be the object store named name in database, or throw a "NotFoundError" DOMException if none.