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.
This commit is contained in:
Dmitry Gozman 2024-10-03 08:09:00 -07:00 committed by GitHub
parent d98fa5da2f
commit 6b1d0361cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -364,6 +364,8 @@ export class CRPage implements PageDelegate {
}
async resetForReuse(): Promise<void> {
// 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<Buffer> {

View File

@ -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 = `
<style>
@ -214,6 +214,7 @@ test('should reset mouse position', async ({ reusedContext, browserName, platfor
div:hover { background: red; }
html, body { margin: 0; padding: 0; }
</style>
<div id=filler>one</div>
<div id=one>one</div>
<div id=two>two</div>
`;
@ -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)');