From 2cfc9976146723d509e5d66c6fe24fbfec27c376 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Wed, 3 Nov 2021 19:41:31 -0700 Subject: [PATCH] test: detach frame while clicking race (#10029) --- tests/page/page-click.spec.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/page/page-click.spec.ts b/tests/page/page-click.spec.ts index 1e3aa0fe36..0b6d837493 100644 --- a/tests/page/page-click.spec.ts +++ b/tests/page/page-click.spec.ts @@ -16,7 +16,7 @@ */ import { test as it, expect } from './pageTest'; -import { attachFrame } from '../config/utils'; +import { attachFrame, detachFrame } from '../config/utils'; async function giveItAChanceToClick(page) { for (let i = 0; i < 5; i++) @@ -820,3 +820,31 @@ it('should retry when navigating during the click', async ({ page, server, mode const error = await page.click('button', { __testHookBeforeStable, timeout: 2000 } as any).catch(e => e); expect(error.message).toContain('element was detached from the DOM, retrying'); }); + +it('should not hang when frame is detached', async ({ page, server, mode }) => { + it.skip(mode !== 'default'); + + await attachFrame(page, 'frame1', server.EMPTY_PAGE); + const frame = page.frames()[1]; + await frame.goto(server.PREFIX + '/input/button.html'); + + // Start moving the button. + await frame.$eval('button', button => { + button.style.transition = 'margin 5s linear 0s'; + button.style.marginLeft = '200px'; + }); + + let detachPromise; + const __testHookBeforeStable = () => { + // Detach the frame after "waiting for stable" has started. + setTimeout(() => { + detachPromise = detachFrame(page, 'frame1'); + }, 1000); + }; + const promise = frame.click('button', { __testHookBeforeStable } as any).catch(e => e); + + await detachPromise; + const error = await promise; + expect(error).toBeTruthy(); + expect(error.message).toMatch(/frame got detached|Frame was detached/); +});