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: make sure inner OOPIFs can be attached to #8304

Merged
merged 1 commit into from May 4, 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
7 changes: 7 additions & 0 deletions src/common/FrameManager.ts
Expand Up @@ -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];
Expand Down
10 changes: 10 additions & 0 deletions test/assets/inner-frame1.html
@@ -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>
1 change: 1 addition & 0 deletions test/assets/inner-frame2.html
@@ -0,0 +1 @@
<button>click</button>
10 changes: 10 additions & 0 deletions test/assets/main-frame.html
@@ -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>
15 changes: 15 additions & 0 deletions test/oopif.spec.ts
Expand Up @@ -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',
]),
})
);
Expand Down Expand Up @@ -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();

Expand Down