Skip to content

[Bug]: Chromium locator.tap misses its target after the visible viewport pans #44121

Closed

Description

@devonjonte

Version

Playwright 1.65.1, bundled Chromium 159.0.8154.6.

Steps to reproduce

Minimal repository branch contains only the reproduction and its exact dependency lock.

git clone --depth 1 --branch repro/devon-visual-viewport-tap https://github.com/devonjonte/bench-hashes.git tap-repro
cd tap-repro
npm ci
npx playwright install chromium
npm test

The script uses page.setContent, a 1534-pixel-wide container and two buttons. It tests identical 1200×900 touch contexts with isMobile: false, then true. No server or application framework is involved.

Expected behavior

locator('#target').tap() reaches the target in both contexts.

Actual behavior

The ordinary touch context passes. The mobile context times out:

locator.tap: Timeout 3000ms exceeded.
<main>…</main> intercepts pointer events

Additional context

After scrolling in the mobile context, visualViewport.offsetLeft is 118. The target's getBoundingClientRect() centre is x=1213. A direct touchscreen tap at x=1095, subtracting the visual offset, reaches the intended button in a separate control. The locator action still fails with current Playwright. Version 1.55.1 also exhibits the issue.

Reporting this reproduction for maintainer triage. No implementation or PR is planned without assignment or approval.

Environment

System:
  OS: Linux 7.0 Ubuntu 26.04.1 LTS (Resolute Raccoon)
  CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700K
  Memory: 11.47 GB / 14.86 GB
  Container: Yes
Binaries:
  Node: 24.21.0 - ~/.nvm/versions/node/v24.21.0/bin/node
  npm: 11.19.0 - ~/.nvm/versions/node/v24.21.0/bin/npm
Languages:
  Bash: 5.3.9 - /usr/bin/bash
npmPackages:
  playwright: 1.65.1 => 1.65.1

— Devon Jonte

Activity

  1. microsoft-playwright-automation commented on Nov 16, 2026

    @microsoft-playwright-automation
  2. microsoft-playwright-automation commented on Nov 16, 2026

    @microsoft-playwright-automation
    Contributor

    Hi, I'm the Playwright bot. I reproduced this and prepared a fix.

    Reproduced in Chromium 159.0.8154.6 on Linux, using Playwright 1.66.0-next at 826ce42b8664ea940424e77ce51f1cdf96dcd37f. Chromium returns element positions relative to the visible viewport, but Playwright checked those positions against the layout viewport. That check reported <main> as an obstruction before sending the tap. The fix converts the coordinates for this check; touch event coordinates remain unchanged.

    The existing locator tap test now covers a mobile page that pans horizontally and vertically. Firefox does not support isMobile, so its test uses an ordinary touch context.

    Condensed reproduction
    const context = await browser.newContext({
      hasTouch: true,
      isMobile: true,
      viewport: { width: 1200, height: 900 },
    });
    const page = await context.newPage();
    await page.setContent(`
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <main style="width: 1534px; height: 1800px; position: relative">
        <button id="a">a</button>
        <button id="b"
          style="position: absolute; left: 1200px; top: 1000px; width: 50px; height: 50px"
          onclick="this.textContent = 'tapped'">b</button>
      </main>
    `);
    await page.locator('#a').tap();
    await page.locator('#b').tap();
    await expect(page.locator('#b')).toHaveText('tapped');
    Checks and browser differences
    • Before the fix, the extended Chromium locator tap test timed out. A final check with the conversion removed failed only in Chromium; Firefox and WebKit passed. Restoring it made all three pass.
    • A separate Chromium coordinate check measured visualViewport.offsetLeft = 334: the button's layout x-position was 1200, but its protocol x-position was 866. Forced taps and clicks reached the button, and their event clientX was 1225.
    • The same coordinate control passed in WebKit 27.2 with mobile emulation and Firefox 159.0 with ordinary touch emulation. Both had zero visual viewport offset.
    • After the fix, the locator regression passed in all three browsers, both headless and headed.
    • tap.spec.ts, browsercontext-viewport-mobile.spec.ts, page-click.spec.ts, page-click-scroll.spec.ts, and elementhandle-bounding-box.spec.ts: 396 passed, 18 skipped across the three browsers.
    • npm run build and npm run flint passed.

    The reported published versions, 1.65.1 and 1.55.1, were not rerun: the failure reproduced on the current source.

    Draft PR: #44148

    Triaged on Linux by the Playwright bot - agent run

  3. pavelfeldman commented on Nov 20, 2026

    @pavelfeldman
    Member

    Looks like a real issue we don't want to invest into at this point. Accepting this as a gap in our implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions