test(focus): add passing test for focusing more than one page (#4347)

This commit is contained in:
Joel Einbinder 2020-11-04 22:42:35 -08:00 committed by GitHub
parent e942138913
commit 3f37d8507e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(`<button id="foo" onfocus="window.gotFocus=true">foo</button>`);
await page2.setContent(`<button id="foo" onfocus="window.gotFocus=true">foo</button>`);
await page1.focus('#foo');
await page2.focus('#foo');
expect(await page1.evaluate(() => !!window['gotFocus'])).toBe(true);
expect(await page2.evaluate(() => !!window['gotFocus'])).toBe(true);
});