LibWeb: Add getters and setters to IDBRequest

This commit is contained in:
stelar7 2024-11-04 19:09:21 +01:00 committed by Andrew Kaster
parent 914ad7bbd6
commit ef75cc53f9
Notes: github-actions[bot] 2024-11-08 18:11:44 +00:00
3 changed files with 31 additions and 2 deletions

View file

@ -27,6 +27,13 @@ void IDBRequest::initialize(JS::Realm& realm)
WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBRequest);
}
void IDBRequest::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_error);
visitor.visit(m_result);
}
// https://w3c.github.io/IndexedDB/#dom-idbrequest-onsuccess
void IDBRequest::set_onsuccess(WebIDL::CallbackType* event_handler)
{

View file

@ -18,6 +18,16 @@ class IDBRequest : public DOM::EventTarget {
public:
virtual ~IDBRequest() override;
[[nodiscard]] JS::Value result() const { return m_result; }
[[nodiscard]] JS::GCPtr<WebIDL::DOMException> error() const { return m_error; }
[[nodiscard]] bool done() const { return m_done; }
[[nodiscard]] bool processed() const { return m_processed; }
void set_done(bool done) { m_done = done; }
void set_result(JS::Value result) { m_result = result; }
void set_error(JS::GCPtr<WebIDL::DOMException> error) { m_error = error; }
void set_processed(bool processed) { m_processed = processed; }
void set_onsuccess(WebIDL::CallbackType*);
WebIDL::CallbackType* onsuccess();
void set_onerror(WebIDL::CallbackType*);
@ -27,6 +37,18 @@ protected:
explicit IDBRequest(JS::Realm&);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Visitor& visitor) override;
private:
// A request has a processed flag which is initially false.
bool m_processed { false };
// A request has a done flag which is initially false.
bool m_done { false };
// A request has a result and an error
JS::Value m_result;
JS::GCPtr<WebIDL::DOMException> m_error;
// FIXME: A request has a source object.
// FIXME: A request has a transaction which is initially null.
};
}

View file

@ -3,8 +3,8 @@
// https://w3c.github.io/IndexedDB/#idbrequest
[Exposed=(Window,Worker)]
interface IDBRequest : EventTarget {
[FIXME] readonly attribute any result;
[FIXME] readonly attribute DOMException? error;
readonly attribute any result;
readonly attribute DOMException? error;
[FIXME] readonly attribute (IDBObjectStore or IDBIndex or IDBCursor)? source;
[FIXME] readonly attribute IDBTransaction? transaction;
[FIXME] readonly attribute IDBRequestReadyState readyState;