Skip to content

Truly independent web browser

LibWeb: Use a pointerId of -1 for synthetic pointer events

Andreas Klingc7ceeb173b23
diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cpp
index 3bdf1db84b5..32f43099264 100644
--- a/Libraries/LibWeb/HTML/HTMLElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLElement.cpp
@@ -1208,7 +1208,12 @@ bool HTMLElement::fire_a_synthetic_pointer_event(Utf16FlyString const& type, DOM
// 1. Let event be the result of creating an event using PointerEvent.
// 2. Initialize event's type attribute to e.
auto event_name = FlyString { type.to_utf16_string().to_utf8() };
- auto event = UIEvents::PointerEvent::create(event_name, {}, 0, 0, 0, 0, HighResolutionTime::current_high_resolution_time(HTML::relevant_global_object(*this)));
+ // NB: Synthetic pointer events are not generated by a pointing device. Pointer Events requires their pointerId to
+ // be -1 and their pointerType to be the empty string.
+ // https://w3c.github.io/pointerevents/#click-auxclick-and-contextmenu
+ UIEvents::PointerEventOptions options;
+ options.pointer_id = -1;
+ auto event = UIEvents::PointerEvent::create(event_name, move(options), 0, 0, 0, 0, HighResolutionTime::current_high_resolution_time(HTML::relevant_global_object(*this)));
// 3. Initialize event's bubbles and cancelable attributes to true.
event->set_bubbles(true);
diff --git a/Tests/LibWeb/Text/expected/wpt-import/uievents/interface/click-event.txt b/Tests/LibWeb/Text/expected/wpt-import/uievents/interface/click-event.txt
index 5b993ccf0e2..27c7bd738c1 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/uievents/interface/click-event.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/uievents/interface/click-event.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail synthetic click event is a PointerEvent
\ No newline at end of file
+1 Pass
+Pass synthetic click event is a PointerEvent
\ No newline at end of file