mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-26 18:09:45 +00:00
LibWeb: Add a simplified Notification constructor
This allows the Notification object to be created in javascript without any additional functionalities. It passes two wpt tests which require a call to the notification constructor with no arguments. https://wpt.live/notifications/constructor-basic.https.html https://wpt.live/notifications/constructor-invalid.https.html
This commit is contained in:
parent
0aec8912c9
commit
a72b0c29bb
Notes:
github-actions[bot]
2025-09-24 10:54:18 +00:00
Author: https://github.com/NiccoloAntonelliDziri 🔰
Commit: a72b0c29bb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6219
Reviewed-by: https://github.com/AtkinsSJ ✅
12 changed files with 263 additions and 0 deletions
39
Libraries/LibWeb/NotificationsAPI/Notification.cpp
Normal file
39
Libraries/LibWeb/NotificationsAPI/Notification.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Niccolo Antonelli-Dziri <niccolo.antonelli-dziri@protonmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/NotificationPrototype.h>
|
||||
#include <LibWeb/NotificationsAPI/Notification.h>
|
||||
|
||||
namespace Web::NotificationsAPI {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(Notification);
|
||||
|
||||
Notification::Notification(JS::Realm& realm)
|
||||
: DOM::EventTarget(realm)
|
||||
{
|
||||
}
|
||||
|
||||
// https://notifications.spec.whatwg.org/#constructors
|
||||
WebIDL::ExceptionOr<GC::Ref<Notification>> Notification::construct_impl(
|
||||
JS::Realm& realm,
|
||||
String, // FIXME: title is unused
|
||||
Optional<NotificationOptions>) // FIXME: options is unused
|
||||
{
|
||||
|
||||
// FIXME: all of the steps specified in the spec
|
||||
|
||||
return realm.create<Notification>(realm);
|
||||
}
|
||||
|
||||
void Notification::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(Notification);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue