diff --git a/packages/playwright-core/src/server/macEditingCommands.ts b/packages/playwright-core/src/server/macEditingCommands.ts index c6de45d462..38634c0a2e 100644 --- a/packages/playwright-core/src/server/macEditingCommands.ts +++ b/packages/playwright-core/src/server/macEditingCommands.ts @@ -127,6 +127,7 @@ export const macEditingCommands: {[key: string]: string|string[]} = { 'Meta+KeyA': 'selectAll:', 'Meta+KeyC': 'copy:', + 'Meta+KeyX': 'cut:', 'Meta+KeyV': 'paste:', 'Meta+KeyZ': 'undo:', 'Shift+Meta+KeyZ': 'redo:', diff --git a/tests/page/page-keyboard.spec.ts b/tests/page/page-keyboard.spec.ts index 879dc93718..3338fdfeb3 100644 --- a/tests/page/page-keyboard.spec.ts +++ b/tests/page/page-keyboard.spec.ts @@ -482,6 +482,17 @@ it('should support simple copy-pasting', async ({ page, isMac, browserName }) => expect(await page.evaluate(() => document.querySelector('div').textContent)).toBe('123123'); }); +it('should support simple cut-pasting', async ({ page, isMac }) => { + const modifier = isMac ? 'Meta' : 'Control'; + await page.setContent(`
123
`); + await page.focus('div'); + await page.keyboard.press(`${modifier}+KeyA`); + await page.keyboard.press(`${modifier}+KeyX`); + await page.keyboard.press(`${modifier}+KeyV`); + await page.keyboard.press(`${modifier}+KeyV`); + expect(await page.evaluate(() => document.querySelector('div').textContent)).toBe('123123'); +}); + it('should support undo-redo', async ({ page, isMac, browserName, isLinux }) => { it.fixme(browserName === 'webkit' && isLinux, 'https://github.com/microsoft/playwright/issues/12000'); const modifier = isMac ? 'Meta' : 'Control';