Skip to content

Truly independent web browser

LibWeb: Implement Event Timing

Andreas Klingbe8dea3a9bc5
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt
index 6c21ffe3f89..bac6eb0f667 100644
--- a/Libraries/LibWeb/CMakeLists.txt
+++ b/Libraries/LibWeb/CMakeLists.txt
@@ -358,6 +358,8 @@ set(SOURCES
EncryptedMediaExtensions/Algorithms.cpp
EncryptedMediaExtensions/MediaKeySystemAccess.cpp
EntriesAPI/FileSystemEntry.cpp
+ EventTiming/EventCounts.cpp
+ EventTiming/EventTiming.cpp
EventTiming/PerformanceEventTiming.cpp
Fetch/Body.cpp
Fetch/BodyInit.cpp
diff --git a/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Libraries/LibWeb/DOM/EventDispatcher.cpp
index 07884957721..2f17dfa95c4 100644
--- a/Libraries/LibWeb/DOM/EventDispatcher.cpp
+++ b/Libraries/LibWeb/DOM/EventDispatcher.cpp
@@ -21,12 +21,15 @@
#include <LibWeb/DOM/Slottable.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/DOM/Utils.h>
+#include <LibWeb/EventTiming/EventTiming.h>
#include <LibWeb/HTML/AttributeNames.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLButtonElement.h>
#include <LibWeb/HTML/HTMLSlotElement.h>
+#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Window.h>
+#include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/UIEvents/MouseEvent.h>
namespace Web::DOM {
@@ -222,6 +225,22 @@ bool EventDispatcher::dispatch(GC::Ref<EventTarget> target, Event& event, bool l
// 1. Set event’s dispatch flag.
event.set_dispatched(true);
+ // https://w3c.github.io/event-timing/#sec-modifications-DOM
+ // OPTIMIZATION: Only trusted events of some types are timed, so nothing else needs to look up the window.
+ GC::Ptr<EventTiming::PerformanceEventTiming> timing_entry;
+ GC::Ptr<HTML::Window> timing_window;
+ if (EventTiming::is_considered_for_event_timing(event)) {
+ timing_window = EventTiming::relevant_window_of_event_target(*target);
+ if (timing_window) {
+ // 1. Let interactionId be the result of computing interactionId given event.
+ auto interaction_id = EventTiming::compute_interaction_id(event, *timing_window);
+
+ // 2. Let timingEntry be the result of initializing event timing given event, the current high resolution
+ // time, and interactionId.
+ timing_entry = EventTiming::initialize_event_timing(event, HighResolutionTime::current_high_resolution_time(HTML::relevant_global_object(*timing_window)), interaction_id);
+ }
+ }
+
// 2. Let targetOverride be target, if legacy target override flag is not given, and target’s associated Document otherwise. [HTML]
// NOTE: legacy target override flag is only used by HTML and only when target is a Window object.
GC::Ptr<EventTarget> target_override;
@@ -464,6 +483,9 @@ bool EventDispatcher::dispatch(GC::Ref<EventTarget> target, Event& event, bool l
}
}
+ // NB: The last target of the event, which finalizing event timing below uses, is cleared by the next steps.
+ GC::Ptr<EventTarget> last_event_target = event.target() ? event.target() : target.ptr();
+
// 7. Set event’s eventPhase attribute to NONE.
event.set_phase(Event::Phase::None);
@@ -503,6 +525,11 @@ bool EventDispatcher::dispatch(GC::Ref<EventTarget> target, Event& event, bool l
}
}
+ // https://w3c.github.io/event-timing/#sec-modifications-DOM
+ // 1. Finalize event timing passing timingEntry, event, target, and the current high resolution time as inputs.
+ if (timing_entry)
+ EventTiming::finalize_event_timing(timing_entry, event, *last_event_target, HighResolutionTime::current_high_resolution_time(HTML::relevant_global_object(*timing_window)));
+
// 13. Return false if event’s canceled flag is set; otherwise true.
return !event.cancelled();
}
diff --git a/Libraries/LibWeb/EventTiming/BindingsGlue.h b/Libraries/LibWeb/EventTiming/BindingsGlue.h
new file mode 100644
index 00000000000..c263c392351
--- /dev/null
+++ b/Libraries/LibWeb/EventTiming/BindingsGlue.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Optional.h>
+#include <AK/Utf16View.h>
+#include <LibGC/Ptr.h>
+#include <LibJS/Runtime/Map.h>
+#include <LibJS/Runtime/PrimitiveString.h>
+#include <LibJS/Runtime/Realm.h>
+#include <LibJS/Runtime/Value.h>
+#include <LibWeb/EventTiming/EventCounts.h>
+
+namespace Web::Bindings {
+
+// Maplike glue for EventCounts (see Meta/Generators/libweb_bindings/glue_headers.py).
+inline GC::Ref<JS::Map> map_entries(JS::Realm& realm, EventTiming::EventCounts& event_counts)
+{
+ auto map_entries = JS::Map::create(realm);
+ for (auto const& entry : event_counts.entries()) {
+ auto key = JS::PrimitiveString::create(realm.vm(), entry.key);
+ map_entries->map_set(JS::Value { key.ptr() }, JS::Value { static_cast<double>(entry.value) });
+ }
+ return map_entries;
+}
+
+inline Optional<JS::Value> map_get(JS::Realm&, EventTiming::EventCounts& event_counts, Utf16View key)
+{
+ auto it = event_counts.entries().find(key);
+ if (it == event_counts.entries().end())
+ return {};
+ return JS::Value { static_cast<double>(it->value) };
+}
+
+inline bool map_has(EventTiming::EventCounts& event_counts, Utf16View key)
+{
+ return event_counts.entries().contains(key);
+}
+
+}
diff --git a/Libraries/LibWeb/EventTiming/EventCounts.cpp b/Libraries/LibWeb/EventTiming/EventCounts.cpp
new file mode 100644
index 00000000000..52f76972115
--- /dev/null
+++ b/Libraries/LibWeb/EventTiming/EventCounts.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibGC/Heap.h>
+#include <LibWeb/EventTiming/EventCounts.h>
+#include <LibWeb/EventTiming/EventTiming.h>
+
+namespace Web::EventTiming {
+
+GC_DEFINE_ALLOCATOR(EventCounts);
+
+GC::Ref<EventCounts> EventCounts::create()
+{
+ return GC::Heap::the().allocate<EventCounts>();
+}
+
+// https://w3c.github.io/event-timing/#sec-modifications-HTML
+EventCounts::EventCounts()
+{
+ // Upon construction of a Performance object whose relevant global object is a Window, its eventCounts must be
+ // initialized to a map containing 0s for all event types that the user agent supports from the list described in
+ // Events exposed.
+ for_each_event_type_considered_for_event_timing([&](Utf16FlyString const& type) {
+ m_entries.set(type, 0);
+ });
+}
+
+EventCounts::~EventCounts() = default;
+
+void EventCounts::increment(Utf16FlyString const& type)
+{
+ auto it = m_entries.find(type);
+ VERIFY(it != m_entries.end());
+ ++it->value;
+}
+
+}
diff --git a/Libraries/LibWeb/EventTiming/EventCounts.h b/Libraries/LibWeb/EventTiming/EventCounts.h
new file mode 100644
index 00000000000..3d0bc648735
--- /dev/null
+++ b/Libraries/LibWeb/EventTiming/EventCounts.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/HashMap.h>
+#include <AK/Utf16FlyString.h>
+#include <LibWeb/Bindings/Wrappable.h>
+#include <LibWeb/Export.h>
+#include <LibWeb/Forward.h>
+
+namespace Web::EventTiming {
+
+// https://w3c.github.io/event-timing/#sec-event-counts
+class WEB_API EventCounts final : public Bindings::GCAllocatedWrappable {
+ WEB_WRAPPABLE(EventCounts, Bindings::GCAllocatedWrappable);
+ GC_DECLARE_ALLOCATOR(EventCounts);
+
+public:
+ static GC::Ref<EventCounts> create();
+
+ virtual ~EventCounts() override;
+
+ OrderedHashMap<Utf16FlyString, u64> const& entries() const { return m_entries; }
+
+ void increment(Utf16FlyString const& type);
+
+private:
+ EventCounts();
+
+ OrderedHashMap<Utf16FlyString, u64> m_entries;
+};
+
+}
diff --git a/Libraries/LibWeb/EventTiming/EventCounts.idl b/Libraries/LibWeb/EventTiming/EventCounts.idl
new file mode 100644
index 00000000000..b6265180858
--- /dev/null
+++ b/Libraries/LibWeb/EventTiming/EventCounts.idl
@@ -0,0 +1,5 @@
+// https://w3c.github.io/event-timing/#sec-event-counts
+[Exposed=Window]
+interface EventCounts {
+ readonly maplike<DOMString, unsigned long long>;
+};
diff --git a/Libraries/LibWeb/EventTiming/EventTiming.cpp b/Libraries/LibWeb/EventTiming/EventTiming.cpp
new file mode 100644
index 00000000000..156fcb28621
--- /dev/null
+++ b/Libraries/LibWeb/EventTiming/EventTiming.cpp
@@ -0,0 +1,581 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/HashTable.h>
+#include <AK/NeverDestroyed.h>
+#include <AK/Random.h>
+#include <AK/Utf16StringBuilder.h>
+#include <LibWeb/DOM/Document.h>
+#include <LibWeb/DOM/Element.h>
+#include <LibWeb/DOM/Event.h>
+#include <LibWeb/EventTiming/EventCounts.h>
+#include <LibWeb/EventTiming/EventTiming.h>
+#include <LibWeb/EventTiming/PerformanceEventTiming.h>
+#include <LibWeb/HTML/AttributeNames.h>
+#include <LibWeb/HTML/EventNames.h>
+#include <LibWeb/HTML/Scripting/Environments.h>
+#include <LibWeb/HTML/Window.h>
+#include <LibWeb/HighResolutionTime/Performance.h>
+#include <LibWeb/HighResolutionTime/TimeOrigin.h>
+#include <LibWeb/Page/Page.h>
+#include <LibWeb/PerformanceTimeline/EntryTypes.h>
+#include <LibWeb/UIEvents/EventNames.h>
+#include <LibWeb/UIEvents/InputEvent.h>
+#include <LibWeb/UIEvents/KeyboardEvent.h>
+#include <LibWeb/UIEvents/MouseEvent.h>
+#include <LibWeb/UIEvents/PointerEvent.h>
+
+namespace Web::EventTiming {
+
+WindowEventTimingState::WindowEventTimingState()
+ // NB: The user interaction value is initially set to a random integer between 100 and 10000.
+ : user_interaction_value(100 + get_random_uniform(9901))
+{
+}
+
+void WindowEventTimingState::visit_edges(GC::Cell::Visitor& visitor)
+{
+ visitor.visit(entries_to_be_queued);
+ for (auto& it : pending_key_downs)
+ visitor.visit(it.value);
+ for (auto& it : pending_pointer_downs)
+ visitor.visit(it.value);
+ visitor.visit(event_counts);
+}
+
+void for_each_event_type_considered_for_event_timing(Function<void(Utf16FlyString const&)> const& callback)
+{
+ // MouseEvents
+ callback(UIEvents::EventNames::auxclick);
+ callback(UIEvents::EventNames::click);
+ callback(UIEvents::EventNames::contextmenu);
+ callback(UIEvents::EventNames::dblclick);
+ callback(UIEvents::EventNames::mousedown);
+ callback(UIEvents::EventNames::mouseenter);
+ callback(UIEvents::EventNames::mouseleave);
+ callback(UIEvents::EventNames::mouseout);
+ callback(UIEvents::EventNames::mouseover);
+ callback(UIEvents::EventNames::mouseup);
+
+ // PointerEvents
+ callback(UIEvents::EventNames::pointerover);
+ callback(UIEvents::EventNames::pointerenter);
+ callback(UIEvents::EventNames::pointerdown);
+ callback(UIEvents::EventNames::pointerup);
+ callback(UIEvents::EventNames::pointercancel);
+ callback(UIEvents::EventNames::pointerout);
+ callback(UIEvents::EventNames::pointerleave);
+ callback(UIEvents::EventNames::gotpointercapture);
+ callback(UIEvents::EventNames::lostpointercapture);
+
+ // TouchEvents
+ static NeverDestroyed<Utf16FlyString> touchstart { "touchstart"_utf16_fly_string };
+ static NeverDestroyed<Utf16FlyString> touchend { "touchend"_utf16_fly_string };
+ static NeverDestroyed<Utf16FlyString> touchcancel { "touchcancel"_utf16_fly_string };
+ callback(*touchstart);
+ callback(*touchend);
+ callback(*touchcancel);
+
+ // KeyboardEvents
+ callback(UIEvents::EventNames::keydown);
+ callback(UIEvents::EventNames::keypress);
+ callback(UIEvents::EventNames::keyup);
+
+ // InputEvents
+ callback(UIEvents::EventNames::beforeinput);
+ callback(UIEvents::EventNames::input);
+
+ // CompositionEvents
+ callback(UIEvents::EventNames::compositionstart);
+ callback(UIEvents::EventNames::compositionupdate);
+ callback(UIEvents::EventNames::compositionend);
+
+ // Drag and Drop
+ callback(HTML::EventNames::dragstart);
+ callback(HTML::EventNames::dragend);
+ callback(HTML::EventNames::dragenter);
+ callback(HTML::EventNames::dragleave);
+ callback(HTML::EventNames::dragover);
+ callback(HTML::EventNames::drop);
+}
+
+HTML::Window* relevant_window_of_event_target(DOM::EventTarget& target)
+{
+ if (auto* window = as_if<HTML::Window>(target))
+ return window;
+ if (auto* node = as_if<DOM::Node>(target))
+ return HTML::window_from_global_object(HTML::relevant_global_object(*node));
+ return nullptr;
+}
+
+// https://w3c.github.io/event-timing/#considered-for-event-timing
+bool is_considered_for_event_timing(DOM::Event const& event)
+{
+ // 1. If event's isTrusted attribute value is set to false, return false.
+ if (!event.is_trusted())
+ return false;
+
+ // 2. If event's type is one of the following: auxclick, click, contextmenu, dblclick, mousedown, mouseenter,
+ // mouseleave, mouseout, mouseover, mouseup, pointerover, pointerenter, pointerdown, pointerup, pointercancel,
+ // pointerout, pointerleave, gotpointercapture, lostpointercapture, touchstart, touchend, touchcancel, keydown,
+ // keypress, keyup, beforeinput, input, compositionstart, compositionupdate, compositionend, dragstart, dragend,
+ // dragenter, dragleave, dragover, drop, return true.
+ static NeverDestroyed<HashTable<Utf16FlyString>> types = [] {
+ HashTable<Utf16FlyString> types;
+ for_each_event_type_considered_for_event_timing([&](Utf16FlyString const& type) {
+ types.set(type);
+ });
+ return types;
+ }();
+ if (types->contains(event.type()))
+ return true;
+
+ // 3. Return false.
+ return false;
+}
+
+// https://w3c.github.io/event-timing/#increase-interaction-count
+static void increase_interaction_count(WindowEventTimingState& state)
+{
+ // 1. Increase window's user interaction value value by a small number chosen by the user agent.
+ state.user_interaction_value += 7;
+
+ // 2. Let interactionCount be window's interactionCount.
+ // 3. Set interactionCount to interactionCount + 1.
+ ++state.interaction_count;
+}
+
+// https://w3c.github.io/event-timing/#compute-interactionid
+WebIDL::UnsignedLongLong compute_interaction_id(DOM::Event const& event, HTML::Window& window)
+{
+ // 1. If event's isTrusted attribute value is false, return 0.
+ if (!event.is_trusted())
+ return 0;
+
+ // 2. Let type be event's type attribute value.
+ auto const& type = event.type();
+
+ // 3. If type is not one among keyup, compositionstart, input, pointercancel, pointerup, click, or contextmenu,
+ // return 0.
+ if (type != UIEvents::EventNames::keyup && type != UIEvents::EventNames::compositionstart && type != UIEvents::EventNames::input
+ && type != UIEvents::EventNames::pointercancel && type != UIEvents::EventNames::pointerup && type != UIEvents::EventNames::click
+ && type != UIEvents::EventNames::contextmenu)
+ return 0;
+
+ // 4. Let window be event's relevant global object.
+ // NB: The window is passed in by the caller.
+ auto& state = window.event_timing_state();
+
+ // 5. Let pendingKeyDowns be window's pending key downs.
+ auto& pending_key_downs = state.pending_key_downs;
+
+ // 6. Let pointerMap be window's pointer interaction value map.
+ auto& pointer_map = state.pointer_interaction_value_map;
+
+ // 7. Let pendingPointerDowns be window's pending pointer downs.
+ auto& pending_pointer_downs = state.pending_pointer_downs;
+
+ // 8. If type is keyup:
+ if (type == UIEvents::EventNames::keyup) {
+ auto const* keyboard_event = as_if<UIEvents::KeyboardEvent>(event);
+ if (!keyboard_event)
+ return 0;
+
+ // 1. If event's isComposing attribute value is true, return 0.
+ if (keyboard_event->is_composing())
+ return 0;
+
+ // 2. Let code be event's keyCode attribute value.
+ auto code = keyboard_event->key_code();
+
+ // 3. If pendingKeyDowns[code] does not exist, return 0.
+ auto pending_key_down = pending_key_downs.get(code);
+ if (!pending_key_down.has_value())
+ return 0;
+
+ // 4. Let entry be pendingKeyDowns[code].
+ auto entry = pending_key_down.release_value();
+
+ // 5. Increase interaction count on window.
+ increase_interaction_count(state);
+
+ // 6. Let interactionId be window's user interaction value value.
+ auto interaction_id = state.user_interaction_value;
+
+ // 7. Set entry's interactionId to interactionId.
+ entry->set_interaction_id(interaction_id);
+
+ // 8. Add entry to window's entries to be queued.
+ state.entries_to_be_queued.append(entry);
+
+ // 9. Remove pendingKeyDowns[code].
+ pending_key_downs.remove(code);
+
+ // 10. Return interactionId.
+ return interaction_id;
+ }
+
+ // 9. If type is compositionstart:
+ if (type == UIEvents::EventNames::compositionstart) {
+ // 1. For each entry in the values of pendingKeyDowns:
+ for (auto& it : pending_key_downs) {
+ // 1. Append entry to window's entries to be queued.
+ state.entries_to_be_queued.append(it.value);
+ }
+
+ // 2. Clear pendingKeyDowns.
+ pending_key_downs.clear();
+
+ // 3. Return 0.
+ return 0;
+ }
+
+ // 10. If type is input:
+ if (type == UIEvents::EventNames::input) {
+ // 1. If event is not an instance of InputEvent, return 0.
+ // NOTE: This check is done to exclude Events for which the type is input but that are not about modified text
+ // content.
+ auto const* input_event = as_if<UIEvents::InputEvent>(event);
+ if (!input_event)
+ return 0;
+
+ // 2. If event's isComposing attribute value is false, return 0.
+ if (!input_event->is_composing())
+ return 0;
+
+ // 3. Increase interaction count on window.
+ increase_interaction_count(state);
+
+ // 4. Return window's user interaction value.
+ return state.user_interaction_value;
+ }
+
+ // 11. Otherwise (type is pointercancel, pointerup, click, or contextmenu):
+ // 1. Let pointerId be event's pointerId attribute value.
+ // AD-HOC: We dispatch click and contextmenu events as MouseEvents rather than PointerEvents, so they have no
+ // pointerId. They come from the mouse, so they use the pointerId of the mouse instead.
+ WebIDL::Long pointer_id = 0;
+ if (auto const* pointer_event = as_if<UIEvents::PointerEvent>(event))
+ pointer_id = pointer_event->pointer_id();
+ else if (is<UIEvents::MouseEvent>(event))
+ pointer_id = UIEvents::mouse_pointer_id;
+ else
+ return 0;
+
+ // 2. If type is click:
+ if (type == UIEvents::EventNames::click) {
+ // 1. If pointerMap[pointerId] does not exist, return 0.
+ auto value = pointer_map.get(pointer_id);
+ if (!value.has_value())
+ return 0;
+
+ // 2. Let value be pointerMap[pointerId].
+ // 3. Remove pointerMap[pointerId].
+ pointer_map.remove(pointer_id);
+
+ // 4. Return value.
+ return *value;
+ }
+
+ // 3. Assert that type is pointerup, pointercancel, or contextmenu.
+ VERIFY(type == UIEvents::EventNames::pointerup || type == UIEvents::EventNames::pointercancel || type == UIEvents::EventNames::contextmenu);
+
+ // 4. If pendingPointerDowns[pointerId] does not exist:
+ auto pending_pointer_down = pending_pointer_downs.get(pointer_id);
+ if (!pending_pointer_down.has_value()) {
+ // 1. If type is contextmenu, return window's user interaction value.
+ if (type == UIEvents::EventNames::contextmenu)
+ return state.user_interaction_value;
+
+ // 2. If type is pointerup and window's is contextmenu triggered flag is true:
+ if (type == UIEvents::EventNames::pointerup && state.is_contextmenu_triggered) {
+ // 1. Set window's is contextmenu triggered flag to false.
+ state.is_contextmenu_triggered = false;
+
+ // 2. Return window's user interaction value.
+ return state.user_interaction_value;
+ }
+
+ // 3. Otherwise, return 0.
+ return 0;
+ }
+
+ // 5. Let pointerDownEntry be pendingPointerDowns[pointerId].
+ // 6. Assert that pointerDownEntry is a PerformanceEventTiming entry.
+ auto pointer_down_entry = pending_pointer_down.release_value();
+
+ // 7. If type is pointerup or contextmenu:
+ if (type == UIEvents::EventNames::pointerup || type == UIEvents::EventNames::contextmenu) {
+ // 1. Increase interaction count on window.
+ increase_interaction_count(state);
+
+ // 2. Set pointerMap[pointerId] to window's user interaction value.
+ pointer_map.set(pointer_id, state.user_interaction_value);
+
+ // 3. Set pointerDownEntry's interactionId to pointerMap[pointerId].
+ pointer_down_entry->set_interaction_id(state.user_interaction_value);
+ }
+
+ // 8. Append pointerDownEntry to window’s entries to be queued.
+ state.entries_to_be_queued.append(pointer_down_entry);
+
+ // 9. Remove pendingPointerDowns[pointerId].
+ pending_pointer_downs.remove(pointer_id);
+
+ // 10. If type is contextmenu, set window's is contextmenu triggered to true.
+ if (type == UIEvents::EventNames::contextmenu)
+ state.is_contextmenu_triggered = true;
+
+ // 11. If type is pointercancel, return 0.
+ if (type == UIEvents::EventNames::pointercancel)
+ return 0;
+
+ // 12. Return pointerMap[pointerId].
+ return pointer_map.get(pointer_id).value_or(0);
+}
+
+// https://w3c.github.io/event-timing/#initialize-event-timing
+GC::Ptr<PerformanceEventTiming> initialize_event_timing(DOM::Event const& event, HighResolutionTime::DOMHighResTimeStamp processing_start, WebIDL::UnsignedLongLong interaction_id)
+{
+ // 1. If the algorithm to determine if event should be considered for Event Timing returns false, then return null.
+ if (!is_considered_for_event_timing(event))
+ return nullptr;
+
+ // 2. Let timingEntry be a new PerformanceEventTiming object with event's relevant realm.
+ // 3. Set timingEntry's name to event's type attribute value.
+ // 4. Set timingEntry's entryType to "event".
+ // 5. Set timingEntry's startTime to event's timeStamp attribute value.
+ // 6. Set timingEntry's processingStart to processingStart.
+ // 7. Set timingEntry's cancelable to event's cancelable attribute value.
+ // 8. Set timingEntry's interactionId to interactionId.
+ // 9. Return timingEntry.
+ return PerformanceEventTiming::create(event, processing_start, interaction_id);
+}
+
+// https://w3c.github.io/event-timing/#generate-a-css-selector
+static Utf16String generate_a_css_selector(DOM::EventTarget const& target)
+{
+ // 1. If target is a Node, run the following steps:
+ if (auto const* node = as_if<DOM::Node>(target)) {
+ // 1. Let selector be a string with an initial value of target's nodeName.
+ Utf16StringBuilder selector;
+ selector.append(node->node_name().view());
+
+ // 2. If target is an Element, run the following steps:
+ if (auto const* element = as_if<DOM::Element>(*node)) {
+ // 1. If target has an id attribute, set selector to the concatenation of « selector, "#", the value of the
+ // id attribute ».
+ if (auto id = element->get_attribute(HTML::AttributeNames::id); id.has_value()) {
+ selector.append_ascii('#');
+ selector.append(*id);
+ }
+ // 2. Otherwise, if target has a src attribute, set selector to the concatenation of « selector, "[src=",
+ // the value of the src attribute, "]" ».
+ else if (auto src = element->get_attribute(HTML::AttributeNames::src); src.has_value()) {
+ selector.append_ascii("[src="sv);
+ selector.append(*src);
+ selector.append_ascii(']');
+ }
+ }
+
+ // 3. Return selector.
+ return selector.to_string();
+ }
+
+ // 2. Otherwise, return an empty string.
+ return {};
+}
+
+// https://w3c.github.io/event-timing/#finalize-event-timing
+void finalize_event_timing(GC::Ptr<PerformanceEventTiming> timing_entry, DOM::Event const& event, DOM::EventTarget& target, HighResolutionTime::DOMHighResTimeStamp processing_end)
+{
+ // 1. If timingEntry is null, then return.
+ if (!timing_entry)
+ return;
+
+ // 2. Let relevantGlobal be target's relevant global object.
+ // 3. If relevantGlobal does not implement Window, return.
+ auto* relevant_global = relevant_window_of_event_target(target);
+ if (!relevant_global)
+ return;
+ auto& state = relevant_global->event_timing_state();
+
+ // 4. Set timingEntry's processingEnd to processingEnd.
+ timing_entry->set_processing_end(processing_end);
+
+ // 5. Assert that target implements Node.
+ // NOTE: This assertion holds due to the types of events supported by the Event Timing API.
+ // NB: Events of these types can also be dispatched at the Window or the Document, which have no element to time.
+ auto* target_node = as_if<DOM::Node>(target);
+
+ // 6. Set timingEntry's eventTarget to target.
+ // NOTE: This will set eventTarget to the last event target. So if retargeting occurs, the last target, closest to
+ // the root, will be used.
+ timing_entry->set_event_target(target_node);
+
+ // 7. Set timingEntry's targetSelector to the result of running the algorithm to generate a CSS selector with
+ // target as input.
+ timing_entry->set_target_selector(generate_a_css_selector(target));
+
+ // 8. If event's type attribute value is pointerdown:
+ if (event.type() == UIEvents::EventNames::pointerdown) {
+ // 1. Let pendingPointerDowns be relevantGlobal's pending pointer downs.
+ auto& pending_pointer_downs = state.pending_pointer_downs;
+
+ // 2. Let pointerId be event's pointerId.
+ auto const* pointer_event = as_if<UIEvents::PointerEvent>(event);
+ auto pointer_id = pointer_event ? pointer_event->pointer_id() : 0;
+
+ // 3. If pendingPointerDowns[pointerId] exists:
+ if (auto previous_pointer_down_entry = pending_pointer_downs.get(pointer_id); previous_pointer_down_entry.has_value()) {
+ // 1. Let previousPointerDownEntry be pendingPointerDowns[pointerId].
+ // 2. Add previousPointerDownEntry to relevantGlobal's entries to be queued.
+ state.entries_to_be_queued.append(*previous_pointer_down_entry);
+ }
+
+ // 4. Set pendingPointerDowns[pointerId] to timingEntry.
+ pending_pointer_downs.set(pointer_id, *timing_entry);
+
+ // 5. Set relevantGlobal's is contextmenu triggered to false.
+ state.is_contextmenu_triggered = false;
+ }
+ // 9. Otherwise, if event's type attribute value is keydown:
+ else if (auto const* keyboard_event = as_if<UIEvents::KeyboardEvent>(event); keyboard_event && event.type() == UIEvents::EventNames::keydown) {
+ // 1. If event's isComposing attribute value is true:
+ if (keyboard_event->is_composing()) {
+ // 1. Append timingEntry to relevantGlobal's entries to be queued.
+ state.entries_to_be_queued.append(*timing_entry);
+
+ // 2. Return.
+ return;
+ }
+
+ // 2. Let pendingKeyDowns be relevantGlobal's pending key downs.
+ auto& pending_key_downs = state.pending_key_downs;
+
+ // 3. Let code be event's keyCode attribute value.
+ auto code = keyboard_event->key_code();
+
+ // 4. If pendingKeyDowns[code] exists:
+ if (auto previous_key_down_entry = pending_key_downs.get(code); previous_key_down_entry.has_value()) {
+ // 1. Let previousKeyDownEntry be pendingKeyDowns[code].
+ // 2. If code is not 229:
+ if (code != 229) {
+ // 1. Increase relevantGlobal's user interaction value value by a small number chosen by the user
+ // agent.
+ state.user_interaction_value += 7;
+
+ // 2. Set previousKeyDownEntry's interactionId to relevantGlobal's user interaction value.
+ (*previous_key_down_entry)->set_interaction_id(state.user_interaction_value);
+ }
+ // NOTE: 229 is a special case since it corresponds to IME keyboard events. Sometimes multiple of these
+ // are sent by the user agent, and they do not correspond to holding a key down repeatedly.
+
+ // 3. Add previousKeyDownEntry to relevantGlobal's entries to be queued.
+ state.entries_to_be_queued.append(*previous_key_down_entry);
+ }
+
+ // 5. Set pendingKeyDowns[code] to timingEntry.
+ pending_key_downs.set(code, *timing_entry);
+ }
+ // 10. Otherwise:
+ else {
+ // 1. Append timingEntry to relevantGlobal's entries to be queued.
+ state.entries_to_be_queued.append(*timing_entry);
+ }
+
+ // AD-HOC: The duration of the entry is set by the next rendering update, which is asked for here in case nothing
+ // else asks for one.
+ relevant_global->associated_document().page().client().request_frame();
+}
+
+// https://w3c.github.io/event-timing/#set-event-timing-entry-duration
+static void set_event_timing_entry_duration(PerformanceEventTiming& timing_entry, HTML::Window& window, HighResolutionTime::DOMHighResTimeStamp rendering_timestamp)
+{
+ auto& state = window.event_timing_state();
+
+ // 1. If timingEntry's duration attribute value is nonzero, return.
+ // AD-HOC: A duration that rounds to zero is a duration that has been set all the same. Otherwise, a pending
+ // pointerdown or keydown entry would be given a duration again by every later rendering update until its
+ // duration rounds to a nonzero value, and its event would be counted in eventCounts each time.
+ if (timing_entry.has_duration())
+ return;
+
+ // 2. Let start be timingEntry's startTime attribute value.
+ auto start = timing_entry.start_time();
+
+ // 3. Set timingEntry's duration to a DOMHighResTimeStamp resulting from renderingTimestamp - start, with
+ // granularity of 8ms or less.
+ timing_entry.set_duration(round((rendering_timestamp - start) / 8) * 8);
+
+ // 4. Let name be timingEntry's name attribute value.
+ Utf16FlyString name { timing_entry.name() };
+
+ // 5. Perform the following steps to update the event counts:
+ // 1. Let eventCounts be window's eventCounts.
+ // 2. Assert that eventCounts contains name.
+ // 3. Set eventCounts[name] to eventCounts[name] + 1.
+ window.performance()->event_counts()->increment(name);
+
+ // 6. If window's has dispatched input event is false, and timingEntry's interactionId is not 0, run the following
+ // steps:
+ if (!state.has_dispatched_input_event && timing_entry.interaction_id() != 0) {
+ // 1. Let firstInputEntry be a copy of timingEntry.
+ // 2. Set firstInputEntry's entryType to "first-input".
+ auto first_input_entry = timing_entry.copy_with_entry_type(PerformanceTimeline::EntryTypes::first_input);
+
+ // 3. Queue firstInputEntry.
+ window.queue_performance_entry(first_input_entry);
+ window.add_performance_entry(first_input_entry, HTML::WindowOrWorkerGlobalScopeMixin::CheckIfPerformanceBufferIsFull::Yes);
+
+ // 4. Set window's has dispatched input event to true.
+ state.has_dispatched_input_event = true;
+ }
+}
+
+// https://w3c.github.io/event-timing/#dispatch-pending-event-timing-entries
+void dispatch_pending_event_timing_entries(DOM::Document& document)
+{
+ // 1. Let window be doc's relevant global object.
+ auto& window = HTML::relevant_window(document);
+ auto& state = window.event_timing_state();
+
+ // OPTIMIZATION: There is nothing to do while no event has been timed.
+ if (state.entries_to_be_queued.is_empty() && state.pending_pointer_downs.is_empty() && state.pending_key_downs.is_empty())
+ return;
+
+ // 2. Let renderingTimestamp be the current high resolution time.
+ auto rendering_timestamp = HighResolutionTime::current_high_resolution_time(HTML::relevant_global_object(window));
+
+ // 3. For each timingEntry in window's entries to be queued:
+ for (auto& timing_entry : state.entries_to_be_queued) {
+ // 1. Set event timing entry duration passing timingEntry, window, and renderingTimestamp.
+ set_event_timing_entry_duration(timing_entry, window, rendering_timestamp);
+
+ // 2. If timingEntry's duration attribute value is greater than or equal to 16, then queue timingEntry.
+ if (timing_entry->duration() >= 16) {
+ window.queue_performance_entry(timing_entry);
+ window.add_performance_entry(timing_entry, HTML::WindowOrWorkerGlobalScopeMixin::CheckIfPerformanceBufferIsFull::Yes);
+ }
+ }
+
+ // 4. Set window's entries to be queued to an empty list.
+ state.entries_to_be_queued.clear();
+
+ // 5. For each pendingPointerDownEntry in the values from window's pending pointer downs:
+ for (auto& it : state.pending_pointer_downs) {
+ // 1. Set event timing entry duration passing pendingPointerDownEntry, window, and renderingTimestamp.
+ set_event_timing_entry_duration(it.value, window, rendering_timestamp);
+ }
+
+ // 6. For each pendingKeyDownEntry in the values from window's pending key downs:
+ for (auto& it : state.pending_key_downs) {
+ // 1. Set event timing entry duration passing pendingKeyDownEntry, window, and renderingTimestamp.
+ set_event_timing_entry_duration(it.value, window, rendering_timestamp);
+ }
+}
+
+}
diff --git a/Libraries/LibWeb/EventTiming/EventTiming.h b/Libraries/LibWeb/EventTiming/EventTiming.h
new file mode 100644
index 00000000000..c057f139bb0
--- /dev/null
+++ b/Libraries/LibWeb/EventTiming/EventTiming.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Function.h>
+#include <AK/HashMap.h>
+#include <AK/Vector.h>
+#include <LibGC/Ptr.h>
+#include <LibWeb/Forward.h>
+#include <LibWebCommon/HighResolutionTime/DOMHighResTimeStamp.h>
+#include <LibWebCommon/WebIDL/Types.h>
+
+namespace Web::EventTiming {
+
+// https://w3c.github.io/event-timing/#sec-modifications-HTML
+// Each Window has the following associated concepts:
+struct WindowEventTimingState {
+ // entries to be queued, a list that stores PerformanceEventTiming objects, which will initially be empty.
+ Vector<GC::Ref<PerformanceEventTiming>> entries_to_be_queued;
+
+ // has dispatched input event, a boolean which is initially set to false.
+ bool has_dispatched_input_event { false };
+
+ // user interaction value, an integer which is initially set to a random integer between 100 and 10000.
+ u64 user_interaction_value { 0 };
+
+ // pending key downs, a map of integers to PerformanceEventTimings which is initially empty.
+ HashMap<u32, GC::Ref<PerformanceEventTiming>> pending_key_downs;
+
+ // pointer interaction value map, a map of integers which is initially empty.
+ HashMap<WebIDL::Long, u64> pointer_interaction_value_map;
+
+ // pending pointer downs, a map of integers to PerformanceEventTimings which is initially empty.
+ HashMap<WebIDL::Long, GC::Ref<PerformanceEventTiming>> pending_pointer_downs;
+
+ // is contextmenu triggered, a boolean which is initially set to false.
+ bool is_contextmenu_triggered { false };
+
+ // eventCounts, a map with entries of the form type → numEvents.
+ // NB: This is created along with the Window's Performance object.
+ GC::Ptr<EventCounts> event_counts;
+
+ // interactionCount, an integer which counts the total number of distinct user interactions, for which there was a
+ // unique interactionId computed via computing interactionId.
+ u64 interaction_count { 0 };
+
+ WindowEventTimingState();
+
+ void visit_edges(GC::Cell::Visitor&);
+};
+
+// NB: The relevant global object of the given event target, if it is a Window. Only nodes and windows are the targets
+// of events that are timed.
+HTML::Window* relevant_window_of_event_target(DOM::EventTarget&);
+
+// https://w3c.github.io/event-timing/#considered-for-event-timing
+bool is_considered_for_event_timing(DOM::Event const&);
+
+// Calls the given callback with every event type that is considered for Event Timing.
+void for_each_event_type_considered_for_event_timing(Function<void(Utf16FlyString const&)> const&);
+
+// https://w3c.github.io/event-timing/#compute-interactionid
+WebIDL::UnsignedLongLong compute_interaction_id(DOM::Event const&, HTML::Window&);
+
+// https://w3c.github.io/event-timing/#initialize-event-timing
+GC::Ptr<PerformanceEventTiming> initialize_event_timing(DOM::Event const&, HighResolutionTime::DOMHighResTimeStamp processing_start, WebIDL::UnsignedLongLong interaction_id);
+
+// https://w3c.github.io/event-timing/#finalize-event-timing
+void finalize_event_timing(GC::Ptr<PerformanceEventTiming>, DOM::Event const&, DOM::EventTarget& target, HighResolutionTime::DOMHighResTimeStamp processing_end);
+
+// https://w3c.github.io/event-timing/#dispatch-pending-event-timing-entries
+void dispatch_pending_event_timing_entries(DOM::Document&);
+
+}
diff --git a/Libraries/LibWeb/EventTiming/PerformanceEventTiming.cpp b/Libraries/LibWeb/EventTiming/PerformanceEventTiming.cpp
index 19ac5e80471..42cd526ad62 100644
--- a/Libraries/LibWeb/EventTiming/PerformanceEventTiming.cpp
+++ b/Libraries/LibWeb/EventTiming/PerformanceEventTiming.cpp
@@ -4,115 +4,93 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibGC/Heap.h>
+#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/EventTiming/PerformanceEventTiming.h>
+#include <LibWeb/PaintTiming/PaintTiming.h>
#include <LibWeb/PerformanceTimeline/EntryTypes.h>
namespace Web::EventTiming {
GC_DEFINE_ALLOCATOR(PerformanceEventTiming);
-// https://www.w3.org/TR/event-timing/#sec-init-event-timing
-PerformanceEventTiming::PerformanceEventTiming(
- String const& name,
- HighResolutionTime::DOMHighResTimeStamp start_time,
- HighResolutionTime::DOMHighResTimeStamp duration,
- DOM::Event const& event,
- HighResolutionTime::DOMHighResTimeStamp processing_start,
- unsigned long long interaction_id)
- : PerformanceTimeline::PerformanceEntry(name, start_time, duration)
- , m_entry_type(PerformanceTimeline::EntryTypes::event)
- , m_start_time(event.time_stamp())
- , m_processing_start(processing_start)
- , m_cancelable(event.cancelable())
- , m_interaction_id(interaction_id)
-
-{
-}
-
-PerformanceEventTiming::~PerformanceEventTiming() = default;
-
-Utf16FlyString const& PerformanceEventTiming::entry_type() const
-{
- return m_entry_type;
-}
-
-HighResolutionTime::DOMHighResTimeStamp PerformanceEventTiming::processing_end() const
+// https://w3c.github.io/event-timing/#initialize-event-timing
+GC::Ref<PerformanceEventTiming> PerformanceEventTiming::create(DOM::Event const& event, HighResolutionTime::DOMHighResTimeStamp processing_start, WebIDL::UnsignedLongLong interaction_id)
{
- dbgln("FIXME: Implement PerformanceEventTiming processing_end()");
- return 0;
+ // 2. Let timingEntry be a new PerformanceEventTiming object with event's relevant realm.
+ // 3. Set timingEntry's name to event's type attribute value.
+ // 4. Set timingEntry's entryType to "event".
+ // 5. Set timingEntry's startTime to event's timeStamp attribute value.
+ // 6. Set timingEntry's processingStart to processingStart.
+ // 7. Set timingEntry's cancelable to event's cancelable attribute value.
+ // 8. Set timingEntry's interactionId to interactionId.
+ return GC::Heap::the().allocate<PerformanceEventTiming>(Utf16String::from_utf16(event.type().view()), PerformanceTimeline::EntryTypes::event, event.time_stamp(), processing_start, event.cancelable(), interaction_id);
}
-HighResolutionTime::DOMHighResTimeStamp PerformanceEventTiming::processing_start() const
+PerformanceEventTiming::PerformanceEventTiming(Utf16String const& name, Utf16FlyString const& entry_type, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp processing_start, bool cancelable, WebIDL::UnsignedLongLong interaction_id)
+ : PerformanceTimeline::PerformanceEntry(name, start_time, 0)
+ , m_entry_type(entry_type)
+ , m_processing_start(processing_start)
+ , m_cancelable(cancelable)
+ , m_interaction_id(interaction_id)
{
- dbgln("FIXME: Implement PerformanceEventTiming processing_start()");
- return 0;
}
-bool PerformanceEventTiming::cancelable() const
-{
- return m_cancelable;
-}
+PerformanceEventTiming::~PerformanceEventTiming() = default;
-GC::Ptr<DOM::Node> PerformanceEventTiming::target()
+GC::Ref<PerformanceEventTiming> PerformanceEventTiming::copy_with_entry_type(Utf16FlyString const& entry_type) const
{
- dbgln("FIXME: Implement PerformanceEventTiming::PerformanceEventTiming target()");
- return nullptr;
+ auto copy = GC::Heap::the().allocate<PerformanceEventTiming>(name(), entry_type, start_time(), m_processing_start, m_cancelable, m_interaction_id);
+ copy->m_duration = m_duration;
+ copy->m_has_duration = m_has_duration;
+ copy->m_processing_end = m_processing_end;
+ copy->m_event_target = m_event_target;
+ copy->m_target_selector = m_target_selector;
+ return copy;
}
-unsigned long long PerformanceEventTiming::interaction_id()
+// https://w3c.github.io/event-timing/#dom-performanceeventtiming-target
+GC::Ptr<DOM::Node> PerformanceEventTiming::target() const
{
- dbgln("FIXME: Implement PerformanceEventTiming interaction_id()");
- return 0;
+ // 1. If this's eventTarget is not exposed for paint timing given null, return null.
+ // NB: Only elements can be exposed for paint timing.
+ auto const* element = as_if<DOM::Element>(m_event_target.ptr());
+ if (!element || !PaintTiming::is_exposed_for_paint_timing(*element, nullptr))
+ return nullptr;
+
+ // 2. Return this's eventTarget.
+ return m_event_target;
}
-// https://www.w3.org/TR/event-timing/#sec-should-add-performanceeventtiming
-PerformanceTimeline::ShouldAddEntry PerformanceEventTiming::should_add_performance_event_timing() const
+// https://w3c.github.io/event-timing/#should-add-performanceeventtiming
+PerformanceTimeline::ShouldAddEntry PerformanceEventTiming::should_add_entry(Optional<PerformanceTimeline::PerformanceObserverInit const&> options) const
{
- dbgln("FIXME: Implement PerformanceEventTiming should_add_performance_event_timing()");
- // 1. If entry’s entryType attribute value equals to "first-input", return true.
+ // 1. If entry's entryType attribute value equals to "first-input", return true.
if (entry_type() == PerformanceTimeline::EntryTypes::first_input)
return PerformanceTimeline::ShouldAddEntry::Yes;
- // 2. Assert that entry’s entryType attribute value equals "event".
+ // 2. Assert that entry's entryType attribute value equals "event".
VERIFY(entry_type() == PerformanceTimeline::EntryTypes::event);
- // FIXME: 3. Let minDuration be computed as follows:
- // FIXME: 3.1. If options is not present or if options’s durationThreshold is not present, let minDuration be 104.
- // FIXME: 3.2. Otherwise, let minDuration be the maximum between 16 and options’s durationThreshold value.
+ // 3. Let minDuration be computed as follows:
+ HighResolutionTime::DOMHighResTimeStamp min_duration = 0;
- // FIXME: 4. If entry’s duration attribute value is greater than or equal to minDuration, return true.
+ // 1. If options is not present or if options's durationThreshold is not present, let minDuration be 104.
+ if (!options.has_value() || !options->duration_threshold.has_value())
+ min_duration = 104;
+ // 2. Otherwise, let minDuration be the maximum between 16 and options's durationThreshold value.
+ else
+ min_duration = max(16.0, options->duration_threshold.value());
+
+ // 4. If entry's duration attribute value is greater than or equal to minDuration, return true.
+ if (duration() >= min_duration)
+ return PerformanceTimeline::ShouldAddEntry::Yes;
// 5. Otherwise, return false.
return PerformanceTimeline::ShouldAddEntry::No;
}
-// https://w3c.github.io/timing-entrytypes-registry/#dfn-availablefromtimeline
-// FIXME: the output here depends on the type of the object instance, but this function is static
-// the commented out if statement won't compile
-PerformanceTimeline::AvailableFromTimeline PerformanceEventTiming::available_from_timeline()
-{
- dbgln("FIXME: Implement PerformanceEventTiming available_from_timeline()");
- // if (entry_type() == "first-input")
- return PerformanceTimeline::AvailableFromTimeline::Yes;
-}
-
-// https://w3c.github.io/timing-entrytypes-registry/#dfn-maxbuffersize
-// FIXME: Same issue as available_from_timeline() above
-Optional<u64> PerformanceEventTiming::max_buffer_size()
-{
- dbgln("FIXME: Implement PerformanceEventTiming max_buffer_size()");
- if (true) //(entry_type() == "first-input")
- return 1;
- // else return 150;
-}
-
-// https://w3c.github.io/timing-entrytypes-registry/#dfn-should-add-entry
-PerformanceTimeline::ShouldAddEntry PerformanceEventTiming::should_add_entry(Optional<PerformanceTimeline::PerformanceObserverInit const&>) const
-{
- return should_add_performance_event_timing();
-}
-
void PerformanceEventTiming::visit_edges(GC::Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
diff --git a/Libraries/LibWeb/EventTiming/PerformanceEventTiming.h b/Libraries/LibWeb/EventTiming/PerformanceEventTiming.h
index d20810e7f83..d17c98b3d99 100644
--- a/Libraries/LibWeb/EventTiming/PerformanceEventTiming.h
+++ b/Libraries/LibWeb/EventTiming/PerformanceEventTiming.h
@@ -8,62 +8,90 @@
#include <LibWeb/Forward.h>
#include <LibWeb/PerformanceTimeline/PerformanceEntry.h>
-#include <LibWeb/WebIDL/ExceptionOr.h>
+#include <LibWebCommon/WebIDL/Types.h>
namespace Web::EventTiming {
-// https://www.w3.org/TR/event-timing/#sec-performance-event-timing
+// https://w3c.github.io/event-timing/#sec-performance-event-timing
class PerformanceEventTiming final : public PerformanceTimeline::PerformanceEntry {
WEB_WRAPPABLE(PerformanceEventTiming, PerformanceTimeline::PerformanceEntry);
GC_DECLARE_ALLOCATOR(PerformanceEventTiming);
public:
+ static GC::Ref<PerformanceEventTiming> create(DOM::Event const&, HighResolutionTime::DOMHighResTimeStamp processing_start, WebIDL::UnsignedLongLong interaction_id);
+
virtual ~PerformanceEventTiming();
- HighResolutionTime::DOMHighResTimeStamp processing_start() const;
- HighResolutionTime::DOMHighResTimeStamp processing_end() const;
- bool cancelable() const;
- GC::Ptr<DOM::Node> target();
- unsigned long long interaction_id();
+ // A copy of this entry, with the given entry type.
+ GC::Ref<PerformanceEventTiming> copy_with_entry_type(Utf16FlyString const& entry_type) const;
+
+ virtual Utf16FlyString const& entry_type() const override { return m_entry_type; }
+
+ virtual HighResolutionTime::DOMHighResTimeStamp duration() const override { return m_duration; }
+ void set_duration(HighResolutionTime::DOMHighResTimeStamp duration)
+ {
+ m_duration = duration;
+ m_has_duration = true;
+ }
+ bool has_duration() const { return m_has_duration; }
+
+ HighResolutionTime::DOMHighResTimeStamp processing_start() const { return m_processing_start; }
+
+ HighResolutionTime::DOMHighResTimeStamp processing_end() const { return m_processing_end; }
+ void set_processing_end(HighResolutionTime::DOMHighResTimeStamp processing_end) { m_processing_end = processing_end; }
+
+ bool cancelable() const { return m_cancelable; }
+
+ GC::Ptr<DOM::Node> target() const;
+ void set_event_target(GC::Ptr<DOM::Node> event_target) { m_event_target = event_target; }
+
+ Utf16String const& target_selector() const { return m_target_selector; }
+ void set_target_selector(Utf16String target_selector) { m_target_selector = move(target_selector); }
+
+ WebIDL::UnsignedLongLong interaction_id() const { return m_interaction_id; }
+ void set_interaction_id(WebIDL::UnsignedLongLong interaction_id) { m_interaction_id = interaction_id; }
- // from the registry:
- // https://w3c.github.io/timing-entrytypes-registry/#dfn-availablefromtimeline
- static PerformanceTimeline::AvailableFromTimeline available_from_timeline();
- // https://w3c.github.io/timing-entrytypes-registry/#dfn-maxbuffersize
- static Optional<u64> max_buffer_size();
// https://w3c.github.io/timing-entrytypes-registry/#dfn-should-add-entry
virtual PerformanceTimeline::ShouldAddEntry should_add_entry(Optional<PerformanceTimeline::PerformanceObserverInit const&> = {}) const override;
- virtual Utf16FlyString const& entry_type() const override;
-
private:
- PerformanceEventTiming(
- String const& name,
- HighResolutionTime::DOMHighResTimeStamp start_time,
- HighResolutionTime::DOMHighResTimeStamp duration,
- DOM::Event const& event,
- HighResolutionTime::DOMHighResTimeStamp processing_start,
- unsigned long long interaction_id);
-
- // m_entry_type defined here for both "event"s and "first-input"s
- // this is the only PerformanceEntry that has two event types it could represent
- // That complicates implementing the registry functions if they remain static
+ PerformanceEventTiming(Utf16String const& name, Utf16FlyString const& entry_type, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp processing_start, bool cancelable, WebIDL::UnsignedLongLong interaction_id);
+
+ virtual void visit_edges(GC::Cell::Visitor&) override;
+
+ // NB: An entry is "event", unless it is the copy of an entry that is queued as the first input.
Utf16FlyString m_entry_type;
- GC::Ptr<DOM::EventTarget> m_event_target;
- HighResolutionTime::DOMHighResTimeStamp m_start_time;
- HighResolutionTime::DOMHighResTimeStamp m_processing_start;
- bool m_cancelable;
- unsigned long long m_interaction_id;
- PerformanceTimeline::ShouldAddEntry should_add_performance_event_timing() const;
+ HighResolutionTime::DOMHighResTimeStamp m_duration { 0 };
+ bool m_has_duration { false };
+ HighResolutionTime::DOMHighResTimeStamp m_processing_start { 0 };
+ HighResolutionTime::DOMHighResTimeStamp m_processing_end { 0 };
+ bool m_cancelable { false };
- virtual void visit_edges(GC::Cell::Visitor&) override;
+ // https://w3c.github.io/event-timing/#eventtarget
+ GC::Ptr<DOM::Node> m_event_target;
+
+ Utf16String m_target_selector;
+ WebIDL::UnsignedLongLong m_interaction_id { 0 };
+};
+
+// NOTE: These two functions are answered by the registry for the given entry type.
+// https://w3c.github.io/timing-entrytypes-registry/#registry
+// NB: PerformanceEventTiming objects have one of two entry types, which the registry answers for separately.
+struct EventEntryTypeRegistry {
+ // https://w3c.github.io/timing-entrytypes-registry/#dfn-availablefromtimeline
+ static PerformanceTimeline::AvailableFromTimeline available_from_timeline() { return PerformanceTimeline::AvailableFromTimeline::No; }
- // FIXME: remaining algorithms described in this spec:
- // https://www.w3.org/TR/event-timing/#sec-increasing-interaction-count
- // https://www.w3.org/TR/event-timing/#sec-computing-interactionid
- // https://www.w3.org/TR/event-timing/#sec-fin-event-timing
- // https://www.w3.org/TR/event-timing/#sec-dispatch-pending
+ // https://w3c.github.io/timing-entrytypes-registry/#dfn-maxbuffersize
+ static Optional<u64> max_buffer_size() { return 150; }
+};
+
+struct FirstInputEntryTypeRegistry {
+ // https://w3c.github.io/timing-entrytypes-registry/#dfn-availablefromtimeline
+ static PerformanceTimeline::AvailableFromTimeline available_from_timeline() { return PerformanceTimeline::AvailableFromTimeline::Yes; }
+
+ // https://w3c.github.io/timing-entrytypes-registry/#dfn-maxbuffersize
+ static Optional<u64> max_buffer_size() { return 1; }
};
}
diff --git a/Libraries/LibWeb/EventTiming/PerformanceEventTiming.idl b/Libraries/LibWeb/EventTiming/PerformanceEventTiming.idl
index e3c74092a64..883bb4d229f 100644
--- a/Libraries/LibWeb/EventTiming/PerformanceEventTiming.idl
+++ b/Libraries/LibWeb/EventTiming/PerformanceEventTiming.idl
@@ -5,12 +5,19 @@ interface PerformanceEventTiming : PerformanceEntry {
readonly attribute DOMHighResTimeStamp processingEnd;
readonly attribute boolean cancelable;
readonly attribute Node? target;
+ readonly attribute DOMString targetSelector;
readonly attribute unsigned long long interactionId;
[Default] object toJSON();
};
-
-// Potential fixme: This spec has some more IDLs
-// https://w3c.github.io/event-timing/#sec-event-counts
// https://w3c.github.io/event-timing/#sec-extensions
+[Exposed=Window]
+partial interface Performance {
+ [SameObject] readonly attribute EventCounts eventCounts;
+ readonly attribute unsigned long long interactionCount;
+};
+
// https://w3c.github.io/event-timing/#sec-modifications-perf-timeline
+partial dictionary PerformanceObserverInit {
+ DOMHighResTimeStamp durationThreshold;
+};
diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h
index 8ca3bcb842e..732328c330c 100644
--- a/Libraries/LibWeb/Forward.h
+++ b/Libraries/LibWeb/Forward.h
@@ -559,7 +559,9 @@ class FileSystemEntry;
namespace Web::EventTiming {
+class EventCounts;
class PerformanceEventTiming;
+struct WindowEventTimingState;
}
diff --git a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
index bb5afe067e9..7eb6913b79b 100644
--- a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
+++ b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
@@ -22,6 +22,7 @@
#include <LibWeb/CSS/StyleScope.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
+#include <LibWeb/EventTiming/EventTiming.h>
#include <LibWeb/HTML/AnimationFrameCallbackDriver.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/EventLoop/ClockPlan.h>
@@ -1245,6 +1246,14 @@ void EventLoop::update_the_rendering_after_style_and_layout(Vector<GC::Root<DOM:
PaintTiming::mark_paint_timing(*document);
}
+ // https://w3c.github.io/event-timing/#sec-modifications-HTML
+ // For each fully active Document in docs, invoke the algorithm to dispatch pending Event Timing entries for that
+ // Document.
+ for (auto& document : docs) {
+ if (document->is_fully_active())
+ EventTiming::dispatch_pending_event_timing_entries(*document);
+ }
+
// AD-HOC: Flush dirty canvas contexts in documents' pages after callbacks
// have had a chance to update them, and before painting snapshots the frame.
for (auto& document : docs)
diff --git a/Libraries/LibWeb/HTML/Window.cpp b/Libraries/LibWeb/HTML/Window.cpp
index 4871b25e0b1..4e0311ca623 100644
--- a/Libraries/LibWeb/HTML/Window.cpp
+++ b/Libraries/LibWeb/HTML/Window.cpp
@@ -393,6 +393,7 @@ void Window::visit_edges(JS::Cell::Visitor& visitor)
visitor.visit(m_statusbar);
visitor.visit(m_toolbar);
visitor.visit(m_external);
+ m_event_timing_state.visit_edges(visitor);
}
void Window::finalize()
diff --git a/Libraries/LibWeb/HTML/Window.h b/Libraries/LibWeb/HTML/Window.h
index 58916b1638c..f29edbba83e 100644
--- a/Libraries/LibWeb/HTML/Window.h
+++ b/Libraries/LibWeb/HTML/Window.h
@@ -21,6 +21,7 @@
#include <LibWeb/Bindings/Forward.h>
#include <LibWeb/Bindings/IdleRequest.h>
#include <LibWeb/DOM/EventTarget.h>
+#include <LibWeb/EventTiming/EventTiming.h>
#include <LibWeb/Export.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/BarProp.h>
@@ -315,6 +316,8 @@ public:
static void for_each_active(Function<IterationDecision(Window&)> callback);
+ EventTiming::WindowEventTimingState& event_timing_state() { return m_event_timing_state; }
+
private:
Window();
@@ -401,6 +404,8 @@ private:
// https://html.spec.whatwg.org/multipage/obsolete.html#dom-external
GC::Ptr<External> m_external;
+
+ EventTiming::WindowEventTimingState m_event_timing_state;
};
void run_animation_frame_callbacks(DOM::Document&, double now);
diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
index 191117318d6..4210f1e5375 100644
--- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
+++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
@@ -32,6 +32,7 @@
#include <LibWeb/ContentSecurityPolicy/BlockingAlgorithms.h>
#include <LibWeb/Crypto/Crypto.h>
#include <LibWeb/DOM/Document.h>
+#include <LibWeb/EventTiming/PerformanceEventTiming.h>
#include <LibWeb/Fetch/BindingsGlue.h>
#include <LibWeb/Fetch/FetchMethod.h>
#include <LibWeb/HTML/BroadcastChannel.h>
diff --git a/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Libraries/LibWeb/HighResolutionTime/Performance.cpp
index 4d3375b9dbd..d7a595ec4c2 100644
--- a/Libraries/LibWeb/HighResolutionTime/Performance.cpp
+++ b/Libraries/LibWeb/HighResolutionTime/Performance.cpp
@@ -12,6 +12,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/EventDispatcher.h>
+#include <LibWeb/EventTiming/EventCounts.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HighResolutionTime/Performance.h>
@@ -62,6 +63,29 @@ GC::Ptr<NavigationTiming::PerformanceNavigation> Performance::navigation()
return m_navigation;
}
+// https://w3c.github.io/event-timing/#dom-performance-eventcounts
+GC::Ref<EventTiming::EventCounts> Performance::event_counts()
+{
+ // The eventCounts attribute's getter returns this's relevant global object's eventCounts.
+ auto* window = HTML::window_from_global_object(relevant_global_object());
+ VERIFY(window);
+ auto& event_counts = window->event_timing_state().event_counts;
+ // NB: The eventCounts of a Window are created along with its Performance object, which is when they are first
+ // asked for.
+ if (!event_counts)
+ event_counts = EventTiming::EventCounts::create();
+ return *event_counts;
+}
+
+// https://w3c.github.io/event-timing/#dom-performance-interactioncount
+WebIDL::UnsignedLongLong Performance::interaction_count()
+{
+ // The interactionCount attribute's getter returns this's relevant global object's interactionCount.
+ auto* window = HTML::window_from_global_object(relevant_global_object());
+ VERIFY(window);
+ return window->event_timing_state().interaction_count;
+}
+
// https://w3c.github.io/hr-time/#timeorigin-attribute
double Performance::time_origin() const
{
diff --git a/Libraries/LibWeb/HighResolutionTime/Performance.h b/Libraries/LibWeb/HighResolutionTime/Performance.h
index 47e1b9fff49..0d6c9d5b436 100644
--- a/Libraries/LibWeb/HighResolutionTime/Performance.h
+++ b/Libraries/LibWeb/HighResolutionTime/Performance.h
@@ -46,6 +46,9 @@ public:
GC::Ptr<NavigationTiming::PerformanceTiming> timing();
GC::Ptr<NavigationTiming::PerformanceNavigation> navigation();
+ GC::Ref<EventTiming::EventCounts> event_counts();
+ WebIDL::UnsignedLongLong interaction_count();
+
private:
explicit Performance(GC::Ref<DOM::EventTarget> relevant_global_object);
diff --git a/Libraries/LibWeb/HighResolutionTime/SupportedPerformanceTypes.h b/Libraries/LibWeb/HighResolutionTime/SupportedPerformanceTypes.h
index 40bc423b7bb..b4defcd8105 100644
--- a/Libraries/LibWeb/HighResolutionTime/SupportedPerformanceTypes.h
+++ b/Libraries/LibWeb/HighResolutionTime/SupportedPerformanceTypes.h
@@ -21,6 +21,8 @@ inline bool is_supported_for_global(SupportedPerformanceEntryTypeGlobals globals
// Please keep these in alphabetical order based on the entry type :^)
#define ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES \
+ __ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::event, EventTiming::EventEntryTypeRegistry, WindowOnly) \
+ __ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::first_input, EventTiming::FirstInputEntryTypeRegistry, WindowOnly) \
__ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::mark, UserTiming::PerformanceMark, WindowAndWorker) \
__ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::measure, UserTiming::PerformanceMeasure, WindowAndWorker) \
__ENUMERATE_SUPPORTED_PERFORMANCE_ENTRY_TYPES(PerformanceTimeline::EntryTypes::navigation, NavigationTiming::PerformanceNavigationTiming, WindowOnly) \
diff --git a/Libraries/LibWeb/PaintTiming/PaintTiming.cpp b/Libraries/LibWeb/PaintTiming/PaintTiming.cpp
index dc8129b36aa..cf1fa1f822d 100644
--- a/Libraries/LibWeb/PaintTiming/PaintTiming.cpp
+++ b/Libraries/LibWeb/PaintTiming/PaintTiming.cpp
@@ -460,4 +460,28 @@ void report_paint_timing(DOM::Document& document, Utf16String const& paint_type,
document.paint_timing_state().set_of_previously_reported_paints.set(paint_type);
}
+// https://w3c.github.io/paint-timing/#exposed-for-paint-timing
+bool is_exposed_for_paint_timing(DOM::Element const& element, GC::Ptr<DOM::Document const> document)
+{
+ // 1. If element is not connected, return false.
+ if (!element.is_connected())
+ return false;
+
+ // 2. If document is null, let document be element's relevant settings object's relevant global object's
+ // associated document.
+ if (!document)
+ document = HTML::relevant_window(element).associated_document();
+
+ // 3. If document is not fully active, return false.
+ if (!document->is_fully_active())
+ return false;
+
+ // 4. If element's root is not equal to document, return false.
+ if (&element.root() != document.ptr())
+ return false;
+
+ // 5. Return true.
+ return true;
+}
+
}
diff --git a/Libraries/LibWeb/PaintTiming/PaintTiming.h b/Libraries/LibWeb/PaintTiming/PaintTiming.h
index 6db0f9deff6..807a925a846 100644
--- a/Libraries/LibWeb/PaintTiming/PaintTiming.h
+++ b/Libraries/LibWeb/PaintTiming/PaintTiming.h
@@ -18,4 +18,7 @@ void mark_paint_timing(DOM::Document&);
// https://w3c.github.io/paint-timing/#report-paint-timing
void report_paint_timing(DOM::Document&, Utf16String const& paint_type, PaintTimingInfo const&);
+// https://w3c.github.io/paint-timing/#exposed-for-paint-timing
+bool is_exposed_for_paint_timing(DOM::Element const&, GC::Ptr<DOM::Document const>);
+
}
diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake
index 521ca1559d7..49ff77d65cc 100644
--- a/Libraries/LibWeb/idl_files.cmake
+++ b/Libraries/LibWeb/idl_files.cmake
@@ -159,6 +159,7 @@ libweb_js_bindings(Encoding/TextEncoderCommon)
libweb_js_bindings(Encoding/TextEncoderStream)
libweb_js_bindings(EncryptedMediaExtensions/MediaKeySystemAccess)
libweb_js_bindings(EntriesAPI/FileSystemEntry)
+libweb_js_bindings(EventTiming/EventCounts)
libweb_js_bindings(EventTiming/PerformanceEventTiming)
libweb_js_bindings(Fetch/Body)
libweb_js_bindings(Fetch/BodyInit)
diff --git a/Meta/Generators/libweb_bindings/glue_headers.py b/Meta/Generators/libweb_bindings/glue_headers.py
index 76ac9bf942c..1903ac6f121 100644
--- a/Meta/Generators/libweb_bindings/glue_headers.py
+++ b/Meta/Generators/libweb_bindings/glue_headers.py
@@ -15,6 +15,7 @@ def bindings_glue_header_for_interface(interface: Interface, wrapper_interface_n
"Animations": "LibWeb/Animations/BindingsGlue.h",
"CSS": "LibWeb/CSS/BindingsGlue.h",
"CookieStore": "LibWeb/CookieStore/BindingsGlue.h",
+ "EventTiming": "LibWeb/EventTiming/BindingsGlue.h",
"IndexedDB": "LibWeb/IndexedDB/BindingsGlue.h",
"TrustedTypes": "LibWeb/TrustedTypes/BindingsGlue.h",
"WebAssembly": "LibWeb/WebAssembly/BindingsGlue.h",
diff --git a/Tests/LibWeb/Text/expected/PerformanceObserver/PerformanceObserver-supportedEntryTypes.txt b/Tests/LibWeb/Text/expected/PerformanceObserver/PerformanceObserver-supportedEntryTypes.txt
index 2e076adc411..b72ade22bbf 100644
--- a/Tests/LibWeb/Text/expected/PerformanceObserver/PerformanceObserver-supportedEntryTypes.txt
+++ b/Tests/LibWeb/Text/expected/PerformanceObserver/PerformanceObserver-supportedEntryTypes.txt
@@ -1,4 +1,4 @@
-PerformanceObserver.supportedEntryTypes: mark,measure,navigation,paint,resource
+PerformanceObserver.supportedEntryTypes: event,first-input,mark,measure,navigation,paint,resource
PerformanceObserver.supportedEntryTypes instanceof Array: true
Object.isFrozen(PerformanceObserver.supportedEntryTypes): true
PerformanceObserver.supportedEntryTypes === PerformanceObserver.supportedEntryTypes: true
diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt
index 49e8936f760..9dbc767d8c4 100644
--- a/Tests/LibWeb/Text/expected/all-window-properties.txt
+++ b/Tests/LibWeb/Text/expected/all-window-properties.txt
@@ -164,6 +164,7 @@ Error
ErrorEvent
EvalError
Event
+EventCounts
EventSource
EventTarget
External
diff --git a/Tests/LibWeb/Text/expected/performance-timing-and-navigation-not-exposed-outside-of-window.txt b/Tests/LibWeb/Text/expected/performance-timing-and-navigation-not-exposed-outside-of-window.txt
index 11f72d4b853..e0402bee95c 100644
--- a/Tests/LibWeb/Text/expected/performance-timing-and-navigation-not-exposed-outside-of-window.txt
+++ b/Tests/LibWeb/Text/expected/performance-timing-and-navigation-not-exposed-outside-of-window.txt
@@ -1,6 +1,6 @@
(window) navigation: object
(window) timing: object
-(window) performance JSON: {"timeOrigin":[removed-potentially-flaky-time-value],"timing":{"navigationStart":[removed-potentially-flaky-time-value],"unloadEventStart":[removed-potentially-flaky-time-value],"unloadEventEnd":[removed-potentially-flaky-time-value],"redirectStart":[removed-potentially-flaky-time-value],"redirectEnd":[removed-potentially-flaky-time-value],"fetchStart":[removed-potentially-flaky-time-value],"domainLookupStart":[removed-potentially-flaky-time-value],"domainLookupEnd":[removed-potentially-flaky-time-value],"connectStart":[removed-potentially-flaky-time-value],"connectEnd":[removed-potentially-flaky-time-value],"secureConnectionStart":[removed-potentially-flaky-time-value],"requestStart":[removed-potentially-flaky-time-value],"responseStart":[removed-potentially-flaky-time-value],"responseEnd":[removed-potentially-flaky-time-value],"domLoading":[removed-potentially-flaky-time-value],"domInteractive":[removed-potentially-flaky-time-value],"domContentLoadedEventStart":[removed-potentially-flaky-time-value],"domContentLoadedEventEnd":[removed-potentially-flaky-time-value],"domComplete":[removed-potentially-flaky-time-value],"loadEventStart":[removed-potentially-flaky-time-value],"loadEventEnd":[removed-potentially-flaky-time-value]},"navigation":{"type":[removed-potentially-flaky-time-value],"redirectCount":[removed-potentially-flaky-time-value]}}
+(window) performance JSON: {"timeOrigin":[removed-potentially-flaky-time-value],"interactionCount":[removed-potentially-flaky-time-value],"timing":{"navigationStart":[removed-potentially-flaky-time-value],"unloadEventStart":[removed-potentially-flaky-time-value],"unloadEventEnd":[removed-potentially-flaky-time-value],"redirectStart":[removed-potentially-flaky-time-value],"redirectEnd":[removed-potentially-flaky-time-value],"fetchStart":[removed-potentially-flaky-time-value],"domainLookupStart":[removed-potentially-flaky-time-value],"domainLookupEnd":[removed-potentially-flaky-time-value],"connectStart":[removed-potentially-flaky-time-value],"connectEnd":[removed-potentially-flaky-time-value],"secureConnectionStart":[removed-potentially-flaky-time-value],"requestStart":[removed-potentially-flaky-time-value],"responseStart":[removed-potentially-flaky-time-value],"responseEnd":[removed-potentially-flaky-time-value],"domLoading":[removed-potentially-flaky-time-value],"domInteractive":[removed-potentially-flaky-time-value],"domContentLoadedEventStart":[removed-potentially-flaky-time-value],"domContentLoadedEventEnd":[removed-potentially-flaky-time-value],"domComplete":[removed-potentially-flaky-time-value],"loadEventStart":[removed-potentially-flaky-time-value],"loadEventEnd":[removed-potentially-flaky-time-value]},"navigation":{"type":[removed-potentially-flaky-time-value],"redirectCount":[removed-potentially-flaky-time-value]}}
(worker) navigation: undefined
(worker) timing: undefined
(worker) performance JSON: {"timeOrigin":[removed-potentially-flaky-time-value]}
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/auxclick.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/auxclick.txt
new file mode 100644
index 00000000000..a1e6eb1b86c
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/auxclick.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing auxclick.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/buffered-and-duration-threshold.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/buffered-and-duration-threshold.txt
new file mode 100644
index 00000000000..23552068b44
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/buffered-and-duration-threshold.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass PerformanceObserver buffering independent of durationThreshold
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/buffered-flag.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/buffered-flag.txt
new file mode 100644
index 00000000000..0d289aeed48
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/buffered-flag.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass PerformanceObserver with buffered flag sees previous Event Timing entries
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/click-timing.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/click-timing.txt
new file mode 100644
index 00000000000..e30de36cadf
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/click-timing.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: compare click timings.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/click.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/click.txt
new file mode 100644
index 00000000000..91e9a4894dd
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/click.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing click.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/contextmenu.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/contextmenu.txt
new file mode 100644
index 00000000000..1e145d342e2
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/contextmenu.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing contextmenu.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/crossiframe.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/crossiframe.txt
new file mode 100644
index 00000000000..9c3b7c15da9
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/crossiframe.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: entries should only be observable by its own frame.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/dblclick.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/dblclick.txt
new file mode 100644
index 00000000000..a538a6db681
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/dblclick.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing dblclick.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/disconnect-target.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/disconnect-target.txt
new file mode 100644
index 00000000000..0822aa974aa
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/disconnect-target.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: when target is disconnected, entry.target returns null.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/duration-with-target-low.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/duration-with-target-low.txt
new file mode 100644
index 00000000000..a32fec931d2
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/duration-with-target-low.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass PerformanceObserver with durationThreshold of 300 and processingDelay of 0 doesn't see any entries in the observer
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/event-click-counts.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/event-click-counts.txt
new file mode 100644
index 00000000000..2b3f46a5cd8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/event-click-counts.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: eventCounts.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/event-counts-zero.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/event-counts-zero.txt
new file mode 100644
index 00000000000..2b3f46a5cd8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/event-counts-zero.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: eventCounts.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/first-input-interactionid-click.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/first-input-interactionid-click.txt
new file mode 100644
index 00000000000..c06a7c6d10d
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/first-input-interactionid-click.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass The interactionId of the first input entry should match the same pointerdown entry of event timing when click.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/first-input-interactionid-key.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/first-input-interactionid-key.txt
new file mode 100644
index 00000000000..e9e52550abd
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/first-input-interactionid-key.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass The interactionId of the first input entry should match the same keydown entry of event timing when press a key.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/gap-pointerdown-pointerup.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/gap-pointerdown-pointerup.txt
new file mode 100644
index 00000000000..f9bfbf9c8c2
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/gap-pointerdown-pointerup.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass pointerdown duration shouldn't wait for pointerup.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/interaction-count-click.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interaction-count-click.txt
new file mode 100644
index 00000000000..c45c596d735
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interaction-count-click.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass EventTiming: verify interactionCount for click interaction
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/interaction-count-press-key.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interaction-count-press-key.txt
new file mode 100644
index 00000000000..b80d7152df0
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interaction-count-press-key.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass EventTiming: verify interactionCount for key interaction
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-aux-pointerdown-and-pointerdown.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-aux-pointerdown-and-pointerdown.txt
new file mode 100644
index 00000000000..acf348f6603
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-aux-pointerdown-and-pointerdown.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: verify pointerdown reporting for mouse aux pointerdown only triggered contextmenu followed immediately by another pointerdown event.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-aux-pointerdown.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-aux-pointerdown.txt
new file mode 100644
index 00000000000..63bd8780bd7
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-aux-pointerdown.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: verify pointerdown reporting for mouse aux pointerdown only triggered contextmenu.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-click.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-click.txt
new file mode 100644
index 00000000000..ce79add76b4
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-click.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: compare event timing interactionId.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-label-click.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-label-click.txt
new file mode 100644
index 00000000000..4a04f4d9257
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-label-click.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: interactionId for clicks forwarded form controls is zero.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-orphan-pointerup.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-orphan-pointerup.txt
new file mode 100644
index 00000000000..355a39eccec
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-orphan-pointerup.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: Orphan pointerup should not be measured as an interaction.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-press-key-as-input.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-press-key-as-input.txt
new file mode 100644
index 00000000000..dbdb2489e89
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-press-key-as-input.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: compare event timing interactionId for key press as input.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-press-key-no-effect.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-press-key-no-effect.txt
new file mode 100644
index 00000000000..48c0033aa8f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/interactionid-press-key-no-effect.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: compare event timing interactionId for key press with no effect.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/keydown.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/keydown.txt
new file mode 100644
index 00000000000..c8cd5d68b18
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/keydown.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing Keydown.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/keyup.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/keyup.txt
new file mode 100644
index 00000000000..a3a81f46263
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/keyup.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing Keyup.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/large-duration-threshold.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/large-duration-threshold.txt
new file mode 100644
index 00000000000..a199bee6a2f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/large-duration-threshold.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass PerformanceObserver observes events according to its durationThreshold
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/medium-duration-threshold.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/medium-duration-threshold.txt
new file mode 100644
index 00000000000..a199bee6a2f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/medium-duration-threshold.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass PerformanceObserver observes events according to its durationThreshold
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/min-duration-threshold.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/min-duration-threshold.txt
new file mode 100644
index 00000000000..805f2cb13ab
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/min-duration-threshold.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass PerformanceObserver with durationThreshold of 0 sees events of duration >= 16
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/mousedown.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mousedown.txt
new file mode 100644
index 00000000000..60a033338f5
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mousedown.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing mousedown.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseenter.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseenter.txt
new file mode 100644
index 00000000000..612dc3dc94c
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseenter.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing mouseenter.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseleave.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseleave.txt
new file mode 100644
index 00000000000..76e5ce989b4
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseleave.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing mouseleave.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseout.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseout.txt
new file mode 100644
index 00000000000..6237c7c391c
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseout.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing mouseout.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseover.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseover.txt
new file mode 100644
index 00000000000..08cc1bd9c7f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseover.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing mouseover.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseup.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseup.txt
new file mode 100644
index 00000000000..9959bf0268e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/mouseup.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing mouseup.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/only-observe-firstInput.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/only-observe-firstInput.txt
new file mode 100644
index 00000000000..65cda1d2366
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/only-observe-firstInput.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: check first-input for a PerformanceObserver observing only first-input.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/orphan-keydown.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/orphan-keydown.txt
new file mode 100644
index 00000000000..20038a458b1
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/orphan-keydown.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: Orphan keydown should be measured as an interaction.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerdown-pointerup-no-overlap.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerdown-pointerup-no-overlap.txt
new file mode 100644
index 00000000000..800a7480580
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerdown-pointerup-no-overlap.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass pointerdown and pointerup should not overlap when there is no pointerdown handler
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerdown.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerdown.txt
new file mode 100644
index 00000000000..033fddecdfa
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerdown.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing pointerdown.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerenter.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerenter.txt
new file mode 100644
index 00000000000..d2cc79c62ff
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerenter.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing pointerenter.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerleave.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerleave.txt
new file mode 100644
index 00000000000..fef2c098e7d
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerleave.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing pointerleave.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerout.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerout.txt
new file mode 100644
index 00000000000..8da593570d8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerout.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing pointerout.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerover.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerover.txt
new file mode 100644
index 00000000000..03c078473f8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerover.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing pointerover.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerup.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerup.txt
new file mode 100644
index 00000000000..af48429dc38
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/pointerup.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing pointerup.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/programmatic-click-not-observed.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/programmatic-click-not-observed.txt
new file mode 100644
index 00000000000..16840285f3e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/programmatic-click-not-observed.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: events from programmatic click are not observed
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/retrievability.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/retrievability.txt
new file mode 100644
index 00000000000..45cb8afadc0
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/retrievability.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: make sure event-timing entries are not retrievable by performance.getEntries*.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/retrieve-firstInput.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/retrieve-firstInput.txt
new file mode 100644
index 00000000000..fccd98dbabf
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/retrieve-firstInput.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: check first-input after onload, observer, click, click.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/shadow-dom-null-target.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/shadow-dom-null-target.txt
new file mode 100644
index 00000000000..3f4b63e21c8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/shadow-dom-null-target.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing: Move pointer within shadow DOM should create event-timing entry with null target.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/supported-types-consistent-with-self.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/supported-types-consistent-with-self.txt
new file mode 100644
index 00000000000..40161837dbb
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/supported-types-consistent-with-self.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass supportedEntryTypes should be consistent with `'PerformanceEventTiming' in Self`
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/supported-types.window.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/supported-types.window.txt
new file mode 100644
index 00000000000..bda7a9ab2a6
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/supported-types.window.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass supportedEntryTypes contains 'event' and 'first-input'.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/timingconditions.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/timingconditions.txt
new file mode 100644
index 00000000000..5dac20d6f97
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/timingconditions.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Event Timing only times certain types of trusted event.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/event-timing/toJSON.txt b/Tests/LibWeb/Text/expected/wpt-import/event-timing/toJSON.txt
new file mode 100644
index 00000000000..44f32a9f886
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/event-timing/toJSON.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Test toJSON() in PerformanceEventTiming.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/auxclick.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/auxclick.html
new file mode 100644
index 00000000000..f9c593834f7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/auxclick.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing auxclick.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target'>Click me</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'auxclick');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/buffered-and-duration-threshold.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/buffered-and-duration-threshold.html
new file mode 100644
index 00000000000..73537707bbe
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/buffered-and-duration-threshold.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: PerformanceObserver with buffered flag and durationThreshold</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='myDiv'>Click me</div>
+<script>
+promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ // Add a PerformanceObserver and observe with a durationThreshold of 30 and buffered flag.
+ return new Promise(async resolve1 => {
+ // Add a slow click event and make sure it's dispatched to observers.
+ await new Promise(async resolve2 => {
+ // Observer to await until event entry is dispatched.
+ new PerformanceObserver(() => {
+ resolve2();
+ }).observe({type: "event", durationThreshold: 16});
+ await clickAndBlockMain('myDiv', { duration: 30 });
+ });
+ const afterFirstClick = performance.now();
+ new PerformanceObserver(t.step_func(list => {
+ const pointerDowns = list.getEntriesByName('pointerdown');
+ pointerDowns.forEach(entry => {
+ if (entry.processingStart < afterFirstClick) {
+ // It is possible that the first event gets a slow duration and hence gets buffered.
+ // In this case the minDuration must be at least 104, otherwise it shouldn't have been
+ // buffered.
+ verifyClickEvent(entry, 'myDiv', true /* isFirst */);
+ } else {
+ verifyClickEvent(pointerDowns[0], 'myDiv', false /* isFirst */, 16 /* minDuration*/);
+ resolve1();
+ }
+ });
+ })).observe({type: 'event', durationThreshold: 16, buffered: true});
+ // This should be the only click observed since the other one would not be buffered.
+ await clickAndBlockMain('myDiv', { duration: 30 } );
+ });
+}, "PerformanceObserver buffering independent of durationThreshold");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/buffered-flag.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/buffered-flag.html
new file mode 100644
index 00000000000..7440c34f98e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/buffered-flag.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: PerformanceObserver sees entries with buffered flag</title>
+<button id='button'>Generate a 'click' event</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<script>
+ let firstInputSeen = false;
+ let eventSeen = false;
+ async_test(t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ const validateEntry = t.step_func(entry => {
+ if (entry.entryType === 'first-input')
+ firstInputSeen = true;
+ else if (entry.entryType === 'event')
+ eventSeen = true;
+ else
+ assert_unreached('Should only observe Event Timing entries!');
+ });
+ // First observer creates second in callback to ensure the entry has been dispatched by the time
+ // the second observer begins observing.
+ new PerformanceObserver((list, obs) => {
+ list.getEntries().forEach(validateEntry);
+ if (!firstInputSeen || !eventSeen)
+ return;
+
+ obs.disconnect();
+ firstInputSeen = false;
+ eventSeen = false;
+ // Second observer requires 'buffered: true' to see entries.
+ const bufferedObserver = new PerformanceObserver(entryList => {
+ entryList.getEntries().forEach(validateEntry);
+ if (firstInputSeen && eventSeen)
+ t.done();
+ });
+ bufferedObserver.observe({type: "event", buffered: true});
+ bufferedObserver.observe({type: 'first-input', buffered: true});
+ }).observe({entryTypes: ['event', 'first-input']});
+ clickAndBlockMain('button');
+ }, "PerformanceObserver with buffered flag sees previous Event Timing entries");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/click-timing.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/click-timing.html
new file mode 100644
index 00000000000..825cde2e9b3
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/click-timing.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: compare timing of two long clicks
+</title>
+<button id='button'>Generate a 'click' event</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<script>
+ /* Timeline:
+ Observer starts
+ Long click 1
+ Long click 2
+ Once two clicks have been received by observer, compare the timestamps.
+ */
+ let timeBeforeFirstClick;
+ let timeAfterFirstClick;
+ let timeAfterSecondClick;
+
+ function testExpectations(observedEntries) {
+ assert_not_equals(timeBeforeFirstClick, undefined);
+ assert_not_equals(timeAfterFirstClick, undefined);
+ assert_not_equals(timeAfterSecondClick, undefined);
+
+ // First click.
+ verifyClickEvent(observedEntries[0], 'button');
+ assert_between_exclusive(observedEntries[0].processingStart,
+ timeBeforeFirstClick,
+ timeAfterFirstClick,
+ "First click's processingStart");
+ assert_greater_than(timeAfterFirstClick, observedEntries[0].startTime,
+ "timeAfterFirstClick should be later than first click's start time.");
+
+ // Second click.
+ verifyClickEvent(observedEntries[1], 'button');
+ assert_between_exclusive(observedEntries[1].processingStart,
+ timeAfterFirstClick,
+ timeAfterSecondClick,
+ "Second click's processingStart");
+ assert_greater_than(timeAfterSecondClick, observedEntries[1].startTime,
+ "timeAfterSecondClick should be later than second click's start time.");
+ }
+
+ promise_test(async function(t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ const observerPromise = new Promise(resolve => {
+ const observedEntries = [];
+ new PerformanceObserver(entryList => {
+ observedEntries.push(...entryList.getEntriesByName("pointerdown"));
+ if (observedEntries.length < 2)
+ return;
+ resolve(observedEntries);
+ }).observe({type: 'event'});
+ })
+
+ timeBeforeFirstClick = performance.now();
+ mainThreadBusy(2);
+ await clickAndBlockMain('button');
+ timeAfterFirstClick = performance.now();
+ mainThreadBusy(2);
+ await clickAndBlockMain('button');
+ timeAfterSecondClick = performance.now();
+
+ const observedEntries = await observerPromise;
+ testExpectations(observedEntries);
+
+ }, "Event Timing: compare click timings.");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/click.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/click.html
new file mode 100644
index 00000000000..fcfc44e746e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/click.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing click.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target'>Click me</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'click');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/contextmenu.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/contextmenu.html
new file mode 100644
index 00000000000..49a7884aedf
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/contextmenu.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing contextmenu.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target' contextmenu="mymenu">Menu
+<menu type="context" id="mymenu">
+ <menuitem label="label"></menuitem>
+</menu>
+</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'contextmenu');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/crossiframe.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/crossiframe.html
new file mode 100644
index 00000000000..ab0523eb8bc
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/crossiframe.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta charset=utf-8 />
+ <title>Event Timing: entries should be observable by its own frame.</title>
+ <meta name="timeout" content="long">
+</head>
+
+<body>
+<button id='button'>Generate a 'click' event</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+
+<script src=resources/event-timing-test-utils.js></script>
+<iframe id='iframe' src=resources/crossiframe-childframe.html></iframe>
+<script>
+ let clickTimeMin;
+ let clickDone;
+
+ function validateEntries(entries) {
+ assert_equals(entries.length, 1, "Only 1 entry should be received");
+ const entry = entries[0];
+ verifyClickEvent(entry, 'button', true);
+
+ assert_less_than(entry.processingStart, clickDone,
+ "The entry's processing start should be before clickDone.");
+ assert_greater_than(entry.startTime, clickTimeMin,
+ "The entry's start time should be later than clickTimeMin.");
+ }
+
+ function validateChildFrameEntries(childFrameData) {
+ if (childFrameData === "failed") {
+ assert_unreached("Did not receive exactly one entry from child as expected");
+ }
+ // |childFrameData| has properties with the same names as its
+ // PerformanceEventTiming counterpart.
+ assert_equals(childFrameData.target, 'iframe_div');
+ verifyClickEvent(childFrameData, null, false, 104, 'mousedown');
+ assert_less_than(childFrameData.processingStart, childFrameData.clickDone,
+ "The entry's processing start should be before than the child frame's clickDone.");
+ }
+
+ promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, "Event Timing is not supported");
+
+ // Wait for load event so we can interact with the iframe.
+ await new Promise(resolve => {
+ window.addEventListener('load', resolve);
+ });
+
+ clickTimeMin = performance.now();
+ mainThreadBusy(2);
+
+ let observedPointerDown = false;
+ const observerPromise = new Promise(resolve => {
+ new PerformanceObserver(t.step_func(entries => {
+ const pointerDowns = entries.getEntriesByName('pointerdown');
+ // Ignore the callback if there were no pointerdown entries.
+ if (pointerDowns.length === 0)
+ return;
+
+ assert_false(observedPointerDown,
+ "Observer of main frames should only capture main-frame event-timing entries");
+ observedPointerDown = true;
+ resolve(pointerDowns);
+ })).observe({type: 'event'});
+ });
+
+ await clickAndBlockMain('button');
+ clickDone = performance.now();
+ const pointerDowns = await observerPromise;
+ validateEntries(pointerDowns);
+
+ const childFrameEntriesPromise = new Promise(resolve => {
+ window.addEventListener("message", (event) => {
+ t.step(() => {
+ validateChildFrameEntries(event.data);
+ });
+ resolve();
+ }, false);
+ });
+
+ // Tap on the iframe, with an offset of 10 to target the div inside it.
+ const actions = new test_driver.Actions()
+ .pointerMove(10, 10, { origin: document.getElementById("iframe") })
+ .pointerDown()
+ .pointerUp();
+ actions.send();
+
+ await childFrameEntriesPromise;
+ }, "Event Timing: entries should only be observable by its own frame.");
+
+</script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/dblclick.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/dblclick.html
new file mode 100644
index 00000000000..83abf0ae827
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/dblclick.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing dblclick.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div>Outside target!</div>
+<div id='target'>Click me</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'dblclick');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/disconnect-target.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/disconnect-target.html
new file mode 100644
index 00000000000..eed15e7119c
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/disconnect-target.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+
+<script src=resources/event-timing-test-utils.js></script>
+
+<button id='the_button'>ClickMe</button>
+
+<script>
+async_test(function(t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ const observer = new PerformanceObserver(t.step_func_done((entryList) => {
+ const entries = entryList.getEntries().filter(e => e.name === 'pointerdown');
+ if (entries.length === 0)
+ return;
+ // There must only be one click entry.
+ assert_equals(entries.length, 1);
+ const entry = entries[0];
+ // This checks that entry.target returns the correct button Node.
+ verifyClickEvent(entry, 'the_button', true);
+ const button = document.getElementById('the_button');
+ button.parentNode.removeChild(button);
+ // After removing the button, entry.target should now return null.
+ assert_equals(entry.target, null);
+ }));
+ observer.observe({entryTypes: ['event']});
+ clickAndBlockMain('the_button');
+}, "Event Timing: when target is disconnected, entry.target returns null.");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/duration-with-target-low.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/duration-with-target-low.html
new file mode 100644
index 00000000000..7f69ff4b0a7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/duration-with-target-low.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: PerformanceObserver with a durationThreshold way smaller than processingDelay</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='myDiv'>Click me</div>
+<script>
+promise_test(async t => {
+ return testDurationWithDurationThreshold(t, 'myDiv', numEntries=5, durThreshold=300, processingDelay=0);
+}, "PerformanceObserver with durationThreshold of 300 and processingDelay of 0 doesn't see any entries in the observer");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/event-click-counts.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/event-click-counts.html
new file mode 100644
index 00000000000..ca0ce3707e5
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/event-click-counts.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: eventCounts.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<div id='div'>Click me</div>
+<button id='button'>Click me</button>
+<script>
+ promise_test( t => {
+ assert_implements(window.EventCounts, "Event Counts isn't supported");
+ function testClicks(expectedCount, resolve) {
+ const clickCount = performance.eventCounts.get('click');
+ if (clickCount < expectedCount) {
+ t.step_timeout(function() {
+ testClicks(expectedCount, resolve);
+ }, 5);
+ return;
+ }
+ assert_equals(clickCount, expectedCount,'Incorrect click count.');
+ assert_equals(performance.eventCounts.get('mousedown'), expectedCount, 'Incorrect mousedown count');
+ assert_equals(performance.eventCounts.get('mouseup'), expectedCount, 'Incorrect mouseup count.');
+ resolve();
+ }
+ function promiseClicks(expectedCount) {
+ return new Promise(resolve => {
+ testClicks(expectedCount, resolve)
+ });
+ }
+
+ return test_driver.click(document.getElementById('div')).then(() => {
+ return promiseClicks(1);
+ }).then(() => {
+ return test_driver.click(document.getElementById('button'));
+ }).then(() => {
+ return promiseClicks(2);
+ }).then(() => {
+ return test_driver.click(document.getElementById('div'));
+ }).then(() => {
+ return promiseClicks(3);
+ });
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/event-counts-zero.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/event-counts-zero.html
new file mode 100644
index 00000000000..6cbd2c72e2b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/event-counts-zero.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: eventCounts.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script>
+ test(() => {
+ assert_implements(window.EventCounts, "Event Counts isn't supported");
+ const eventTypes = [
+ 'auxclick',
+ 'click',
+ 'contextmenu',
+ 'dblclick',
+ 'mousedown',
+ 'mouseenter',
+ 'mouseleave',
+ 'mouseout',
+ 'mouseover',
+ 'mouseup',
+ 'pointerover',
+ 'pointerenter',
+ 'pointerdown',
+ 'pointerup',
+ 'pointercancel',
+ 'pointerout',
+ 'pointerleave',
+ 'gotpointercapture',
+ 'lostpointercapture',
+ 'touchstart',
+ 'touchend',
+ 'touchcancel',
+ 'keydown',
+ 'keypress',
+ 'keyup',
+ 'beforeinput',
+ 'input',
+ 'compositionstart',
+ 'compositionupdate',
+ 'compositionend',
+ 'dragstart',
+ 'dragend',
+ 'dragenter',
+ 'dragleave',
+ 'dragover',
+ 'drop'
+ ];
+ eventTypes.forEach(type => {
+ assert_equals(performance.eventCounts.get(type), 0, 'There is a nonzero value for ' + type);
+ })
+ assert_equals(performance.eventCounts.size, eventTypes.length,
+ 'The size of performance.eventCounts is incorrect.');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/first-input-interactionid-click.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/first-input-interactionid-click.html
new file mode 100644
index 00000000000..b34ef6663f3
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/first-input-interactionid-click.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>First Input: interactionId-click.</title>
+<button id='testButtonId'>Click me</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+
+<script>
+ let firstInputInteractionId = 0;
+ let eventTimingPointerDownInteractionId = 0;
+ let hasFirstInputEntry = false;
+ let hasEventTimingPointerDownEntry = false;
+
+ promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ const callback = (entryList) => {
+ entryList.getEntries().forEach(entry => {
+ switch (entry.entryType) {
+ case 'first-input': {
+ firstInputInteractionId = entry.interactionId;
+ hasFirstInputEntry = true;
+ break;
+ }
+ case 'event': {
+ if ('pointerdown' == entry.name) {
+ eventTimingPointerDownInteractionId = entry.interactionId;
+ hasEventTimingPointerDownEntry = true;
+ }
+ break;
+ }
+ }
+ });
+ };
+ const readyToResolve = () => {
+ return hasFirstInputEntry && hasEventTimingPointerDownEntry;
+ }
+ const observerPromise = createPerformanceObserverPromise(['event', 'first-input'], callback, readyToResolve);
+ await interactAndObserve('click', document.getElementById('testButtonId'), observerPromise);
+
+ assert_greater_than(firstInputInteractionId, 0, 'The first input entry should have a non-trivial interactionId');
+ assert_equals(firstInputInteractionId, eventTimingPointerDownInteractionId, 'The first input entry should have the same interactionId as the event timing pointerdown entry');
+
+ }, "The interactionId of the first input entry should match the same pointerdown entry of event timing when click.");
+</script>
+
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/first-input-interactionid-key.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/first-input-interactionid-key.html
new file mode 100644
index 00000000000..f039d261f3d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/first-input-interactionid-key.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>First Input: interactionId-key.</title>
+<input id='input'>
+<textarea id='textarea'></textarea>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+
+<script>
+ const key = 'a'; // Arbitrary key picked for testing.
+ let firstInputInteractionId = 0;
+ let eventTimingKeyDownInteractionId = 0;
+ let hasFirstInputEntry = false;
+ let hasEventTimingKeyDownEntry = false;
+
+ promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ const callback = (entryList) => {
+ entryList.getEntries().forEach(entry => {
+ switch (entry.entryType) {
+ case 'first-input': {
+ firstInputInteractionId = entry.interactionId;
+ hasFirstInputEntry = true;
+ break;
+ }
+ case 'event': {
+ if ('keydown' == entry.name) {
+ eventTimingKeyDownInteractionId = entry.interactionId;
+ hasEventTimingKeyDownEntry = true;
+ }
+ break;
+ }
+ }
+ });
+ };
+ const readyToResolve = () => {
+ return hasFirstInputEntry && hasEventTimingKeyDownEntry;
+ }
+ const observerPromise = createPerformanceObserverPromise(['event', 'first-input'], callback, readyToResolve);
+ await interactAndObserve('key', document.getElementById('input'), observerPromise, key);
+
+ assert_greater_than(firstInputInteractionId, 0, 'The first input entry should have a non-trivial interactionId');
+ assert_equals(firstInputInteractionId, eventTimingKeyDownInteractionId, 'The first input entry should have the same interactionId as the event timing keydown entry');
+ assert_equals(firstInputInteractionId.target, eventTimingKeyDownInteractionId.target, 'The first input entry should have the same target as the event timing keydown entry');
+ assert_not_equals(firstInputInteractionId.target, null, 'The first input entry should have a non-null target');
+
+ }, "The interactionId of the first input entry should match the same keydown entry of event timing when press a key.");
+</script>
+
+</html>
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/gap-pointerdown-pointerup.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/gap-pointerdown-pointerup.html
new file mode 100644
index 00000000000..a876a3a9212
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/gap-pointerdown-pointerup.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: pointerdown/up gap.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target'>Click me</div>
+<script>
+ promise_test(async t => {
+ const pointerDowns = []
+ const pointerUps = []
+ blockNextEventListener(window, 'pointerdown', 30)
+ blockNextEventListener(window, 'pointerup', 30)
+
+ // A keydown is used as an interleaving event, to make sure the pointerdown's
+ // timing entry had it's duration set before triggering the pointerup. Using
+ // only `await afterNextPaint()` after the first event is not enough to
+ // guarantee this in all browsers. See discussion in
+ // https://github.com/web-platform-tests/wpt/pull/55577#discussion_r2466579023
+ blockNextEventListener(window, 'keydown', 30)
+ const {promise: interleavingEventTimingEntryObserved, resolve: resolveInterleaving } = Promise.withResolvers();
+ new PerformanceObserver( (entries) => {
+ entries.getEntries().forEach( (e) => {
+ if (e.name == 'pointerdown')
+ pointerDowns.push(e)
+ if (e.name =='pointerup')
+ pointerUps.push(e)
+ if (e.name == 'keydown')
+ resolveInterleaving()
+ })
+ }).observe({type: 'event', durationThreshold: 16})
+ const pointerDownHandled = new Promise( resolve => window.addEventListener('pointerdown', e => resolve(), true) )
+ const pointerUpHandled = new Promise( resolve => window.addEventListener('pointerup', e => resolve(), true) )
+
+ await new test_driver.Actions()
+ .pointerMove(0, 0)
+ .pointerDown()
+ .send()
+ await pointerDownHandled
+ await afterNextPaint()
+ await new test_driver.Actions()
+ .keyDown('k')
+ .keyUp('k')
+ .send()
+ await interleavingEventTimingEntryObserved
+ const waitStart = performance.now()
+ await t.step_wait(() => (performance.now() - waitStart > 50))
+ await new test_driver.Actions()
+ .pointerUp()
+ .send()
+ await pointerUpHandled
+ await t.step_wait(() => (pointerDowns.length != 0 && pointerUps.length != 0), 'Wait for the event timing entries to be processed.')
+ assert_equals(pointerDowns.length, 1)
+ assert_equals(pointerUps.length, 1)
+ assert_greater_than(pointerUps[0].startTime, pointerDowns[0].startTime + pointerDowns[0].duration)
+ }, "pointerdown duration shouldn't wait for pointerup.")
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/interaction-count-click.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/interaction-count-click.html
new file mode 100644
index 00000000000..40a89523157
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/interaction-count-click.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: interactionCount-click</title>
+<div id='div'>Click me</div>
+<button id='button'>Click me</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<script>
+ interactionCount_test('click', [div, button, div]);
+</script>
+
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/interaction-count-press-key.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/interaction-count-press-key.html
new file mode 100644
index 00000000000..6db5c476664
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/interaction-count-press-key.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: interactionCount-press-key</title>
+<input id='input'>
+<textarea id='textarea'></textarea>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<script>
+ interactionCount_test('key', [input, textarea, input], 'h');
+</script>
+
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-aux-pointerdown-and-pointerdown.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-aux-pointerdown-and-pointerdown.html
new file mode 100644
index 00000000000..127eaa18bda
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-aux-pointerdown-and-pointerdown.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: interactionId-aux-pointerdown-and-pointerdown</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target'>Right click me to bring up OS level contextmenu popup.</div>
+
+<script>
+ let platformSupported = false;
+ const map = new Map();
+ const events = ['pointerdown'];
+
+ // This test replicates a real world scenario that - on triggering contextmenu
+ // with a pointer, pointerdown is captured but not pointerup. (crbug/1413096)
+ // In this case, we need to make sure event timing will correctly report the
+ // pointerdown entry with a valid/non-trivial interactionId.
+ promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ // Workaround https://bugs.webkit.org/show_bug.cgi?id=213060, which causes
+ // WebKit-based browsers to never release the pointerdown, breaking
+ // subsequent tests.
+ t.add_cleanup(() => orphanAuxPointerup(document.getElementById('target')).catch(() => {}));
+ // This test is not applicable to platforms like Windows where contextmenu
+ // is triggered on aux pointerup. So we do a platform behavior test first to
+ // distinguish and skip those platforms who do not dispatch contextmenu on
+ // aux pointerdown.
+ document.getElementById('target').addEventListener('contextmenu', () => { platformSupported = true; });
+ await auxPointerdown(document.getElementById('target'));
+ // 2000ms is a magic number picked to wait for contextmenu being observed
+ // from the performance observer. Consider enlarge it if flaky.
+ await t.step_timeout(() => { }, 2000);
+ if (!platformSupported) {
+ return;
+ }
+
+ // Perform test on qualified platforms
+ const callback = (entryList) => { entryList.getEntries().filter(filterAndAddToMap(events, map)); };
+ const readyToResolve = () => { return map.has('pointerdown'); };
+ const observerPromise = createPerformanceObserverPromise(['event'], callback, readyToResolve);
+
+ await interactAndObserve('aux-pointerdown-and-pointerdown', document.getElementById('target'), observerPromise);
+
+ assert_greater_than(map.get('pointerdown'), 0, 'The pointerdown entry should have a non-trivial interactionId');
+ }, "Event Timing: verify pointerdown reporting for mouse aux pointerdown only triggered contextmenu followed immediately by another pointerdown event.");
+
+</script>
+
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-aux-pointerdown.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-aux-pointerdown.html
new file mode 100644
index 00000000000..3f3e8a217c0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-aux-pointerdown.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: interactionId-aux-pointerdown</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target'>Right click me to bring up OS level contextmenu popup.</div>
+
+<script>
+ let platformSupported = false;
+ const map = new Map();
+ const events = ['pointerdown'];
+
+ // This test replicates a real world scenario that - on triggering contextmenu
+ // with a pointer, pointerdown is captured but not pointerup. (crbug/1413096)
+ // In this case, we need to make sure event timing will correctly report the
+ // pointerdown entry with a valid/non-trivial interactionId.
+ promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ // Workaround https://bugs.webkit.org/show_bug.cgi?id=213060, which causes
+ // WebKit-based browsers to never release the pointerdown, breaking
+ // subsequent tests.
+ t.add_cleanup(() => orphanAuxPointerup(document.getElementById('target')).catch(() => {}));
+ // This test is not applicable to platforms like Windows where contextmenu
+ // is triggered on aux pointerup. So we do a platform behavior test first to
+ // distinguish and skip those platforms who do not dispatch contextmenu on
+ // aux pointerdown.
+ document.getElementById('target').addEventListener('contextmenu', () => { platformSupported = true; });
+ await auxPointerdown(document.getElementById('target'));
+ // 2000ms is a magic number picked to wait for contextmenu being observed
+ // from the performance observer. Consider enlarge it if flaky.
+ await t.step_timeout(() => { }, 2000);
+ if (!platformSupported) {
+ return;
+ }
+
+ // Perform test on qualified platforms
+ const callback = (entryList) => { entryList.getEntries().filter(filterAndAddToMap(events, map)); };
+ const readyToResolve = () => { return map.has('pointerdown'); };
+ const observerPromise = createPerformanceObserverPromise(['event'], callback, readyToResolve);
+
+ await interactAndObserve('aux-pointerdown', document.getElementById('target'), observerPromise);
+
+ assert_greater_than(map.get('pointerdown'), 0, 'The pointerdown entry should have a non-trivial interactionId');
+ }, "Event Timing: verify pointerdown reporting for mouse aux pointerdown only triggered contextmenu.");
+
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-click.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-click.html
new file mode 100644
index 00000000000..9193b63c77a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-click.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: interactionId-click.</title>
+<button id='button'>Click me.</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<script>
+ let observedEntries = [];
+ let map = new Map();
+
+ function eventsForCheck(entry) {
+ if (entry.name === 'pointerdown' || entry.name === 'pointerup' || entry.name === 'click'
+ || entry.name === 'mousedown' || entry.name === 'mouseup') {
+ map.set(entry.name, entry.interactionId);
+ return true;
+ }
+ return false;
+ }
+ async_test(function(t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ addListenersAndClick(document.getElementById('button')).then(() => {
+ new PerformanceObserver(t.step_func(entryList => {
+ observedEntries = observedEntries.concat(entryList.getEntries().filter(eventsForCheck));
+ if (observedEntries.length < 5)
+ return;
+ assert_equals(map.get('mousedown'), 0, 'Should not have a interactionId');
+ assert_equals(map.get('mouseup'), 0, 'Should not have a interactionId');
+ assert_greater_than(map.get('pointerdown'), 0, 'Should have a non-trivial interactionId');
+ assert_equals(map.get('pointerdown'), map.get('pointerup'), 'Pointerdown and pointerup should have the same interactionId');
+ assert_equals(map.get('pointerdown'), map.get('click'), 'Pointerdown and click should have the same interactionId');
+ t.done();
+ })).observe({ type: 'event', buffered: true });
+ });
+
+ }, "Event Timing: compare event timing interactionId.");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-label-click.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-label-click.html
new file mode 100644
index 00000000000..5772164734c
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-label-click.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<meta charset=utf-8 />
+<title>Event Timing: Test interactionId for clicks forwarded to form controls</title>
+
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+
+<label id="label" for="control">Click me</label>
+<select id="control"></select>
+
+<script>
+ promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ const entriesPromise = new Promise(resolve => {
+ let clickEntries = [];
+ let observer = new PerformanceObserver(entryList => {
+ clickEntries = clickEntries.concat(
+ entryList.getEntries().filter(entry => entry.name == 'click'));
+ if (clickEntries.length == 2) {
+ observer.disconnect();
+ resolve(clickEntries);
+ }
+ });
+ observer.observe({type: 'event', buffered: true});
+ });
+
+ addListeners(label, ['click']);
+ addListeners(control, ['click']);
+
+ await click(label);
+ let entries = await entriesPromise;
+
+ controlEntry = entries[0].target.id === 'control' ? entries[0] : entries[1];
+ labelEntry = entries[0].target.id === 'label' ? entries[0] : entries[1];
+
+ assert_equals(
+ labelEntry.target.id, 'label', 'Expected an entry for the label');
+ assert_greater_than(
+ labelEntry.interactionId, 0,
+ 'Expected interactionId for "label" to be non-zero');
+ assert_equals(
+ controlEntry.target.id, 'control', 'Expected an entry for the control');
+ assert_equals(
+ controlEntry.interactionId, 0,
+ 'Expected interactionId for "control" to be zero');
+ }, 'Event Timing: interactionId for clicks forwarded form controls is zero.');
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-orphan-pointerup.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-orphan-pointerup.html
new file mode 100644
index 00000000000..8342f378086
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-orphan-pointerup.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: interactionId-orphan-pointerup.</title>
+<button id='testButtonId'>Orphan Pointerup</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+
+<script>
+ let observedEntries = [];
+ const map = new Map();
+ // keydown is being sent right after a pointerup to see if pointerup is present.
+ const events = ['pointerup', 'keydown'];
+
+ promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ const callback = (entryList) => { observedEntries = observedEntries.concat(entryList.getEntries().filter(filterAndAddToMap(events, map))); };
+ const readyToResolve = () => { return observedEntries.length >= 1; };
+ const observerPromise = createPerformanceObserverPromise(['event'], callback, readyToResolve);
+
+ await interactAndObserve('orphan-pointerup', document.getElementById('testButtonId'), observerPromise);
+
+ // This test passes when either:
+ // - There is no orphan pointerup triggered by the browser.
+ // - The orphan pointerup doesn't have an interactionId.
+ assert_true(!map.has('pointerup') || map.get('pointerup') === 0, 'Should either have no triggered orphan pointerup event or have a trivial interactionId for orphan pointerup event.');
+ }, "Event Timing: Orphan pointerup should not be measured as an interaction.");
+
+</script>
+
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-press-key-as-input.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-press-key-as-input.html
new file mode 100644
index 00000000000..e35288a083a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-press-key-as-input.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<meta name="timeout" content="long">
+<title>Event Timing: interactionId-press-key-as-input.</title>
+<textarea id='test'></textarea>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+
+<script>
+ let observedEntries = [];
+ let map = new Map();
+ const events = ['keydown', 'keyup'];
+
+ async_test(function (t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ new PerformanceObserver(t.step_func(entryList => {
+ observedEntries = observedEntries.concat(entryList.getEntries().filter(filterAndAddToMap(events, map)));
+
+ if (observedEntries.length < 2)
+ return;
+
+ events.forEach(e => assert_greater_than(map.get(e), 0, 'Should have a non-trivial interactionId for ' + e + ' event'));
+ assert_equals(map.get('keydown'), map.get('keyup'), 'The keydown and the keyup should have the same interactionId');
+ assert_equals('t', document.getElementById('test').value);
+ t.done();
+ })).observe({ type: "event" });
+
+ addListenersAndPress(document.getElementById('test'), 't', events);
+ }, "Event Timing: compare event timing interactionId for key press as input.");
+</script>
+
+</html>
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-press-key-no-effect.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-press-key-no-effect.html
new file mode 100644
index 00000000000..ae582daaec4
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/interactionid-press-key-no-effect.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<meta name="timeout" content="long">
+<title>Event Timing: interactionId-press-key-no-effect.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+
+<body>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tempus
+ lacinia nisi, eget tempor orci. Nullam congue pharetra arcu, et consectetur
+ massa mollis tincidunt. Quisque odio sapien, viverra finibus lectus ac,
+ consectetur ornare quam. In hac habitasse platea dictumst. Morbi cursus est
+ odio, non fermentum ligula posuere vitae. Sed ullamcorper convallis rhoncus.
+ In condimentum neque nec metus hendrerit, et cursus ipsum aliquet.
+ </p>
+</body>
+<script>
+ let observedEntries = [];
+ let map = new Map();
+ const events = ['keydown', 'keyup'];
+
+ async_test(function (t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ new PerformanceObserver(t.step_func(entryList => {
+ observedEntries = observedEntries.concat(entryList.getEntries().filter(filterAndAddToMap(events, map)));
+
+ if (observedEntries.length < 2)
+ return;
+
+ events.forEach(e => assert_greater_than(map.get(e), 0, 'Should have a non-trivial interactionId for ' + e + ' event'));
+ assert_equals(map.get('keydown'), map.get('keyup'), 'The keydown and the keyup should have the same interactionId');
+ t.done();
+ })).observe({ type: "event" });
+
+ addListenersAndPress(document.body, 't', events);
+ }, "Event Timing: compare event timing interactionId for key press with no effect.");
+</script>
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/keydown.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/keydown.html
new file mode 100644
index 00000000000..39690e76797
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/keydown.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing Keydown.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<input type='text' id='target'>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'keydown');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/keyup.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/keyup.html
new file mode 100644
index 00000000000..ac2438d3438
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/keyup.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing Keyup.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<input type='text' id='target'>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'keyup');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/large-duration-threshold.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/large-duration-threshold.html
new file mode 100644
index 00000000000..64fee440b44
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/large-duration-threshold.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: PerformanceObserver with a durationThreshold of 125</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='myDiv'>Click me</div>
+<script>
+promise_test(async t => {
+ return testDuration(t, 'myDiv', numEntries=2, dur=125, slowDur=140);
+}, "PerformanceObserver observes events according to its durationThreshold");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/medium-duration-threshold.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/medium-duration-threshold.html
new file mode 100644
index 00000000000..96275efa35b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/medium-duration-threshold.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: PerformanceObserver with a durationThreshold of 50</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='myDiv'>Click me</div>
+<script>
+promise_test(async t => {
+ return testDuration(t, 'myDiv', numEntries=3, dur=50, slowDur=70);
+}, "PerformanceObserver observes events according to its durationThreshold");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/min-duration-threshold.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/min-duration-threshold.html
new file mode 100644
index 00000000000..b70d6857fe1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/min-duration-threshold.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: PerformanceObserver with a durationThreshold less than 16</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='myDiv'>Click me</div>
+<script>
+promise_test(async t => {
+ return testDuration(t, 'myDiv', numEntries=5, dur=0, slowDur=20);
+}, "PerformanceObserver with durationThreshold of 0 sees events of duration >= 16");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/mousedown.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/mousedown.html
new file mode 100644
index 00000000000..d5aa84e6407
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/mousedown.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<meta name="timeout" content="long">
+<title>Event Timing mousedown.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target'>Click me</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'mousedown');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseenter.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseenter.html
new file mode 100644
index 00000000000..1723677ee4d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseenter.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing mouseenter.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div>Outside target!</div>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ // PointerMove also creates mouseenter events on the body
+ return testEventType(t, 'mouseenter', true);
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseleave.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseleave.html
new file mode 100644
index 00000000000..9889c42f5db
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseleave.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing mouseleave.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div>Outside target!</div>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ // Loose event because a mouseleave from html -> body also occurs
+ return testEventType(t, 'mouseleave', true);
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseout.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseout.html
new file mode 100644
index 00000000000..ba92a30cf33
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseout.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing mouseout.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div>Outside target!</div>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'mouseout', true /* looseCount */);
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseover.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseover.html
new file mode 100644
index 00000000000..4edd66e3da2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseover.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing mouseover.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div>Outside target!</div>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'mouseover', true /* looseCount */);
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseup.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseup.html
new file mode 100644
index 00000000000..55a380a64f2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/mouseup.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing mouseup.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'mouseup');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/only-observe-firstInput.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/only-observe-firstInput.html
new file mode 100644
index 00000000000..b5c2bc1d082
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/only-observe-firstInput.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: only observe the first input</title>
+<button id='button'>Generate a 'click' event</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+
+<script src=resources/event-timing-test-utils.js></script>
+
+<script>
+ /* Test:
+ PerformanceObserver for first-input is registered
+ Click 1
+ Click 2
+ Wait
+ Expected result:
+ PerformanceObserver should observe one and only one entry.
+ */
+ async_test(function(t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ let hasObservedFirstInput = false;
+ new PerformanceObserver(t.step_func((entryList) => {
+ assert_false(hasObservedFirstInput);
+ hasObservedFirstInput = true;
+ const observedEntries = entryList.getEntries().filter(
+ entry => entry.name === 'pointerdown');
+ assert_equals(observedEntries.length, 1);
+ assert_equals(observedEntries[0].entryType, 'first-input');
+ assert_equals(observedEntries[0].name, 'pointerdown');
+ })).observe({ entryTypes: ['first-input'] });
+ on_event(window, 'load', () => {
+ clickAndBlockMain('button').then(() => {
+ clickAndBlockMain('button').then(wait).then( () => {
+ // After some wait, the PerformanceObserver should have processed both clicks.
+ // One and only one first-input entry should have been dispatched, so
+ // |hasObservedFirstInput| should be true.
+ t.step_timeout( () => {
+ assert_true(hasObservedFirstInput);
+ t.done();
+ }, 10);
+ });
+ });
+ });
+ },
+ "Event Timing: check first-input for a PerformanceObserver observing only first-input."
+ );
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/orphan-keydown.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/orphan-keydown.html
new file mode 100644
index 00000000000..8b36c673640
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/orphan-keydown.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: orphan keydown.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+
+<body>
+ <button id='target'>Click me</button>
+
+ <script>
+ let observedEntries = [];
+ const map = new Map();
+ const events = ['keydown'];
+
+ promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ const callback = (entryList) => {observedEntries = observedEntries.concat(entryList.getEntries().filter(filterAndAddToMap(events, map))); };
+ const readyToResolve = () => { return observedEntries.length >= 1; };
+ const observerPromise = createPerformanceObserverPromise(['event'], callback, readyToResolve);
+
+ await interactAndObserve('orphan-keydown', document.getElementById('target'), observerPromise);
+
+ assert_equals(observedEntries.length, 1, "Keydown without a keyup should be fired properly.");
+ assert_greater_than(map.get('keydown'), 0, "Should have a non-trivial interactionId.")
+ }, "Event Timing: Orphan keydown should be measured as an interaction.");
+ </script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerdown-pointerup-no-overlap.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerdown-pointerup-no-overlap.html
new file mode 100644
index 00000000000..bb7ff012f2b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerdown-pointerup-no-overlap.html
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: pointerdown and pointerup should not overlap when there is a paint in between</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<button id='button'>Click me.</button>
+<script>
+ promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ const button = document.getElementById('button');
+ const observedEntries = [];
+
+ button.addEventListener('pointerdown', () => {
+ mainThreadBusy(30);
+ });
+ button.addEventListener('pointerup', () => {
+ mainThreadBusy(30);
+ });
+ button.addEventListener('click', () => {
+ mainThreadBusy(150);
+ });
+
+ const observerPromise = new Promise(resolve => {
+ new PerformanceObserver(entryList => {
+ observedEntries.push(...entryList.getEntries().filter(entry =>
+ entry.name === 'pointerdown' || entry.name === 'pointerup' || entry.name === 'click'
+ ));
+
+ // We expect pointerdown, pointerup, and click.
+ if (observedEntries.length >= 3) {
+ resolve();
+ }
+ }).observe({type: 'event', durationThreshold: 16, buffered: true});
+ });
+
+ const actions1 = new test_driver.Actions();
+ await actions1
+ .addPointer("testPointer", "mouse")
+ .pointerMove(0, 0, {origin: button})
+ .pointerDown({button: actions1.ButtonType.LEFT})
+ .pause(50)
+ .send();
+
+ // Wait for a paint to occur
+ await afterNextPaint();
+
+ // Perform pointerup
+ const actions2 = new test_driver.Actions();
+ await actions2
+ .addPointer("testPointer", "mouse")
+ .pointerMove(0, 0, {origin: button})
+ .pointerUp({button: actions2.ButtonType.LEFT})
+ .send();
+
+ await observerPromise;
+
+ const pointerdownEntry = observedEntries.find(e => e.name === 'pointerdown');
+ const pointerupEntry = observedEntries.find(e => e.name === 'pointerup');
+ const clickEntry = observedEntries.find(e => e.name === 'click');
+
+ assert_true(!!pointerdownEntry, 'Should have pointerdown entry');
+ assert_true(!!pointerupEntry, 'Should have pointerup entry');
+ assert_true(!!clickEntry, 'Should have click entry');
+
+ // Calculate end times: startTime + duration.
+ const pointerdownEndTime = pointerdownEntry.startTime + pointerdownEntry.duration;
+ const pointerupStartTime = pointerupEntry.startTime;
+
+ // pointerdown should complete BEFORE pointerup starts.
+ assert_less_than_equal(pointerdownEndTime, pointerupStartTime,
+ 'pointerdown should end before or when pointerup starts (no overlap)');
+ }, 'pointerdown and pointerup should not overlap when there is no pointerdown handler');
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerdown.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerdown.html
new file mode 100644
index 00000000000..2ddad0e3280
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerdown.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<meta name="timeout" content="long">
+<title>Event Timing pointerdown.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'pointerdown');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerenter.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerenter.html
new file mode 100644
index 00000000000..a97b9551655
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerenter.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing pointerenter.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div>Outside target!</div>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ // A looseCount because the first move of pointerenter causes a
+ // `pointerenter` on body
+ return testEventType(t, 'pointerenter', true);
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerleave.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerleave.html
new file mode 100644
index 00000000000..7deb7c1baa2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerleave.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing pointerleave.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div>Outside target!</div>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ // Loose event because a pointerleave from html -> body also occurs
+ return testEventType(t, 'pointerleave', true);
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerout.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerout.html
new file mode 100644
index 00000000000..deeb59c4c2b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerout.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing pointerout.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div>Outside target!</div>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'pointerout', true /* looseCount */);
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerover.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerover.html
new file mode 100644
index 00000000000..025d4d6b73b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerover.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing pointerover.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div>Outside target!</div>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'pointerover', true /* looseCount */);
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerup.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerup.html
new file mode 100644
index 00000000000..fbf9af2992c
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/pointerup.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing pointerup.</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<div id='target'>Target</div>
+<script>
+ promise_test(async t => {
+ return testEventType(t, 'pointerup');
+ })
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/programmatic-click-not-observed.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/programmatic-click-not-observed.html
new file mode 100644
index 00000000000..f89cbbceada
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/programmatic-click-not-observed.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<div id='div' onclick='delay()'>Click me</div>
+<div id='div2'>No, click me!</div>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+
+<script src=resources/event-timing-test-utils.js></script>
+<script>
+ let delayCalled = false;
+ let beforeClick;
+ function delay() {
+ const end = performance.now() + 150;
+ while(performance.now() < end) {}
+ delayCalled = true;
+ }
+ promise_test(function(t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ let observedPointerDown = false;
+ const observerPromise = new Promise(resolve => {
+ const observer = new PerformanceObserver(t.step_func(entryList => {
+ const pointerDowns = entryList.getEntriesByName('pointerdown');
+ // Ignore cases in which there is no pointerdown.
+ if (pointerDowns.length === 0)
+ return;
+
+ assert_false(observedPointerDown, 'There must only be one pointerdown entry.');
+ assert_equals(pointerDowns.length, 1);
+ const entry = pointerDowns[0];
+ // This ensures that the entry is exposing timing from the second click, i.e.
+ // the one from the clickAndBlockMain() call.
+ assert_greater_than_equal(entry.processingStart, beforeClick);
+ verifyClickEvent(entry, 'div2', true);
+ observedPointerDown = true;
+ resolve();
+ }));
+ observer.observe({entryTypes: ['event']});
+ });
+ document.getElementById('div').click();
+ // Take the timestamp after the programmatic click but before the next click.
+ beforeClick = performance.now();
+ // After the programmatic click, use another input to know when entries have been
+ // dispatched to the PerformanceObserver callback.
+ const clickPromise = clickAndBlockMain('div2');
+ return Promise.all([observerPromise, clickPromise]);
+ }, "Event Timing: events from programmatic click are not observed");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/resources/crossiframe-childframe.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/resources/crossiframe-childframe.html
new file mode 100644
index 00000000000..6a8bc6b6424
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/resources/crossiframe-childframe.html
@@ -0,0 +1,39 @@
+<!DOCType html>
+<html>
+<body>
+<script src=event-timing-test-utils.js></script>
+<div style="width: 300px; height: 300px" id='iframe_div' onmousedown="mainThreadBusy(120)">
+<script>
+(async () => {
+ const observerPromise = new Promise(resolve => {
+ new PerformanceObserver(entryList => {
+ const mouseDowns = entryList.getEntriesByName('mousedown');
+ if (mouseDowns.length === 0)
+ return;
+ resolve(mouseDowns);
+ }).observe({ type:'event' });
+ });
+ const entries = await observerPromise;
+ const clickDone = performance.now();
+ if (entries.length !== 1) {
+ top.postMessage("failed", "*");
+ return;
+ }
+ const entry = entries[0];
+ top.postMessage({
+ // Entry values (|entry| itself is not clonable)
+ "name": entry.name,
+ "cancelable": entry.cancelable,
+ "entryType": entry.entryType,
+ "startTime": entry.startTime,
+ "processingStart": entry.processingStart,
+ "processingEnd": entry.processingEnd,
+ "duration": entry.duration,
+ // Other values
+ "clickDone" : clickDone,
+ "target": entry.target.id,
+ }, '*');
+}) ();
+</script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/resources/event-timing-test-utils.js b/Tests/LibWeb/Text/input/wpt-import/event-timing/resources/event-timing-test-utils.js
new file mode 100644
index 00000000000..0174d81f32c
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/resources/event-timing-test-utils.js
@@ -0,0 +1,631 @@
+function mainThreadBusy(ms) {
+ // Add 2ms to ensure we block for *at least* the requested amount of time,
+ // even in the face of two forms of timer imprecision:
+ //
+ // (1) Firefox rounds performance.now() to 1ms for privacy protection against
+ // timing attacks (e.g., Spectre), which can cause the loop to exit up to 1ms
+ // early when timestamps round unfavorably.
+ // (2) Firefox also introduces "jitter" randomness to web-exposed timestamps,
+ // an anti-fingerprinting protection that may make performance.now() lie by
+ // up to 1ms (while still increasing monotonically).
+ const target = performance.now() + ms + 2;
+ while (performance.now() < target);
+}
+
+async function wait() {
+ return new Promise(resolve => step_timeout(resolve, 0));
+}
+
+async function raf() {
+ return new Promise(resolve => requestAnimationFrame(resolve));
+}
+
+async function afterNextPaint() {
+ await raf();
+ await wait();
+}
+
+async function blockNextEventListener(target, eventType, duration = 120) {
+ return new Promise(resolve => {
+ target.addEventListener(eventType, () => {
+ mainThreadBusy(duration);
+ resolve();
+ }, { once: true });
+ });
+}
+
+async function clickAndBlockMain(id, options = {}) {
+ options = {
+ eventType: "pointerdown",
+ duration: 120,
+ ...options
+ };
+ const element = document.getElementById(id);
+
+ await Promise.all([
+ blockNextEventListener(element, options.eventType, options.duration),
+ click(element),
+ ]);
+}
+
+
+// This method should receive an entry of type 'event'. |isFirst| is true only when we want
+// to check that the event also happens to correspond to the first event. In this case, the
+// timings of the 'first-input' entry should be equal to those of this entry. |minDuration|
+// is used to compared against entry.duration.
+function verifyEvent(entry, eventType, targetId, isFirst=false, minDuration=104, notCancelable=false) {
+ assert_equals(entry.cancelable, !notCancelable, 'cancelable property');
+ assert_equals(entry.name, eventType);
+ assert_equals(entry.entryType, 'event');
+ assert_greater_than_equal(entry.duration, minDuration,
+ "The entry's duration should be greater than or equal to " + minDuration + " ms.");
+ assert_greater_than_equal(entry.processingStart, entry.startTime,
+ "The entry's processingStart should be greater than or equal to startTime.");
+ assert_greater_than_equal(entry.processingEnd, entry.processingStart,
+ "The entry's processingEnd must be at least as large as processingStart.");
+ // |duration| is a number rounded to the nearest 8 ms, so add 4 to get a lower bound
+ // on the actual duration.
+ assert_greater_than_equal(entry.duration + 4, entry.processingEnd - entry.startTime,
+ "The entry's duration must be at least as large as processingEnd - startTime.");
+ if (isFirst) {
+ let firstInputs = performance.getEntriesByType('first-input');
+ assert_equals(firstInputs.length, 1, 'There should be a single first-input entry');
+ let firstInput = firstInputs[0];
+ assert_equals(firstInput.name, entry.name);
+ assert_equals(firstInput.entryType, 'first-input');
+ assert_equals(firstInput.startTime, entry.startTime);
+ assert_equals(firstInput.duration, entry.duration);
+ assert_equals(firstInput.processingStart, entry.processingStart);
+ assert_equals(firstInput.processingEnd, entry.processingEnd);
+ assert_equals(firstInput.cancelable, entry.cancelable);
+ }
+ if (targetId) {
+ const target = document.getElementById(targetId);
+ assert_equals(entry.target, target);
+ }
+}
+
+function verifyClickEvent(entry, targetId, isFirst=false, minDuration=104, event='pointerdown') {
+ verifyEvent(entry, event, targetId, isFirst, minDuration);
+}
+
+
+ // Add a PerformanceObserver and observe with a durationThreshold of |dur|. This test will
+ // attempt to check that the duration is appropriately checked by:
+ // * Asserting that entries received have a duration which is the smallest multiple of 8
+ // that is greater than or equal to |dur|.
+ // * Issuing |numEntries| entries that has duration greater than |slowDur|.
+ // * Asserting that exactly |numEntries| entries are received.
+ // Parameters:
+ // |t| - the test harness.
+ // |dur| - the durationThreshold for the PerformanceObserver.
+ // |id| - the ID of the element to be clicked.
+ // |numEntries| - the number of entries.
+ // |slowDur| - the min duration of a slow entry.
+async function testDuration(t, id, numEntries, dur, slowDur) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ const observerPromise = new Promise(async resolve => {
+ let minDuration = Math.ceil(dur / 8) * 8;
+ // Exposed events must always have a minimum duration of 16.
+ minDuration = Math.max(minDuration, 16);
+ let numEntriesReceived = 0;
+ new PerformanceObserver(list => {
+ const pointerDowns = list.getEntriesByName('pointerdown');
+ pointerDowns.forEach(e => {
+ t.step(() => {
+ verifyClickEvent(e, id, false /* isFirst */, minDuration);
+ });
+ });
+ numEntriesReceived += pointerDowns.length;
+ // All the entries should be received since the slowDur is higher
+ // than the duration threshold.
+ if (numEntriesReceived === numEntries)
+ resolve();
+ }).observe({type: "event", durationThreshold: dur});
+ });
+ const clicksPromise = new Promise(async resolve => {
+ for (let index = 0; index < numEntries; index++) {
+ // Add some click events that has at least slowDur for duration.
+ await clickAndBlockMain(id, { duration: slowDur });
+ }
+ resolve();
+ });
+ return Promise.all([observerPromise, clicksPromise]);
+}
+
+ // Add a PerformanceObserver and observe with a durationThreshold of |durThreshold|. This test will
+ // attempt to check that the duration is appropriately checked by:
+ // * Asserting that entries received have a duration which is the smallest multiple of 8
+ // that is greater than or equal to |durThreshold|.
+ // * Issuing |numEntries| entries that have at least |processingDelay| as duration.
+ // * Asserting that the entries we receive has duration greater than or equals to the
+ // duration threshold we setup
+ // Parameters:
+ // |t| - the test harness.
+ // |id| - the ID of the element to be clicked.
+ // |durThreshold| - the durationThreshold for the PerformanceObserver.
+ // |numEntries| - the number of slow and number of fast entries.
+ // |processingDelay| - the event duration we add on each event.
+ async function testDurationWithDurationThreshold(t, id, numEntries, durThreshold, processingDelay) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ const observerPromise = new Promise(async resolve => {
+ let minDuration = Math.ceil(durThreshold / 8) * 8;
+ // Exposed events must always have a minimum duration of 16.
+ minDuration = Math.max(minDuration, 16);
+ new PerformanceObserver(t.step_func(list => {
+ const pointerDowns = list.getEntriesByName('pointerdown');
+ pointerDowns.forEach(p => {
+ assert_greater_than_equal(p.duration, minDuration,
+ "The entry's duration should be greater than or equal to " + minDuration + " ms.");
+ });
+ resolve();
+ })).observe({type: "event", durationThreshold: durThreshold});
+ });
+ for (let index = 0; index < numEntries; index++) {
+ // These clicks are expected to be ignored, unless the test has some extra delays.
+ // In that case, the test will verify the event duration to ensure the event duration is
+ // greater than the duration threshold
+ await clickAndBlockMain(id, { duration: processingDelay });
+ }
+ // Send click with event duration equals to or greater than |durThreshold|, so the
+ // observer promise can be resolved
+ await clickAndBlockMain(id, { duration: durThreshold });
+ return observerPromise;
+ }
+
+// Apply events that trigger an event of the given |eventType| to be dispatched to the
+// |target|. Some of these assume that the target is not on the top left corner of the
+// screen, which means that (0, 0) of the viewport is outside of the |target|.
+function applyAction(eventType, target) {
+ const actions = new test_driver.Actions();
+ if (eventType === 'auxclick') {
+ actions.pointerMove(0, 0, {origin: target})
+ .pointerDown({button: actions.ButtonType.MIDDLE})
+ .pointerUp({button: actions.ButtonType.MIDDLE});
+ } else if (eventType === 'click' || eventType === 'mousedown' || eventType === 'mouseup'
+ || eventType === 'pointerdown' || eventType === 'pointerup'
+ || eventType === 'touchstart' || eventType === 'touchend') {
+ actions.pointerMove(0, 0, {origin: target})
+ .pointerDown()
+ .pointerUp();
+ } else if (eventType === 'contextmenu') {
+ actions.pointerMove(0, 0, {origin: target})
+ .pointerDown({button: actions.ButtonType.RIGHT})
+ .pointerUp({button: actions.ButtonType.RIGHT});
+ } else if (eventType === 'dblclick') {
+ actions.pointerMove(0, 0, {origin: target})
+ .pointerDown()
+ .pointerUp()
+ .pointerDown()
+ .pointerUp()
+ // Reset by clicking outside of the target.
+ .pointerMove(0, 0)
+ .pointerDown()
+ } else if (eventType === 'mouseenter' || eventType === 'mouseover'
+ || eventType === 'pointerenter' || eventType === 'pointerover') {
+ // Move outside of the target and then back inside.
+ // Moving it to 0, 1 because 0, 0 doesn't cause the pointer to
+ // move in Firefox. See https://github.com/w3c/webdriver/issues/1545
+ actions.pointerMove(0, 1)
+ .pointerMove(0, 0, {origin: target});
+ } else if (eventType === 'mouseleave' || eventType === 'mouseout'
+ || eventType === 'pointerleave' || eventType === 'pointerout') {
+ actions.pointerMove(0, 0, {origin: target})
+ .pointerMove(0, 0);
+ } else if (eventType === 'keyup' || eventType === 'keydown') {
+ // Any key here as an input should work.
+ // TODO: Switch this to use test_driver.Actions.key{up,down}
+ // when test driver supports it.
+ // Please check crbug.com/893480.
+ const key = 'k';
+ return test_driver.send_keys(target, key);
+ } else {
+ assert_unreached('The event type ' + eventType + ' is not supported.');
+ }
+ return actions.send();
+}
+
+function requiresListener(eventType) {
+ return ['mouseenter',
+ 'mouseleave',
+ 'pointerdown',
+ 'pointerenter',
+ 'pointerleave',
+ 'pointerout',
+ 'pointerover',
+ 'pointerup',
+ 'keyup',
+ 'keydown'
+ ].includes(eventType);
+}
+
+function notCancelable(eventType) {
+ return ['mouseenter', 'mouseleave', 'pointerenter', 'pointerleave'].includes(eventType);
+}
+
+// Tests the given |eventType|'s performance.eventCounts value. Since this is populated only when
+// the event is processed, we check every 10 ms until we've found the |expectedCount|.
+function testCounts(t, resolve, looseCount, eventType, expectedCount) {
+ const counts = performance.eventCounts.get(eventType);
+ if (counts < expectedCount) {
+ t.step_timeout(() => {
+ testCounts(t, resolve, looseCount, eventType, expectedCount);
+ }, 10);
+ return;
+ }
+ if (looseCount) {
+ assert_greater_than_equal(performance.eventCounts.get(eventType), expectedCount,
+ `Should have at least ${expectedCount} ${eventType} events`)
+ } else {
+ assert_equals(performance.eventCounts.get(eventType), expectedCount,
+ `Should have ${expectedCount} ${eventType} events`);
+ }
+ resolve();
+}
+
+// Tests the given |eventType| by creating events whose target are the element with id
+// 'target'. The test assumes that such element already exists. |looseCount| is set for
+// eventTypes for which events would occur for other interactions other than the ones being
+// specified for the target, so the counts could be larger.
+async function testEventType(t, eventType, looseCount=false, targetId='target') {
+ assert_implements(window.EventCounts, "Event Counts isn't supported");
+ const target = document.getElementById(targetId);
+ if (requiresListener(eventType)) {
+ target.addEventListener(eventType, () =>{});
+ }
+ const initialCount = performance.eventCounts.get(eventType);
+ if (!looseCount) {
+ assert_equals(initialCount, 0, 'No events yet.');
+ }
+ // Trigger two 'fast' events of the type.
+ await applyAction(eventType, target);
+ await applyAction(eventType, target);
+ await afterNextPaint();
+ await new Promise(t.step_func(resolve => {
+ testCounts(t, resolve, looseCount, eventType, initialCount + 2);
+ }));
+ // The durationThreshold used by the observer. A slow events needs to be slower than that.
+ const durationThreshold = 16;
+ // Now add an event handler to cause a slow event.
+ target.addEventListener(eventType, () => {
+ mainThreadBusy(durationThreshold + 4);
+ });
+ const observerPromise = new Promise(async resolve => {
+ new PerformanceObserver(t.step_func(entryList => {
+ let eventTypeEntries = entryList.getEntriesByName(eventType);
+ if (eventTypeEntries.length === 0)
+ return;
+
+ let entry = null;
+ if (!looseCount) {
+ entry = eventTypeEntries[0];
+ assert_equals(eventTypeEntries.length, 1);
+ } else {
+ // The other events could also be considered slow. Find the one with the correct
+ // target.
+ eventTypeEntries.forEach(e => {
+ if (e.target === document.getElementById(targetId))
+ entry = e;
+ });
+ if (!entry)
+ return;
+ }
+ verifyEvent(entry,
+ eventType,
+ targetId,
+ false /* isFirst */,
+ durationThreshold,
+ notCancelable(eventType));
+ // Shouldn't need async testing here since we already got the observer entry, but might as
+ // well reuse the method.
+ testCounts(t, resolve, looseCount, eventType, initialCount + 3);
+ })).observe({type: 'event', durationThreshold: durationThreshold});
+ });
+ // Cause a slow event.
+ await applyAction(eventType, target);
+
+ await afterNextPaint();
+
+ await observerPromise;
+}
+
+function addListeners(target, events) {
+ const eventListener = (e) => {
+ mainThreadBusy(200);
+ };
+ events.forEach(e => { target.addEventListener(e, eventListener); });
+}
+
+// The testdriver.js, testdriver-vendor.js and testdriver-actions.js need to be
+// included to use this function.
+async function tap(target) {
+ return new test_driver.Actions()
+ .addPointer("touchPointer", "touch")
+ .pointerMove(0, 0, { origin: target })
+ .pointerDown()
+ .pointerUp()
+ .send();
+}
+
+async function click(target) {
+ return test_driver.click(target);
+}
+
+async function auxClick(target) {
+ const actions = new test_driver.Actions();
+ return actions.addPointer("mousePointer", "mouse")
+ .pointerMove(0, 0, { origin: target })
+ .pointerDown({ button: actions.ButtonType.RIGHT })
+ .pointerUp({ button: actions.ButtonType.RIGHT })
+ .send();
+}
+
+async function pointerdown(target) {
+ const actions = new test_driver.Actions();
+ return actions.addPointer("mousePointer", "mouse")
+ .pointerMove(0, 0, { origin: target })
+ .pointerDown()
+ .send();
+}
+
+async function orphanPointerup(target) {
+ const actions = new test_driver.Actions();
+ await actions.addPointer("mousePointer", "mouse")
+ .pointerMove(0, 0, { origin: target })
+ .pointerUp()
+ .send();
+
+ // Orphan pointerup doesn't get triggered in some browsers. Sending a
+ // non-pointer related event to make sure that at least an event gets handled.
+ // If a browsers sends an orphan pointerup, it will always be before the
+ // keydown, so the test will correctly handle it.
+ await pressKey(target, 'a');
+}
+
+async function auxPointerdown(target) {
+ const actions = new test_driver.Actions();
+ return actions.addPointer("mousePointer", "mouse")
+ .pointerMove(0, 0, { origin: target })
+ .pointerDown({ button: actions.ButtonType.RIGHT })
+ .send();
+}
+
+async function orphanAuxPointerup(target) {
+ const actions = new test_driver.Actions();
+ await actions.addPointer("mousePointer", "mouse")
+ .pointerMove(0, 0, { origin: target })
+ .pointerUp({ button: actions.ButtonType.RIGHT })
+ .send();
+
+ // Orphan pointerup doesn't get triggered in some browsers. Sending a
+ // non-pointer related event to make sure that at least an event gets handled.
+ // If a browsers sends an orphan pointerup, it will always be before the
+ // keydown, so the test will correctly handle it.
+ await pressKey(target, 'a');
+}
+
+// The testdriver.js, testdriver-vendor.js need to be included to use this
+// function.
+async function pressKey(target, key) {
+ await test_driver.send_keys(target, key);
+}
+
+async function flingAndTapInTarget(target) {
+ const actions = new test_driver.Actions();
+ return actions.addPointer("pointer1", "touch")
+ .pointerMove(0, 0, {origin: target})
+ .pointerDown()
+ .pointerMove(0, -50, {origin: target})
+ .pointerMove(0, -50, {origin: target})
+ .pointerUp()
+ .pause(60)
+ .pointerMove(0, 0, {origin: target})
+ .pointerDown()
+ .pointerUp()
+ .send();
+}
+
+async function textSelectionInTarget(target) {
+ const actions = new test_driver.Actions();
+ return actions.addPointer("pointer1", "mouse")
+ .pointerMove(0, 0, {origin: target})
+ .pointerDown({button: actions.ButtonType.LEFT})
+ .pointerMove(20, 60, {origin: target})
+ .pointerMove(20, 120, {origin: target})
+ .pointerUp()
+ .send();
+}
+
+// The testdriver.js, testdriver-vendor.js need to be included to use this
+// function.
+async function addListenersAndPress(target, key, events) {
+ addListeners(target, events);
+ return pressKey(target, key);
+}
+
+// The testdriver.js, testdriver-vendor.js need to be included to use this
+// function.
+async function addListenersAndClick(target) {
+ addListeners(target,
+ ['mousedown', 'mouseup', 'pointerdown', 'pointerup', 'click']);
+ return click(target);
+}
+
+function filterAndAddToMap(events, map) {
+ return function (entry) {
+ if (events.includes(entry.name)) {
+ map.set(entry.name, entry.interactionId);
+ return true;
+ }
+ return false;
+ }
+}
+
+async function createPerformanceObserverPromise(observeTypes, callback, readyToResolve
+) {
+ return new Promise(resolve => {
+ new PerformanceObserver(entryList => {
+ callback(entryList);
+
+ if (readyToResolve()) {
+ resolve();
+ }
+ }).observe({ entryTypes: observeTypes });
+ });
+}
+
+const ENTER_KEY = '\uE007';
+const SPACE_KEY = '\uE00D';
+
+async function blockPointerDownEventListener(target, duration, count) {
+ return new Promise(resolve => {
+ target.addEventListener("pointerdown", () => {
+ event_count++;
+ mainThreadBusy(duration);
+ if (event_count == count)
+ resolve();
+ });
+ });
+}
+
+async function blockCapturePointerDownEventListener(target, duration) {
+ return new Promise(resolve => {
+ target.addEventListener("pointerdown", (e) => {
+ mainThreadBusy(duration);
+ target.setPointerCapture(e.pointerId);
+ resolve();
+ });
+ });
+}
+
+async function flingTapAndBlockMain(target, duration) {
+ return Promise.all([
+ blockPointerDownEventListener(target, duration, 2),
+ blockNextEventListener(target, "pointercancel", duration),
+ blockNextEventListener(target, "scroll", duration),
+ flingAndTapInTarget(target),
+ ]);
+}
+
+async function textSelectionAndBlockMain(target, duration) {
+ return Promise.all([
+ blockCapturePointerDownEventListener(target, "pointerdown", duration),
+ blockNextEventListener(target, "pointermove", duration),
+ blockNextEventListener(target, "scroll", duration),
+ blockNextEventListener(target, "pointerup", duration),
+ textSelectionInTarget(target),
+ // afterNextPaint(),
+ ]);
+}
+
+// The testdriver.js, testdriver-vendor.js need to be included to use this
+// function.
+async function interactAndObserve(interactionType, target, observerPromise, key = '') {
+ let interactionPromise;
+ switch (interactionType) {
+ case 'key': {
+ addListeners(target, ['keydown', 'keyup']);
+ interactionPromise = pressKey(target, key);
+ }
+ case 'tap': {
+ addListeners(target, ['pointerdown', 'pointerup']);
+ interactionPromise = tap(target);
+ break;
+ }
+ case 'click': {
+ addListeners(target,
+ ['mousedown', 'mouseup', 'pointerdown', 'pointerup', 'click']);
+ interactionPromise = click(target);
+ break;
+ }
+ case 'auxclick': {
+ addListeners(target,
+ ['mousedown', 'mouseup', 'pointerdown', 'pointerup', 'contextmenu', 'auxclick']);
+ interactionPromise = auxClick(target);
+ break;
+ }
+ case 'aux-pointerdown': {
+ addListeners(target,
+ ['mousedown', 'pointerdown', 'contextmenu']);
+ interactionPromise = auxPointerdown(target);
+ break;
+ }
+ case 'aux-pointerdown-and-pointerdown': {
+ addListeners(target,
+ ['mousedown', 'pointerdown', 'contextmenu']);
+ interactionPromise = Promise.all([auxPointerdown(target), pointerdown(target)]);
+ break;
+ }
+ case 'orphan-pointerup': {
+ addListeners(target, ['pointerup', 'keydown']);
+ interactionPromise = orphanPointerup(target);
+ break;
+ }
+ case 'space-key-simulated-click': {
+ addListeners(target, ['keydown', 'click']);
+ interactionPromise = interact('key', target, SPACE_KEY);
+ break;
+ }
+ case 'enter-key-simulated-click': {
+ addListeners(target, ['keydown', 'click']);
+ interactionPromise = interact('key', target, ENTER_KEY);
+ break;
+ }
+ case 'fling-tap': {
+ interactionPromise = flingTapAndBlockMain(target, 30);
+ break;
+ }
+ case 'selection-scroll': {
+ interactionPromise = textSelectionAndBlockMain(target, 30);
+ break;
+ }
+ case 'orphan-keydown': {
+ addListeners(target, ['keydown']);
+ interactionPromise = new test_driver.Actions()
+ .pointerMove(0, 0, {origin: target})
+ .pointerDown()
+ .pointerUp()
+ .addTick()
+ .keyDown('a')
+ .send();
+ break;
+ }
+ }
+ return Promise.all([interactionPromise, observerPromise]);
+}
+
+async function interact(interactionType, element, key = '') {
+ switch (interactionType) {
+ case 'click': {
+ return click(element);
+ }
+ case 'tap': {
+ return tap(element);
+ }
+ case 'key': {
+ return test_driver.send_keys(element, key);
+ }
+ }
+}
+
+async function verifyInteractionCount(t, expectedCount) {
+ await t.step_wait(() => {
+ return performance.interactionCount >= expectedCount;
+ }, 'interactionCount did not increase enough', 10000, 5);
+ assert_equals(performance.interactionCount, expectedCount,
+ 'interactionCount increased more than expected');
+}
+
+function interactionCount_test(interactionType, elements, key = '') {
+ return promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming,
+ 'Event Timing is not supported');
+ assert_equals(performance.interactionCount, 0, 'Initial count is not 0');
+
+ let expectedCount = 1;
+ for (let element of elements) {
+ await interact(interactionType, element, key);
+ await verifyInteractionCount(t, expectedCount++);
+ }
+ }, `EventTiming: verify interactionCount for ${interactionType} interaction`);
+}
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/retrievability.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/retrievability.html
new file mode 100644
index 00000000000..0cf216c9e27
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/retrievability.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<title>Event Timing: make sure 'event' entries are not retrievable by performance.getEntries* APIs.</title>
+<meta name="timeout" content="long">
+<button id='button'>Generate a 'click' event</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+
+<script src=resources/event-timing-test-utils.js></script>
+
+<script>
+ function validateEntries() {
+ const entriesByName = performance.getEntriesByName('pointerdown', 'event');
+ const entriesByType = performance.getEntriesByType('event');
+ const allEntries = performance.getEntries();
+ assert_equals(entriesByName.length, 0, 'Event Timing entry should not be retrievable by getEntriesByName');
+ assert_equals(entriesByType.length, 0, 'Event Timing entry should not be retrievable by getEntriesByType');
+ assert_equals(allEntries.filter(e => e.entryType === 'event').length, 0, 'Event Timing entry should not be retrievable by getEntries');
+ }
+
+ /* Timeline:
+ Begin Busy Loop
+ Click 1 arrives
+ End Busy Loop
+ (Dispatch and Process Click 1 - buffered)
+ Onload Event Fires
+ Validate entries
+ */
+ async_test(function(t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ new PerformanceObserver(t.step_func(entryList => {
+ if (entryList.getEntriesByName('pointerdown').length > 0) {
+ validateEntries();
+ t.done();
+ }
+ })).observe({entryTypes: ['event']});
+ clickAndBlockMain('button');
+ }, "Event Timing: make sure event-timing entries are not retrievable by performance.getEntries*.");
+
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/retrieve-firstInput.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/retrieve-firstInput.html
new file mode 100644
index 00000000000..ff5512c3978
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/retrieve-firstInput.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: first-input entry should be buffered even without observer</title>
+<button id='button'>Generate a 'click' event</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+
+<script src=resources/event-timing-test-utils.js></script>
+
+<script>
+ async_test(function(t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ function testEntries() {
+ // First callback is not ensured to have the entry.
+ if (performance.getEntriesByType('first-input').length === 0) {
+ t.step_timeout(testEntries, 10);
+ return;
+ }
+ assert_equals(performance.getEntriesByType('first-input').length, 1,
+ "There should be a first-input entry in the performance timeline");
+ const entry = performance.getEntriesByType('first-input')[0];
+ assert_equals(entry.name, 'pointerdown');
+ assert_equals(entry.entryType, 'first-input');
+ assert_greater_than_equal(entry.duration, 104,
+ "The first input was a long one.");
+ t.done();
+ }
+ clickAndBlockMain('button').then(wait).then(t.step_func(testEntries));
+ },
+ "Event Timing: check first-input after onload, observer, click, click."
+ );
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/shadow-dom-null-target.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/shadow-dom-null-target.html
new file mode 100644
index 00000000000..3209c9322fa
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/shadow-dom-null-target.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=../resources/testdriver-actions.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<body>
+<div id='host'>
+</div>
+<script>
+promise_test(async t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+
+ const host = document.getElementById('host');
+ const shadowRoot = host.attachShadow({mode: "closed"});
+
+ const durationThreshold = 16;
+
+ const innerSpan1 = document.createElement("span");
+ innerSpan1.textContent = "Span1";
+ const innerSpan2 = document.createElement("span");
+ innerSpan2.textContent = "Span2";
+
+ shadowRoot.append(innerSpan1);
+ shadowRoot.append(innerSpan2);
+
+ innerSpan2.addEventListener("mouseover", function(e) {
+ // To make this is a slow event
+ mainThreadBusy(durationThreshold + 4);
+ });
+
+ const span1Rect = innerSpan1.getBoundingClientRect();
+ const span2Rect = innerSpan2.getBoundingClientRect();
+
+ const actions = new test_driver.Actions();
+ // Move the pointer to innerSpan1
+ await actions.pointerMove(
+ Math.ceil(span1Rect.x + span1Rect.width / 2),
+ Math.ceil(span1Rect.y + span1Rect.height / 2)
+ ).send();
+
+ await afterNextPaint();
+
+ const observerPromise = new Promise(resolve => {
+ new PerformanceObserver(t.step_func(entryList => {
+ let mouseOverEntries = entryList.getEntriesByName("mouseover");
+ assert_equals(mouseOverEntries.length, 1);
+ assert_equals(mouseOverEntries[0].target, null);
+ resolve();
+ })).observe({type: 'event', durationThreshold: durationThreshold});
+ });
+
+ // Move the pointer to innerSpan2
+ // Here we move the pointer within the shadow DOM
+ await actions.pointerMove(
+ Math.ceil(span2Rect.x + span2Rect.width / 2),
+ Math.ceil(span2Rect.y + span2Rect.height / 2)
+ ).send();
+
+ await afterNextPaint();
+
+ await observerPromise;
+}, "Event Timing: Move pointer within shadow DOM should create event-timing entry with null target.");
+</script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/supported-types-consistent-with-self.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/supported-types-consistent-with-self.html
new file mode 100644
index 00000000000..869de20319f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/supported-types-consistent-with-self.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: supportedEntryTypes should be consistent with `'PerformanceEventTiming' in Self`
+</title>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script>
+test(() => {
+ const isFirstInputSupportedInEntryTypes = PerformanceObserver.supportedEntryTypes.includes('first-input');
+ const isEventSupportedInEntryTypes = PerformanceObserver.supportedEntryTypes.includes('event');
+
+ const isEventTimingSupportedInSelf = 'PerformanceEventTiming' in self;
+
+ assert_equals(isFirstInputSupportedInEntryTypes, isEventTimingSupportedInSelf)
+ assert_equals(isEventSupportedInEntryTypes, isEventTimingSupportedInSelf)
+}, "supportedEntryTypes should be consistent with `'PerformanceEventTiming' in Self`");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/supported-types.window.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/supported-types.window.html
new file mode 100644
index 00000000000..022eda38cad
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/supported-types.window.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<div id=log></div>
+<script src="../event-timing/supported-types.window.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/supported-types.window.js b/Tests/LibWeb/Text/input/wpt-import/event-timing/supported-types.window.js
new file mode 100644
index 00000000000..1cc43495c09
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/supported-types.window.js
@@ -0,0 +1,12 @@
+test(() => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ assert_implements(typeof PerformanceObserver.supportedEntryTypes !== "undefined",
+ 'supportedEntryTypes is not supported');
+ const types = PerformanceObserver.supportedEntryTypes;
+ assert_true(types.includes("first-input"),
+ "There should be 'first-input' in PerformanceObserver.supportedEntryTypes");
+ assert_true(types.includes("event"),
+ "There should be 'event' in PerformanceObserver.supportedEntryTypes");
+ assert_greater_than(types.indexOf("first-input"), types.indexOf('event'),
+ "The 'first-input' entry should appear after the 'event' entry");
+}, "supportedEntryTypes contains 'event' and 'first-input'.");
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/timingconditions.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/timingconditions.html
new file mode 100644
index 00000000000..cdfa89e1160
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/timingconditions.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing only times certain types of trusted event.
+</title>
+<meta name="timeout" content="long">
+<button id='button' tabindex="0">Generate a 'click' event</button>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+
+<script src=resources/event-timing-test-utils.js></script>
+<script>
+ let trustedClickStart;
+ function trustedClickAndBlockMain(id) {
+ trustedClickStart = performance.now();
+ mainThreadBusy(2);
+ return clickAndBlockMain(id);
+ }
+
+ function untrustedClickAndBlockMain(id) {
+ const target = document.getElementById(id);
+ // Block mainthread in the callback, as dispatchEvent() is a sync call.
+ target.addEventListener('pointerdown', () => mainThreadBusy(120), true);
+ const eventDispatchStart = performance.now();
+ target.dispatchEvent(new PointerEvent('pointerdown'));
+ assert_greater_than(performance.now() - eventDispatchStart, 119, "dispatchEvent() should run the event handler synchronously.");
+ }
+
+ function trustedFocusAndBlockMain(id) {
+ const target = document.getElementById(id);
+ // Guarantees target isn't focused to ensure the focus event is fired:
+ target.blur()
+ trustedFocusStart = performance.now();
+ // Block mainthread in the callback, as focus() is a sync call.
+ target.addEventListener('focus', () => mainThreadBusy(120), true);
+ target.focus();
+ assert_greater_than(performance.now() - trustedFocusStart, 119, "focus() should run the event handler synchronously.");
+ }
+
+ promise_test(function(t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ let observedPointerDown = false;
+ const observerPromise = new Promise(resolve => {
+ new PerformanceObserver(t.step_func(entryList => {
+ const observerCallbackTime = performance.now();
+ const pointerDowns = entryList.getEntriesByName('pointerdown');
+ assert_equals(entryList.getEntriesByName('focus').length, 0);
+ // Ignore cases in which there is no pointerdown.
+ if (pointerDowns.length === 0)
+ return;
+
+ assert_false(observedPointerDown, 'Got more than one callback with pointerdown.');
+ assert_equals(pointerDowns.length, 1,
+ "Should only observe one pointerdown entry. Instead, got these: " +
+ JSON.stringify(pointerDowns) + ".");
+ assert_equals(pointerDowns[0].name, 'pointerdown',
+ "The observed entry should be a pointerdown");
+ assert_less_than(pointerDowns[0].startTime, observerCallbackTime,
+ "The startTime should be before observerCallbackTime");
+ assert_greater_than(pointerDowns[0].startTime, trustedClickStart,
+ "The startTime should be after trustedClickStart");
+ observedPointerDown = true;
+ resolve();
+ })).observe({ entryTypes: ['event'] });
+ });
+ // Untrusted event of a type event timing cares about.
+ untrustedClickAndBlockMain('button');
+ // Trusted event of a type event timing doesn't cares about.
+ trustedFocusAndBlockMain('button');
+ // Trusted event of a type event timing cares about.
+ const clickPromise = trustedClickAndBlockMain('button').then(wait);
+ return Promise.all([observerPromise, clickPromise]);
+ }, "Event Timing only times certain types of trusted event.");
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/event-timing/toJSON.html b/Tests/LibWeb/Text/input/wpt-import/event-timing/toJSON.html
new file mode 100644
index 00000000000..0ffab3af0ac
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/event-timing/toJSON.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>Event Timing: toJSON</title>
+<body>
+<script src=../resources/testharness.js></script>
+<script src=../resources/testharnessreport.js></script>
+<script src=../resources/testdriver.js></script>
+<script src=../resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<button id='button'>Generate a 'click' event</button>
+<script>
+ async_test(function (t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ const observer = new PerformanceObserver(
+ t.step_func_done(function(entryList) {
+ const entry = entryList.getEntries()[0];
+ assert_equals(typeof(entry.toJSON), 'function');
+ const json = entry.toJSON();
+ assert_equals(typeof(json), 'object');
+ const keys = [
+ // PerformanceEntry
+ 'name',
+ 'entryType',
+ 'startTime',
+ 'duration',
+ // PerformanceEventTiming
+ 'processingStart',
+ 'processingEnd',
+ 'cancelable',
+ ];
+ for (const key of keys) {
+ assert_equals(json[key], entry[key],
+ 'PerformanceEventTiming ${key} entry does not match its toJSON value');
+ }
+ assert_equals(json['target'], undefined, 'toJSON should not include target');
+ })
+ );
+ observer.observe({type: 'event'});
+ clickAndBlockMain('button');
+ }, 'Test toJSON() in PerformanceEventTiming.');
+</script>
+</body>