fix: make sure inner OOPIFs can be attached to (#8304)

This commit is contained in:
Alex Rudenko 2022-05-04 07:46:38 +02:00 committed by GitHub
parent a414827a39
commit 553959884f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 0 deletions

View File

@ -136,6 +136,13 @@ export class FrameManager extends EventEmitter {
const result = await Promise.all([
client.send('Page.enable'),
client.send('Page.getFrameTree'),
client !== this._client
? client.send('Target.setAutoAttach', {
autoAttach: true,
waitForDebuggerOnStart: false,
flatten: true,
})
: Promise.resolve(),
]);
const { frameTree } = result[1];

View File

@ -0,0 +1,10 @@
<script>
window.addEventListener('DOMContentLoaded', () => {
const iframe = document.createElement('iframe');
const url = new URL(location.href);
url.hostname = 'inner-frame2.test';
url.pathname = '/inner-frame2.html';
iframe.src = url.toString();
document.body.appendChild(iframe);
}, false);
</script>

View File

@ -0,0 +1 @@
<button>click</button>

View File

@ -0,0 +1,10 @@
<script>
window.addEventListener('DOMContentLoaded', () => {
const iframe = document.createElement('iframe');
const url = new URL(location.href);
url.hostname = 'inner-frame1.test';
url.pathname = '/inner-frame1.html';
iframe.src = url.toString();
document.body.appendChild(iframe);
}, false);
</script>

View File

@ -31,6 +31,7 @@ describeChromeOnly('OOPIF', function () {
args: (defaultBrowserOptions.args || []).concat([
'--site-per-process',
'--remote-debugging-port=21222',
'--host-rules=MAP * 127.0.0.1',
]),
})
);
@ -263,6 +264,20 @@ describeChromeOnly('OOPIF', function () {
expect(oopifs(context).length).toBe(1);
expect(page.frames().length).toBe(2);
});
it('should wait for inner OOPIFs', async () => {
const { server } = getTestState();
await page.goto(`http://mainframe:${server.PORT}/main-frame.html`);
const frame2 = await page.waitForFrame((frame) =>
frame.url().endsWith('inner-frame2.html')
);
expect(oopifs(context).length).toBe(2);
expect(page.frames().filter((frame) => frame.isOOPFrame()).length).toBe(2);
expect(
await frame2.evaluate(() => document.querySelectorAll('button').length)
).toStrictEqual(1);
});
it('should load oopif iframes with subresources and request interception', async () => {
const { server } = getTestState();