Skip to content

Commit

Permalink
fix: error for pre-existing OOPIFs
Browse files Browse the repository at this point in the history
Issues: #7844, #7896
  • Loading branch information
OrKoN committed Jan 14, 2022
1 parent 59578d9 commit adab250
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/common/FrameManager.ts
Expand Up @@ -257,7 +257,7 @@ export class FrameManager extends EventEmitter {
const session = Connection.fromSession(this._client).session(
event.sessionId
);
frame._updateClient(session);
if (frame) frame._updateClient(session);
this.setupEventListeners(session);
await this.initialize(session);
}
Expand Down
25 changes: 24 additions & 1 deletion test/oopif.spec.ts
Expand Up @@ -28,7 +28,10 @@ describeChromeOnly('OOPIF', function () {
const { puppeteer, defaultBrowserOptions } = getTestState();
browser = await puppeteer.launch(
Object.assign({}, defaultBrowserOptions, {
args: (defaultBrowserOptions.args || []).concat(['--site-per-process']),
args: (defaultBrowserOptions.args || []).concat([
'--site-per-process',
'--remote-debugging-port=21222',
]),
})
);
});
Expand Down Expand Up @@ -268,6 +271,26 @@ describeChromeOnly('OOPIF', function () {
await utils.detachFrame(oopIframe, 'frame1');
expect(oopIframe.childFrames()).toHaveLength(0);
});

it('should detect existing OOPIFs when Puppeteer connects to an existing page', async () => {
const { server, puppeteer } = getTestState();

const frame = page.waitForFrame((frame) =>
frame.url().endsWith('/oopif.html')
);
await page.goto(server.PREFIX + '/dynamic-oopif.html');
await frame;
expect(oopifs(context).length).toBe(1);
expect(page.frames().length).toBe(2);

const browserURL = 'http://127.0.0.1:21222';
const browser1 = await puppeteer.connect({ browserURL });
const target = await browser1.waitForTarget((target) =>
target.url().endsWith('dynamic-oopif.html')
);
await target.page();
browser1.disconnect();
});
});

/**
Expand Down

0 comments on commit adab250

Please sign in to comment.