diff --git a/docs/api/puppeteer.page.setuseragent.md b/docs/api/puppeteer.page.setuseragent.md index 3bb93b0d647..5843ea51332 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 eeb75273852..81d5da97e25 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 619c4e44dc1..e44345c3a8a 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 3feb5c11b39..0fc2969be45 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 a0b46a5b575..112db1e9979 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;