mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
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;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
for (const frame of this._frames.values())
|
||||
frame._stopNetworkIdleTimer();
|
||||
}
|
||||
|
||||
mainFrame(): Frame {
|
||||
return this._mainFrame;
|
||||
}
|
||||
@ -926,6 +931,7 @@ export class Frame {
|
||||
}
|
||||
|
||||
_onDetached() {
|
||||
this._stopNetworkIdleTimer();
|
||||
this._detached = true;
|
||||
this._detachedCallback();
|
||||
for (const data of this._contextData.values()) {
|
||||
|
||||
@ -145,6 +145,7 @@ export class Page extends EventEmitter {
|
||||
}
|
||||
|
||||
_didClose() {
|
||||
this._frameManager.dispose();
|
||||
assert(this._closedState !== 'closed', 'Page closed twice');
|
||||
this._closedState = 'closed';
|
||||
this.emit(Events.Page.Close);
|
||||
@ -152,11 +153,13 @@ export class Page extends EventEmitter {
|
||||
}
|
||||
|
||||
_didCrash() {
|
||||
this._frameManager.dispose();
|
||||
this.emit(Events.Page.Crash);
|
||||
this._crashedCallback(new Error('Page crashed'));
|
||||
}
|
||||
|
||||
_didDisconnect() {
|
||||
this._frameManager.dispose();
|
||||
assert(!this._disconnected, 'Page disconnected twice');
|
||||
this._disconnected = true;
|
||||
this._disconnectedCallback(new Error('Page closed'));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user