1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 10:57:26 +00:00

LibWeb: Implement IDBRequest.onsuccess

(cherry picked from commit 5ebc09c83b5ffd75341f8ddca9db3a49f587ed8d)
This commit is contained in:
Jamie Mansfield 2024-06-22 11:32:36 +01:00 committed by Nico Weber
parent 2f0b9c6dab
commit 6d268be6fc
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;
};