Skip to content

Truly independent web browser

LibWeb: Fire mouse click events as PointerEvents

sideshowbarker1c714afb3768
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp
index 7079131efcb..6aa4135e248 100644
--- a/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Libraries/LibWeb/Page/EventHandler.cpp
@@ -3411,7 +3411,7 @@ bool EventHandler::fire_click_events(GC::Ref<DOM::Node> node, MouseEventCoordina
if (button == UIEvents::MouseButton::Primary) {
// https://w3c.github.io/pointerevents/#click
- run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(HTML::relevant_global_object(*node), m_navigable->active_window_proxy(), UIEvents::EventNames::click, screen_position, coordinates.page_offset, coordinates.viewport_position, coordinates.offset, {}, button, buttons, modifiers, click_count).release_value_but_fixme_should_propagate_errors());
+ run_activation_behavior = node->dispatch_event(UIEvents::PointerEvent::create_from_platform_event(HTML::relevant_global_object(*node), m_navigable->active_window_proxy(), UIEvents::EventNames::click, screen_position, coordinates.page_offset, coordinates.viewport_position, coordinates.offset, {}, button, buttons, modifiers, click_count).release_value_but_fixme_should_propagate_errors());
// https://w3c.github.io/uievents/#event-type-dblclick
// This event type MUST be dispatched after the event type click if a click and
@@ -3420,7 +3420,7 @@ bool EventHandler::fire_click_events(GC::Ref<DOM::Node> node, MouseEventCoordina
node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(HTML::relevant_global_object(*node), m_navigable->active_window_proxy(), UIEvents::EventNames::dblclick, screen_position, coordinates.page_offset, coordinates.viewport_position, coordinates.offset, {}, button, buttons, modifiers, click_count).release_value_but_fixme_should_propagate_errors());
} else {
// https://w3c.github.io/pointerevents/#auxclick
- run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(HTML::relevant_global_object(*node), m_navigable->active_window_proxy(), UIEvents::EventNames::auxclick, screen_position, coordinates.page_offset, coordinates.viewport_position, coordinates.offset, {}, button, buttons, modifiers, click_count).release_value_but_fixme_should_propagate_errors());
+ run_activation_behavior = node->dispatch_event(UIEvents::PointerEvent::create_from_platform_event(HTML::relevant_global_object(*node), m_navigable->active_window_proxy(), UIEvents::EventNames::auxclick, screen_position, coordinates.page_offset, coordinates.viewport_position, coordinates.offset, {}, button, buttons, modifiers, click_count).release_value_but_fixme_should_propagate_errors());
}
return run_activation_behavior;
@@ -4027,7 +4027,7 @@ void EventHandler::maybe_show_context_menu(GC::Ref<DOM::Node> node, MouseEventCo
if ((modifiers & UIEvents::Mod_Shift) == 0) {
// 1. Let menuevent = create a PointerEvent with "contextmenu", target
// 2. If native is valid, then set MouseEvent attributes from native.
- auto menuevent = UIEvents::MouseEvent::create_from_platform_event(HTML::relevant_global_object(*node), m_navigable->active_window_proxy(), UIEvents::EventNames::contextmenu, screen_position, coordinates.page_offset, coordinates.viewport_position, coordinates.offset, {}, UIEvents::MouseButton::Secondary, buttons, modifiers).release_value_but_fixme_should_propagate_errors();
+ auto menuevent = UIEvents::PointerEvent::create_from_platform_event(HTML::relevant_global_object(*node), m_navigable->active_window_proxy(), UIEvents::EventNames::contextmenu, screen_position, coordinates.page_offset, coordinates.viewport_position, coordinates.offset, {}, UIEvents::MouseButton::Secondary, buttons, modifiers).release_value_but_fixme_should_propagate_errors();
// 3. Let result = dispatch menuevent at target.
bool result = node->dispatch_event(menuevent);
diff --git a/Libraries/LibWeb/UIEvents/PointerEvent.cpp b/Libraries/LibWeb/UIEvents/PointerEvent.cpp
index 21aa4b405ce..021901a844c 100644
--- a/Libraries/LibWeb/UIEvents/PointerEvent.cpp
+++ b/Libraries/LibWeb/UIEvents/PointerEvent.cpp
@@ -42,9 +42,10 @@ double PointerEvent::client_y() const { return should_have_fractional_coordinate
double PointerEvent::offset_x() const { return should_have_fractional_coordinates() ? m_offset_x : MouseEvent::offset_x(); }
double PointerEvent::offset_y() const { return should_have_fractional_coordinates() ? m_offset_y : MouseEvent::offset_y(); }
-WebIDL::ExceptionOr<GC::Ref<PointerEvent>> PointerEvent::create_from_platform_event(JS::Object const& relevant_global_object, GC::Ptr<HTML::WindowProxy> window_proxy, FlyString const& event_name, CSSPixelPoint screen, CSSPixelPoint page, CSSPixelPoint client, CSSPixelPoint offset, Optional<CSSPixelPoint> movement, unsigned button, unsigned buttons, unsigned modifiers)
+WebIDL::ExceptionOr<GC::Ref<PointerEvent>> PointerEvent::create_from_platform_event(JS::Object const& relevant_global_object, GC::Ptr<HTML::WindowProxy> window_proxy, FlyString const& event_name, CSSPixelPoint screen, CSSPixelPoint page, CSSPixelPoint client, CSSPixelPoint offset, Optional<CSSPixelPoint> movement, unsigned button, unsigned buttons, unsigned modifiers, int detail)
{
PointerEventOptions event_options;
+ event_options.detail = detail;
event_options.ctrl_key = modifiers & Mod_Ctrl;
event_options.shift_key = modifiers & Mod_Shift;
event_options.alt_key = modifiers & Mod_Alt;
@@ -55,9 +56,14 @@ WebIDL::ExceptionOr<GC::Ref<PointerEvent>> PointerEvent::create_from_platform_ev
event_options.client_y = client.y().to_double();
event_options.view = window_proxy;
event_options.pointer_id = mouse_pointer_id;
- event_options.is_primary = true;
event_options.pointer_type = PointerTypes::Mouse;
- event_options.pressure = event_name != EventNames::pointerup && buttons ? ACTIVE_PRESSURE_DEFAULT_IN_ACTIVE_BUTTON_STATE : 0;
+ // https://w3c.github.io/pointerevents/#click
+ // For these events, all PointerEvent specific attributes (defined in this spec) other than pointerId and
+ // pointerType MUST have their default values.
+ if (event_name != EventNames::click && event_name != EventNames::auxclick && event_name != EventNames::contextmenu) {
+ event_options.is_primary = true;
+ event_options.pressure = event_name != EventNames::pointerup && buttons ? ACTIVE_PRESSURE_DEFAULT_IN_ACTIVE_BUTTON_STATE : 0;
+ }
if (movement.has_value()) {
event_options.movement_x = movement.value().x().to_double();
event_options.movement_y = movement.value().y().to_double();
@@ -72,9 +78,10 @@ WebIDL::ExceptionOr<GC::Ref<PointerEvent>> PointerEvent::create_from_platform_ev
return event;
}
-WebIDL::ExceptionOr<GC::Ref<PointerEvent>> PointerEvent::create_from_platform_event(JS::Object const& relevant_global_object, GC::Ptr<HTML::WindowProxy> window_proxy, Utf16FlyString const& event_name, CSSPixelPoint screen, CSSPixelPoint page, CSSPixelPoint client, CSSPixelPoint offset, Optional<CSSPixelPoint> movement, unsigned button, unsigned buttons, unsigned modifiers)
+WebIDL::ExceptionOr<GC::Ref<PointerEvent>> PointerEvent::create_from_platform_event(JS::Object const& relevant_global_object, GC::Ptr<HTML::WindowProxy> window_proxy, Utf16FlyString const& event_name, CSSPixelPoint screen, CSSPixelPoint page, CSSPixelPoint client, CSSPixelPoint offset, Optional<CSSPixelPoint> movement, unsigned button, unsigned buttons, unsigned modifiers, int detail)
{
PointerEventOptions event_options;
+ event_options.detail = detail;
event_options.ctrl_key = modifiers & Mod_Ctrl;
event_options.shift_key = modifiers & Mod_Shift;
event_options.alt_key = modifiers & Mod_Alt;
@@ -85,9 +92,14 @@ WebIDL::ExceptionOr<GC::Ref<PointerEvent>> PointerEvent::create_from_platform_ev
event_options.client_y = client.y().to_double();
event_options.view = window_proxy;
event_options.pointer_id = mouse_pointer_id;
- event_options.is_primary = true;
event_options.pointer_type = PointerTypes::Mouse;
- event_options.pressure = event_name != EventNames::pointerup && buttons ? ACTIVE_PRESSURE_DEFAULT_IN_ACTIVE_BUTTON_STATE : 0;
+ // https://w3c.github.io/pointerevents/#click
+ // For these events, all PointerEvent specific attributes (defined in this spec) other than pointerId and
+ // pointerType MUST have their default values.
+ if (event_name != EventNames::click && event_name != EventNames::auxclick && event_name != EventNames::contextmenu) {
+ event_options.is_primary = true;
+ event_options.pressure = event_name != EventNames::pointerup && buttons ? ACTIVE_PRESSURE_DEFAULT_IN_ACTIVE_BUTTON_STATE : 0;
+ }
if (movement.has_value()) {
event_options.movement_x = movement->x().to_double();
event_options.movement_y = movement->y().to_double();
diff --git a/Libraries/LibWeb/UIEvents/PointerEvent.h b/Libraries/LibWeb/UIEvents/PointerEvent.h
index 2014a06bc97..d0777f1e49d 100644
--- a/Libraries/LibWeb/UIEvents/PointerEvent.h
+++ b/Libraries/LibWeb/UIEvents/PointerEvent.h
@@ -66,8 +66,8 @@ public:
HighResolutionTime::DOMHighResTimeStamp);
[[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<PointerEvent>> create_for_constructor(FlyString const&, Bindings::PointerEventInit const&, HighResolutionTime::DOMHighResTimeStamp);
[[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<PointerEvent>> create_for_constructor(Utf16String const&, Bindings::PointerEventInit const&, HighResolutionTime::DOMHighResTimeStamp);
- [[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<PointerEvent>> create_from_platform_event(JS::Object const& relevant_global_object, GC::Ptr<HTML::WindowProxy>, FlyString const& event_name, CSSPixelPoint screen, CSSPixelPoint page, CSSPixelPoint client, CSSPixelPoint offset, Optional<CSSPixelPoint> movement, unsigned button, unsigned buttons, unsigned modifiers);
- [[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<PointerEvent>> create_from_platform_event(JS::Object const& relevant_global_object, GC::Ptr<HTML::WindowProxy>, Utf16FlyString const& event_name, CSSPixelPoint screen, CSSPixelPoint page, CSSPixelPoint client, CSSPixelPoint offset, Optional<CSSPixelPoint> movement, unsigned button, unsigned buttons, unsigned modifiers);
+ [[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<PointerEvent>> create_from_platform_event(JS::Object const& relevant_global_object, GC::Ptr<HTML::WindowProxy>, FlyString const& event_name, CSSPixelPoint screen, CSSPixelPoint page, CSSPixelPoint client, CSSPixelPoint offset, Optional<CSSPixelPoint> movement, unsigned button, unsigned buttons, unsigned modifiers, int detail = 0);
+ [[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<PointerEvent>> create_from_platform_event(JS::Object const& relevant_global_object, GC::Ptr<HTML::WindowProxy>, Utf16FlyString const& event_name, CSSPixelPoint screen, CSSPixelPoint page, CSSPixelPoint client, CSSPixelPoint offset, Optional<CSSPixelPoint> movement, unsigned button, unsigned buttons, unsigned modifiers, int detail = 0);
virtual ~PointerEvent() override;
diff --git a/Tests/LibWeb/Text/expected/UIEvents/mouse-click-events-are-pointer-events.txt b/Tests/LibWeb/Text/expected/UIEvents/mouse-click-events-are-pointer-events.txt
new file mode 100644
index 00000000000..a0fcd5ba499
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/UIEvents/mouse-click-events-are-pointer-events.txt
@@ -0,0 +1,13 @@
+Primary button:
+pointerdown: PointerEvent, pointerId 0, pointerType mouse, button 0, detail 0, isPrimary true, pressure 0.5, trusted true
+click: PointerEvent, pointerId 0, pointerType mouse, button 0, detail 1, isPrimary false, pressure 0, trusted true
+Primary button, second click:
+pointerdown: PointerEvent, pointerId 0, pointerType mouse, button 0, detail 0, isPrimary true, pressure 0.5, trusted true
+click: PointerEvent, pointerId 0, pointerType mouse, button 0, detail 2, isPrimary false, pressure 0, trusted true
+Middle button:
+pointerdown: PointerEvent, pointerId 0, pointerType mouse, button 1, detail 0, isPrimary true, pressure 0.5, trusted true
+auxclick: PointerEvent, pointerId 0, pointerType mouse, button 1, detail 1, isPrimary false, pressure 0, trusted true
+Secondary button:
+pointerdown: PointerEvent, pointerId 0, pointerType mouse, button 2, detail 0, isPrimary true, pressure 0.5, trusted true
+contextmenu: PointerEvent, pointerId 0, pointerType mouse, button 2, detail 0, isPrimary false, pressure 0, trusted true
+auxclick: PointerEvent, pointerId 0, pointerType mouse, button 2, detail 1, isPrimary false, pressure 0, trusted true
diff --git a/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected] b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
new file mode 100644
index 00000000000..20c27130ab9
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
@@ -0,0 +1,10 @@
+Harness status: Error
+
+Found 4 tests
+
+3 Pass
+1 Fail
+Pass click using mouse is a PointerEvent with correct properties
+Pass click using mouse is a PointerEvent with correct properties when no other PointerEvent listeners are present
+Pass click using mouse is a PointerEvent with correct properties using non-pointing device
+Fail click using mouse is a PointerEvent with correct properties in a subframe
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected] b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
new file mode 100644
index 00000000000..111cc6ef412
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
@@ -0,0 +1,9 @@
+Harness status: OK
+
+Found 3 tests
+
+2 Pass
+1 Fail
+Pass click using pen is a PointerEvent with correct properties
+Pass click using pen is a PointerEvent with correct properties when no other PointerEvent listeners are present
+Fail click using pen is a PointerEvent with correct properties in a subframe
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected] b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
new file mode 100644
index 00000000000..702bec57cb8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
@@ -0,0 +1,9 @@
+Harness status: OK
+
+Found 3 tests
+
+2 Pass
+1 Fail
+Pass click using touch is a PointerEvent with correct properties
+Pass click using touch is a PointerEvent with correct properties when no other PointerEvent listeners are present
+Fail click using touch is a PointerEvent with correct properties in a subframe
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected] b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
new file mode 100644
index 00000000000..04e8c6543ff
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass click using mouse is a PointerEvent
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected] b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
new file mode 100644
index 00000000000..77dcdf8d8c7
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass click using pen is a PointerEvent
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected] b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
new file mode 100644
index 00000000000..bbf53c319c3
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/pointerevents/[email protected]
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass click using touch is a PointerEvent
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/UIEvents/mouse-click-events-are-pointer-events.html b/Tests/LibWeb/Text/input/UIEvents/mouse-click-events-are-pointer-events.html
new file mode 100644
index 00000000000..ffe87a3dbb9
--- /dev/null
+++ b/Tests/LibWeb/Text/input/UIEvents/mouse-click-events-are-pointer-events.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<div id="target" style="width: 100px; height: 100px"></div>
+<script>
+ test(() => {
+ const target = document.getElementById("target");
+ for (const type of ["pointerdown", "click", "auxclick", "contextmenu"]) {
+ target.addEventListener(type, event => {
+ println(`${type}: ${event.constructor.name}, pointerId ${event.pointerId}, pointerType ${event.pointerType}, button ${event.button}, detail ${event.detail}, isPrimary ${event.isPrimary}, pressure ${event.pressure}, trusted ${event.isTrusted}`);
+ if (type === "contextmenu")
+ event.preventDefault();
+ });
+ }
+
+ println("Primary button:");
+ internals.click(50, 50);
+ println("Primary button, second click:");
+ internals.click(50, 50, 2);
+ println("Middle button:");
+ internals.click(50, 50, 1, internals.BUTTON_MIDDLE);
+ println("Secondary button:");
+ internals.click(50, 50, 1, internals.BUTTON_RIGHT);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/pointerevents/pointerevent_click_is_a_pointerevent.html b/Tests/LibWeb/Text/input/wpt-import/pointerevents/pointerevent_click_is_a_pointerevent.html
new file mode 100644
index 00000000000..ccd5b540c29
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/pointerevents/pointerevent_click_is_a_pointerevent.html
@@ -0,0 +1,125 @@
+<!DOCTYPE HTML>
+<title>click is a PointerEvent</title>
+<meta name="variant" content="?mouse">
+<meta name="variant" content="?pen">
+<meta name="variant" content="?touch">
+<link rel="help" href="https://github.com/w3c/pointerevents/pull/317">
+<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="pointerevent_support.js"></script>
+
+<input id="target" style="margin: 20px">
+
+<iframe src="resources/minimal.html" height="100" width="100"></iframe>
+
+<script>
+'use strict';
+const pointer_type = location.search.substring(1);
+let subframe_loaded = getMessageData("subframe-loaded", frames[0]);
+
+function assertClickProperties(
+ click_event, window_object, pointerdown_event, pointerup_event) {
+ assert_equals(click_event.constructor, window_object.PointerEvent,
+ "click should use a PointerEvent constructor");
+ assert_true(click_event instanceof window_object.PointerEvent,
+ "click should be a PointerEvent instance");
+ assert_equals(click_event.composed, true, "click.composed should be true");
+
+ if (pointerdown_event) {
+ assert_equals(click_event.pointerId, pointerdown_event.pointerId,
+ "click.pointerId should match pointerdown.pointerId");
+ assert_equals(click_event.pointerType, pointerdown_event.pointerType,
+ "click.pointerType should match pointerdown.pointerType");
+ }
+
+ if (pointerup_event) {
+ assert_equals(click_event.pointerId, pointerup_event.pointerId,
+ "click.pointerId should match pointerup.pointerId");
+ assert_equals(click_event.pointerType, pointerup_event.pointerType,
+ "click.pointerType should match pointerup.pointerType");
+ }
+}
+
+promise_test(async test => {
+ const target = document.getElementById("target");
+
+ let pointerdown_prevented = preventDefaultPointerdownOnce(target, test);
+
+ let pointerdown_promise = getEvent("pointerdown", target, test);
+ let pointerup_promise = getEvent("pointerup", target, test);
+ let click_promise = getEvent("click", target, test);
+
+ await clickInTarget(pointer_type, target);
+
+ await pointerdown_prevented;
+ let pointerdown_event = await pointerdown_promise;
+ let pointerup_event = await pointerup_promise;
+ let click_event = await click_promise;
+
+ assertClickProperties(click_event, this, pointerdown_event, pointerup_event);
+}, "click using " + pointer_type + " is a PointerEvent with correct properties");
+
+promise_test(async test => {
+ const target = document.getElementById("target");
+
+ let click_promise = getEvent("click", target, test);
+ await clickInTarget(pointer_type, target);
+
+ let click_event = await click_promise;
+
+ assertClickProperties(click_event, this);
+ assert_not_equals(click_event.pointerId, -1,
+ "click.pointerId should not be -1");
+}, "click using " + pointer_type + " is a PointerEvent with correct properties"
+ + " when no other PointerEvent listeners are present");
+
+// Run this part of the test only once, since it doesn't rely on the pointer_type.
+if (pointer_type == "mouse") {
+ promise_test(async test => {
+ const target = document.getElementById("target");
+ let click_promise = getEvent("click", target, test);
+ target.click();
+ let click_event = await click_promise;
+ assert_equals(click_event.pointerId, -1,
+ "click.pointerId should be -1");
+
+ target.type = "button";
+ target.focus();
+ click_promise = getEvent("click", target, test);
+ // Press enter
+ let actions = new test_driver.Actions()
+ .keyDown("\uE007")
+ .keyUp("\uE007");
+ await actions.send();
+ click_event = await click_promise;
+ assertClickProperties(click_event, this);
+ assert_equals(click_event.pointerId, -1,
+ "click.pointerId should be -1");
+ }, "click using " + pointer_type + " is a PointerEvent with correct properties"
+ + " using non-pointing device");
+}
+
+promise_test(async test => {
+ // This subtest must be run last as workaround for a WebKit issue where webdriver
+ // fails to correctly direct focus after clicking outside of the frame. This bug
+ // does not occur during normal browsing. https://webkit.org/b/298676
+ await subframe_loaded;
+
+ const target = frames[0];
+ let pointerdown_promise = getEvent("pointerdown", target, test);
+ let pointerup_promise = getEvent("pointerup", target, test);
+ let click_promise = getEvent("click", target, test);
+
+ await clickInTarget(pointer_type, frames[0].document.body);
+
+ let pointerdown_event = await pointerdown_promise;
+ let pointerup_event = await pointerup_promise;
+ let click_event = await click_promise;
+
+ assertClickProperties(click_event, frames[0], pointerdown_event, pointerup_event);
+}, "click using " + pointer_type + " is a PointerEvent with correct properties"
+ + " in a subframe");
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/pointerevents/pointerevent_click_is_a_pointerevent_multiple_clicks.html b/Tests/LibWeb/Text/input/wpt-import/pointerevents/pointerevent_click_is_a_pointerevent_multiple_clicks.html
new file mode 100644
index 00000000000..cd0cf504a10
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/pointerevents/pointerevent_click_is_a_pointerevent_multiple_clicks.html
@@ -0,0 +1,98 @@
+<!DOCTYPE HTML>
+<title>click is a PointerEvent</title>
+<meta name="variant" content="?mouse">
+<meta name="variant" content="?pen">
+<meta name="variant" content="?touch">
+<link rel="help" href="https://github.com/w3c/pointerevents/pull/317">
+<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>
+
+<input id="target" style="margin: 20px">
+
+<script>
+'use strict';
+let target = document.getElementById("target");
+let pointerId_one = 0;
+let pointerType_one = "";
+let pointerId_two = 0;
+let pointerType_two = "";
+let pointerId_three = 0;
+let pointerType_three = "";
+let inputSource = location.search.substring(1);
+const phase_one = 1;
+const phase_two = 2;
+const phase_three = 3;
+let pointerdown_phase = phase_one;
+let click_phase = phase_one;
+
+target.addEventListener("pointerdown", (e)=>{
+ if(pointerdown_phase === phase_one){
+ pointerdown_phase = phase_two;
+ pointerId_one = e.pointerId;
+ pointerType_one = e.pointerType;
+ }else if(pointerdown_phase === phase_two){
+ pointerdown_phase = phase_three;
+ pointerId_two = e.pointerId;
+ pointerType_two = e.pointerType;
+ }else if(pointerdown_phase === phase_three){
+ pointerId_three = e.pointerId;
+ pointerType_three = e.pointerType;
+ }
+});
+
+function test_pointer(e, pointerId, pointerType, click_phase){
+ assert_equals(e.constructor, window.PointerEvent, "click should use a PointerEvent constructor in phase " + click_phase);
+ assert_true(e instanceof PointerEvent, "click should be a PointerEvent in phase " + click_phase);
+ assert_equals(e.pointerId, pointerId, "click's pointerId should match the pointerId of the pointer event that triggers it in phase " + click_phase);
+ assert_equals(e.pointerType, pointerType, "click's pointerType should match the pointerType of the pointer event that triggers it in phase " + click_phase);
+}
+
+function testFunction(test){
+ return test.step_func(e=>{
+ if(click_phase === phase_one){
+ test_pointer(e, pointerId_one, pointerType_one, click_phase);
+ click_phase = phase_two;
+ }else if(click_phase === phase_two){
+ test_pointer(e, pointerId_two, pointerType_two, click_phase);
+ click_phase = phase_three;
+ }else if(click_phase === phase_three)
+ test_pointer(e, pointerId_three, pointerType_three, click_phase);
+ });
+}
+
+function run_test(pointerType){
+ promise_test((test) => new Promise((resolve, reject) => {
+ const testPointer = pointerType + "TestPointer";
+ let clickFunc = testFunction(test);
+ test.add_cleanup(() => {
+ target.removeEventListener("click", clickFunc);
+ pointerId_one = 0;
+ pointerType_one = "";
+ pointerId_two = 0;
+ pointerType_two = "";
+ pointerId_three = 0;
+ pointerType_three = "";
+ pointerdown_phase = phase_one;
+ click_phase = phase_one;
+ });
+ target.addEventListener("click", clickFunc);
+ let eventWatcher = new EventWatcher(test, target, ["click"]);
+ let actions = new test_driver.Actions();
+ actions = actions
+ .addPointer(testPointer, pointerType)
+ .pointerMove(0,0, {origin:target, sourceName:testPointer})
+ .pointerDown({sourceName:testPointer})
+ .pointerUp({sourceName:testPointer})
+ .pointerDown({sourceName:testPointer})
+ .pointerUp({sourceName:testPointer})
+ .pointerDown({sourceName:testPointer})
+ .pointerUp({sourceName:testPointer});
+ Promise.all([eventWatcher.wait_for(["click", "click", "click"]), actions.send()]).then(()=>resolve());
+ }), "click using " + pointerType + " is a PointerEvent");
+}
+
+run_test(inputSource);
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/pointerevents/resources/minimal.html b/Tests/LibWeb/Text/input/wpt-import/pointerevents/resources/minimal.html
new file mode 100644
index 00000000000..9402b95cb17
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/pointerevents/resources/minimal.html
@@ -0,0 +1,4 @@
+<body>Minimal HTML</body>
+<script>
+ parent.postMessage({"type": "subframe-loaded"}, "*");
+</script>