From af42663edbd7001e578407997e44a1d33bfe54d5 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Wed, 20 Sep 2023 14:52:43 +0200 Subject: [PATCH] test: unskip touch tests (#10955) --- docs/api/puppeteer.page.setuseragent.md | 2 +- packages/puppeteer-core/src/api/Page.ts | 5 +---- packages/puppeteer-core/src/bidi/Page.ts | 11 +++++++++++ test/TestExpectations.json | 24 ++++++++++++------------ test/src/TargetManager.spec.ts | 1 + 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/docs/api/puppeteer.page.setuseragent.md b/docs/api/puppeteer.page.setuseragent.md index 3bb93b0d..5843ea51 100644 --- a/docs/api/puppeteer.page.setuseragent.md +++ b/docs/api/puppeteer.page.setuseragent.md @@ -8,7 +8,7 @@ sidebar_label: Page.setUserAgent ```typescript class Page { - setUserAgent( + abstract setUserAgent( userAgent: string, userAgentMetadata?: Protocol.Emulation.UserAgentMetadata ): Promise; diff --git a/packages/puppeteer-core/src/api/Page.ts b/packages/puppeteer-core/src/api/Page.ts index eeb75273..81d5da97 100644 --- a/packages/puppeteer-core/src/api/Page.ts +++ b/packages/puppeteer-core/src/api/Page.ts @@ -1443,13 +1443,10 @@ export abstract class Page extends EventEmitter { * page * @returns Promise which resolves when the user agent is set. */ - async setUserAgent( + abstract setUserAgent( userAgent: string, userAgentMetadata?: Protocol.Emulation.UserAgentMetadata ): Promise; - async setUserAgent(): Promise { - throw new Error('Not implemented'); - } /** * Object containing metrics as key/value pairs. diff --git a/packages/puppeteer-core/src/bidi/Page.ts b/packages/puppeteer-core/src/bidi/Page.ts index 619c4e44..e44345c3 100644 --- a/packages/puppeteer-core/src/bidi/Page.ts +++ b/packages/puppeteer-core/src/bidi/Page.ts @@ -155,6 +155,17 @@ export class BidiPage extends Page { return this.mainFrame().context().cdpSession; } + override async setUserAgent( + userAgent: string, + userAgentMetadata?: Protocol.Emulation.UserAgentMetadata | undefined + ): Promise { + // TODO: handle CDP-specific cases such as mprach. + await this._client().send('Network.setUserAgentOverride', { + userAgent: userAgent, + userAgentMetadata: userAgentMetadata, + }); + } + constructor( browsingContext: BrowsingContext, browserContext: BidiBrowserContext diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 3feb5c11..0fc2969b 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -1829,18 +1829,6 @@ "parameters": ["cdp", "firefox"], "expectations": ["SKIP"] }, - { - "testIdPattern": "[emulation.spec] Emulation Page.emulate should support clicking", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["chrome", "webDriverBiDi"], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[emulation.spec] Emulation Page.emulate should work", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["chrome", "webDriverBiDi"], - "expectations": ["FAIL"] - }, { "testIdPattern": "[emulation.spec] Emulation Page.emulateCPUThrottling should change the CPU throttling rate successfully", "platforms": ["darwin", "linux", "win32"], @@ -3881,12 +3869,24 @@ "parameters": ["cdp", "firefox"], "expectations": ["SKIP"] }, + { + "testIdPattern": "[touchscreen.spec] Touchscreen should report touchMove", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["chrome", "webDriverBiDi"], + "expectations": ["PASS"] + }, { "testIdPattern": "[touchscreen.spec] Touchscreen should tap the button", "platforms": ["darwin", "linux", "win32"], "parameters": ["cdp", "firefox"], "expectations": ["FAIL"] }, + { + "testIdPattern": "[touchscreen.spec] Touchscreen should tap the button", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["chrome", "webDriverBiDi"], + "expectations": ["PASS"] + }, { "testIdPattern": "[tracing.spec] Tracing should throw if tracing on two pages", "platforms": ["darwin", "linux", "win32"], diff --git a/test/src/TargetManager.spec.ts b/test/src/TargetManager.spec.ts index a0b46a5b..112db1e9 100644 --- a/test/src/TargetManager.spec.ts +++ b/test/src/TargetManager.spec.ts @@ -48,6 +48,7 @@ describe('TargetManager', () => { await state.close(); }); + // CDP-specific test. it('should handle targets', async () => { const {server, context, browser} = state;