Skip to content

Commit 4b7794b

Browse files
committed
cherry-pick(#34544): fix(aria): disregard text area textContent
1 parent 1efbedd commit 4b7794b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/playwright-core/src/server/injected/ariaSnapshot.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export function generateAriaTree(rootElement: Element): AriaSnapshot {
5757

5858
if (node.nodeType === Node.TEXT_NODE && node.nodeValue) {
5959
const text = node.nodeValue;
60-
if (text)
60+
// <textarea>AAA</textarea> should not report AAA as a child of the textarea.
61+
if (ariaNode.role !== 'textbox' && text)
6162
ariaNode.children.push(node.nodeValue || '');
6263
return;
6364
}

tests/page/page-aria-snapshot.spec.ts

+13
Original file line numberDiff line numberDiff line change
@@ -605,3 +605,16 @@ it('should escape special yaml values', async ({ page }) => {
605605
- textbox: "555"
606606
`);
607607
});
608+
609+
it('should not report textarea textContent', async ({ page }) => {
610+
await page.setContent(`<textarea>Before</textarea>`);
611+
await checkAndMatchSnapshot(page.locator('body'), `
612+
- textbox: Before
613+
`);
614+
await page.evaluate(() => {
615+
document.querySelector('textarea').value = 'After';
616+
});
617+
await checkAndMatchSnapshot(page.locator('body'), `
618+
- textbox: After
619+
`);
620+
});

0 commit comments

Comments
 (0)