LibWeb: Implement IDBRequest::ready_state()

This commit is contained in:
stelar7 2024-11-07 20:17:58 +01:00 committed by Jelle Raaijmakers
commit 29ddaa76e7
Notes: github-actions[bot] 2024-11-26 13:52:33 +00:00
3 changed files with 13 additions and 2 deletions

View file

@ -1,11 +1,11 @@
/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/IDBRequestPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/IndexedDB/IDBRequest.h>
@ -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;
}
}

View file

@ -1,12 +1,14 @@
/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Bindings/IDBRequestPrototype.h>
#include <LibWeb/DOM/EventTarget.h>
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<WebIDL::DOMException> error) { m_error = error; }

View file

@ -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;