diff --git a/src/common/FrameManager.ts b/src/common/FrameManager.ts index 163c92d14874d..52b8cc77d2a92 100644 --- a/src/common/FrameManager.ts +++ b/src/common/FrameManager.ts @@ -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]; diff --git a/test/assets/inner-frame1.html b/test/assets/inner-frame1.html new file mode 100644 index 0000000000000..00f19ec166b19 --- /dev/null +++ b/test/assets/inner-frame1.html @@ -0,0 +1,10 @@ + diff --git a/test/assets/inner-frame2.html b/test/assets/inner-frame2.html new file mode 100644 index 0000000000000..9a236cc48f035 --- /dev/null +++ b/test/assets/inner-frame2.html @@ -0,0 +1 @@ + diff --git a/test/assets/main-frame.html b/test/assets/main-frame.html new file mode 100644 index 0000000000000..0c50feff85828 --- /dev/null +++ b/test/assets/main-frame.html @@ -0,0 +1,10 @@ + diff --git a/test/oopif.spec.ts b/test/oopif.spec.ts index b8e39b6973ccd..fbd1cdf5fccd3 100644 --- a/test/oopif.spec.ts +++ b/test/oopif.spec.ts @@ -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();