Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error for pre-existing OOPIFs #7899

Merged
merged 1 commit into from Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/FrameManager.ts
Expand Up @@ -256,7 +256,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 @@ -309,6 +312,26 @@ describeChromeOnly('OOPIF', function () {
expect(result.x).toBeGreaterThan(150); // padding + margin + border left
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();
});
});

/**
Expand Down