fix: error for pre-existing OOPIFs (#7899)

Issues: #7844, #7896
This commit is contained in:
Alex Rudenko 2022-01-17 08:00:00 +01:00 committed by GitHub
parent 486bbe010d
commit d7937b806d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View File

@ -256,7 +256,7 @@ export class FrameManager extends EventEmitter {
const session = Connection.fromSession(this._client).session( const session = Connection.fromSession(this._client).session(
event.sessionId event.sessionId
); );
frame._updateClient(session); if (frame) frame._updateClient(session);
this.setupEventListeners(session); this.setupEventListeners(session);
await this.initialize(session); await this.initialize(session);
} }

View File

@ -28,7 +28,10 @@ describeChromeOnly('OOPIF', function () {
const { puppeteer, defaultBrowserOptions } = getTestState(); const { puppeteer, defaultBrowserOptions } = getTestState();
browser = await puppeteer.launch( browser = await puppeteer.launch(
Object.assign({}, defaultBrowserOptions, { Object.assign({}, defaultBrowserOptions, {
args: (defaultBrowserOptions.args || []).concat(['--site-per-process']), args: (defaultBrowserOptions.args || []).concat([
'--site-per-process',
'--remote-debugging-port=21222',
]),
}) })
); );
}); });
@ -309,6 +312,26 @@ describeChromeOnly('OOPIF', function () {
expect(result.x).toBeGreaterThan(150); // padding + margin + border left expect(result.x).toBeGreaterThan(150); // padding + margin + border left
expect(result.y).toBeGreaterThan(150); // padding + margin + border top expect(result.y).toBeGreaterThan(150); // padding + margin + border top
}); });
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();
});
}); });
/** /**