fix(networkidle): do not produce networkidle event on errored pages (#13938)

This commit is contained in:
Dmitry Gozman 2022-05-04 20:52:50 +01:00 committed by GitHub
parent f4933e6d8b
commit cf5101d44a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -85,6 +85,8 @@ type SelectorInFrame = {
info: SelectorInfo;
};
const kDummyFrameId = '<dummy>';
export class FrameManager {
private _page: Page;
private _frames = new Map<string, Frame>();
@ -99,6 +101,11 @@ export class FrameManager {
this._mainFrame = undefined as any as Frame;
}
createDummyMainFrameIfNeeded() {
if (!this._mainFrame)
this.frameAttached(kDummyFrameId, null);
}
dispose() {
for (const frame of this._frames.values())
frame._stopNetworkIdleTimer();
@ -468,7 +475,8 @@ export class Frame extends SdkObject {
this._firedLifecycleEvents.add('commit');
this._subtreeLifecycleEvents.add('commit');
this._startNetworkIdleTimer();
if (id !== kDummyFrameId)
this._startNetworkIdleTimer();
}
isDetached(): boolean {

View File

@ -587,8 +587,7 @@ export class Page extends SdkObject {
private _setIsError(error: Error) {
this._pageIsError = error;
if (!this._frameManager.mainFrame())
this._frameManager.frameAttached('<dummy>', null);
this._frameManager.createDummyMainFrameIfNeeded();
}
isClosed(): boolean {