From 00b8d9f3dbc6f2d6be0ff01ec10907e726f7775d Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 1 Jun 2022 20:24:25 -0700 Subject: [PATCH] test: opener tab does not throttle rAF (#14564) --- tests/library/popup.spec.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/library/popup.spec.ts b/tests/library/popup.spec.ts index 79d7f049d3..279d43adbd 100644 --- a/tests/library/popup.spec.ts +++ b/tests/library/popup.spec.ts @@ -15,6 +15,7 @@ */ import { browserTest as it, expect } from '../config/browserTest'; +import type { Page } from 'playwright-core'; it('should inherit user agent from browser context @smoke', async function({ browser, server }) { const context = await browser.newContext({ @@ -238,3 +239,31 @@ it('should not dispatch binding on a closed page', async function({ browser, ser else expect(messages.join('|')).toBe('binding|close'); }); + +it('should not throttle rAF in the opener page', async ({ page, server, browserName }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/14557' }); + it.fixme(browserName === 'firefox'); + await page.goto(server.EMPTY_PAGE); + const [popup] = await Promise.all([ + page.waitForEvent('popup'), + page.evaluate(() => { window.open('about:blank'); }), + ]); + await Promise.all([ + waitForRafs(page, 30), + waitForRafs(popup, 30) + ]); + console.log('done'); +}); + +async function waitForRafs(page: Page, count: number): Promise { + await page.evaluate(count => new Promise(resolve => { + const onRaf = () => { + --count; + if (!count) + resolve(); + else + requestAnimationFrame(onRaf); + }; + requestAnimationFrame(onRaf); + }), count); +} \ No newline at end of file