fix: support undo/redo editing commands (#13606)

Fixes #13601
This commit is contained in:
Andrey Lushnikov 2022-04-18 23:22:52 -06:00 committed by GitHub
parent 3c896f6bc5
commit 80bc532874
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -128,4 +128,6 @@ export const macEditingCommands: {[key: string]: string|string[]} = {
'Meta+KeyA': 'selectAll:',
'Meta+KeyC': 'copy:',
'Meta+KeyV': 'paste:',
'Meta+KeyZ': 'undo:',
'Shift+Meta+KeyZ': 'redo:',
};

View file

@ -476,6 +476,20 @@ it('should support simple copy-pasting', async ({ page, isMac, browserName }) =>
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';
await page.setContent(`<div contenteditable></div>`);
const div = page.locator('div');
await expect(div).toHaveText('');
await div.type('123');
await expect(div).toHaveText('123');
await page.keyboard.press(`${modifier}+KeyZ`);
await expect(div).toHaveText('');
await page.keyboard.press(`Shift+${modifier}+KeyZ`);
await expect(div).toHaveText('123');
});
it('should type repeatedly in contenteditable in shadow dom', async ({ page }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/12941' });