From 6b1d0361cd552aa9ac1fddf626842226f71eef23 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 3 Oct 2024 08:09:00 -0700 Subject: [PATCH] fix(chromium): reset mouse position upon page reuse (#32944) Similarly to Firefox, move the mouse to (-1, -1) upon page reuse. This fixes the corresponding test on all platforms. --- packages/playwright-core/src/server/chromium/crPage.ts | 2 ++ tests/library/browsercontext-reuse.spec.ts | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/playwright-core/src/server/chromium/crPage.ts b/packages/playwright-core/src/server/chromium/crPage.ts index c1ff803338..57ebc5fa69 100644 --- a/packages/playwright-core/src/server/chromium/crPage.ts +++ b/packages/playwright-core/src/server/chromium/crPage.ts @@ -364,6 +364,8 @@ export class CRPage implements PageDelegate { } async resetForReuse(): Promise { + // See https://github.com/microsoft/playwright/issues/22432. + await this.rawMouse.move(-1, -1, 'none', new Set(), new Set(), true); } async pdf(options: channels.PagePdfParams): Promise { diff --git a/tests/library/browsercontext-reuse.spec.ts b/tests/library/browsercontext-reuse.spec.ts index 14590a3ae3..30319f0aad 100644 --- a/tests/library/browsercontext-reuse.spec.ts +++ b/tests/library/browsercontext-reuse.spec.ts @@ -203,10 +203,10 @@ test('should ignore binding from beforeunload', async ({ reusedContext }) => { expect(called).toBe(false); }); -test('should reset mouse position', async ({ reusedContext, browserName, platform }) => { +test('should reset mouse position', { + annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/22432' }, +}, async ({ reusedContext, browserName, platform }) => { // Note: this test only reproduces the issue locally when run with --repeat-each=20. - test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/22432' }); - test.fixme(browserName === 'chromium' && platform !== 'darwin', 'chromium keeps hover on linux/win'); const pageContent = ` +
one
one
two
`; @@ -224,7 +225,7 @@ test('should reset mouse position', async ({ reusedContext, browserName, platfor await expect(page.locator('#one')).toHaveCSS('background-color', 'rgb(0, 0, 255)'); await expect(page.locator('#two')).toHaveCSS('background-color', 'rgb(0, 0, 255)'); - await page.mouse.move(10, 45); + await page.mouse.move(10, 75); await expect(page.locator('#one')).toHaveCSS('background-color', 'rgb(0, 0, 255)'); await expect(page.locator('#two')).toHaveCSS('background-color', 'rgb(255, 0, 0)');