From 553959884f4edb4deab760fa8ca38fc1c85c05c5 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Wed, 4 May 2022 07:46:38 +0200 Subject: [PATCH] fix: make sure inner OOPIFs can be attached to (#8304) --- src/common/FrameManager.ts | 7 +++++++ test/assets/inner-frame1.html | 10 ++++++++++ test/assets/inner-frame2.html | 1 + test/assets/main-frame.html | 10 ++++++++++ test/oopif.spec.ts | 15 +++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 test/assets/inner-frame1.html create mode 100644 test/assets/inner-frame2.html create mode 100644 test/assets/main-frame.html 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();