LibWeb: Implement IDBRequest.onsuccess

This commit is contained in:
Jamie Mansfield 2024-06-22 11:32:36 +01:00 committed by Andreas Kling
parent fe3962a64d
commit 5ebc09c83b
Notes: sideshowbarker 2024-07-16 23:38:54 +09:00
4 changed files with 20 additions and 1 deletions

View file

@ -105,6 +105,7 @@ namespace Web::HTML::EventNames {
__ENUMERATE_HTML_EVENT(statechange) \
__ENUMERATE_HTML_EVENT(storage) \
__ENUMERATE_HTML_EVENT(submit) \
__ENUMERATE_HTML_EVENT(success) \
__ENUMERATE_HTML_EVENT(suspend) \
__ENUMERATE_HTML_EVENT(timeupdate) \
__ENUMERATE_HTML_EVENT(toggle) \

View file

@ -1,11 +1,13 @@
/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
*
* 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>
namespace Web::IndexedDB {
@ -25,4 +27,16 @@ void IDBRequest::initialize(JS::Realm& realm)
WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBRequest);
}
// https://w3c.github.io/IndexedDB/#dom-idbrequest-onsuccess
void IDBRequest::set_onsuccess(WebIDL::CallbackType* event_handler)
{
set_event_handler_attribute(HTML::EventNames::success, event_handler);
}
// https://w3c.github.io/IndexedDB/#dom-idbrequest-onsuccess
WebIDL::CallbackType* IDBRequest::onsuccess()
{
return event_handler_attribute(HTML::EventNames::success);
}
}

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -17,6 +18,9 @@ class IDBRequest : public DOM::EventTarget {
public:
virtual ~IDBRequest() override;
void set_onsuccess(WebIDL::CallbackType*);
WebIDL::CallbackType* onsuccess();
protected:
explicit IDBRequest(JS::Realm&);

View file

@ -10,7 +10,7 @@ interface IDBRequest : EventTarget {
[FIXME] readonly attribute IDBRequestReadyState readyState;
// Event handlers:
[FIXME] attribute EventHandler onsuccess;
attribute EventHandler onsuccess;
[FIXME] attribute EventHandler onerror;
};