mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
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.
This commit is contained in:
parent
4c8ba3ed67
commit
439e048a4c
@ -29,7 +29,7 @@ export type PlaywrightInitializer = {
|
||||
firefox: BrowserTypeChannel,
|
||||
webkit: BrowserTypeChannel,
|
||||
electron?: ElectronChannel,
|
||||
deviceDescriptors: types.Devices,
|
||||
deviceDescriptors: { name: string, descriptor: types.DeviceDescriptor }[],
|
||||
selectors: SelectorsChannel,
|
||||
};
|
||||
|
||||
|
||||
@ -35,7 +35,9 @@ export class Playwright extends ChannelOwner<PlaywrightChannel, PlaywrightInitia
|
||||
this.webkit = BrowserType.from(initializer.webkit);
|
||||
if (initializer.electron)
|
||||
(this as any).electron = Electron.from(initializer.electron);
|
||||
this.devices = initializer.deviceDescriptors;
|
||||
this.devices = {};
|
||||
for (const { name, descriptor } of initializer.deviceDescriptors)
|
||||
this.devices[name] = descriptor;
|
||||
this.selectors = Selectors.from(initializer.selectors);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,12 +25,14 @@ import { ElectronDispatcher } from './electronDispatcher';
|
||||
export class PlaywrightDispatcher extends Dispatcher<Playwright, PlaywrightInitializer> 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');
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user