From 439e048a4cf9f6b9c50cb420c67d0c40be7838c6 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 16 Jul 2020 13:18:54 -0700 Subject: [PATCH] feat(rpc): migrate DeviceDescriptors payload to an array (#2981) Currently it is an object with arbitrary keys - that makes it hard to have a protocol definition. --- src/rpc/channels.ts | 2 +- src/rpc/client/playwright.ts | 4 +++- src/rpc/server/playwrightDispatcher.ts | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/rpc/channels.ts b/src/rpc/channels.ts index 4d09618b5f..f8d62f39df 100644 --- a/src/rpc/channels.ts +++ b/src/rpc/channels.ts @@ -29,7 +29,7 @@ export type PlaywrightInitializer = { firefox: BrowserTypeChannel, webkit: BrowserTypeChannel, electron?: ElectronChannel, - deviceDescriptors: types.Devices, + deviceDescriptors: { name: string, descriptor: types.DeviceDescriptor }[], selectors: SelectorsChannel, }; diff --git a/src/rpc/client/playwright.ts b/src/rpc/client/playwright.ts index 246af0424d..d22de2d1b6 100644 --- a/src/rpc/client/playwright.ts +++ b/src/rpc/client/playwright.ts @@ -35,7 +35,9 @@ export class Playwright extends ChannelOwner implements PlaywrightChannel { constructor(scope: DispatcherScope, playwright: Playwright) { const electron = (playwright as any).electron as (Electron | undefined); + const deviceDescriptors = Object.entries(playwright.devices) + .map(([name, descriptor]) => ({ name, descriptor })); super(scope, playwright, 'playwright', { chromium: new BrowserTypeDispatcher(scope, playwright.chromium!), firefox: new BrowserTypeDispatcher(scope, playwright.firefox!), webkit: new BrowserTypeDispatcher(scope, playwright.webkit!), electron: electron ? new ElectronDispatcher(scope, electron) : undefined, - deviceDescriptors: playwright.devices, + deviceDescriptors, selectors: new SelectorsDispatcher(scope, playwright.selectors), }, false, 'playwright'); }