diff --git a/tests/page/page-network-idle.spec.ts b/tests/page/page-network-idle.spec.ts index 7d7a90f9d1..d570ccbb8b 100644 --- a/tests/page/page-network-idle.spec.ts +++ b/tests/page/page-network-idle.spec.ts @@ -156,17 +156,23 @@ it('should wait for networkidle from the popup', async ({ page, server }) => { } }); -it('should wait for networkidle when iframe attaches and detaches', async ({ page }) => { - await page.setContent(` +it('should wait for networkidle when iframe attaches and detaches', async ({ page, server }) => { + server.setRoute('/empty.html', () => {}); + let done = false; + const promise = page.setContent(` - `, { waitUntil: 'networkidle' }); - expect(await page.$('iframe')).toBe(null); + `, { waitUntil: 'networkidle' }).then(() => done = true); + await page.waitForTimeout(600); + expect(done).toBe(false); + await page.evaluate(() => { + document.querySelector('iframe').remove(); + }); + await promise; + expect(done).toBe(true); });