fix(events): avoid firing events after close/detach (#2919)
This commit is contained in:
parent
fc6861410b
commit
c63b706aac
|
|
@ -71,6 +71,11 @@ export class FrameManager {
|
||||||
this._mainFrame = undefined as any as Frame;
|
this._mainFrame = undefined as any as Frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
for (const frame of this._frames.values())
|
||||||
|
frame._stopNetworkIdleTimer();
|
||||||
|
}
|
||||||
|
|
||||||
mainFrame(): Frame {
|
mainFrame(): Frame {
|
||||||
return this._mainFrame;
|
return this._mainFrame;
|
||||||
}
|
}
|
||||||
|
|
@ -926,6 +931,7 @@ export class Frame {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDetached() {
|
_onDetached() {
|
||||||
|
this._stopNetworkIdleTimer();
|
||||||
this._detached = true;
|
this._detached = true;
|
||||||
this._detachedCallback();
|
this._detachedCallback();
|
||||||
for (const data of this._contextData.values()) {
|
for (const data of this._contextData.values()) {
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ export class Page extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
_didClose() {
|
_didClose() {
|
||||||
|
this._frameManager.dispose();
|
||||||
assert(this._closedState !== 'closed', 'Page closed twice');
|
assert(this._closedState !== 'closed', 'Page closed twice');
|
||||||
this._closedState = 'closed';
|
this._closedState = 'closed';
|
||||||
this.emit(Events.Page.Close);
|
this.emit(Events.Page.Close);
|
||||||
|
|
@ -152,11 +153,13 @@ export class Page extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
_didCrash() {
|
_didCrash() {
|
||||||
|
this._frameManager.dispose();
|
||||||
this.emit(Events.Page.Crash);
|
this.emit(Events.Page.Crash);
|
||||||
this._crashedCallback(new Error('Page crashed'));
|
this._crashedCallback(new Error('Page crashed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
_didDisconnect() {
|
_didDisconnect() {
|
||||||
|
this._frameManager.dispose();
|
||||||
assert(!this._disconnected, 'Page disconnected twice');
|
assert(!this._disconnected, 'Page disconnected twice');
|
||||||
this._disconnected = true;
|
this._disconnected = true;
|
||||||
this._disconnectedCallback(new Error('Page closed'));
|
this._disconnectedCallback(new Error('Page closed'));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue