mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibWeb: Implement IDBTransaction::abort
This commit is contained in:
parent
2954278e37
commit
7c3f44282d
Notes:
github-actions[bot]
2024-12-14 22:04:18 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/7c3f44282d5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2696 Reviewed-by: https://github.com/gmta
2 changed files with 15 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/IndexedDB/IDBTransaction.h>
|
||||
#include <LibWeb/IndexedDB/Internal/Algorithms.h>
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
|
||||
|
@ -69,4 +70,16 @@ WebIDL::CallbackType* IDBTransaction::onerror()
|
|||
return event_handler_attribute(HTML::EventNames::error);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> IDBTransaction::abort()
|
||||
{
|
||||
// 1. If this's state is committing or finished, then throw an "InvalidStateError" DOMException.
|
||||
if (m_state == TransactionState::Committing || m_state == TransactionState::Finished)
|
||||
return WebIDL::InvalidStateError::create(realm(), "Transaction is ending"_string);
|
||||
|
||||
// 2. Set this's state to inactive and run abort a transaction with this and null.
|
||||
m_state = TransactionState::Inactive;
|
||||
abort_a_transaction(*this, nullptr);
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ public:
|
|||
[[nodiscard]] bool is_readonly() const { return m_mode == Bindings::IDBTransactionMode::Readonly; }
|
||||
[[nodiscard]] bool is_readwrite() const { return m_mode == Bindings::IDBTransactionMode::Readwrite; }
|
||||
|
||||
WebIDL::ExceptionOr<void> abort();
|
||||
|
||||
void set_onabort(WebIDL::CallbackType*);
|
||||
WebIDL::CallbackType* onabort();
|
||||
void set_oncomplete(WebIDL::CallbackType*);
|
||||
|
|
Loading…
Add table
Reference in a new issue