cua icon indicating copy to clipboard operation
cua copied to clipboard

[Bug]: Background pixel click on Electron/Chromium web content is silently degraded to AXPress

Open corywang517 opened this issue 1 month ago • 3 comments

Primary area

Cua Driver

Summary

On macOS, a window-scoped left click with x,y and the default delivery_mode is delivered as an AX hit-test + AXPress. The call returns success ("PX hit-test pressed the background element via AX", path "ax") but the requested coordinates are dropped, so Chromium/Electron web content usually does nothing. Reproduced with VS Code 1.136.1 (Electron 42.10.0) and Chrome.

Reproduction

  1. Open an Electron app with a text editor (VS Code 1.136.1, Electron Framework 42.10.0) and place the caret at Ln 1, Col 1.
  2. Call click with pid, window_id, x=300, y=336, left button, single click, no modifiers, and omit delivery_mode (background default).
  3. Observe the success text and the editor caret/status bar.
  4. Repeat the same click with delivery_mode:"foreground".

Expected behavior

A left click at x,y should deliver a real pointer event at that coordinate (or refuse when it cannot), not a semantic AXPress on whatever element the hit-test finds.

Actual behavior

The call reports success while dropping the coordinates. The renderer receives no real pointerdown/mousedown sequence; canvas/WebGL/React pointer handlers and caret placement do nothing, and agents treat the success as completion.

Environment

Cua component and version/commit: cua-driver 0.28.0 (bundled @trycua/cua-driver 0.28.0); also reproducible with the 0.28.2 CLI build. Operating system and architecture: macOS 26.1 (Darwin 25.0.0), arm64. Application/browser/window system/image: Visual Studio Code 1.136.1 (Electron 42.10.0), Chrome; no image.

Evidence

  • Result text: "✅ PX hit-test pressed the background element via AX." with structured path:"ax", verified:false, effect:"unverifiable".
  • Status bar before/after the background click: Ln 1, Col 1 -> Ln 1, Col 1 (no change).
  • Same click with delivery_mode:"foreground": "✅ Posted click ... (foreground CGEvent)"; status bar Ln 3, Col 13.
  • Source: crates/platform-macos/src/tools/click.rs, 0.28.x lines ~879-936 (main ~1156-1224). The background PX backend resolves the point with AXUIElementCopyElementAtPosition and returns immediately after a successful AXPress.

Workaround and additional context

Workaround: use delivery_mode:"foreground" for coordinate clicks, or element_token for semantic controls. Suggested fix: skip the AX backend when the hit-test element is inside an AXWebArea, or require an advertised AXPress and a non-web role; alternatively add an explicit px_only delivery flag. The existing silent-no-op guard only covers the LibreOffice VCL toolkit; Electron/Chromium has no equivalent.

Submission checks

  • [x] I searched for duplicate issues and active pull requests.
  • [x] This issue describes a single problem.
  • [x] I removed credentials, private data, sensitive screenshots, and vulnerability details from this public report.

corywang517 avatar Oct 19 '26 03:10 corywang517

I'd like to take this, unless @injaneity has already started. Plan: in macOS tools/click.rs, the background PX hit-test sends AXPress to whatever element is under the point and returns "pressed"; only LibreOffice VCL falls through to the routed pixel click. I'd keep the AX shortcut for elements that are real press targets, and fall through to the pixel route for generic web content in Chromium/Electron (AXGroup, AXWebArea, AXStaticText and similar), so x,y is honoured there. Native controls keep the AX shortcut, so Chromium windows still aren't made key just for first-mouse.

Evidence: unit tests for the fall-through rule, and a live before/after in VS Code and Chrome clicking a spot inside a web view.

This looks like the Electron side of #4350, so I'll keep the change narrow and link it there.

S3yon avatar Oct 19 '26 15:10 S3yon

Safari (WebKit) does the same on 0.38.0, so a fall-through limited to Chromium/Electron would leave it out.

Page: one full-window <canvas> whose click handler writes the click point into document.title. Safari is in the background. click {"pid":…,"window_id":…,"x":300,"y":252} (window pixels over page point 300,200), with default delivery, returns:

{"delivery":{"mode":"background"},"effect":"unverifiable","route":"accessibility","summary":"✅ PX hit-test pressed the background element via AX."}

The handler never runs: the title is unchanged. The same click with delivery_mode:"foreground" sets the title to x=300 y=200 n=1. Safari's AX tree has no element for the canvas. macOS 26.5.2 (25F84), arm64.

nick-inkeep avatar Oct 23 '26 08:10 nick-inkeep

Thanks, that's useful. The rule I have in mind keys on the AX role under the point, not on the app, so a hit on WebKit's AXWebArea should fall through to the pixel route too. I'll add Safari to the live before/after, next to VS Code and Chrome.

S3yon avatar Oct 26 '26 22:10 S3yon