Skip to content

Truly independent web browser

LibWeb: Let middle-button autoscroll follow the pointer across documents

sideshowbarker7c5eba773e44
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp
index 7b1d77cd6ed..d2e06637125 100644
--- a/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Libraries/LibWeb/Page/EventHandler.cpp
@@ -556,7 +556,7 @@ EventResult EventHandler::handle_mousedown(CSSPixelPoint visual_viewport_positio
return EventResult::Accepted;
if (!pressed_on_chrome)
- run_mousedown_default_actions(read, *document, visual_viewport_position, button, modifiers, click_count);
+ run_mousedown_default_actions(read, *document, visual_viewport_position, screen_position, button, modifiers, click_count);
return EventResult::Handled;
}
@@ -781,16 +781,13 @@ EventResult EventHandler::handle_mousemove(CSSPixelPoint visual_viewport_positio
if (m_navigable->active_document() != document)
return result_of_move(EventResult::Accepted);
- if (!m_middle_button_scroll_handler && !is_handling_mouse_selection())
+ if (!is_handling_mouse_selection())
return result_of_move(EventResult::Handled);
document->update_layout(DOM::UpdateLayoutReason::EventHandlerHandleMouseMove);
if (!has_committed_root_box())
return result_of_move(EventResult::Accepted);
- if (m_middle_button_scroll_handler)
- m_middle_button_scroll_handler->update_mouse_position(visual_viewport_position);
-
// https://w3c.github.io/uievents/#event-type-mousemove
// NB: The event has no default action, so a page that cancels it leaves a drag going.
update_mouse_selection(read, visual_viewport_position);
@@ -3613,12 +3610,15 @@ static bool is_inside_button(GC::Ptr<DOM::Node const> node)
return false;
}
-void EventHandler::run_mousedown_default_actions(Layout::BegunRead const& read, DOM::Document& document, CSSPixelPoint visual_viewport_position, unsigned button, unsigned modifiers, int click_count)
+void EventHandler::run_mousedown_default_actions(Layout::BegunRead const& read, DOM::Document& document, CSSPixelPoint visual_viewport_position, CSSPixelPoint screen_position, unsigned button, unsigned modifiers, int click_count)
{
+ // NB: A press that ends a middle button scroll has no default actions, whichever document gets it.
if (m_middle_button_scroll_handler) {
stop_middle_button_scroll();
return;
}
+ if (m_navigable->page().press_ends_a_middle_button_scroll())
+ return;
if (button == UIEvents::MouseButton::Middle) {
if (!m_navigable->page().enable_autoscroll())
@@ -3636,8 +3636,10 @@ void EventHandler::run_mousedown_default_actions(Layout::BegunRead const& read,
}
if (auto* hit_layout_node = hit->layout_node(read)) {
- if (auto container = MiddleButtonScrollHandler::find_scrollable_ancestor(document, *hit_layout_node))
- m_middle_button_scroll_handler = make<MiddleButtonScrollHandler>(*container, visual_viewport_position);
+ if (auto container = MiddleButtonScrollHandler::find_scrollable_ancestor(document, *hit_layout_node)) {
+ m_middle_button_scroll_handler = make<MiddleButtonScrollHandler>(*container, visual_viewport_position, screen_position);
+ m_navigable->page().set_middle_button_scrolling_navigable({}, m_navigable);
+ }
}
return;
@@ -6115,6 +6117,27 @@ void EventHandler::stop_middle_button_scroll()
return;
m_middle_button_scroll_handler->request_indicator_repaint();
m_middle_button_scroll_handler = nullptr;
+ if (m_navigable->page().middle_button_scrolling_navigable().ptr() == m_navigable.ptr())
+ m_navigable->page().set_middle_button_scrolling_navigable({}, nullptr);
+}
+
+void EventHandler::update_middle_button_scroll(Badge<Page>, CSSPixelPoint screen_position)
+{
+ if (m_middle_button_scroll_handler)
+ m_middle_button_scroll_handler->update_mouse_screen_position(screen_position);
+}
+
+// A press anywhere ends a middle button scroll.
+void EventHandler::end_middle_button_scroll_for_press(Badge<Page>)
+{
+ stop_middle_button_scroll();
+}
+
+// So does the release of the middle button that a scroll was dragged with.
+void EventHandler::end_middle_button_scroll_after_release_elsewhere(Badge<Page>, u32 button)
+{
+ if (button == UIEvents::MouseButton::Middle && m_middle_button_scroll_handler && m_middle_button_scroll_handler->mouse_has_moved_beyond_dead_zone())
+ stop_middle_button_scroll();
}
void EventHandler::release_held_scroll_key()
diff --git a/Libraries/LibWeb/Page/EventHandler.h b/Libraries/LibWeb/Page/EventHandler.h
index 8e08711bc34..20b1391bcbe 100644
--- a/Libraries/LibWeb/Page/EventHandler.h
+++ b/Libraries/LibWeb/Page/EventHandler.h
@@ -166,6 +166,10 @@ public:
void reset_mouse_input_tracking(Badge<Page>);
void reset_hover_for_document_replacement(Badge<HTML::LocalNavigable>);
+ void update_middle_button_scroll(Badge<Page>, CSSPixelPoint screen_position);
+ void end_middle_button_scroll_for_press(Badge<Page>);
+ void end_middle_button_scroll_after_release_elsewhere(Badge<Page>, u32 button);
+
Optional<MiddleButtonScrollHandler&> middle_button_scroll_handler() const
{
if (m_middle_button_scroll_handler)
@@ -270,7 +274,7 @@ private:
Optional<Target> target_for_mouse_position(CSSPixelPoint position, Optional<i64> visual_animation_sample_time_nanoseconds = {});
GC::Ptr<DOM::Node> focus_candidate_for_position(Layout::BegunRead const& read, CSSPixelPoint) const;
- void run_mousedown_default_actions(Layout::BegunRead const& read, DOM::Document&, CSSPixelPoint visual_viewport_position, unsigned button, unsigned modifiers, int click_count);
+ void run_mousedown_default_actions(Layout::BegunRead const& read, DOM::Document&, CSSPixelPoint visual_viewport_position, CSSPixelPoint screen_position, unsigned button, unsigned modifiers, int click_count);
void run_activation_behavior(DOM::Node const&, unsigned button, unsigned modifiers);
void maybe_show_context_menu(GC::Ref<DOM::Node>, MouseEventCoordinates const&, CSSPixelPoint screen_position, CSSPixelPoint viewport_position, unsigned buttons, unsigned modifiers);
diff --git a/Libraries/LibWeb/Page/MiddleButtonScrollHandler.cpp b/Libraries/LibWeb/Page/MiddleButtonScrollHandler.cpp
index 24884e16d34..379e5e7cf65 100644
--- a/Libraries/LibWeb/Page/MiddleButtonScrollHandler.cpp
+++ b/Libraries/LibWeb/Page/MiddleButtonScrollHandler.cpp
@@ -8,11 +8,13 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/HTML/LocalNavigable.h>
+#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Page/AutoScrollHandler.h>
#include <LibWeb/Page/MiddleButtonScrollHandler.h>
#include <LibWeb/Painting/BoxViews.h>
+#include <LibWeb/Painting/Scrolling.h>
namespace Web {
@@ -21,10 +23,11 @@ static constexpr double SPEED_FACTOR = 5.0;
static constexpr double MAX_SPEED_PER_SECOND = 5000.0;
static constexpr double MAX_FRAME_INTERVAL_MS = 100.0;
-MiddleButtonScrollHandler::MiddleButtonScrollHandler(DOM::Element& container, CSSPixelPoint origin)
+MiddleButtonScrollHandler::MiddleButtonScrollHandler(DOM::Element& container, CSSPixelPoint origin, CSSPixelPoint screen_origin)
: m_container_element(container)
, m_origin(origin)
- , m_mouse_position(origin)
+ , m_screen_origin(screen_origin)
+ , m_mouse_screen_position(screen_origin)
{
request_indicator_repaint();
}
@@ -52,24 +55,50 @@ GC::Ptr<DOM::Element> MiddleButtonScrollHandler::find_scrollable_ancestor(DOM::D
return element;
}
+ auto const* viewport = document.layout_node(layout_node.held_read());
+ auto document_can_scroll = viewport && Painting::could_be_scrolled_by_wheel_event(*viewport);
+
if (auto* containing_block = layout_node.containing_block(); containing_block) {
- if (auto container = AutoScrollHandler::find_scrollable_ancestor(*containing_block))
+ if (auto container = AutoScrollHandler::find_scrollable_ancestor(*containing_block); container && (document_can_scroll || container != document.scrolling_element()))
return container;
}
+ // A nested document that can't scroll hands the scroll to the document it's nested in, from its container on.
+ if (!document_can_scroll) {
+ if (auto navigable = document.navigable(); navigable && navigable->container()) {
+ auto& container = *navigable->container();
+ auto& parent_document = container.document();
+ Layout::ForcedReadScope read { parent_document };
+ parent_document.update_layout(DOM::UpdateLayoutReason::EventHandlerHandleMouseDown);
+ if (auto* container_layout_node = container.layout_node(read))
+ return find_scrollable_ancestor(parent_document, *container_layout_node);
+ }
+ }
+
if (auto scrolling_element = document.scrolling_element())
return const_cast<DOM::Element*>(scrolling_element.ptr());
return {};
}
+// NB: A drag out of the dead zone counts as soon as the pointer gets there, so that releasing the button ends the
+// scroll even before a rendering update has scrolled anything.
+void MiddleButtonScrollHandler::update_mouse_screen_position(CSSPixelPoint screen_position)
+{
+ m_mouse_screen_position = screen_position;
+ auto distance_x = (m_mouse_screen_position.x() - m_screen_origin.x()).to_double();
+ auto distance_y = (m_mouse_screen_position.y() - m_screen_origin.y()).to_double();
+ if (AK::hypot(distance_x, distance_y) >= DEAD_ZONE_RADIUS)
+ m_mouse_has_moved_beyond_dead_zone = true;
+}
+
void MiddleButtonScrollHandler::perform_tick(double frame_timestamp)
{
auto elapsed_ms = clamp(frame_timestamp - m_last_frame_time.value_or(frame_timestamp), 0.0, MAX_FRAME_INTERVAL_MS);
m_last_frame_time = frame_timestamp;
- auto distance_x = (m_mouse_position.x() - m_origin.x()).to_double();
- auto distance_y = (m_mouse_position.y() - m_origin.y()).to_double();
+ auto distance_x = (m_mouse_screen_position.x() - m_screen_origin.x()).to_double();
+ auto distance_y = (m_mouse_screen_position.y() - m_screen_origin.y()).to_double();
if (auto distance = AK::hypot(distance_x, distance_y); distance < DEAD_ZONE_RADIUS)
return;
diff --git a/Libraries/LibWeb/Page/MiddleButtonScrollHandler.h b/Libraries/LibWeb/Page/MiddleButtonScrollHandler.h
index fc9104ca583..0f2389103c3 100644
--- a/Libraries/LibWeb/Page/MiddleButtonScrollHandler.h
+++ b/Libraries/LibWeb/Page/MiddleButtonScrollHandler.h
@@ -19,14 +19,14 @@ class MiddleButtonScrollHandler {
public:
AK_ALLOC_WITH_KMALLOC;
- MiddleButtonScrollHandler(DOM::Element& container, CSSPixelPoint origin);
+ MiddleButtonScrollHandler(DOM::Element& container, CSSPixelPoint origin, CSSPixelPoint screen_origin);
~MiddleButtonScrollHandler();
void visit_edges(JS::Cell::Visitor&) const;
static GC::Ptr<DOM::Element> find_scrollable_ancestor(DOM::Document&, Layout::Node&);
- void update_mouse_position(CSSPixelPoint position) { m_mouse_position = position; }
+ void update_mouse_screen_position(CSSPixelPoint screen_position);
void perform_tick(double frame_timestamp);
void request_indicator_repaint();
@@ -36,7 +36,11 @@ public:
private:
GC::Ref<DOM::Element> m_container_element;
CSSPixelPoint m_origin;
- CSSPixelPoint m_mouse_position;
+
+ // The speed follows the pointer's distance from where the scroll started, measured on the screen: Wherever the
+ // pointer moves (over a nested document, e.g.), its screen position is known.
+ CSSPixelPoint m_screen_origin;
+ CSSPixelPoint m_mouse_screen_position;
Optional<double> m_last_frame_time;
CSSPixelPoint m_fractional_delta;
OwnPtr<HTML::UserScrollGestureHold> m_scroll_gesture_hold;
diff --git a/Libraries/LibWeb/Page/Page.cpp b/Libraries/LibWeb/Page/Page.cpp
index 35db83a231b..eebac73a8c7 100644
--- a/Libraries/LibWeb/Page/Page.cpp
+++ b/Libraries/LibWeb/Page/Page.cpp
@@ -522,7 +522,11 @@ EventResult Page::handle_mouseup(HTML::LocalNavigable& root, DevicePixelPoint po
navigable->event_handler().reset_mouse_input_tracking({});
}
};
- return root.event_handler().handle_mouseup(device_to_css_point(position), device_to_css_point(screen_position), button, buttons, modifiers, remote_target);
+ GC::Ptr<HTML::LocalNavigable> middle_button_scrolling_navigable = m_middle_button_scrolling_navigable.ptr();
+ auto result = root.event_handler().handle_mouseup(device_to_css_point(position), device_to_css_point(screen_position), button, buttons, modifiers, remote_target);
+ if (middle_button_scrolling_navigable && !middle_button_scrolling_navigable->has_been_destroyed())
+ middle_button_scrolling_navigable->event_handler().end_middle_button_scroll_after_release_elsewhere({}, button);
+ return result;
}
EventResult Page::handle_mouseup(DevicePixelPoint position, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers)
@@ -537,7 +541,15 @@ EventResult Page::handle_mousedown(HTML::LocalNavigable& root, DevicePixelPoint
navigable->event_handler().reset_mouse_input_tracking({});
m_mouse_event_tracking_navigable = nullptr;
}
- return root.event_handler().handle_mousedown(device_to_css_point(position), device_to_css_point(screen_position), button, buttons, modifiers, click_count, scrollbar_dragged_by_compositor, remote_target);
+ // NB: A press anywhere, in any document, ends a middle button scroll. It still goes where it's aimed, but it has no
+ // default actions there, so it can't start a scroll of its own.
+ GC::Ptr<HTML::LocalNavigable> middle_button_scrolling_navigable = m_middle_button_scrolling_navigable.ptr();
+ m_press_ends_a_middle_button_scroll = middle_button_scrolling_navigable && !middle_button_scrolling_navigable->has_been_destroyed();
+ auto result = root.event_handler().handle_mousedown(device_to_css_point(position), device_to_css_point(screen_position), button, buttons, modifiers, click_count, scrollbar_dragged_by_compositor, remote_target);
+ if (m_press_ends_a_middle_button_scroll && !middle_button_scrolling_navigable->has_been_destroyed())
+ middle_button_scrolling_navigable->event_handler().end_middle_button_scroll_for_press({});
+ m_press_ends_a_middle_button_scroll = false;
+ return result;
}
EventResult Page::handle_mousedown(DevicePixelPoint position, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, int click_count)
@@ -555,8 +567,16 @@ void Page::set_hover_reporting_navigable(Badge<EventHandler>, GC::Ptr<HTML::Loca
m_hover_reporting_navigable = navigable;
}
+void Page::set_middle_button_scrolling_navigable(Badge<EventHandler>, GC::Ptr<HTML::LocalNavigable> navigable)
+{
+ m_middle_button_scrolling_navigable = navigable;
+}
+
EventResult Page::handle_mousemove(HTML::LocalNavigable& root, DevicePixelPoint position, DevicePixelPoint screen_position, unsigned buttons, unsigned modifiers, Optional<RemoteInputEventTarget>* remote_target)
{
+ // A middle button scroll follows the pointer wherever it moves, whichever document the move goes to.
+ if (auto navigable = m_middle_button_scrolling_navigable; navigable && !navigable->has_been_destroyed())
+ navigable->event_handler().update_middle_button_scroll({}, device_to_css_point(screen_position));
return root.event_handler().handle_mousemove(device_to_css_point(position), device_to_css_point(screen_position), buttons, modifiers, remote_target);
}
diff --git a/Libraries/LibWeb/Page/Page.h b/Libraries/LibWeb/Page/Page.h
index a9bc5371907..cf4566182f7 100644
--- a/Libraries/LibWeb/Page/Page.h
+++ b/Libraries/LibWeb/Page/Page.h
@@ -291,6 +291,9 @@ public:
GC::Ptr<HTML::LocalNavigable> hover_reporting_navigable() const { return m_hover_reporting_navigable.ptr(); }
void set_hover_reporting_navigable(Badge<EventHandler>, GC::Ptr<HTML::LocalNavigable>);
+ void set_middle_button_scrolling_navigable(Badge<EventHandler>, GC::Ptr<HTML::LocalNavigable>);
+ GC::Ptr<HTML::LocalNavigable> middle_button_scrolling_navigable() const { return m_middle_button_scrolling_navigable.ptr(); }
+ bool press_ends_a_middle_button_scroll() const { return m_press_ends_a_middle_button_scroll; }
Gfx::Cursor current_cursor() const { return m_cursor->current(); }
PageCursor& cursor() { return *m_cursor; }
@@ -582,6 +585,11 @@ private:
// once passed through, e.g.) leaves the report standing.
GC::Weak<HTML::LocalNavigable> m_hover_reporting_navigable;
+ // The navigable whose middle button scroll is running. It hears of every mouse event, wherever the pointer is.
+ GC::Weak<HTML::LocalNavigable> m_middle_button_scrolling_navigable;
+ // Whether the press being handled ends a middle button scroll, and so has no default actions.
+ bool m_press_ends_a_middle_button_scroll { false };
+
GC::Ptr<HTML::Navigable> m_top_level_traversable;
OwnPtr<Compositor::CompositorContextHandle> m_retired_page_compositor_context;
Vector<GC::Ref<HTML::Navigable>> m_navigables_being_destroyed;
diff --git a/Tests/LibWeb/Text/expected/UIEvents/middle-button-autoscroll-started-over-a-nested-document.txt b/Tests/LibWeb/Text/expected/UIEvents/middle-button-autoscroll-started-over-a-nested-document.txt
new file mode 100644
index 00000000000..467521228a9
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/UIEvents/middle-button-autoscroll-started-over-a-nested-document.txt
@@ -0,0 +1,10 @@
+#iframe: scrolled with the pointer away from the start: true
+#iframe: stopped with the pointer back over the start: true
+#iframe: stopped by a press outside it: true
+#object: scrolled with the pointer away from the start: true
+#object: stopped with the pointer back over the start: true
+#object: stopped by a press outside it: true
+#scrollable-iframe: scrolled itself true, and the page false
+#iframe: a drag released outside it stops: true
+#iframe: a drag released before the next frame stops: true
+#iframe: a middle press over #object ends the scroll and starts none: true
diff --git a/Tests/LibWeb/Text/input/UIEvents/middle-button-autoscroll-started-over-a-nested-document.html b/Tests/LibWeb/Text/input/UIEvents/middle-button-autoscroll-started-over-a-nested-document.html
new file mode 100644
index 00000000000..4317a9952be
--- /dev/null
+++ b/Tests/LibWeb/Text/input/UIEvents/middle-button-autoscroll-started-over-a-nested-document.html
@@ -0,0 +1,104 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ body { margin: 0; height: 6000px; }
+ .row { height: 300px; }
+ iframe, object { display: block; width: 200px; height: 100px; border: 0; }
+</style>
+<div class="row"><iframe id="iframe" srcdoc="<p>frame</p>"></iframe></div>
+<div class="row"><iframe id="scrollable-iframe" srcdoc="<body style='height: 3000px'>tall</body>"></iframe></div>
+<div class="row"><object id="object" type="image/svg+xml" data="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='100'%3E%3Crect width='200' height='100' fill='green'/%3E%3C/svg%3E" width="200" height="100"></object></div>
+<script>
+ // A middle button scroll started over a nested document follows the pointer wherever it moves, and a press
+ // anywhere, or the release of a drag, ends it.
+ promiseTest(async () => {
+ await new Promise(resolve => document.readyState === "complete" ? resolve() : addEventListener("load", resolve));
+ const frames = async count => {
+ for (let i = 0; i < count; i++) {
+ await new Promise(resolve => setTimeout(resolve, 50));
+ await animationFrame();
+ }
+ };
+ async function startOver(id) {
+ const element = document.getElementById(id);
+ element.scrollIntoView();
+ scrollBy(0, -20);
+ await animationFrame();
+ const rect = element.getBoundingClientRect();
+ return [rect.left + 50, rect.top + 50];
+ }
+
+ for (const id of ["iframe", "object"]) {
+ const [x, y] = await startOver(id);
+ const start = scrollY;
+ internals.mouseDown(x, y, 1, internals.BUTTON_MIDDLE);
+ internals.mouseUp(x, y, internals.BUTTON_MIDDLE);
+ internals.mouseMove(x + 400, y + 100);
+ await frames(3);
+ println(`#${id}: scrolled with the pointer away from the start: ${scrollY > start}`);
+ internals.mouseMove(x, y);
+ await frames(1);
+ const back = scrollY;
+ await frames(3);
+ println(`#${id}: stopped with the pointer back over the start: ${scrollY === back}`);
+ internals.mouseMove(x + 400, y + 100);
+ await frames(1);
+ internals.mouseDown(x + 400, y + 100, 1, internals.BUTTON_LEFT);
+ internals.mouseUp(x + 400, y + 100, internals.BUTTON_LEFT);
+ const pressed = scrollY;
+ await frames(3);
+ println(`#${id}: stopped by a press outside it: ${scrollY === pressed}`);
+ }
+
+ // A nested document that can scroll scrolls itself, and the page stays put.
+ {
+ const iframe = document.getElementById("scrollable-iframe");
+ const [x, y] = await startOver("scrollable-iframe");
+ const start = scrollY;
+ internals.mouseDown(x, y, 1, internals.BUTTON_MIDDLE);
+ internals.mouseUp(x, y, internals.BUTTON_MIDDLE);
+ internals.mouseMove(x + 400, y + 100);
+ await frames(3);
+ internals.mouseDown(x + 400, y + 100, 1, internals.BUTTON_LEFT);
+ internals.mouseUp(x + 400, y + 100, internals.BUTTON_LEFT);
+ println(`#scrollable-iframe: scrolled itself ${iframe.contentWindow.scrollY > 0}, and the page ${scrollY !== start}`);
+ }
+
+ const [x, y] = await startOver("iframe");
+ internals.mouseDown(x, y, 1, internals.BUTTON_MIDDLE);
+ internals.mouseMove(x + 400, y + 100);
+ await frames(3);
+ internals.mouseUp(x + 400, y + 100, internals.BUTTON_MIDDLE);
+ const released = scrollY;
+ await frames(3);
+ println(`#iframe: a drag released outside it stops: ${scrollY === released}`);
+
+ // So does a drag released before a rendering update has scrolled anything.
+ {
+ const [x, y] = await startOver("iframe");
+ internals.mouseDown(x, y, 1, internals.BUTTON_MIDDLE);
+ internals.mouseMove(x + 400, y + 100);
+ internals.mouseUp(x + 400, y + 100, internals.BUTTON_MIDDLE);
+ const released = scrollY;
+ await frames(3);
+ println(`#iframe: a drag released before the next frame stops: ${scrollY === released}`);
+ }
+
+ // A middle press in another nested document ends the scroll without starting one of its own.
+ {
+ const [x, y] = await startOver("iframe");
+ internals.mouseDown(x, y, 1, internals.BUTTON_MIDDLE);
+ internals.mouseUp(x, y, internals.BUTTON_MIDDLE);
+ internals.mouseMove(x + 400, y + 100);
+ await frames(2);
+ const object = document.getElementById("object").getBoundingClientRect();
+ internals.mouseDown(object.left + 50, object.top + 50, 1, internals.BUTTON_MIDDLE);
+ internals.mouseUp(object.left + 50, object.top + 50, internals.BUTTON_MIDDLE);
+ internals.mouseMove(object.left + 450, object.top + 150);
+ const pressed = scrollY;
+ await frames(3);
+ println(`#iframe: a middle press over #object ends the scroll and starts none: ${scrollY === pressed}`);
+ }
+
+ });
+</script>