diff --git a/Tests/LibWeb/Text/expected/PerformanceObserver/PerformanceObserver-supportedEntryTypes.txt b/Tests/LibWeb/Text/expected/PerformanceObserver/PerformanceObserver-supportedEntryTypes.txt
new file mode 100644
index 00000000000..1d7ad1b86a4
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/PerformanceObserver/PerformanceObserver-supportedEntryTypes.txt
@@ -0,0 +1,5 @@
+PerformanceObserver.supportedEntryTypes: mark,measure
+PerformanceObserver.supportedEntryTypes instanceof Array: true
+Object.isFrozen(PerformanceObserver.supportedEntryTypes): true
+PerformanceObserver.supportedEntryTypes === PerformanceObserver.supportedEntryTypes: true
+sorted alphabetically: true
diff --git a/Tests/LibWeb/Text/input/PerformanceObserver/PerformanceObserver-supportedEntryTypes.html b/Tests/LibWeb/Text/input/PerformanceObserver/PerformanceObserver-supportedEntryTypes.html
new file mode 100644
index 00000000000..662fd94df66
--- /dev/null
+++ b/Tests/LibWeb/Text/input/PerformanceObserver/PerformanceObserver-supportedEntryTypes.html
@@ -0,0 +1,21 @@
+
+
diff --git a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
index b55f66b2694..3fc9b9e2f71 100644
--- a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
+++ b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
@@ -12,6 +12,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -59,6 +60,7 @@ void WindowOrWorkerGlobalScopeMixin::initialize(JS::Realm&)
void WindowOrWorkerGlobalScopeMixin::visit_edges(JS::Cell::Visitor& visitor)
{
visitor.visit(m_performance);
+ visitor.visit(m_supported_entry_types_array);
for (auto& it : m_timers)
visitor.visit(it.value);
for (auto& observer : m_registered_performance_observer_objects)
@@ -595,4 +597,28 @@ JS::NonnullGCPtr WindowOrWorkerGlobalScopeMixin
return JS::NonnullGCPtr { *m_performance };
}
+// https://w3c.github.io/performance-timeline/#dfn-frozen-array-of-supported-entry-types
+JS::NonnullGCPtr WindowOrWorkerGlobalScopeMixin::supported_entry_types() const
+{
+ // Each global object has an associated frozen array of supported entry types, which is initialized to the
+ // FrozenArray created from the sequence of strings among the registry that are supported for the global
+ // object, in alphabetical order.
+ auto& vm = this_impl().vm();
+ auto& realm = this_impl().realm();
+
+ if (!m_supported_entry_types_array) {
+ Vector supported_entry_types;
+
+#define __ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(entry_type, cpp_class) \
+ supported_entry_types.append(JS::PrimitiveString::create(vm, entry_type));
+ ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES
+#undef __ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES
+
+ m_supported_entry_types_array = JS::Array::create_from(realm, supported_entry_types);
+ MUST(m_supported_entry_types_array->set_integrity_level(JS::Object::IntegrityLevel::Frozen));
+ }
+
+ return *m_supported_entry_types_array;
+}
+
}
diff --git a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h
index 4071e859cc6..14d9efc1ec1 100644
--- a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h
+++ b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h
@@ -65,6 +65,8 @@ public:
[[nodiscard]] JS::NonnullGCPtr performance();
+ JS::NonnullGCPtr supported_entry_types() const;
+
protected:
void initialize(JS::Realm&);
void visit_edges(JS::Cell::Visitor&);
@@ -95,6 +97,8 @@ private:
OrderedHashMap m_performance_entry_buffer_map;
JS::GCPtr m_performance;
+
+ mutable JS::GCPtr m_supported_entry_types_array;
};
}
diff --git a/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp b/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp
index a71807f926c..85b0e2ca0c4 100644
--- a/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp
+++ b/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp
@@ -218,6 +218,17 @@ Vector> PerformanceObserver::t
return records;
}
+// https://w3c.github.io/performance-timeline/#dom-performanceobserver-supportedentrytypes
+JS::NonnullGCPtr PerformanceObserver::supported_entry_types(JS::VM& vm)
+{
+ // 1. Let globalObject be the environment settings object's global object.
+ auto* window_or_worker = dynamic_cast(&vm.get_global_object());
+ VERIFY(window_or_worker);
+
+ // 2. Return globalObject's frozen array of supported entry types.
+ return window_or_worker->supported_entry_types();
+}
+
void PerformanceObserver::unset_requires_dropped_entries(Badge)
{
m_requires_dropped_entries = false;
diff --git a/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.h b/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.h
index d6da82ed13a..3e440133612 100644
--- a/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.h
+++ b/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.h
@@ -46,6 +46,8 @@ public:
void append_to_observer_buffer(Badge, JS::NonnullGCPtr);
+ static JS::NonnullGCPtr supported_entry_types(JS::VM&);
+
private:
PerformanceObserver(JS::Realm&, JS::GCPtr);
diff --git a/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.idl b/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.idl
index 9656deb6435..d8818b111c6 100644
--- a/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.idl
+++ b/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.idl
@@ -21,5 +21,6 @@ interface PerformanceObserver {
undefined observe(optional PerformanceObserverInit options = {});
undefined disconnect();
PerformanceEntryList takeRecords();
- //[SameObject] static readonly attribute sequence supportedEntryTypes;
+ // FIXME: [SameObject] static readonly attribute FrozenArray supportedEntryTypes;
+ [SameObject] static readonly attribute any supportedEntryTypes;
};