From 3f37d8507e54aca278bcfa1c30c55e1fb4aed705 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Wed, 4 Nov 2020 22:42:35 -0800 Subject: [PATCH] test(focus): add passing test for focusing more than one page (#4347) --- test/emulation-focus.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/emulation-focus.spec.ts b/test/emulation-focus.spec.ts index 30bdd1efd9..75d9b1abba 100644 --- a/test/emulation-focus.spec.ts +++ b/test/emulation-focus.spec.ts @@ -171,3 +171,15 @@ it('should change focused iframe', async ({page, server}) => { expect(focused).toEqual([false, true]); } }); + +// @see https://github.com/microsoft/playwright/issues/3476 +it('should focus with more than one page/context', async ({contextFactory}) => { + const page1 = await (await contextFactory()).newPage(); + const page2 = await (await contextFactory()).newPage(); + await page1.setContent(``); + await page2.setContent(``); + await page1.focus('#foo'); + await page2.focus('#foo'); + expect(await page1.evaluate(() => !!window['gotFocus'])).toBe(true); + expect(await page2.evaluate(() => !!window['gotFocus'])).toBe(true); +});