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 Feb 2, 2022
1 parent 43b7e6c commit cc0abb0
Show file tree
Hide file tree
Showing 2 changed files with 13 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:',
};
11 changes: 11 additions & 0 deletions tests/page/page-keyboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,17 @@ 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, isMac }) => {
it.skip(!isMac);
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 cc0abb0

Please sign in to comment.