diff --git a/Libraries/LibWeb/IndexedDB/IDBRequest.cpp b/Libraries/LibWeb/IndexedDB/IDBRequest.cpp index dbf7b2530e9..bc3edb0f485 100644 --- a/Libraries/LibWeb/IndexedDB/IDBRequest.cpp +++ b/Libraries/LibWeb/IndexedDB/IDBRequest.cpp @@ -1,11 +1,11 @@ /* * Copyright (c) 2024, Shannon Booth * Copyright (c) 2024, Jamie Mansfield + * Copyright (c) 2024, stelar7 * * SPDX-License-Identifier: BSD-2-Clause */ -#include #include #include #include @@ -58,4 +58,11 @@ WebIDL::CallbackType* IDBRequest::onerror() return event_handler_attribute(HTML::EventNames::error); } +// https://w3c.github.io/IndexedDB/#dom-idbrequest-readystate +[[nodiscard]] Bindings::IDBRequestReadyState IDBRequest::ready_state() const +{ + // The readyState getter steps are to return "pending" if this's done flag is false, and "done" otherwise. + return m_done ? Bindings::IDBRequestReadyState::Done : Bindings::IDBRequestReadyState::Pending; +} + } diff --git a/Libraries/LibWeb/IndexedDB/IDBRequest.h b/Libraries/LibWeb/IndexedDB/IDBRequest.h index 42c24fec5c0..6232818e111 100644 --- a/Libraries/LibWeb/IndexedDB/IDBRequest.h +++ b/Libraries/LibWeb/IndexedDB/IDBRequest.h @@ -1,12 +1,14 @@ /* * Copyright (c) 2024, Shannon Booth * Copyright (c) 2024, Jamie Mansfield + * Copyright (c) 2024, stelar7 * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once +#include #include namespace Web::IndexedDB { @@ -26,6 +28,8 @@ public: [[nodiscard]] bool processed() const { return m_processed; } [[nodiscard]] IDBRequestSource source() const { return m_source; } + [[nodiscard]] Bindings::IDBRequestReadyState ready_state() const; + void set_done(bool done) { m_done = done; } void set_result(JS::Value result) { m_result = result; } void set_error(GC::Ptr error) { m_error = error; } diff --git a/Libraries/LibWeb/IndexedDB/IDBRequest.idl b/Libraries/LibWeb/IndexedDB/IDBRequest.idl index 868788274d9..7adfbadb84a 100644 --- a/Libraries/LibWeb/IndexedDB/IDBRequest.idl +++ b/Libraries/LibWeb/IndexedDB/IDBRequest.idl @@ -10,7 +10,7 @@ interface IDBRequest : EventTarget { readonly attribute DOMException? error; readonly attribute (IDBObjectStore or IDBIndex or IDBCursor)? source; [FIXME] readonly attribute IDBTransaction? transaction; - [FIXME] readonly attribute IDBRequestReadyState readyState; + readonly attribute IDBRequestReadyState readyState; // Event handlers: attribute EventHandler onsuccess;