Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(frames): do not start network idle timer after detach (#4502)

Dmitry Gozman5e6eed0d8716
diff --git a/src/client/connection.ts b/src/client/connection.ts
index bf0461d640..cc0e01dc64 100644
--- a/src/client/connection.ts
+++ b/src/client/connection.ts
@@ -122,7 +122,7 @@ export class Connection {
}
const object = this._objects.get(guid);
if (!object)
- throw new Error(`Cannot find object to call "${method}": ${guid}`);
+ throw new Error(`Cannot find object to emit "${method}": ${guid}`);
object._channel.emit(method, this._replaceGuidsWithChannels(params));
}
diff --git a/src/server/frames.ts b/src/server/frames.ts
index 043df215e6..8ce888a285 100644
--- a/src/server/frames.ts
+++ b/src/server/frames.ts
@@ -1056,7 +1056,10 @@ export class Frame extends EventEmitter {
_startNetworkIdleTimer() {
assert(!this._networkIdleTimer);
- if (this._firedLifecycleEvents.has('networkidle'))
+ // We should not start a timer and report networkidle in detached frames.
+ // This happens at least in Firefox for child frames, where we may get requestFinished
+ // after the frame was detached - probably a race in the Firefox itself.
+ if (this._firedLifecycleEvents.has('networkidle') || this._detached)
return;
this._networkIdleTimer = setTimeout(() => this._onLifecycleEvent('networkidle'), 500);
}