mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 16:16:43 +00:00
LibWeb: Implement CookieChangeEvent
This commit is contained in:
parent
185f8f7d56
commit
70efa8c1c5
Notes:
github-actions[bot]
2025-08-08 17:11:33 +00:00
Author: https://github.com/IdanHo
Commit: 70efa8c1c5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5766
Reviewed-by: https://github.com/trflynn89 ✅
9 changed files with 107 additions and 1 deletions
|
@ -80,6 +80,7 @@ set(SOURCES
|
|||
ContentSecurityPolicy/Violation.cpp
|
||||
Cookie/Cookie.cpp
|
||||
Cookie/ParsedCookie.cpp
|
||||
CookieStore/CookieChangeEvent.cpp
|
||||
CookieStore/CookieStore.cpp
|
||||
CredentialManagement/Credential.cpp
|
||||
CredentialManagement/CredentialsContainer.cpp
|
||||
|
|
40
Libraries/LibWeb/CookieStore/CookieChangeEvent.cpp
Normal file
40
Libraries/LibWeb/CookieStore/CookieChangeEvent.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CookieChangeEventPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CookieStore/CookieChangeEvent.h>
|
||||
|
||||
namespace Web::CookieStore {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(CookieChangeEvent);
|
||||
|
||||
GC::Ref<CookieChangeEvent> CookieChangeEvent::create(JS::Realm& realm, FlyString const& event_name, CookieChangeEventInit const& event_init)
|
||||
{
|
||||
return realm.create<CookieChangeEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
GC::Ref<CookieChangeEvent> CookieChangeEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CookieChangeEventInit const& event_init)
|
||||
{
|
||||
return create(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
CookieChangeEvent::CookieChangeEvent(JS::Realm& realm, FlyString const& event_name, CookieChangeEventInit const& event_init)
|
||||
: DOM::Event(realm, event_name, event_init)
|
||||
, m_changed(event_init.changed.value_or({}))
|
||||
, m_deleted(event_init.deleted.value_or({}))
|
||||
{
|
||||
}
|
||||
|
||||
CookieChangeEvent::~CookieChangeEvent() = default;
|
||||
|
||||
void CookieChangeEvent::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(CookieChangeEvent);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
}
|
43
Libraries/LibWeb/CookieStore/CookieChangeEvent.h
Normal file
43
Libraries/LibWeb/CookieStore/CookieChangeEvent.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CookieStore/CookieStore.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::CookieStore {
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dictdef-cookiechangeeventinit
|
||||
struct CookieChangeEventInit final : public DOM::EventInit {
|
||||
Optional<Vector<CookieListItem>> changed;
|
||||
Optional<Vector<CookieListItem>> deleted;
|
||||
};
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#cookiechangeevent
|
||||
class CookieChangeEvent final : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(CookieChangeEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(CookieChangeEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<CookieChangeEvent> create(JS::Realm&, FlyString const& event_name, CookieChangeEventInit const& event_init);
|
||||
[[nodiscard]] static GC::Ref<CookieChangeEvent> construct_impl(JS::Realm&, FlyString const& event_name, CookieChangeEventInit const& event_init);
|
||||
|
||||
virtual ~CookieChangeEvent() override;
|
||||
|
||||
Vector<CookieListItem> changed() const { return m_changed; }
|
||||
Vector<CookieListItem> deleted() const { return m_deleted; }
|
||||
|
||||
private:
|
||||
CookieChangeEvent(JS::Realm&, FlyString const& event_name, CookieChangeEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
Vector<CookieListItem> m_changed;
|
||||
Vector<CookieListItem> m_deleted;
|
||||
};
|
||||
|
||||
}
|
15
Libraries/LibWeb/CookieStore/CookieChangeEvent.idl
Normal file
15
Libraries/LibWeb/CookieStore/CookieChangeEvent.idl
Normal file
|
@ -0,0 +1,15 @@
|
|||
#import <DOM/Event.idl>
|
||||
#import <CookieStore/CookieStore.idl>
|
||||
|
||||
dictionary CookieChangeEventInit : EventInit {
|
||||
CookieList changed;
|
||||
CookieList deleted;
|
||||
};
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#cookiechangeevent
|
||||
[Exposed=Window, SecureContext]
|
||||
interface CookieChangeEvent : Event {
|
||||
constructor(DOMString type, optional CookieChangeEventInit eventInitDict = {});
|
||||
[SameObject] readonly attribute FrozenArray<CookieListItem> changed;
|
||||
[SameObject] readonly attribute FrozenArray<CookieListItem> deleted;
|
||||
};
|
|
@ -175,6 +175,7 @@ enum class Source;
|
|||
|
||||
namespace Web::CookieStore {
|
||||
|
||||
class CookieChangeEvent;
|
||||
class CookieStore;
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ libweb_js_bindings(Clipboard/ClipboardItem)
|
|||
libweb_js_bindings(ContentSecurityPolicy/SecurityPolicyViolationEvent)
|
||||
libweb_js_bindings(Compression/CompressionStream)
|
||||
libweb_js_bindings(Compression/DecompressionStream)
|
||||
libweb_js_bindings(CookieStore/CookieChangeEvent)
|
||||
libweb_js_bindings(CookieStore/CookieStore)
|
||||
libweb_js_bindings(CredentialManagement/Credential)
|
||||
libweb_js_bindings(CredentialManagement/CredentialsContainer)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
source_set("CookieStore") {
|
||||
configs += [ "//Userland/Libraries/LibWeb:configs" ]
|
||||
deps = [ "//Userland/Libraries/LibWeb:all_generated" ]
|
||||
sources = [ "CookieStore.cpp" ]
|
||||
sources = [
|
||||
"CookieChangeEvent.cpp",
|
||||
"CookieStore.cpp",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ standard_idl_files = [
|
|||
"//Userland/Libraries/LibWeb/Animations/KeyframeEffect.idl",
|
||||
"//Userland/Libraries/LibWeb/Clipboard/Clipboard.idl",
|
||||
"//Userland/Libraries/LibWeb/Clipboard/ClipboardEvent.idl",
|
||||
"//Userland/Libraries/LibWeb/CookieStore/CookieChangeEvent.idl",
|
||||
"//Userland/Libraries/LibWeb/CookieStore/CookieStore.idl",
|
||||
"//Userland/Libraries/LibWeb/Crypto/Crypto.idl",
|
||||
"//Userland/Libraries/LibWeb/Crypto/CryptoKey.idl",
|
||||
|
|
|
@ -79,6 +79,7 @@ Comment
|
|||
CompositionEvent
|
||||
CompressionStream
|
||||
ConstantSourceNode
|
||||
CookieChangeEvent
|
||||
CookieStore
|
||||
CountQueuingStrategy
|
||||
Credential
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue