Skip to content

Commit

Permalink
feat(keyboard): support simple copy-pasting using meta+c/v
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 9, 2021
1 parent 43b7e6c commit 0ed3352
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/playwright-core/src/server/macEditingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,6 @@ export const macEditingCommands: {[key: string]: string|string[]} = {
'Shift+Meta+ArrowRight': 'moveToRightEndOfLineAndModifySelection:',

'Meta+KeyA': 'selectAll:',
'Meta+KeyC': 'copy:',
'Meta+KeyV': 'paste:',
};
10 changes: 10 additions & 0 deletions tests/page/page-keyboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ it('should dispatch a click event on a button when Enter gets pressed', async ({
expect((await actual.jsonValue()).clicked).toBe(true);
});

it('should support simple copy-pasting', async ({ page }) => {
await page.setContent(`<div contenteditable>123</div>`);
await page.focus('div');
await page.keyboard.press('Meta+KeyA');
await page.keyboard.press('Meta+KeyC');
await page.keyboard.press('Meta+KeyV');
await page.keyboard.press('Meta+KeyV');
expect(await page.evaluate(() => document.querySelector('div').textContent)).toBe('123123');
});

async function captureLastKeydown(page) {
const lastEvent = await page.evaluateHandle(() => {
const lastEvent = {
Expand Down

0 comments on commit 0ed3352

Please sign in to comment.