Skip to content

Commit

Permalink
fix: improve frame session management (#13022)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN authored Sep 3, 2024
1 parent 9aef4ab commit 049e13c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
8 changes: 2 additions & 6 deletions packages/puppeteer-core/src/cdp/Frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,8 @@ export class CdpFrame extends Frame {

@throwIfDetached
async addPreloadScript(preloadScript: CdpPreloadScript): Promise<void> {
// TODO: this might be not correct and we might be adding a preload
// script multiple times to the nested frames.
if (
this.#client === this._frameManager.client &&
this !== this._frameManager.mainFrame()
) {
const parentFrame = this.parentFrame();
if (parentFrame && this.#client === parentFrame.client) {
return;
}
if (preloadScript.getIdForFrame(this)) {
Expand Down
7 changes: 3 additions & 4 deletions packages/puppeteer-core/src/cdp/FrameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,10 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
): void {
let frame = this.frame(frameId);
if (frame) {
if (session && frame.client !== this.#client) {
// TODO: check this condition. It might not be correct for
// nested frames.
const parentFrame = this.frame(parentFrameId);
if (session && parentFrame && frame.client !== parentFrame?.client) {
// If an OOP iframes becomes a normal iframe
// again it is first attached to the parent page before the
// again it is first attached to the parent frame before the
// target is removed.
frame.updateClient(session);
}
Expand Down

0 comments on commit 049e13c

Please sign in to comment.