LibWeb: Add constructor for Notification and getter methods

The full constructor for NotificationsAPI::Notification is implemented
along with the getter methods.
It is now possible to call the elements of Notification in JS without
getting undefined but the default values (or the ones passed in
options).

The method `current_wall_time` is added in EnvironmentSettingsObject.

This passes a least a few more tests because of the getter methods
that are created.

https://wpt.live/notifications/constructor-basic.https.html

https://wpt.live/notifications/idlharness.https.any.html
This commit is contained in:
Niccolo Antonelli Dziri
2025-10-04 16:30:20 +02:00
committed by Sam Atkins
parent 94ca0dcbef
commit bd76078f97
Notes: github-actions[bot] 2026-02-13 16:49:18 +00:00
10 changed files with 834 additions and 26 deletions

View File

@@ -17,6 +17,7 @@
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/Scripting/ModuleMap.h>
#include <LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.h>
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/ServiceWorker/Registration.h>
namespace Web::HTML {
@@ -138,6 +139,24 @@ public:
virtual void discard_environment() override;
// FIXME: This method below is from HighResolutionTime spec in section 3. Section for Specification Authors.
// The following other methods are currently not supported:
// `current relative timestamp` https://www.w3.org/TR/hr-time-3/#dfn-current-relative-timestamp
// `current monotonic time` https://www.w3.org/TR/hr-time-3/#dfn-current-monotonic-time
// `current coarsened wall time` https://www.w3.org/TR/hr-time-3/#dfn-current-wall-time
// https://w3c.github.io/hr-time/#dfn-eso-current-wall-time
HighResolutionTime::DOMHighResTimeStamp current_wall_time() const
{
// An environment settings object settingsObject's current wall time is the result of the following steps:
// 1. Let unsafeWallTime be the wall clock's unsafe current time.
auto unsafe_walltime = HighResolutionTime::wall_clock_unsafe_current_time();
// 2. Return the result of calling coarsen time with unsafeWallTime and settingsObject's cross-origin isolated capability.
return HighResolutionTime::coarsen_time(unsafe_walltime, cross_origin_isolated_capability() == HTML::CanUseCrossOriginIsolatedAPIs::Yes);
}
protected:
explicit EnvironmentSettingsObject(NonnullOwnPtr<JS::ExecutionContext>);