diff --git a/test/emulation.spec.js b/test/emulation.spec.js index 330592eec9..2aef30efcb 100644 --- a/test/emulation.spec.js +++ b/test/emulation.spec.js @@ -183,8 +183,10 @@ module.exports.describe = function({testRunner, expect, playwright, headless, FF await page.emulateMedia({ colorScheme: 'light' }); const navigated = page.goto(server.EMPTY_PAGE); for (let i = 0; i < 9; i++) { - page.emulateMedia({ colorScheme: ['dark', 'light'][i & 1] }); - await new Promise(f => setTimeout(f, 1)); + await Promise.all([ + page.emulateMedia({ colorScheme: ['dark', 'light'][i & 1] }), + new Promise(f => setTimeout(f, 1)), + ]); } await navigated; expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(true); diff --git a/test/navigation.spec.js b/test/navigation.spec.js index 1a3c449d92..47cb0493ae 100644 --- a/test/navigation.spec.js +++ b/test/navigation.spec.js @@ -767,7 +767,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF await page.goto(server.PREFIX + '/one-style.html', {waitUntil: []}); await page.waitForLoadState({ waitUntil: 'domcontentloaded' }); }); - it.skip(FFOX)('should work with pages that have loaded before being connected to', async({page, context, server}) => { + it('should work with pages that have loaded before being connected to', async({page, context, server}) => { await page.goto(server.EMPTY_PAGE); await page.evaluate(async () => { const child = window.open(document.location.href); @@ -903,7 +903,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF it('should work', async({page, server}) => { await page.goto(server.PREFIX + '/frames/one-frame.html'); const frame = page.frames()[1]; - + const requestPromise = new Promise(resolve => page.route(server.PREFIX + '/one-style.css',resolve)); await frame.goto(server.PREFIX + '/one-style.html', {waitUntil: 'domcontentloaded'}); const request = await requestPromise; diff --git a/test/page.spec.js b/test/page.spec.js index 3a8a176a72..facb5a8b3e 100644 --- a/test/page.spec.js +++ b/test/page.spec.js @@ -76,7 +76,7 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF await newPage.close(); expect(newPage.isClosed()).toBe(true); }); - it.skip(FFOX)('should terminate network waiters', async({context, server}) => { + it('should terminate network waiters', async({context, server}) => { const newPage = await context.newPage(); const results = await Promise.all([ newPage.waitForRequest(server.EMPTY_PAGE).catch(e => e), @@ -220,18 +220,18 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF }); }); // @see https://github.com/GoogleChrome/puppeteer/issues/3865 - it.skip(FFOX)('should not throw when there are console messages in detached iframes', async({page, server}) => { + it('should not throw when there are console messages in detached iframes', async({page, server}) => { await page.goto(server.EMPTY_PAGE); await page.evaluate(async() => { // 1. Create a popup that Playwright is not connected to. const win = window.open(window.location.href, 'Title', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=200,top=0,left=0'); - while (window.document.readyState !== 'complete') - await new Promise(f => setTimeout(f, 100)); + if (window.document.readyState !== 'complete') + await new Promise(f => window.addEventListener('load', f)); // 2. In this popup, create an iframe that console.logs a message. win.document.body.innerHTML = ``; const frame = win.document.querySelector('iframe'); - while (frame.contentDocument.readyState !== 'complete') - await new Promise(f => setTimeout(f, 100)); + if (!frame.contentDocument || frame.contentDocument.readyState !== 'complete') + await new Promise(f => frame.addEventListener('load', f)); // 3. After that, remove the iframe. frame.remove(); }); diff --git a/test/popup.spec.js b/test/popup.spec.js index 8a2364e8ca..bb7a748a8d 100644 --- a/test/popup.spec.js +++ b/test/popup.spec.js @@ -96,7 +96,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WE expect(await popup.evaluate(() => !!window.opener)).toBe(false); await context.close(); }); - it.skip(FFOX)('should work with clicking target=_blank', async({newContext, server}) => { + it('should work with clicking target=_blank', async({newContext, server}) => { const context = await newContext(); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -109,7 +109,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WE expect(await popup.evaluate(() => !!window.opener)).toBe(true); await context.close(); }); - it.skip(FFOX)('should work with fake-clicking target=_blank and rel=noopener', async({newContext, server}) => { + it('should work with fake-clicking target=_blank and rel=noopener', async({newContext, server}) => { const context = await newContext(); const page = await context.newPage(); // TODO: FFOX sends events for "one-style.html" request to both pages. @@ -125,7 +125,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WE expect(await popup.evaluate(() => !!window.opener)).toBe(false); await context.close(); }); - it.skip(FFOX)('should work with clicking target=_blank and rel=noopener', async({newContext, server}) => { + it('should work with clicking target=_blank and rel=noopener', async({newContext, server}) => { const context = await newContext(); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -138,7 +138,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WE expect(await popup.evaluate(() => !!window.opener)).toBe(false); await context.close(); }); - it.skip(FFOX)('should not treat navigations as new popups', async({newContext, server}) => { + it('should not treat navigations as new popups', async({newContext, server}) => { const context = await newContext(); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); diff --git a/test/screenshot.spec.js b/test/screenshot.spec.js index 6b184ff236..8dd8d0a50d 100644 --- a/test/screenshot.spec.js +++ b/test/screenshot.spec.js @@ -181,8 +181,7 @@ module.exports.describe = function({testRunner, expect, product, FFOX, CHROMIUM, const screenshot = await page.screenshot(); expect(screenshot).toBeGolden('screenshot-webgl.png'); }); - // firefox is flaky - it.skip(FFOX)('should work while navigating', async({page, server}) => { + it('should work while navigating', async({page, server}) => { await page.setViewportSize({width: 500, height: 500}); await page.goto(server.PREFIX + '/redirectloop1.html'); for (let i = 0; i < 10; i++) { diff --git a/test/types.d.ts b/test/types.d.ts index 5aaa2ef67d..8059f82807 100644 --- a/test/types.d.ts +++ b/test/types.d.ts @@ -24,7 +24,7 @@ interface Expect { type DescribeFunction = ((name: string, inner: () => void) => void) & {skip(condition: boolean): DescribeFunction}; -type ItFunction = ((name: string, inner: (state: STATE) => Promise) => void) & {skip(condition: boolean): ItFunction}; +type ItFunction = ((name: string, inner: (state: STATE) => Promise) => void) & {skip(condition: boolean): ItFunction; repeat(n: number): ItFunction}; type TestRunner = { describe: DescribeFunction; @@ -94,10 +94,10 @@ interface TestServer { waitForRequest(path: string): Promise; reset(); serveFile(request: IncomingMessage, response: ServerResponse, pathName: string); - + PORT: number; PREFIX: string; CROSS_PROCESS_PREFIX: string; EMPTY_PAGE: string; - + } \ No newline at end of file