detach non-main frames; clear websockets, dialogs and workers

This commit is contained in:
Simon Knott 2024-08-01 09:48:40 +02:00
parent b55ad6028a
commit 4d7cac0c03
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 9 additions and 4 deletions

View file

@ -114,10 +114,13 @@ export class FrameManager {
dispose(reason: string) {
for (const frame of this._frames.values()) {
frame.dispose(reason);
frame._onDetached(reason);
frame._stopNetworkIdleTimer();
frame._invalidateNonStallingEvaluations(reason);
this.clearWebSockets(frame);
}
this.closeOpenDialogs();
}
mainFrame(): Frame {
@ -1563,10 +1566,10 @@ export class Frame extends SdkObject {
]);
}
_onDetached() {
_onDetached(reason = 'Frame was detached') {
this._stopNetworkIdleTimer();
this._detachedScope.close(new Error('Frame was detached'));
this.dispose('Frame was detached');
this._detachedScope.close(new Error(reason));
this.dispose(reason);
}
dispose(reason: string) {

View file

@ -284,6 +284,7 @@ export class Page extends SdkObject {
this._closedPromise.resolve();
this.instrumentation.onPageClose(this);
this.openScope.close(new TargetClosedError());
this._clearWorkers();
}
_didCrash() {
@ -293,6 +294,7 @@ export class Page extends SdkObject {
this._crashed = true;
this.instrumentation.onPageClose(this);
this.openScope.close(new Error('Page crashed'));
this._clearWorkers();
}
async _onFileChooserOpened(handle: dom.ElementHandle) {