diff --git a/.mocharc.cjs b/.mocharc.cjs index f2c7a3b3176..54fae5d77b2 100644 --- a/.mocharc.cjs +++ b/.mocharc.cjs @@ -20,8 +20,8 @@ module.exports = { require: ['./test/build/mocha-utils.js', 'source-map-support/register'], spec: 'test/build/**/*.spec.js', exit: !!process.env.CI, - retries: 0, + retries: process.env.CI ? 3 : 0, parallel: !!process.env.PARALLEL, - timeout: 25_000, + timeout: 10_000, reporter: process.env.CI ? 'spec' : 'dot', }; diff --git a/packages/puppeteer-core/src/common/bidi/Page.ts b/packages/puppeteer-core/src/common/bidi/Page.ts index c709eb7b41b..4fbafd86459 100644 --- a/packages/puppeteer-core/src/common/bidi/Page.ts +++ b/packages/puppeteer-core/src/common/bidi/Page.ts @@ -22,6 +22,7 @@ import { PageEmittedEvents, WaitForOptions, } from '../../api/Page.js'; +import {isErrorLike} from '../../util/ErrorLike.js'; import {ConsoleMessage, ConsoleMessageLocation} from '../ConsoleMessage.js'; import {Handler} from '../EventEmitter.js'; import {EvaluateFunc, HandleFor} from '../types.js'; @@ -45,12 +46,18 @@ export class Page extends PageBase { super(); this.#context = context; - this.#context.connection.send('session.subscribe', { - events: [ - ...this.#subscribedEvents.keys(), - ] as Bidi.Session.SubscribeParameters['events'], - contexts: [this.#context.id], - }); + this.#context.connection + .send('session.subscribe', { + events: [ + ...this.#subscribedEvents.keys(), + ] as Bidi.Session.SubscribeParameters['events'], + contexts: [this.#context.id], + }) + .catch(error => { + if (isErrorLike(error) && !error.message.includes('Target closed')) { + throw error; + } + }); for (const [event, subscriber] of this.#subscribedEvents) { this.#context.on(event, subscriber); diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 592d696e06c..ca642c01db6 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -107,6 +107,12 @@ "parameters": ["cdp", "firefox"], "expectations": ["SKIP"] }, + { + "testIdPattern": "[emulation.spec] Emulation Page.viewport should detect touch when applying viewport with touches", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["firefox"], + "expectations": ["FAIL", "PASS", "TIMEOUT"] + }, { "testIdPattern": "[evaluation.spec] Evaluation specs Frame.evaluate should execute after cross-site navigation", "platforms": ["darwin", "linux", "win32"], @@ -801,7 +807,7 @@ "testIdPattern": "[jshandle.spec] JSHandle JSHandle.asElement should return ElementHandle for TextNodes", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL", "TIMEOUT"] + "expectations": ["FAIL", "PASS", "TIMEOUT"] }, { "testIdPattern": "[jshandle.spec] JSHandle JSHandle.jsonValue should not work with dates", diff --git a/test/src/ariaqueryhandler.spec.ts b/test/src/ariaqueryhandler.spec.ts index f051245eed0..77148fdb01b 100644 --- a/test/src/ariaqueryhandler.spec.ts +++ b/test/src/ariaqueryhandler.spec.ts @@ -197,7 +197,9 @@ describe('AriaQueryHandler', () => { }); }); describe('queryAllArray', () => { - it('$$eval should handle many elements', async () => { + it('$$eval should handle many elements', async function () { + this.timeout(25_000); + const {page} = getTestState(); await page.setContent(''); await page.evaluate( diff --git a/test/src/evaluation.spec.ts b/test/src/evaluation.spec.ts index 222372a3b3e..525f5ad11c8 100644 --- a/test/src/evaluation.spec.ts +++ b/test/src/evaluation.spec.ts @@ -474,6 +474,7 @@ describe('Evaluation specs', function () { expect(result).toEqual([42]); }); it('should transfer 100Mb of data from page to node.js', async function () { + this.timeout(25_000); const {page} = getTestState(); const a = await page.evaluate(() => { diff --git a/test/src/queryselector.spec.ts b/test/src/queryselector.spec.ts index 8da5465a9e5..7b035603d5d 100644 --- a/test/src/queryselector.spec.ts +++ b/test/src/queryselector.spec.ts @@ -129,7 +129,9 @@ describe('querySelector', function () { ); expect(sum).toBe(8); }); - it('should handle many elements', async () => { + it('should handle many elements', async function () { + this.timeout(25_000); + const {page} = getTestState(); await page.evaluate( ` @@ -479,7 +481,9 @@ describe('querySelector', function () { ); expect(sum).toBe(8); }); - it('$$eval should handle many elements', async () => { + it('$$eval should handle many elements', async function () { + this.timeout(25_000); + const {page} = getTestState(); await page.evaluate( `