Skip to content

fix(fillField): prevent rich-editor keystroke leak to sibling inputs#5531

Merged
DavertMik merged 2 commits into4.xfrom
fix/rich-editor-keystroke-leak
Apr 22, 2026
Merged

fix(fillField): prevent rich-editor keystroke leak to sibling inputs#5531
DavertMik merged 2 commits into4.xfrom
fix/rich-editor-keystroke-leak

Conversation

@DavertMik
Copy link
Copy Markdown
Contributor

Summary

  • Fixes I.fillField('iframe', …) (and similar wrappers) typing into an unrelated outer input instead of the editor inside the iframe.
  • Two root causes, both in lib/helper/extras/richTextEditor.js:
    • IFRAME branch assumed the iframe <body> was editable — on Monaco/CodeMirror/ACE (hidden internal textarea) body.focus() silently no-ops and page.keyboard.type lands on whatever the root page had focused.
    • Detection walked the DOM upward when the matched element looked hidden, so on busy pages it could pick up an unrelated editor elsewhere.
  • Fix: detection only walks down from the user's locator; the IFRAME branch re-detects the real input surface inside the iframe; every focus/click is verified against document.activeElement before typing — a failed focus throws instead of leaking.
  • Backing-textarea fixtures (TinyMCE legacy, CKEditor 4/5, CodeMirror 5, Summernote) wrapped so #editor is the visible container, matching the new descendant-only contract.

Test plan

  • #fillField - rich text editors — all 12 editors, 4 cases each (48 tests) pass against Playwright.
  • New rich editor with sibling focused input — no keystroke leak suite (7 tests): IFRAME (Monaco), HIDDEN_TEXTAREA (CodeMirror 5) and CONTENTEDITABLE (CKEditor 5) paths each verify that I.fillField on the editor does not leak into an outer <input autofocus placeholder="Title"> sibling. Plus a negative test confirming I.fillField('#editor-inner', …) on a display:none backing textarea throws instead of leaking.
  • Full rich-text suite: 55/55 passing (npx mocha test/helper/Playwright_test.js --grep "#fillField - rich text editors").
  • Run the same grep against Puppeteer_test.js / WebDriver_test.js once their environments are up.

🤖 Generated with Claude Code

DavertMik and others added 2 commits April 22, 2026 12:44
The IFRAME branch typed via the root-page keyboard against an iframe body
that's not contenteditable (Monaco-style editors), so keystrokes landed on
whatever the outer document had focused. Detection also climbed the DOM
when the matched element looked hidden, which could pick up unrelated
editors elsewhere on the page.

Now: detection only walks down from the user's locator, the IFRAME branch
re-detects the real input surface inside the iframe, and every focus/click
is verified against document.activeElement before typing — a failed focus
throws instead of leaking. Backing-textarea fixtures (TinyMCE legacy,
CKEditor 4/5, CodeMirror 5, Summernote) wrapped so #editor is the visible
container. Adds sibling-input regression coverage for IFRAME, CONTENTEDITABLE
and HIDDEN_TEXTAREA paths plus a negative test for hidden backing locators.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… form controls

- WebDriver/BiDi rejects element refs as executeScript args from inside a
  switched-frame context, breaking the inner-iframe focus/select calls.
  Run those scripts via document.querySelector on the marker instead, then
  send keystrokes via the already-frame-aware page keyboard.
- Add EDITOR.UNREACHABLE: when the user's locator points at a display:none
  INPUT/TEXTAREA, throw a clear error instead of falling through. Without
  this, Puppeteer's lenient el.type() silently leaks to whatever has focus.
- Test reads outer-input value via executeScript to dodge a pre-existing
  WebDriver grabValueFrom bug that drops empty strings in forEachAsync.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@DavertMik DavertMik merged commit f40a32c into 4.x Apr 22, 2026
10 checks passed
@DavertMik DavertMik deleted the fix/rich-editor-keystroke-leak branch April 22, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant