mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-14 20:34:30 +01:00
6fdbdc2548
* fix: avoid TOCTOU race in smoke test click by using page.click
The smoke test for statusbar 'quick input' was flaky because click() in
PlaywrightDriver used two separate operations:
1. getElementXY( CDP round-trip to get {x, y}selector)
2. page.mouse.click(x, another CDP commandy)
Between these two steps, the page's JS event loop is free to process
queued tasks (~1ms window). In the failing case, the markdown-language-
features extension registers a Language Status '{}' item in the status
bar during this window, shifting the EOL item's x position. The click
then lands on '{}' instead of EOL.
Clicking '{}' invokes ShowTooltipCommand which calls hover.show(true),
trapping keyboard focus in a hover so the EOL quick input neverwidget
opens and the test times out.
Fix: use page.click(selector) for the common no-offset case. Playwright's
native click waits for the element's bounding box to be stable across
multiple frames before dispatching the click, eliminating the race.
Validated with 50 consecutive runs (0 failures vs. ~1-in-22 before).
Also delete ELECTRON_RUN_AS_NODE from the environment before launching
the test binary. When this env var is set, Electron acts as a plain
Node.js binary and rejects Chromium flags like --remote-debugging-port
that Playwright injects, preventing dev-mode smoke tests from launching.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* address review: fix double-offset bug and reduce page.click timeout
- Fix pre-existing double offset: getElementXY already incorporates both
xoffset/yoffset into the returned coordinates, so don't add them again
in mouse.click when both offsets are provided.
- Reduce page.click timeout from 2000ms to 100ms so each poll attempt
in waitAndClick's retry loop (200 100ms = 20s budget) stays within
its intended time budget.
- Use xoffset ?? 0 / yoffset ?? 0 instead of falsy checks.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: fall back to legacy click for elements with degenerate bounding box
The previous attempt to use page.click() for all clicks broke smoke tests that
target elements like Monaco's hidden .native-edit-context contenteditable, which
Playwright refuses to interact with (even with force: true) because the element
has a degenerate bounding box. Try page.click first (preserves the TOCTOU fix
for status bar items), then fall back to getElementXY + mouse.click on failure.
(Written by Copilot)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: don't skip Playwright actionability checks on click
Removing 'force: true' from page.click - the actionability checks (specifically
the 'stable' check that waits for the bounding box to be unchanged across 2
frames) are exactly what fixes the original TOCTOU race. Skipping them caused
clicks to fire during layout shifts and not register their handlers properly,
breaking unrelated tests like the Problems View statusbar click.
The fallback to legacy getElementXY + mouse.click still handles elements that
genuinely fail actionability checks (e.g. Monaco's hidden .native-edit-context).
(Written by Copilot)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: narrow TOCTOU guard in statusbar.clickOn instead of broad click() change
Revert the playwrightDriver.click() change (which regressed multiple unrelated CI
tests) and instead add a narrowly-scoped fix in statusbar.clickOn(): for
editor-area status items, poll getElementXY until two consecutive samples are
identical before clicking. This guards against the language status ({}) item
shifting EOL/encoding/etc. between position lookup and click dispatch, without
affecting any other test surface.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: use page.click with stable-coords fallback to eliminate statusbar TOCTOU
Use Playwright's page.click (which re-verifies elementFromPoint immediately
before dispatching, closing the TOCTOU window) for editor-area status bar
items. Fall back to a stable-coordinates click when page.click's actionability
check the known case is Monaco's .native-edit-context overlayfails
(z-index: -10) which elementFromPoint returns instead of the intended target.
Before the fallback, input state is reset (mouse.move to 0,0 + small wait)
so partial hover/mousedown from the failed attempt don't corrupt subsequent
events.
The stable-coordinates fallback polls getElementXY until two consecutive
samples match, then clicks at those exact minimising (thoughcoordinates
not eliminating) the TOCTOU window in the fallback path too.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* address review: narrow fallback to pointer-intercept errors, use wait() helper, clarify robustClick docs
- robustClick now only falls back on 'intercepts pointer events' errors;
all other errors are rethrown so real failures aren't silently masked
- Wrap fallback error to preserve both the original and fallback messages
- Replace raw setTimeout with existing wait() helper
- Clarify Code.robustClick JSDoc: not a polling replacement for waitAndClick
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* simplify: remove unnecessary input-state reset before fallback click
The 'intercepts pointer events' error fires at Playwright's actionability
check phase, before any mouse events are dispatched to the so therepage
is no partial hover/mousedown state to reset.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
VS Code Automation Package
This package contains functionality for automating various components of the VS Code UI, via an automation "driver" that connects from a separate process. It is used by the smoke tests.