diff --git a/packages/playwright-core/src/server/frames.ts b/packages/playwright-core/src/server/frames.ts index 3cc44c0446..90ad50dc4f 100644 --- a/packages/playwright-core/src/server/frames.ts +++ b/packages/playwright-core/src/server/frames.ts @@ -1633,6 +1633,7 @@ export class Frame extends SdkObject { if (this._networkIdleTimer) clearTimeout(this._networkIdleTimer); this._networkIdleTimer = undefined; + this._firedNetworkIdleSelf = false; } async extendInjectedScript(source: string, arg?: any): Promise { diff --git a/tests/page/page-network-idle.spec.ts b/tests/page/page-network-idle.spec.ts index d570ccbb8b..ca73eafda2 100644 --- a/tests/page/page-network-idle.spec.ts +++ b/tests/page/page-network-idle.spec.ts @@ -176,3 +176,33 @@ it('should wait for networkidle when iframe attaches and detaches', async ({ pag await promise; expect(done).toBe(true); }); + +it('should work after repeated navigations in the same page', async ({ page, server }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/18283' }); + + let requestCount = 0; + await page.route('**/empty.html', route => { + route.fulfill({ + contentType: 'text/html', + body: ` + ` + }); + }); + + await page.route('**/sample', route => { + requestCount++; + route.fulfill({ + contentType: 'application/json', + body: JSON.stringify({ + content: 'sample' + }) + }); + }); + + await page.goto(server.EMPTY_PAGE, { waitUntil: 'networkidle' }); + expect(requestCount).toBe(1); + await page.goto(server.EMPTY_PAGE, { waitUntil: 'networkidle' }); + expect(requestCount).toBe(2); +});