properly dispose all frames
This commit is contained in:
parent
118cb77ba9
commit
6edd10df6d
|
|
@ -23,7 +23,7 @@ import type * as frames from './frames';
|
|||
import type { InjectedScript, HitTargetInterceptionResult, ElementState } from './injected/injectedScript';
|
||||
import type { CallMetadata } from './instrumentation';
|
||||
import * as js from './javascript';
|
||||
import { Page } from './page';
|
||||
import type { Page } from './page';
|
||||
import type { Progress } from './progress';
|
||||
import { ProgressController } from './progress';
|
||||
import type * as types from './types';
|
||||
|
|
@ -56,8 +56,6 @@ export class FrameExecutionContext extends js.ExecutionContext {
|
|||
super(frame, delegate, world || 'content-script');
|
||||
this.frame = frame;
|
||||
this.world = world;
|
||||
|
||||
this.frame._page.on(Page.Events.Crash, () => this.contextDestroyed('Page crashed'));
|
||||
}
|
||||
|
||||
override adoptIfNeeded(handle: js.JSHandle): Promise<js.JSHandle> | null {
|
||||
|
|
|
|||
|
|
@ -112,10 +112,11 @@ export class FrameManager {
|
|||
this.frameAttached(kDummyFrameId, null);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
dispose(reason: string) {
|
||||
for (const frame of this._frames.values()) {
|
||||
frame.dispose(reason);
|
||||
frame._stopNetworkIdleTimer();
|
||||
frame._invalidateNonStallingEvaluations('Target crashed');
|
||||
frame._invalidateNonStallingEvaluations(reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1565,10 +1566,14 @@ export class Frame extends SdkObject {
|
|||
_onDetached() {
|
||||
this._stopNetworkIdleTimer();
|
||||
this._detachedScope.close(new Error('Frame was detached'));
|
||||
this.dispose('Frame was detached');
|
||||
}
|
||||
|
||||
dispose(reason: string) {
|
||||
for (const data of this._contextData.values()) {
|
||||
if (data.context)
|
||||
data.context.contextDestroyed('Frame was detached');
|
||||
data.contextPromise.resolve({ destroyedReason: 'Frame was detached' });
|
||||
data.context.contextDestroyed(reason);
|
||||
data.contextPromise.resolve({ destroyedReason: reason });
|
||||
}
|
||||
if (this._parentFrame)
|
||||
this._parentFrame._childFrames.delete(this);
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ export class Page extends SdkObject {
|
|||
}
|
||||
|
||||
_didClose() {
|
||||
this._frameManager.dispose();
|
||||
this._frameManager.dispose('Page closed');
|
||||
this._frameThrottler.dispose();
|
||||
assert(this._closedState !== 'closed', 'Page closed twice');
|
||||
this._closedState = 'closed';
|
||||
|
|
@ -287,7 +287,7 @@ export class Page extends SdkObject {
|
|||
}
|
||||
|
||||
_didCrash() {
|
||||
this._frameManager.dispose();
|
||||
this._frameManager.dispose('Page crashed');
|
||||
this._frameThrottler.dispose();
|
||||
this.emit(Page.Events.Crash);
|
||||
this._crashed = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue