Lightpanda: the headless browser designed for AI and automation
refactor(input): group the touch state, resolve its frame in user_input
Adrià Arrufat5f2ebe55f2b5
diff --git a/src/browser/EventManager.zig b/src/browser/EventManager.zigindex b9fb5cc66..ffd9df821 100644--- a/src/browser/EventManager.zig+++ b/src/browser/EventManager.zig@@ -303,7 +303,9 @@ fn dispatchNode(self: *EventManager, target: *Node, event: *Event) !void {if (node_path_len > 0) {const last = path_buffer[node_path_len - 1];if (event._needs_retargeting) {- if (rootIsShadowRoot(getAdjustedTarget(event._dispatch_target, last))) {+ if (rootIsShadowRoot(getAdjustedTarget(event._dispatch_target, last)) or+ rootIsShadowRoot(getAdjustedTarget(original_touch, last)))+ {clear_targets = true;}}@@ -314,9 +316,6 @@ fn dispatchNode(self: *EventManager, target: *Node, event: *Event) !void {}}}- if (event._needs_retargeting and rootIsShadowRoot(getAdjustedTarget(original_touch, last))) {- clear_targets = true;- }}const path = path_buffer[0..path_len];diff --git a/src/browser/Frame.zig b/src/browser/Frame.zigindex 5e0294b0b..bffd3f428 100644--- a/src/browser/Frame.zig+++ b/src/browser/Frame.zig@@ -479,27 +479,8 @@ pub fn deinit(self: *Frame) void {// The Page outlives an iframe or popup that re-navigates: don't leave its// pointer state on this document's elements.+ user_input.forgetFrame(self);const page = self.page;- if (page.input_hover_target) |el| {- if (el.ownerFrame(self) == self) {- page.input_hover_target = null;- }- }- if (page.input_pointer.down_target) |el| {- if (el.ownerFrame(self) == self) {- page.input_pointer.reset();- }- }- if (page.input_touch_contact) |contact| {- if (contact.target.ownerFrame(self) == self) {- page.input_touch_contact = null;- }- }- if (page.input_last_tap) |tap| {- if (tap.pinned) |el| if (el.ownerFrame(self) == self) {- page.input_last_tap = null;- };- }if (comptime lp.IS_DEBUG) {log.debug(.frame, "frame.deinit", .{ .url = self.url, .type = self._type });diff --git a/src/browser/Page.zig b/src/browser/Page.zigindex 7ad042293..6a912f116 100644--- a/src/browser/Page.zig+++ b/src/browser/Page.zig@@ -196,11 +196,8 @@ input_modifiers: if (lp.build_config.wpt_extensions) @import("frame/user_input.z// The element the synthetic pointer is currently overinput_hover_target: ?*Element = null,-// The active touch contact; single-touch, so at most one.-input_touch_contact: ?@import("frame/user_input.zig").TouchContact = null,-input_touch_next_pointer_id: i32 = @import("frame/user_input.zig").first_touch_pointer_id,-// The last tap that activated, for counting the next one.-input_last_tap: ?@import("frame/user_input.zig").LastTap = null,+// Touch contact and tap state; see user_input.TouchInput.+input_touch: @import("frame/user_input.zig").TouchInput = .{},// Per-gesture button state for the synthetic mouse pointer; see// user_input.PointerButtons.diff --git a/src/browser/frame/user_input.zig b/src/browser/frame/user_input.zigindex b22a6cb58..33e981fa3 100644--- a/src/browser/frame/user_input.zig+++ b/src/browser/frame/user_input.zig@@ -59,10 +59,20 @@ const HoverContext = struct {y: f64 = 0,buttons: u16 = 0,modifiers: Modifiers = .{},- with_pointer: bool = true,fn emit(ctx: HoverContext, frame: *Frame, target: *Element, comptime suffix: []const u8, related: ?*Element, bubbling: bool) void {- dispatchBoundaryEvent(frame, target, "mouse" ++ suffix, "pointer" ++ suffix, related, bubbling, ctx);+ dispatchPointerBoundary(frame, target, "pointer" ++ suffix, related, bubbling, ctx);+ dispatchMouseBoundary(frame, target, "mouse" ++ suffix, related, bubbling, ctx);+ }+};++/// A touch's compatibility hover: the pointer half already fired with the+/// touch, so only the mouse half is left.+const CompatHover = struct {+ ctx: HoverContext,++ fn emit(self: CompatHover, frame: *Frame, target: *Element, comptime suffix: []const u8, related: ?*Element, bubbling: bool) void {+ dispatchMouseBoundary(frame, target, "mouse" ++ suffix, related, bubbling, self.ctx);}};@@ -70,14 +80,14 @@ const HoverContext = struct {// hovered item so that trasitions can fire the correct events. e.g. mouseout// bubbles up normally, but mouseleave will only fire on parents where the new// target isn't part of.-pub fn updateHoverTarget(frame: *Frame, to: ?*Element, ctx: HoverContext) void {+pub fn updateHoverTarget(frame: *Frame, to: ?*Element, emitter: anytype) void {const page = frame.page;const from = page.input_hover_target;if (from == to) {return;}page.input_hover_target = to;- dispatchBoundaryEvents(frame, from, to, ctx);+ dispatchBoundaryEvents(frame, from, to, emitter);}/// `emitter.emit` fires one boundary event, named by its suffix ("out",@@ -133,38 +143,38 @@ fn dispatchBoundaryEvents(frame: *Frame, from: ?*Element, to: ?*Element, emitter}}-// Fire a pointer/mouse event pair, e.g. pointerout + mouseout-fn dispatchBoundaryEvent(frame: *Frame, target: *Element, comptime mouse_typ: []const u8, comptime pointer_typ: []const u8, related: ?*Element, bubbling: bool, ctx: HoverContext) void {+fn dispatchPointerBoundary(frame: *Frame, target: *Element, comptime pointer_typ: []const u8, related: ?*Element, bubbling: bool, ctx: HoverContext) void {const modifiers = ctx.modifiers;const related_target = if (related) |r| r.asEventTarget() else null;+ const pointer_event = PointerEvent.initTrusted(pointer_typ, .{+ .bubbles = bubbling,+ .cancelable = bubbling,+ .composed = bubbling,+ .clientX = ctx.x,+ .clientY = ctx.y,+ // No button changed state: https://www.w3.org/TR/pointerevents3/#the-button-property+ .button = -1,+ .buttons = ctx.buttons,+ .pointerId = 1,+ .pointerType = "mouse",+ .isPrimary = true,+ .relatedTarget = related_target,+ .ctrlKey = modifiers.ctrl,+ .shiftKey = modifiers.shift,+ .altKey = modifiers.alt,+ .metaKey = modifiers.meta,+ }, frame) catch |err| {+ log.debug(.frame, "boundary pointer event", .{ .err = err, .type = pointer_typ });+ return;+ };+ frame._event_manager.dispatch(target.asEventTarget(), pointer_event.asEvent()) catch |err| {+ log.debug(.frame, "boundary pointer dispatch", .{ .err = err, .type = pointer_typ });+ };+}- if (ctx.with_pointer) {- const pointer_event = PointerEvent.initTrusted(pointer_typ, .{- .bubbles = bubbling,- .cancelable = bubbling,- .composed = bubbling,- .clientX = ctx.x,- .clientY = ctx.y,- // No button changed state: https://www.w3.org/TR/pointerevents3/#the-button-property- .button = -1,- .buttons = ctx.buttons,- .pointerId = 1,- .pointerType = "mouse",- .isPrimary = true,- .relatedTarget = related_target,- .ctrlKey = modifiers.ctrl,- .shiftKey = modifiers.shift,- .altKey = modifiers.alt,- .metaKey = modifiers.meta,- }, frame) catch |err| {- log.debug(.frame, "boundary pointer event", .{ .err = err, .type = pointer_typ });- return;- };- frame._event_manager.dispatch(target.asEventTarget(), pointer_event.asEvent()) catch |err| {- log.debug(.frame, "boundary pointer dispatch", .{ .err = err, .type = pointer_typ });- };- }-+fn dispatchMouseBoundary(frame: *Frame, target: *Element, comptime mouse_typ: []const u8, related: ?*Element, bubbling: bool, ctx: HoverContext) void {+ const modifiers = ctx.modifiers;+ const related_target = if (related) |r| r.asEventTarget() else null;const mouse_event = MouseEvent.initTrusted(comptime .wrap(mouse_typ), .{.bubbles = bubbling,.cancelable = bubbling,@@ -356,7 +366,7 @@ fn commonClickTarget(down: *Element, up: *Element) *Element {}pub fn moveSequence(frame: *Frame, target: *Element, g: Gesture) !void {- updateHoverTarget(frame, target, .{ .x = g.x, .y = g.y, .buttons = g.buttons_down, .modifiers = g.modifiers });+ updateHoverTarget(frame, target, HoverContext{ .x = g.x, .y = g.y, .buttons = g.buttons_down, .modifiers = g.modifiers });// A move changes no button: https://www.w3.org/TR/pointerevents3/#the-button-propertyvar pg = g;pg.button = -1;@@ -619,6 +629,8 @@ pub const TouchContact = struct {start: Touch.Point,pointer_id: i32,tap_count: u32 = 1,+ // WebDriver chose the target, which then stands in for every hit-test.+ pinned: bool = false,suppress_mouse: bool = false,start_prevented: bool = false,phase: Phase = .slop,@@ -641,11 +653,14 @@ pub const TouchContact = struct {/// A released contact reports a 1x1 point; a cancelled one keeps its/// geometry.- fn gesture(self: TouchContact, point: Touch.Point, phase: enum { down, up, cancel }, modifiers: Modifiers) Gesture {+ fn gesture(self: TouchContact, point: Touch.Point, phase: enum { down, move, up, cancel }, modifiers: Modifiers) Gesture {const released = phase == .up;return .{- .button = if (phase == .cancel) -1 else mouse_button.main,- .buttons_down = if (phase == .down) 1 else 0,+ .button = switch (phase) {+ .down, .up => mouse_button.main,+ .move, .cancel => -1,+ },+ .buttons_down = if (phase == .down or phase == .move) 1 else 0,.click_count = self.tap_count,.x = point.x,.y = point.y,@@ -687,6 +702,14 @@ pub const LastTap = struct {pinned: ?*Element,};+pub const TouchInput = struct {+ // Single-touch, so at most one.+ contact: ?TouchContact = null,+ next_pointer_id: i32 = first_touch_pointer_id,+ // The last tap that activated, for counting the next one.+ last_tap: ?LastTap = null,+};+const TouchDispatch = struct {modifiers: Modifiers = .{},// A scrolling contact's touch events aren't cancelable.@@ -696,6 +719,7 @@ const TouchDispatch = struct {/// Fires the touch event on `target` (no hit-test); returns whether/// preventDefault() cancelled it.fn dispatchTouchEvent(frame: *Frame, target: *Element, typ: TouchType, point: Touch.Point, opts: TouchDispatch) !bool {+ const owner = target.ownerFrame(frame) orelse frame;const event: *TouchEvent = try .initTrustedWithTouch(@tagName(typ), .{.bubbles = true,.composed = true,@@ -703,7 +727,7 @@ fn dispatchTouchEvent(frame: *Frame, target: *Element, typ: TouchType, point: To.ctrlKey = opts.modifiers.ctrl,.metaKey = opts.modifiers.meta,.shiftKey = opts.modifiers.shift,- }, target, point, frame);+ }, target, point, owner);// touchcancel is never cancelable per spec; the others follow the same// passive-listener-dependent rule as wheel (see EventManager).@@ -711,43 +735,45 @@ fn dispatchTouchEvent(frame: *Frame, target: *Element, typ: TouchType, point: Toevent.asEvent()._cancelable_unless_passive = true;}- return frame._event_manager.dispatchCancelable(target.asEventTarget(), event.asEvent());+ return owner._event_manager.dispatchCancelable(target.asEventTarget(), event.asEvent());}/// A point that misses every element falls back to the document element, as/// WebDriver's pointerMove does, rather than dropping the contact. `target`/// replaces the hit-test for WebDriver, whose actions have no viewport point.pub fn touchStart(frame: *Frame, target: ?*Element, point: Touch.Point, modifiers: Modifiers) !void {- const page = frame.page;- if (page.input_touch_contact != null) {+ const touch = &frame.page.input_touch;+ if (touch.contact != null) {return;}+ const owner = if (target) |el| el.ownerFrame(frame) orelse frame else frame;const resolved = target orelse- (try frame.window._document.elementFromPoint(point.x, point.y, frame)) orelse- frame.window._document.getDocumentElement() orelse return;+ (try owner.window._document.elementFromPoint(point.x, point.y, owner)) orelse+ owner.window._document.getDocumentElement() orelse return;if (comptime lp.IS_DEBUG) {log.debug(.frame, "frame touch", .{- .url = frame.url,+ .url = owner.url,.node = resolved,.x = point.x,.y = point.y,- .type = frame._type,+ .type = owner._type,});}var contact: TouchContact = .{.target = resolved,.point = point,.start = point,- .pointer_id = page.input_touch_next_pointer_id,- .tap_count = nextTapCount(page.input_last_tap, point, target),+ .pointer_id = touch.next_pointer_id,+ .tap_count = nextTapCount(touch.last_tap, point, target),+ .pinned = target != null,};- page.input_last_tap = null;- page.input_touch_next_pointer_id = if (contact.pointer_id == std.math.maxInt(i32)) first_touch_pointer_id else contact.pointer_id + 1;+ touch.last_tap = null;+ touch.next_pointer_id = if (contact.pointer_id == std.math.maxInt(i32)) first_touch_pointer_id else contact.pointer_id + 1;const g = contact.gesture(point, .down, modifiers);- dispatchBoundaryEvents(frame, null, resolved, TouchBoundary{ .g = g });- contact.suppress_mouse = try emitPointer(frame, resolved, "pointerdown", g, 0);- contact.start_prevented = try dispatchTouchEvent(frame, resolved, .touchstart, point, .{ .modifiers = modifiers });- page.input_touch_contact = contact;+ dispatchBoundaryEvents(owner, null, resolved, TouchBoundary{ .g = g });+ contact.suppress_mouse = try emitPointer(owner, resolved, "pointerdown", g, 0);+ contact.start_prevented = try dispatchTouchEvent(owner, resolved, .touchstart, point, .{ .modifiers = modifiers });+ touch.contact = contact;}/// Taps count 1, 2, 3, then start over, as in Chrome.@@ -767,8 +793,9 @@ fn nextTapCount(last_tap: ?LastTap, start: Touch.Point, pinned: ?*Element) u32 {/// A drag the page doesn't cancel scrolls: its touch events stop being/// cancelable, and where touch-action allows the pan the pointer is cancelled.pub fn touchMove(frame: *Frame, over: ?*Element, point: Touch.Point, modifiers: Modifiers) !void {- const page = frame.page;- var contact = page.input_touch_contact orelse return;+ const touch = &frame.page.input_touch;+ var contact = touch.contact orelse return;+ const owner = contact.target.ownerFrame(frame) orelse frame;contact.point = point;const dx = point.x - contact.start.x;const dy = point.y - contact.start.y;@@ -777,26 +804,24 @@ pub fn touchMove(frame: *Frame, over: ?*Element, point: Touch.Point, modifiers:if (leaves_slop) {contact.phase = .drag;}- var g = contact.gesture(point, .down, modifiers);- g.button = -1;if (contact.phase != .pan) {- _ = try emitPointer(frame, contact.target, "pointermove", g, 0);+ _ = try emitPointer(owner, contact.target, "pointermove", contact.gesture(point, .move, modifiers), 0);}if (contact.phase == .slop) {- page.input_touch_contact = contact;+ touch.contact = contact;return;}- const prevented = try dispatchTouchEvent(frame, contact.target, .touchmove, point, contact.dispatch(modifiers));+ const prevented = try dispatchTouchEvent(owner, contact.target, .touchmove, point, contact.dispatch(modifiers));if (leaves_slop and !prevented and !contact.start_prevented) {contact.phase = .scroll;- if (allowsPan(frame, contact.target, dx, dy)) {+ if (allowsPan(owner, contact.target, dx, dy)) {contact.phase = .pan;const cg = contact.gesture(point, .cancel, modifiers);- _ = try emitPointer(frame, contact.target, "pointercancel", cg, 0);- dispatchBoundaryEvents(frame, contact.target, null, TouchBoundary{ .g = cg });+ _ = try emitPointer(owner, contact.target, "pointercancel", cg, 0);+ dispatchBoundaryEvents(owner, contact.target, null, TouchBoundary{ .g = cg });}}- page.input_touch_contact = contact;+ touch.contact = contact;}/// Whether `target`'s effective touch-action allows a pan in the drag's@@ -816,65 +841,70 @@ pub fn touchHover(frame: *Frame, target: *Element, modifiers: Modifiers) !void {.button = -1,.modifiers = modifiers,.pointer_type = "touch",- .pointer_id = frame.page.input_touch_next_pointer_id,+ .pointer_id = frame.page.input_touch.next_pointer_id,}, 0);}/// Puppeteer sends the released point and Chrome dispatches there; Playwright/// sends none, so the stored contact is used. The compatibility mouse events-/// hit-test the release point; `compat_target` replaces that for WebDriver.-pub fn touchEnd(frame: *Frame, point: ?Touch.Point, modifiers: Modifiers, compat_target: ?*Element) !void {- const contact = frame.page.input_touch_contact orelse return;+/// hit-test the release point, unless WebDriver pinned the target.+pub fn touchEnd(frame: *Frame, point: ?Touch.Point, modifiers: Modifiers) !void {+ const touch = &frame.page.input_touch;+ const contact = touch.contact orelse return;+ const owner = contact.target.ownerFrame(frame) orelse frame;// Cleared before dispatch so a throwing listener can't leave a stale// contact blocking every later touchStart.- frame.page.input_touch_contact = null;+ touch.contact = null;+ const pinned: ?*Element = if (contact.pinned) contact.target else null;const lift = point orelse contact.point;const g = contact.gesture(lift, .up, modifiers);if (contact.phase != .pan) {- _ = try emitPointer(frame, contact.target, "pointerup", g, 0);- dispatchBoundaryEvents(frame, contact.target, null, TouchBoundary{ .g = g });+ _ = try emitPointer(owner, contact.target, "pointerup", g, 0);+ dispatchBoundaryEvents(owner, contact.target, null, TouchBoundary{ .g = g });}- const prevented = try dispatchTouchEvent(frame, contact.target, .touchend, lift, contact.dispatch(modifiers));+ const prevented = try dispatchTouchEvent(owner, contact.target, .touchend, lift, contact.dispatch(modifiers));if (contact.start_prevented or contact.phase != .slop or prevented) return;- frame.page.input_last_tap = .{+ touch.last_tap = .{.count = contact.tap_count,.x = contact.start.x,.y = contact.start.y,.released_ms = lp.datetime.milliTimestamp(.boot),- .pinned = compat_target,+ .pinned = pinned,};- var target = try touchCompatTarget(frame, lift, compat_target) orelse return;- updateHoverTarget(frame, target, .{ .x = lift.x, .y = lift.y, .modifiers = modifiers, .with_pointer = false });+ var target = try touchCompatTarget(owner, lift, pinned) orelse return;+ updateHoverTarget(owner, target, CompatHover{ .ctx = .{ .x = lift.x, .y = lift.y, .modifiers = modifiers } });if (contact.suppress_mouse) {- return mouseUpAndClick(frame, target, g, true, target);+ return mouseUpAndClick(owner, target, g, true, target);}// Each listener can replace the element under the finger, so every// compatibility event hit-tests again, as Chrome does.- target = try touchCompatTarget(frame, lift, compat_target) orelse return;- _ = try emitMouse(frame, target, "mousemove", g, 0);- const down_target = try touchCompatTarget(frame, lift, compat_target) orelse return;+ target = try touchCompatTarget(owner, lift, pinned) orelse return;+ _ = try emitMouse(owner, target, "mousemove", g, 0);+ const down_target = try touchCompatTarget(owner, lift, pinned) orelse return;var dg = g;dg.buttons_down = 1;- try mouseDown(frame, down_target, dg);- const up_target = try touchCompatTarget(frame, lift, compat_target) orelse return;+ try mouseDown(owner, down_target, dg);+ const up_target = try touchCompatTarget(owner, lift, pinned) orelse return;// Chrome drops the click when mousedown's target is removed before the// release.const click_target = if (down_target.asNode().isConnected()) commonClickTarget(down_target, up_target) else null;- try mouseUpAndClick(frame, up_target, g, false, click_target);+ try mouseUpAndClick(owner, up_target, g, false, click_target);}pub fn touchCancel(frame: *Frame, modifiers: Modifiers) !void {- const contact = frame.page.input_touch_contact orelse return;- frame.page.input_touch_contact = null;+ const touch = &frame.page.input_touch;+ const contact = touch.contact orelse return;+ const owner = contact.target.ownerFrame(frame) orelse frame;+ touch.contact = null;if (contact.phase != .pan) {const g = contact.gesture(contact.point, .cancel, modifiers);- _ = try emitPointer(frame, contact.target, "pointercancel", g, 0);- dispatchBoundaryEvents(frame, contact.target, null, TouchBoundary{ .g = g });+ _ = try emitPointer(owner, contact.target, "pointercancel", g, 0);+ dispatchBoundaryEvents(owner, contact.target, null, TouchBoundary{ .g = g });}- _ = try dispatchTouchEvent(frame, contact.target, .touchcancel, contact.point, .{ .modifiers = modifiers });+ _ = try dispatchTouchEvent(owner, contact.target, .touchcancel, contact.point, .{ .modifiers = modifiers });}fn touchCompatTarget(frame: *Frame, point: Touch.Point, pinned: ?*Element) !?*Element {@@ -882,6 +912,32 @@ fn touchCompatTarget(frame: *Frame, point: Touch.Point, pinned: ?*Element) !?*Elreturn frame.window._document.elementFromPoint(point.x, point.y, frame);}+/// Drops the page's input state on `frame`'s elements, which are going away.+pub fn forgetFrame(frame: *Frame) void {+ const page = frame.page;+ if (page.input_hover_target) |el| {+ if (el.ownerFrame(frame) == frame) {+ page.input_hover_target = null;+ }+ }+ if (page.input_pointer.down_target) |el| {+ if (el.ownerFrame(frame) == frame) {+ page.input_pointer.reset();+ }+ }+ const touch = &page.input_touch;+ if (touch.contact) |contact| {+ if (contact.target.ownerFrame(frame) == frame) {+ touch.contact = null;+ }+ }+ if (touch.last_tap) |tap| {+ if (tap.pinned) |el| if (el.ownerFrame(frame) == frame) {+ touch.last_tap = null;+ };+ }+}+/// Whether the element has a click activation behavior that handleClick/// implements.fn hasClickActivationBehavior(node: *Node) bool {diff --git a/src/browser/webapi/WebDriver.zig b/src/browser/webapi/WebDriver.zigindex b0c55f594..49ddf507a 100644--- a/src/browser/webapi/WebDriver.zig+++ b/src/browser/webapi/WebDriver.zig@@ -251,18 +251,11 @@ fn performPointerSource(source: js.Object, frame: *Frame) !void {}const el = target orelse continue;if (is_touch) {- if (frame.page.input_touch_contact) |contact| {- // Touch implicitly captures the original down target.- const owner = contact.target.ownerFrame(frame) orelse continue;- Frame.user_input.touchMove(owner, el, .{ .x = 0, .y = 0 }, frame.page.input_modifiers) catch |err| {- log.debug(.app, "webdriver touch", .{ .err = err });- };- } else {- const owner = el.ownerFrame(frame) orelse continue;- Frame.user_input.touchHover(owner, el, frame.page.input_modifiers) catch |err| {- log.debug(.app, "webdriver touch", .{ .err = err });- };- }+ const moved = if (frame.page.input_touch.contact != null)+ Frame.user_input.touchMove(frame, el, .{ .x = 0, .y = 0 }, frame.page.input_modifiers)+ else+ Frame.user_input.touchHover(frame, el, frame.page.input_modifiers);+ moved catch |err| log.debug(.app, "webdriver touch", .{ .err = err });continue;}Frame.user_input.moveSequence(frame, el, .{@@ -272,8 +265,7 @@ fn performPointerSource(source: js.Object, frame: *Frame) !void {} else if (action_type.eql(comptime .wrap("pointerDown"))) {const el = target orelse continue;if (is_touch) {- const owner = el.ownerFrame(frame) orelse continue;- Frame.user_input.touchStart(owner, el, .{ .x = 0, .y = 0 }, frame.page.input_modifiers) catch |err| {+ Frame.user_input.touchStart(frame, el, .{ .x = 0, .y = 0 }, frame.page.input_modifiers) catch |err| {log.debug(.app, "webdriver touch", .{ .err = err });};continue;@@ -291,9 +283,7 @@ fn performPointerSource(source: js.Object, frame: *Frame) !void {}) catch {};} else if (action_type.eql(comptime .wrap("pointerUp"))) {if (is_touch) {- const contact = frame.page.input_touch_contact orelse continue;- const owner = contact.target.ownerFrame(frame) orelse continue;- Frame.user_input.touchEnd(owner, null, frame.page.input_modifiers, contact.target) catch |err| {+ Frame.user_input.touchEnd(frame, null, frame.page.input_modifiers) catch |err| {log.debug(.app, "webdriver touch", .{ .err = err });};continue;diff --git a/src/server/bidi/input.zig b/src/server/bidi/input.zigindex 8a8c4d420..0d72f7c68 100644--- a/src/server/bidi/input.zig+++ b/src/server/bidi/input.zig@@ -344,7 +344,7 @@ const ParseError = error{const SourceActions = struct {id: []const u8,type: Source.Kind,- parameters: ?std.json.Value = null,+ parameters: ?struct { pointerType: enum { mouse, pen, touch } = .mouse } = null,actions: []const std.json.Value,};@@ -382,7 +382,7 @@ fn parseTicks(bidi: *BiDi, arena: Allocator, actions: []const std.json.Value) Paconst sa = std.json.parseFromValueLeaky(SourceActions, arena, value, .{ .ignore_unknown_fields = true }) catch {return error.InvalidActions;};- const source = try state.findOrCreate(allocator, sa.id, sa.type, isTouch(sa.parameters));+ const source = try state.findOrCreate(allocator, sa.id, sa.type, if (sa.parameters) |p| p.pointerType == .touch else false);const parsed = try arena.alloc(Action, sa.actions.len);for (sa.actions, parsed) |raw, *action| {@@ -407,13 +407,6 @@ fn parseTicks(bidi: *BiDi, arena: Allocator, actions: []const std.json.Value) Pareturn ticks;}-fn isTouch(parameters: ?std.json.Value) bool {- const params = parameters orelse return false;- if (params != .object) return false;- const pointer_type = params.object.get("pointerType") orelse return false;- return pointer_type == .string and std.mem.eql(u8, pointer_type.string, "touch");-}-// `arena` outlives the command: an action can run after its json is gone.fn parseAction(arena: Allocator, kind: Source.Kind, raw: std.json.Value) ParseError!Action {const obj = switch (raw) {@@ -595,7 +588,7 @@ fn dispatch(bidi: *BiDi, frame: *Frame, source: *Source, action: *const Action)const i = std.mem.findScalar(u8, pointer.pressed.items, button) orelse return;_ = pointer.pressed.orderedRemove(i);if (pointer.touch) {- return user_input.touchEnd(frame, .{ .x = pointer.x, .y = pointer.y }, .{}, null);+ return user_input.touchEnd(frame, .{ .x = pointer.x, .y = pointer.y }, .{});}try user_input.triggerMouseRelease(frame, pointer.x, pointer.y, button, pointer.click_count);},diff --git a/src/server/cdp/domains/input.zig b/src/server/cdp/domains/input.zigindex 1b207635e..041129fc0 100644--- a/src/server/cdp/domains/input.zig+++ b/src/server/cdp/domains/input.zig@@ -194,10 +194,10 @@ fn dispatchTouchEvent(cmd: *CDP.Command) !void {switch (params.type) {.touchStart => {- if (frame.page.input_touch_contact != null) return error.InvalidParams;+ if (frame.page.input_touch.contact != null) return error.InvalidParams;},.touchMove, .touchEnd, .touchCancel => {- const contact = frame.page.input_touch_contact orelse return error.InvalidParams;+ const contact = frame.page.input_touch.contact orelse return error.InvalidParams;if (params.touchPoints.len == 1 and params.touchPoints[0].id != contact.point.id) {return error.InvalidParams;}@@ -212,7 +212,7 @@ fn dispatchTouchEvent(cmd: *CDP.Command) !void {switch (params.type) {.touchStart => try Frame.user_input.touchStart(frame, null, point.?, modifiers),.touchMove => try Frame.user_input.touchMove(frame, null, point.?, modifiers),- .touchEnd => try Frame.user_input.touchEnd(frame, point, modifiers, null),+ .touchEnd => try Frame.user_input.touchEnd(frame, point, modifiers),.touchCancel => try Frame.user_input.touchCancel(frame, modifiers),}}@@ -1379,13 +1379,8 @@ test "cdp.input: dispatchTouchEvent reports the client's radius, angle and forcevar ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;-- const url = "http://localhost:9582/src/browser/tests/mcp_actions.html";- try frame.navigate(url, .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);@@ -1437,13 +1432,8 @@ test "cdp.input: dispatchTouchEvent touchStart populates touches/targetTouches/cvar ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;-- const url = "http://localhost:9582/src/browser/tests/mcp_actions.html";- try frame.navigate(url, .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);@@ -1493,11 +1483,8 @@ test "cdp.input: dispatchTouchEvent preserves each event's modifier keys" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);@@ -1603,27 +1590,22 @@ test "cdp.input: dispatchTouchEvent a touchStart past every element still opensvar ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;-- const url = "http://localhost:9582/src/browser/tests/mcp_actions.html";- try frame.navigate(url, .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;try ctx.processMessage(.{.id = 1,.method = "Input.dispatchTouchEvent",.params = .{ .type = "touchStart", .touchPoints = &.{.{ .x = 0, .y = 3000 }} },});- try testing.expect(frame.page.input_touch_contact != null);+ try testing.expect(frame.page.input_touch.contact != null);try ctx.processMessage(.{.id = 2,.method = "Input.dispatchTouchEvent",.params = .{ .type = "touchEnd", .touchPoints = &.{} },});- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);}test "cdp.input: dispatchTouchEvent empty touchStart is InvalidParams" {@@ -1696,11 +1678,8 @@ test "cdp.input: dispatchTouchEvent touchMove with no active contact is InvalidPtest "cdp.input: dispatchTouchEvent tracks the client's chosen id and rejects mismatches" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);@@ -1724,14 +1703,14 @@ test "cdp.input: dispatchTouchEvent tracks the client's chosen id and rejects mi.params = .{ .type = "touchStart", .touchPoints = &.{.{ .x = x, .y = y, .id = 0.5 }} },});try ctx.expectSentError(-31998, "InvalidParams", .{ .id = 1 });- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);try ctx.processMessage(.{.id = 2,.method = "Input.dispatchTouchEvent",.params = .{ .type = "touchStart", .touchPoints = &.{.{ .x = x, .y = y, .id = 7 }} },});- try testing.expectEqual(@as(i32, 7), frame.page.input_touch_contact.?.point.id);+ try testing.expectEqual(@as(i32, 7), frame.page.input_touch.contact.?.point.id);try ctx.processMessage(.{.id = 3,@@ -1739,8 +1718,8 @@ test "cdp.input: dispatchTouchEvent tracks the client's chosen id and rejects mi.params = .{ .type = "touchMove", .touchPoints = &.{.{ .x = x + 100, .y = y + 100, .id = 8 }} },});try ctx.expectSentError(-31998, "InvalidParams", .{ .id = 3 });- try testing.expectEqual(x, frame.page.input_touch_contact.?.point.x);- try testing.expectEqual(y, frame.page.input_touch_contact.?.point.y);+ try testing.expectEqual(x, frame.page.input_touch.contact.?.point.x);+ try testing.expectEqual(y, frame.page.input_touch.contact.?.point.y);try ctx.processMessage(.{.id = 4,@@ -1754,14 +1733,14 @@ test "cdp.input: dispatchTouchEvent tracks the client's chosen id and rejects mi.params = .{ .type = "touchEnd", .touchPoints = &.{.{ .x = x + 1, .y = y + 20, .id = 8 }} },});try ctx.expectSentError(-31998, "InvalidParams", .{ .id = 5 });- try testing.expect(frame.page.input_touch_contact != null);+ try testing.expect(frame.page.input_touch.contact != null);try ctx.processMessage(.{.id = 6,.method = "Input.dispatchTouchEvent",.params = .{ .type = "touchEnd", .touchPoints = &.{.{ .x = x + 1, .y = y + 20, .id = 7 }} },});- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);try testing.expect((try ls.local.compileAndRun(\\JSON.stringify(touchEvents) === JSON.stringify([\\ ['touchstart', 7, target.getBoundingClientRect().x, target.getBoundingClientRect().y],@@ -1775,13 +1754,8 @@ test "cdp.input: dispatchTouchEvent a second touchStart while a contact is activvar ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;-- const url = "http://localhost:9582/src/browser/tests/mcp_actions.html";- try frame.navigate(url, .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);@@ -1831,13 +1805,8 @@ test "cdp.input: dispatchTouchEvent a touchEnd carrying the released point is acvar ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;-- const url = "http://localhost:9582/src/browser/tests/mcp_actions.html";- try frame.navigate(url, .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);@@ -1869,7 +1838,7 @@ test "cdp.input: dispatchTouchEvent a touchEnd carrying the released point is ac.method = "Input.dispatchTouchEvent",.params = .{ .type = "touchEnd", .touchPoints = &.{.{ .x = end_x, .y = end_y }} },});- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);const result = try ls.local.compileAndRun("window.endTarget === true && window.endX === " ++ "document.getElementById('hoverTarget').getBoundingClientRect().x + 5" ++@@ -1883,63 +1852,15 @@ test "cdp.input: dispatchTouchEvent a touchEnd carrying the released point is ac.method = "Input.dispatchTouchEvent",.params = .{ .type = "touchStart", .touchPoints = &.{.{ .x = rect_x, .y = rect_y }} },});- try testing.expect(frame.page.input_touch_contact != null);-}--test "cdp.input: dispatchTouchEvent an empty touchEnd uses the stored position" {- var ctx = try testing.context();- defer ctx.deinit();-- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;-- const url = "http://localhost:9582/src/browser/tests/mcp_actions.html";- try frame.navigate(url, .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);-- var ls: lp.js.Local.Scope = undefined;- frame.js.localScope(&ls);- defer ls.deinit();-- _ = try ls.local.compileAndRun(- \\const t = document.getElementById('hoverTarget');- \\t.addEventListener('touchend', (e) => {- \\ const touch = e.changedTouches[0];- \\ window.endX = touch.clientX;- \\ window.endY = touch.clientY;- \\});- , null);-- const rect_x = try (try ls.local.compileAndRun("document.getElementById('hoverTarget').getBoundingClientRect().x", null)).toF64();- const rect_y = try (try ls.local.compileAndRun("document.getElementById('hoverTarget').getBoundingClientRect().y", null)).toF64();-- try ctx.processMessage(.{- .id = 1,- .method = "Input.dispatchTouchEvent",- .params = .{ .type = "touchStart", .touchPoints = &.{.{ .x = rect_x, .y = rect_y }} },- });- try ctx.processMessage(.{- .id = 2,- .method = "Input.dispatchTouchEvent",- .params = .{ .type = "touchEnd", .touchPoints = &.{} },- });-- const result = try ls.local.compileAndRun("window.endX === document.getElementById('hoverTarget').getBoundingClientRect().x && window.endY === document.getElementById('hoverTarget').getBoundingClientRect().y", null);- try testing.expect(result.isTrue());+ try testing.expect(frame.page.input_touch.contact != null);}test "cdp.input: dispatchTouchEvent rejects populated touchCancel without lifting contact" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;-- const url = "http://localhost:9582/src/browser/tests/mcp_actions.html";- try frame.navigate(url, .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);@@ -1971,14 +1892,14 @@ test "cdp.input: dispatchTouchEvent rejects populated touchCancel without liftin.params = .{ .type = "touchCancel", .touchPoints = &.{.{ .x = cancel_x, .y = cancel_y }} },});try ctx.expectSentError(-31998, "InvalidParams", .{ .id = 2 });- try testing.expect(frame.page.input_touch_contact != null);+ try testing.expect(frame.page.input_touch.contact != null);try ctx.processMessage(.{.id = 3,.method = "Input.dispatchTouchEvent",.params = .{ .type = "touchCancel", .touchPoints = &.{} },});- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);const result = try ls.local.compileAndRun("window.cancelable === false && window.cancelX === " ++ "document.getElementById('hoverTarget').getBoundingClientRect().x" ++@@ -1992,13 +1913,8 @@ test "cdp.input: dispatchTouchEvent a multi-point touchEnd/touchCancel is Invalivar ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;-- const url = "http://localhost:9582/src/browser/tests/mcp_actions.html";- try frame.navigate(url, .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);@@ -2750,11 +2666,8 @@ test "cdp.input: dispatchKeyEvent Enter on a checkbox, radio or select" {test "cdp.input: touch tap emits pointer and compatibility activation in order" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);defer ls.deinit();@@ -2787,18 +2700,15 @@ test "cdp.input: touch tap emits pointer and compatibility activation in order"\\tapEvents.find(e => e.type === 'mousedown').buttons === 1 && tapEvents.find(e => e.type === 'mousedown').detail === 1 &&\\tapEvents.find(e => e.type === 'mouseup').buttons === 0 && tapEvents.find(e => e.type === 'click').detail === 1, null)).isTrue());- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);try testing.expectEqual(@as(u16, 0), frame.page.input_pointer.held);}test "cdp.input: touch tap cancellation distinguishes touch pointer and mouse defaults" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);defer ls.deinit();@@ -2845,7 +2755,7 @@ test "cdp.input: touch tap cancellation distinguishes touch pointer and mouse deconst passed = (try ls.local.compileAndRun(case[1], null)).isTrue();if (!passed) std.debug.print("failed prevention case: {s}\n", .{case[0]});try testing.expect(passed);- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);}}@@ -2912,11 +2822,8 @@ test "cdp.input: touch pointer retains its target while compatibility events hittest "cdp.input: touch slop, scroll and touch-action" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);defer ls.deinit();@@ -2954,7 +2861,7 @@ test "cdp.input: touch slop, scroll and touch-action" {for (cases) |c| {_ = try ls.local.compileAndRun("log = []; preventType = ''; t.style.touchAction = ''; t.parentElement.style.touchAction = '';", null);if (c.setup.len > 0) _ = try ls.local.compileAndRun(c.setup, null);- frame.page.input_last_tap = null;+ frame.page.input_touch.last_tap = null;try ctx.processMessage(.{ .id = 1, .method = "Input.dispatchTouchEvent", .params = .{ .type = "touchStart", .touchPoints = &.{.{ .x = x, .y = y }} } });for (c.moves) |m| {try ctx.processMessage(.{ .id = 2, .method = "Input.dispatchTouchEvent", .params = .{ .type = "touchMove", .touchPoints = &.{.{ .x = x + m[0], .y = y + m[1] }} } });@@ -2972,11 +2879,8 @@ test "cdp.input: touch slop, scroll and touch-action" {test "cdp.input: consecutive taps count up" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);defer ls.deinit();@@ -3008,7 +2912,7 @@ test "cdp.input: consecutive taps count up" {try testing.expectEqualSlices(u8, "mousedown:2 click:2 dblclick:2 mousedown:1 click:1", try (try ls.local.compileAndRun("log.join(' ')", null)).toStringSlice());_ = try ls.local.compileAndRun("log = []", null);- frame.page.input_last_tap.?.released_ms -= 401;+ frame.page.input_touch.last_tap.?.released_ms -= 401;try Tap.run(&ctx, x + 20, y + 21, false);try Tap.run(&ctx, x + 20, y + 21, true);try Tap.run(&ctx, x + 20, y + 21, false);@@ -3018,11 +2922,8 @@ test "cdp.input: consecutive taps count up" {test "cdp.input: passive prevention and finger jitter do not suppress repeated taps" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);defer ls.deinit();@@ -3057,11 +2958,8 @@ test "cdp.input: passive prevention and finger jitter do not suppress repeated ttest "cdp.input: touch tap respects disabled controls across compatibility handlers" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);defer ls.deinit();@@ -3097,18 +2995,15 @@ test "cdp.input: touch tap respects disabled controls across compatibility handlconst passed = (try ls.local.compileAndRun(case[1], null)).isTrue();if (!passed) std.debug.print("disabled tap case: {s}\n", .{case[0]});try testing.expect(passed);- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);}}test "cdp.input: touch tap revalidates targets between compatibility events" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);defer ls.deinit();@@ -3141,18 +3036,15 @@ test "cdp.input: touch tap revalidates targets between compatibility events" {const passed = (try ls.local.compileAndRun(case[1], null)).isTrue();if (!passed) std.debug.print("mutating tap case: {s}\n", .{case[0]});try testing.expect(passed);- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);}}test "cdp.input: touch cancellation retains last contact geometry through pointer leave" {var ctx = try testing.context();defer ctx.deinit();- const bc = try ctx.loadBrowserContext(.{});- const page = try bc.session.createPage();- const frame = page.frame().?;- try frame.navigate("http://localhost:9582/src/browser/tests/mcp_actions.html", .{ .reason = .address_bar, .kind = .{ .push = null } });- try testing.waitForPage(bc);+ const bc = try ctx.loadBrowserContext(.{ .url = "mcp_actions.html" });+ const frame = bc.mainFrame().?;var ls: lp.js.Local.Scope = undefined;frame.js.localScope(&ls);defer ls.deinit();@@ -3172,7 +3064,7 @@ test "cdp.input: touch cancellation retains last contact geometry through pointe\\events.every(e => e.button === -1 && e.buttons === 0 && e.width === 6 && e.height === 8 && e.pressure === 0 && e.id === 2) &&\\!events[0].cancelable && events[1].cancelable && !events[2].cancelable, null)).isTrue());- try testing.expect(frame.page.input_touch_contact == null);+ try testing.expect(frame.page.input_touch.contact == null);}test "cdp.input: re-navigating an iframe drops the pointer state on its elements" {