Skip to content

Commit

Permalink
fix(oopifs): ignore target closure when broadcasting across oopifs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman committed Feb 2, 2021
1 parent 5564b20 commit 9e09bd3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/server/chromium/crPage.ts
Expand Up @@ -93,7 +93,17 @@ export class CRPage implements PageDelegate {
}

private async _forAllFrameSessions(cb: (frame: FrameSession) => Promise<any>) {
await Promise.all(Array.from(this._sessions.values()).map(frame => cb(frame)));
const frameSessions = Array.from(this._sessions.values());
await Promise.all(frameSessions.map(frameSession => {
if (frameSession._isMainFrame())
return cb(frameSession);
return cb(frameSession).catch(e => {
// Broadcasting a message to the closed iframe shoule be a noop.
if (e.message && (e.message.includes('Target closed.') || e.message.includes('Session closed.')))
return;
throw e;
});
}));
}

private _sessionForFrame(frame: frames.Frame): FrameSession {
Expand Down Expand Up @@ -348,7 +358,7 @@ class FrameSession {
});
}

private _isMainFrame(): boolean {
_isMainFrame(): boolean {
return this._targetId === this._crPage._targetId;
}

Expand Down

0 comments on commit 9e09bd3

Please sign in to comment.