Skip to content

The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.

fix(ego-browser): honor preventDefault in synthetic wheel fallback

0x0c4f5e83ea898
diff --git a/package/ego-browser/src/driver/pointer.ts b/package/ego-browser/src/driver/pointer.ts
index 388cdfc..76b3390 100644
--- a/package/ego-browser/src/driver/pointer.ts
+++ b/package/ego-browser/src/driver/pointer.ts
@@ -485,6 +485,8 @@ async function isVisibleAndFocused() {
* would be dropped. The WheelEvent triggers page wheel handlers (virtualized
* lists, custom scrollers); the window.scrollBy actually moves an ordinary page,
* since an untrusted WheelEvent does not perform the default scroll action.
+ * The manual scroll is skipped when a handler calls preventDefault(), matching
+ * how a real CDP wheel leaves the page in place (maps, canvases, custom scrollers).
*/
async function dispatchSyntheticWheel(
x: number,
@@ -496,7 +498,7 @@ async function dispatchSyntheticWheel(
const target = document.elementFromPoint(${JSON.stringify(x)}, ${JSON.stringify(y)})
|| document.scrollingElement || document.body;
if (!target) return;
- target.dispatchEvent(new WheelEvent("wheel", {
+ const notPrevented = target.dispatchEvent(new WheelEvent("wheel", {
bubbles: true,
cancelable: true,
deltaX: ${JSON.stringify(deltaX)},
@@ -504,7 +506,9 @@ async function dispatchSyntheticWheel(
clientX: ${JSON.stringify(x)},
clientY: ${JSON.stringify(y)}
}));
- window.scrollBy(${JSON.stringify(deltaX)}, ${JSON.stringify(deltaY)});
+ if (notPrevented) {
+ window.scrollBy(${JSON.stringify(deltaX)}, ${JSON.stringify(deltaY)});
+ }
})()`);
}