Skip to content

Commit

Permalink
cherry-pick(#34544): fix(aria): disregard text area textContent
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Jan 30, 2025
1 parent 1efbedd commit 4b7794b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/playwright-core/src/server/injected/ariaSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export function generateAriaTree(rootElement: Element): AriaSnapshot {

if (node.nodeType === Node.TEXT_NODE && node.nodeValue) {
const text = node.nodeValue;
if (text)
// <textarea>AAA</textarea> should not report AAA as a child of the textarea.
if (ariaNode.role !== 'textbox' && text)
ariaNode.children.push(node.nodeValue || '');
return;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/page/page-aria-snapshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,3 +605,16 @@ it('should escape special yaml values', async ({ page }) => {
- textbox: "555"
`);
});

it('should not report textarea textContent', async ({ page }) => {
await page.setContent(`<textarea>Before</textarea>`);
await checkAndMatchSnapshot(page.locator('body'), `
- textbox: Before
`);
await page.evaluate(() => {
document.querySelector('textarea').value = 'After';
});
await checkAndMatchSnapshot(page.locator('body'), `
- textbox: After
`);
});

0 comments on commit 4b7794b

Please sign in to comment.