fix: make reoccurring networkidle work (#18323)

Fixes https://github.com/microsoft/playwright/issues/18283

Signed-off-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
Max Schmitt 2022-10-25 13:35:18 -07:00 committed by GitHub
parent 0fe1998c72
commit 721ae2b3ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View file

@ -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<js.JSHandle> {

View file

@ -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: `
<script>
fetch('http://localhost:8000/sample').then(res => console.log(res.json()))
</script>`
});
});
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);
});