From d94fbcd53c959382d76c41d0d523228b39fffd07 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 25 Sep 2026 12:11:59 -0700 Subject: [PATCH] test(firefox): Alt+key should not type text on macOS Fixes: https://github.com/microsoft/playwright/issues/42928 --- tests/page/page-keyboard.spec.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/page/page-keyboard.spec.ts b/tests/page/page-keyboard.spec.ts index 5c18214b26e40..d8d16e521473f 100644 --- a/tests/page/page-keyboard.spec.ts +++ b/tests/page/page-keyboard.spec.ts @@ -69,6 +69,24 @@ it('should send a character with insertText', async ({ page, server }) => { expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('嗨a'); }); +it('should not type text with Alt modifier', { + annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/42928' }, +}, async ({ page }) => { + await page.setContent(`
`); + for (const locator of [page.locator('input'), page.locator('textarea'), page.locator('div')]) { + await locator.press('Alt+KeyA'); + await locator.press('Alt+Digit1'); + await locator.press('Alt+Shift+KeyA'); + await page.keyboard.down('Alt'); + await page.keyboard.press('b'); + await page.keyboard.up('Alt'); + await locator.press('c'); + } + await expect(page.locator('input')).toHaveValue('c'); + await expect(page.locator('textarea')).toHaveValue('c'); + await expect(page.locator('div')).toHaveText('c'); +}); + it('insertText should only emit input event', async ({ page, server }) => { await page.goto(server.PREFIX + '/input/textarea.html'); await page.focus('textarea'); @@ -115,9 +133,7 @@ it('should dispatch key events in separate tasks', async ({ page, browserName, i expect(await log.jsonValue()).toEqual(['keydown', 'microtask-keydown', 'keypress', 'microtask-keypress']); }); -it('should report shiftKey', async ({ page, server, browserName, platform }) => { - it.fail(browserName === 'firefox' && platform === 'darwin'); - +it('should report shiftKey', async ({ page, server }) => { await page.goto(server.PREFIX + '/input/keyboard.html'); const keyboard = page.keyboard; const codeForKey = { 'Shift': 16, 'Alt': 18, 'Control': 17 };