From f045e13e00ac2e94003572799fa63a758b262440 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 5 Sep 2023 16:12:17 -0700 Subject: [PATCH] test: contextmenu on right click (#26885) Reference https://github.com/microsoft/playwright/issues/26515 --- tests/page/page-click.spec.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/page/page-click.spec.ts b/tests/page/page-click.spec.ts index c05cb2d00c..2c8a32b40d 100644 --- a/tests/page/page-click.spec.ts +++ b/tests/page/page-click.spec.ts @@ -1118,3 +1118,26 @@ it('should click if opened select covers the button', async ({ page }) => { await page.click('button'); expect(await page.evaluate('window.__CLICKED')).toBe(42); }); + +it('should fire contextmenu event on right click in correct order', async ({ page, server, browserName }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/26515' }); + it.fixme(browserName === 'chromium', 'mouseup is fired'); + it.fixme(browserName === 'firefox', 'mouseup is fired'); + await page.goto(server.EMPTY_PAGE); + await page.setContent(` + + `); + await page.evaluate(() => { + const logEvent = e => console.log(e.type); + document.addEventListener('mousedown', logEvent); + document.addEventListener('mouseup', logEvent); + document.addEventListener('contextmenu', logEvent); + }); + const entries = []; + page.on('console', message => entries.push(message.text())); + await page.getByRole('button', { name: 'Click me' }).click({ button: 'right' }); + await expect.poll(() => entries).toEqual([ + 'mousedown', + 'contextmenu', + ]); +});