Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

test(cdp): cover overflow container wheel axes

ldm0acda5d7b2d21
diff --git a/moli-cdp-smoke/README.md b/moli-cdp-smoke/README.md
index e66c6f17e..e70786c92 100644
--- a/moli-cdp-smoke/README.md
+++ b/moli-cdp-smoke/README.md
@@ -98,12 +98,14 @@ Covered well:
the public CDP boundary. Three acknowledged `Input.dispatchMouseEvent`
wheel commands remain delayed until one fixed one-second deadline, preserve
event order, defer their microtask checkpoint, and publish one derived
- IntersectionObserver transition. `Page.captureScreenshot` must flush pending
- wheel work before paint and retire that window so later input receives a
- fresh deadline. A wheel handler that calls `document.open()` must also stop
+ IntersectionObserver transition. Coordinate-targeted vertical and horizontal
+ wheels must update an inner `overflow: auto` container's `scrollTop` and
+ `scrollLeft` without moving the page. `Page.captureScreenshot` must flush
+ pending wheel work before paint and retire that window so later input receives
+ a fresh deadline. A wheel handler that calls `document.open()` must also stop
the remainder of its batch from entering the replacement Document. These are
- Moli scheduling contracts rather than Chromium-compatibility claims; the
- group records a non-applicable result when pointed at Chromium.
+ Moli scheduling contracts rather than Chromium-compatibility claims; the group
+ records a non-applicable result when pointed at Chromium.
- The focused `dom-hit-test` group drives `DOM.getNodeForLocation` through the real layout hit index and requires the same option-aware topmost node, backend node id, and frame id shape from Moli and Chromium.
- Node creation stack capture retains at most the newest 1,024 traces per Inspector session; focused renderer tests cover FIFO eviction, shared payloads, document replacement, and session detach while the wire smoke retains enable/disable/session semantics and verifies that `document.open()` preserves capture for replacement-document nodes.
- Optional chrome-remote-interface 0.34.0 and cdp-use 1.4.5 coverage for verified browser/page sessions, multiple targets, local/session storage ownership, history traversal, child-frame isolated worlds, Fetch fulfillment with page-session event routing, complete Network terminals, and the declared position-click boundary.
diff --git a/moli-cdp-smoke/moli_cdp_smoke/fixture.py b/moli-cdp-smoke/moli_cdp_smoke/fixture.py
index a9ba6a632..bdf900314 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/fixture.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/fixture.py
@@ -204,6 +204,34 @@ __actionWindowObserver.observe(document.getElementById("target"));
</script>
"""
+ACTION_WINDOW_OVERFLOW_FIXTURE = """<!doctype html>
+<style>
+html, body { margin: 0; }
+body { width: 1000px; height: 1000px; }
+#scroller {
+ position: absolute;
+ left: 20px;
+ top: 20px;
+ width: 100px;
+ height: 100px;
+ overflow: auto;
+}
+#content { width: 500px; height: 500px; }
+</style>
+<div id="scroller"><div id="content"></div></div>
+<script>
+globalThis.__actionWindowOverflowDeltas = [];
+const scroller = document.getElementById("scroller");
+scroller.addEventListener("wheel", event => {
+ __actionWindowOverflowDeltas.push([event.deltaX, event.deltaY]);
+ fetch(
+ "/action-window-witness/entered?source=overflow" +
+ "&deltaX=" + event.deltaX + "&deltaY=" + event.deltaY
+ );
+});
+</script>
+"""
+
ACTION_WINDOW_CAPTURE_FIXTURE = """<!doctype html>
<style>
html, body { margin: 0; background: white; }
@@ -630,6 +658,8 @@ class FixtureServer:
self._send_html(LAYOUT_SCREENSHOT_FIXTURE)
elif route == "/action-window-deadline":
self._send_html(ACTION_WINDOW_DEADLINE_FIXTURE)
+ elif route == "/action-window-overflow":
+ self._send_html(ACTION_WINDOW_OVERFLOW_FIXTURE)
elif route == "/action-window-capture":
self._send_html(ACTION_WINDOW_CAPTURE_FIXTURE)
elif route == "/action-window-replacement":
diff --git a/moli-cdp-smoke/moli_cdp_smoke/groups/action_window.py b/moli-cdp-smoke/moli_cdp_smoke/groups/action_window.py
index 6d36592b1..7072d339b 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/groups/action_window.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/groups/action_window.py
@@ -155,15 +155,19 @@ async def _dispatch_wheel(
client: RawCdpClient,
session_id: str,
delta_y: float,
+ *,
+ delta_x: float = 0,
+ x: float = 20,
+ y: float = 20,
) -> None:
await _success(
client,
"Input.dispatchMouseEvent",
{
"type": "mouseWheel",
- "x": 20,
- "y": 20,
- "deltaX": 0,
+ "x": x,
+ "y": y,
+ "deltaX": delta_x,
"deltaY": delta_y,
},
session_id=session_id,
@@ -321,6 +325,79 @@ async def _run_deadline_contract(
)
+async def _run_overflow_container_contract(
+ client: RawCdpClient,
+ session_id: str,
+ fixture: str,
+ results: list[dict[str, Any]],
+) -> None:
+ await _reset_witness(fixture)
+ await _navigate(client, session_id, f"{fixture}/action-window-overflow")
+ initial = await _evaluate_json(
+ client,
+ session_id,
+ """JSON.stringify({
+ container: [scroller.scrollLeft, scroller.scrollTop],
+ page: [scrollX, scrollY],
+ deltas: __actionWindowOverflowDeltas
+ })""",
+ )
+ assert_equal(
+ initial,
+ {"container": [0, 0], "page": [0, 0], "deltas": []},
+ "overflow container initial state",
+ )
+
+ opened_at = asyncio.get_running_loop().time()
+ await _dispatch_wheel(client, session_id, 60, x=50, y=50)
+ await _dispatch_wheel(client, session_id, 0, delta_x=45, x=50, y=50)
+ assert_equal(
+ await _witness_count(fixture),
+ 0,
+ "vertical and horizontal container wheels remain delayed",
+ )
+
+ await _wait_for_witness(fixture, 2)
+ elapsed = asyncio.get_running_loop().time() - opened_at
+ if elapsed < 0.85:
+ raise SmokeError(
+ f"overflow-container wheel batch applied before its deadline: {elapsed:.3f}s"
+ )
+ state = await _evaluate_json(
+ client,
+ session_id,
+ """JSON.stringify({
+ container: [scroller.scrollLeft, scroller.scrollTop],
+ page: [scrollX, scrollY],
+ deltas: __actionWindowOverflowDeltas
+ })""",
+ )
+ assert_equal(
+ state,
+ {
+ "container": [45, 60],
+ "page": [0, 0],
+ "deltas": [[0, 60], [45, 0]],
+ },
+ "overflow container wheel batch state",
+ )
+ record_contract(
+ results,
+ "raw_cdp_action_window_overflow_container_axes",
+ contract=(
+ "delayed vertical and horizontal wheels hit the innermost overflow container "
+ "at their CDP coordinates without scrolling the page"
+ ),
+ source="Moli coordinate hit testing and fixed action-window scheduling",
+ commands=[
+ "Input.dispatchMouseEvent(mouseWheel deltaY)",
+ "Input.dispatchMouseEvent(mouseWheel deltaX)",
+ "Runtime.evaluate",
+ ],
+ observed={"elapsedSeconds": round(elapsed, 3), **state},
+ )
+
+
async def _run_capture_barrier_contract(
client: RawCdpClient,
session_id: str,
@@ -450,6 +527,7 @@ async def run_action_window_group(
try:
context_id, session_id = await _open_target(client)
await _run_deadline_contract(client, session_id, fixture, results)
+ await _run_overflow_container_contract(client, session_id, fixture, results)
await _run_capture_barrier_contract(client, session_id, fixture, results)
await _run_replacement_contract(client, session_id, fixture, results)
finally:
diff --git a/moli-cdp-smoke/moli_cdp_smoke/runner.py b/moli-cdp-smoke/moli_cdp_smoke/runner.py
index c767f1f1a..7ec066d4c 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/runner.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/runner.py
@@ -88,7 +88,7 @@ RAW_GROUPS: tuple[SmokeGroup, ...] = (
),
SmokeGroup(
"action-window",
- "Moli raw-CDP wheel batching, screenshot flush/reset, and exact-Document retirement contracts.",
+ "Moli raw-CDP wheel batching, overflow-container axes, screenshot flush/reset, and exact-Document retirement contracts.",
"raw",
run_action_window_group,
),
diff --git a/moli-cdp-smoke/tests/test_action_window.py b/moli-cdp-smoke/tests/test_action_window.py
index e9d2e7955..dff259ef7 100644
--- a/moli-cdp-smoke/tests/test_action_window.py
+++ b/moli-cdp-smoke/tests/test_action_window.py
@@ -47,6 +47,7 @@ class ActionWindowFixtureTests(unittest.TestCase):
def test_action_window_pages_expose_each_contract_fixture(self) -> None:
expected_markers = {
"/action-window-deadline": "__actionWindowObserver",
+ "/action-window-overflow": "__actionWindowOverflowDeltas",
"/action-window-capture": "__actionWindowCaptureDeltas",
"/action-window-replacement": "__actionWindowReplacementDeltas",
}
diff --git a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface.rs b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface.rs
index 40c1c910c..00cd8c931 100644
--- a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface.rs
+++ b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface.rs
@@ -386,33 +386,35 @@ fn wheel_default_action_scrolls_the_innermost_container_then_chains_to_the_root(
document.body.style.margin = "0";
document.body.innerHTML =
'<div id="scroller" style="width: 200px; height: 100px; overflow: auto">' +
- '<div style="height: 500px"></div>' +
+ '<div style="width: 500px; height: 500px"></div>' +
'</div>' +
- '<div style="height: 2000px"></div>';
+ '<div style="width: 2000px; height: 2000px"></div>';
})()
"#,
)
.expect("nested wheel fixture should initialize");
refresh_layout_for_test(&mut vm);
- vm.dispatch_mouse_event_at_point(10.0, 10.0, "wheel", -1, Some(0), 0.0, 60.0)
+ vm.dispatch_mouse_event_at_point(10.0, 10.0, "wheel", -1, Some(0), 35.0, 60.0)
.expect("nested wheel input should dispatch");
assert_eq!(
- vm.eval("JSON.stringify([document.getElementById('scroller').scrollTop, window.scrollY])")
+ vm.eval(
+ "JSON.stringify([document.getElementById('scroller').scrollLeft, document.getElementById('scroller').scrollTop, window.scrollX, window.scrollY])"
+ )
.expect("nested wheel positions should evaluate"),
- "[60,0]"
+ "[35,60,0,0]"
);
vm.eval(
- "document.getElementById('scroller').scrollTop = document.getElementById('scroller').scrollHeight"
+ "document.getElementById('scroller').scrollTo(document.getElementById('scroller').scrollWidth, document.getElementById('scroller').scrollHeight)"
)
.expect("nested scroller should move to its boundary");
- vm.dispatch_mouse_event_at_point(10.0, 10.0, "wheel", -1, Some(0), 0.0, 40.0)
+ vm.dispatch_mouse_event_at_point(10.0, 10.0, "wheel", -1, Some(0), 25.0, 40.0)
.expect("chained wheel input should dispatch");
assert_eq!(
- vm.eval("String(window.scrollY)")
+ vm.eval("JSON.stringify([window.scrollX, window.scrollY])")
.expect("root chained scroll position should evaluate"),
- "40"
+ "[25,40]"
);
}