Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test(webkit): closing dialog > contenteditable (#37084)

Simon Knottc7bf035c35bd
diff --git a/tests/page/page-keyboard.spec.ts b/tests/page/page-keyboard.spec.ts
index 86ff5508b6..0abbfd2c1d 100644
--- a/tests/page/page-keyboard.spec.ts
+++ b/tests/page/page-keyboard.spec.ts
@@ -714,3 +714,21 @@ Keydown: Escape Escape STANDARD []
Keyup: Escape Escape STANDARD []
`.trim());
});
+
+it('should close dialog on Escape key press in contenteditable', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/36727' } }, async ({ page }) => {
+ await page.setContent(`
+ <dialog>
+ <div contenteditable>Edit Me</div>
+ </dialog>
+ `);
+
+ const dialog = page.locator('dialog');
+ const widget = dialog.locator('[contenteditable]');
+ await dialog.evaluate((node: HTMLDialogElement) => node.showModal());
+ await expect(dialog).toHaveJSProperty('open', true);
+ await expect(widget).toBeVisible();
+
+ await widget.press('Escape');
+ await expect(dialog).toHaveJSProperty('open', false);
+ await expect(widget).not.toBeVisible();
+});