1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-01 11:15:37 +00:00

LibWeb: Add Internals.middleClick

This simulates click of the middle mouse button, which is necessary for
testing whether the `auxevent` fires correctly.

(cherry picked from commit 728fca1b1ffd8b472bc8524e5e8ec8443de011a5)
This commit is contained in:
Tim Ledbetter 2024-06-21 22:35:12 +01:00 committed by Nico Weber
parent 030ea71dff
commit 2554d766bc
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);