LibWeb: Add Internals.middleClick

This simulates click of the middle mouse button, which is necessary for
testing whether the `auxevent` fires correctly.
This commit is contained in:
Tim Ledbetter 2024-06-21 22:35:12 +01:00 committed by Andreas Kling
parent 9220a89d2f
commit 728fca1b1f
Notes: sideshowbarker 2024-07-17 01:04:03 +09:00
3 changed files with 17 additions and 2 deletions

View file

@ -77,10 +77,20 @@ void Internals::commit_text()
}
void Internals::click(double x, double y)
{
click(x, y, UIEvents::MouseButton::Primary);
}
void Internals::middle_click(double x, double y)
{
click(x, y, UIEvents::MouseButton::Middle);
}
void Internals::click(double x, double y, UIEvents::MouseButton button)
{
auto& page = global_object().browsing_context()->page();
page.handle_mousedown({ x, y }, { x, y }, 1, 0, 0);
page.handle_mouseup({ x, y }, { x, y }, 1, 0, 0);
page.handle_mousedown({ x, y }, { x, y }, button, 0, 0);
page.handle_mouseup({ x, y }, { x, y }, button, 0, 0);
}
void Internals::move_pointer_to(double x, double y)

View file

@ -8,6 +8,7 @@
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Internals/InternalAnimationTimeline.h>
#include <LibWeb/UIEvents/MouseButton.h>
namespace Web::Internals {
@ -27,6 +28,7 @@ public:
void commit_text();
void click(double x, double y);
void middle_click(double x, double y);
void move_pointer_to(double x, double y);
void wheel(double x, double y, double delta_x, double delta_y);
@ -37,6 +39,8 @@ public:
private:
explicit Internals(JS::Realm&);
virtual void initialize(JS::Realm&) override;
void click(double x, double y, UIEvents::MouseButton);
};
}

View file

@ -13,6 +13,7 @@ interface Internals {
undefined commitText();
undefined click(double x, double y);
undefined middleClick(double x, double y);
undefined movePointerTo(double x, double y);
undefined wheel(double x, double y, double deltaX, double deltaY);