feat(stealth): in-bbox landing jitter + eased wheel/drag (humanize v4)
Completes the humanize suite: - Clicks land on a jittered point inside the element's box (Fast/Human) instead of its exact centre. `resolve_element_center` now also returns the element width/height (box_model_dims); the CSS-selector path reports zero size → land on centre (no jitter, no regression). Jitter is clamped to the inner box so the click never misses. - Wheel scrolls split into eased, jittered segments (humanize::scroll_segments, unit-tested) instead of one instant jump. - Drag follows the curved trajectory at Fast/Human (linear 10-step at Off). Off is unchanged throughout. 9/9 unit tests; verified headless — jittered click still lands (→ iana.org), segmented scroll moves the page.
This commit is contained in:
@@ -55,8 +55,15 @@ pub async fn click(
|
||||
.await;
|
||||
|
||||
match resolved {
|
||||
Ok((x, y, effective_session_id)) => {
|
||||
dispatch_click(client, &effective_session_id, x, y, button, click_count).await
|
||||
Ok((cx, cy, w, h, effective_session_id)) => {
|
||||
// Land on a jittered point inside the element rather than its exact
|
||||
// centre (Fast/Human). Zero size or Off → exact centre.
|
||||
let (tx, ty) = humanize::landing_point(
|
||||
(cx - w / 2.0, cy - h / 2.0, w, h),
|
||||
humanize::active_level(),
|
||||
humanize::next_seed(),
|
||||
);
|
||||
dispatch_click(client, &effective_session_id, tx, ty, button, click_count).await
|
||||
}
|
||||
Err(e) => {
|
||||
// (B) The coordinate path failed — typically a persistent overlay
|
||||
@@ -191,7 +198,7 @@ pub async fn hover(
|
||||
selector_or_ref: &str,
|
||||
iframe_sessions: &HashMap<String, String>,
|
||||
) -> Result<(), String> {
|
||||
let (x, y, effective_session_id) = resolve_element_center(
|
||||
let (x, y, _w, _h, effective_session_id) = resolve_element_center(
|
||||
client,
|
||||
session_id,
|
||||
ref_map,
|
||||
@@ -999,7 +1006,7 @@ pub async fn tap_touch(
|
||||
selector_or_ref: &str,
|
||||
iframe_sessions: &HashMap<String, String>,
|
||||
) -> Result<(), String> {
|
||||
let (x, y, effective_session_id) = resolve_element_center(
|
||||
let (x, y, _w, _h, effective_session_id) = resolve_element_center(
|
||||
client,
|
||||
session_id,
|
||||
ref_map,
|
||||
|
||||
Reference in New Issue
Block a user