Skip to content

Commit

Permalink
fix: rely on frameSubtreeWillBeDetached to emit contextDestroyed even…
Browse files Browse the repository at this point in the history
…ts (GoogleChromeLabs#3029)

Co-authored-by: browser-automation-bot <133232582+browser-automation-bot@users.noreply.github.com>
  • Loading branch information
OrKoN and browser-automation-bot authored Jan 24, 2025
1 parent 6fe665f commit 0d04e0b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 31 deletions.
12 changes: 0 additions & 12 deletions src/bidiMapper/modules/cdp/CdpTargetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ export class CdpTargetManager {
'Page.frameAttached',
this.#handleFrameAttachedEvent.bind(this),
);
cdpClient.on(
'Page.frameDetached',
this.#handleFrameDetachedEvent.bind(this),
);
cdpClient.on(
'Page.frameSubtreeWillBeDetached',
this.#handleFrameSubtreeWillBeDetached.bind(this),
Expand Down Expand Up @@ -149,14 +145,6 @@ export class CdpTargetManager {
}
}

#handleFrameDetachedEvent(params: Protocol.Page.FrameDetachedEvent) {
// In case of OOPiF no need in deleting BrowsingContext.
if (params.reason === 'swap') {
return;
}
this.#browsingContextStorage.findContext(params.frameId)?.dispose(true);
}

#handleFrameSubtreeWillBeDetached(
params: Protocol.Page.FrameSubtreeWillBeDetachedEvent,
) {
Expand Down
4 changes: 3 additions & 1 deletion src/bidiMapper/modules/context/BrowsingContextImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ export class BrowsingContextImpl {

dispose(emitContextDestroyed: boolean) {
this.#navigationTracker.dispose();
this.#deleteAllChildren();

this.#realmStorage.deleteRealms({
browsingContextId: this.id,
Expand All @@ -227,6 +226,9 @@ export class BrowsingContextImpl {
);
}

// Dispose children after the events are emitted.
this.#deleteAllChildren();

this.#eventManager.clearBufferedEvents(this.id);

this.#browsingContextStorage.deleteContextById(this.id);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 0d04e0b

Please sign in to comment.