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

This fixes a common flaky error on the bots:
```
Error: Cannot find object to emit "loadstate": Frame@f5b80c8c318c5471a1e6af552866e981
```
This commit is contained in:
Dmitry Gozman 2020-11-19 19:20:53 -08:00 committed by GitHub
parent 240d51f1d3
commit 5e6eed0d87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -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));
}

View file

@ -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);
}