Skip to content

[Regression]: WebKit locator.fill() doesn't work for contenteditable inside shadow DOM #39983

@hi-ogawa

Description

@hi-ogawa

Last Good Version

1.58.2

First Bad Version

1.59.0

Steps to reproduce

Reproduction: https://github.com/hi-ogawa/reproductions/tree/main/vitest-10036-playwright-webkit-fill-shadow-dom

When running a following code:

const page = await browser.newPage();

await page.setContent(`
  <div id="host"></div>
  <script>
    const host = document.getElementById('host')
    const root = host.attachShadow({ mode: 'open' })
    const editor = document.createElement('div')
    editor.contentEditable = 'true'
    root.appendChild(editor)
    window.__editor = editor
  </script>
`);

const locator = page.locator('div[contenteditable="true"]');

await locator.fill("Hello");

const fillResult = await page.evaluate(() => ({
  textContent: window.__editor.textContent,
  innerText: window.__editor.innerText,
}));
console.log(fillResult)

On playwright 1.58.2, both chromium and webkit show 'Hello':

# chromium
{ textContent: 'Hello', innerText: 'Hello' }

# webkit
{ textContent: 'Hello', innerText: 'Hello' }

On 1.59.0, webkit doesn't show Hello:

# chromium
{ textContent: 'Hello', innerText: 'Hello' }

# webkit
{ textContent: '', innerText: '' }

Expected behavior

Webkit should show { textContent: 'Hello', innerText: 'Hello' }

Actual behavior

Webkit shows { textContent: '', innerText: '' }

Additional context

The issue discovered through Vitest browser mode's test suites vitest-dev/vitest#10036

Environment

System:
    OS: Linux 6.18 Arch Linux
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-12650H
    Memory: 12.06 GB / 31.05 GB
    Container: Yes
  Binaries:
    Node: 24.14.1 - /home/hiroshi/.vite-plus/js_runtime/node/24.14.1/bin/node
    npm: 11.11.0 - /home/hiroshi/.vite-plus/js_runtime/node/24.14.1/bin/npm
    pnpm: 10.31.0 - /home/hiroshi/.vite-plus/bin/pnpm
    bun: 1.3.9 - /home/hiroshi/.bun/bin/bun
    Deno: 2.6.6 - /home/hiroshi/.local/bin/deno
  IDEs:
    VSCode: 1.108.2 - /usr/bin/code
    Claude Code: 2.1.89 - /home/hiroshi/.local/bin/claude
    Codex: 0.118.0 - /home/hiroshi/.vite-plus/bin/codex
    opencode: 1.2.17 - /home/hiroshi/.opencode/bin/opencode
  Languages:
    Bash: 5.3.9 - /usr/bin/bash
  npmPackages:
    playwright: 1.59.0 => 1.59.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions