mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
chore: cleanup code around device descriptors (#404)
This commit is contained in:
parent
a494efed0f
commit
92b14cf996
@ -17,7 +17,4 @@
|
||||
|
||||
const {DeviceDescriptors} = require('./lib/deviceDescriptors');
|
||||
|
||||
const descriptors = DeviceDescriptors.slice();
|
||||
module.exports = descriptors;
|
||||
for (const device of descriptors)
|
||||
module.exports[device.name] = device;
|
||||
module.exports = DeviceDescriptors;
|
||||
|
@ -20,15 +20,14 @@ import * as https from 'https';
|
||||
import * as URL from 'url';
|
||||
import * as browsers from '../browser';
|
||||
import { BrowserFetcher, BrowserFetcherOptions, BrowserFetcherRevisionInfo, OnProgressCallback } from '../browserFetcher';
|
||||
import { DeviceDescriptor, DeviceDescriptors } from '../deviceDescriptors';
|
||||
import { DeviceDescriptors } from '../deviceDescriptors';
|
||||
import * as Errors from '../errors';
|
||||
import * as types from '../types';
|
||||
import { assert } from '../helper';
|
||||
import { ConnectionTransport, WebSocketTransport, SlowMoTransport } from '../transport';
|
||||
import { ConnectionOptions, createBrowserFetcher, CRLauncher, LauncherChromeArgOptions, LauncherLaunchOptions } from './crLauncher';
|
||||
import { CRBrowser } from './crBrowser';
|
||||
|
||||
type Devices = { [name: string]: DeviceDescriptor } & DeviceDescriptor[];
|
||||
|
||||
export class CRPlaywright {
|
||||
private _projectRoot: string;
|
||||
private _launcher: CRLauncher;
|
||||
@ -80,11 +79,8 @@ export class CRPlaywright {
|
||||
return this._launcher.executablePath();
|
||||
}
|
||||
|
||||
get devices(): Devices {
|
||||
const result = DeviceDescriptors.slice() as Devices;
|
||||
for (const device of DeviceDescriptors)
|
||||
result[device.name] = device;
|
||||
return result;
|
||||
get devices(): types.Devices {
|
||||
return DeviceDescriptors;
|
||||
}
|
||||
|
||||
get errors(): any {
|
||||
|
@ -17,13 +17,7 @@
|
||||
|
||||
import * as types from './types';
|
||||
|
||||
export type DeviceDescriptor = {
|
||||
name: string,
|
||||
userAgent: string,
|
||||
viewport: types.Viewport,
|
||||
};
|
||||
|
||||
export const DeviceDescriptors: DeviceDescriptor[] = [
|
||||
const descriptors: types.DeviceDescriptor[] = [
|
||||
{
|
||||
'name': 'Blackberry PlayBook',
|
||||
'userAgent': 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/7.2.1.0 Safari/536.2+',
|
||||
@ -877,3 +871,7 @@ export const DeviceDescriptors: DeviceDescriptor[] = [
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export const DeviceDescriptors = descriptors as types.Devices;
|
||||
for (const device of descriptors)
|
||||
DeviceDescriptors[device.name] = device;
|
||||
|
@ -19,12 +19,11 @@ import * as browsers from '../browser';
|
||||
import { FFBrowser } from './ffBrowser';
|
||||
import { BrowserFetcher, BrowserFetcherOptions, OnProgressCallback, BrowserFetcherRevisionInfo } from '../browserFetcher';
|
||||
import { WebSocketTransport, SlowMoTransport } from '../transport';
|
||||
import { DeviceDescriptors, DeviceDescriptor } from '../deviceDescriptors';
|
||||
import { DeviceDescriptors } from '../deviceDescriptors';
|
||||
import * as Errors from '../errors';
|
||||
import * as types from '../types';
|
||||
import { FFLauncher, createBrowserFetcher } from './ffLauncher';
|
||||
|
||||
type Devices = { [name: string]: DeviceDescriptor } & DeviceDescriptor[];
|
||||
|
||||
export class FFPlaywright {
|
||||
private _projectRoot: string;
|
||||
private _launcher: FFLauncher;
|
||||
@ -61,11 +60,8 @@ export class FFPlaywright {
|
||||
return this._launcher.executablePath();
|
||||
}
|
||||
|
||||
get devices(): Devices {
|
||||
const result = DeviceDescriptors.slice() as Devices;
|
||||
for (const device of DeviceDescriptors)
|
||||
result[device.name] = device;
|
||||
return result;
|
||||
get devices(): types.Devices {
|
||||
return DeviceDescriptors;
|
||||
}
|
||||
|
||||
get errors(): any {
|
||||
|
@ -92,3 +92,10 @@ export const mediaTypes: Set<MediaType> = new Set(['screen', 'print']);
|
||||
|
||||
export type ColorScheme = 'dark' | 'light' | 'no-preference';
|
||||
export const colorSchemes: Set<ColorScheme> = new Set(['dark', 'light', 'no-preference']);
|
||||
|
||||
export type DeviceDescriptor = {
|
||||
name: string,
|
||||
userAgent: string,
|
||||
viewport: Viewport,
|
||||
};
|
||||
export type Devices = { [name: string]: DeviceDescriptor } & DeviceDescriptor[];
|
||||
|
@ -18,6 +18,7 @@ import * as browsers from '../browser';
|
||||
import { BrowserFetcher, BrowserFetcherOptions, OnProgressCallback, BrowserFetcherRevisionInfo } from '../browserFetcher';
|
||||
import { DeviceDescriptors } from '../deviceDescriptors';
|
||||
import * as Errors from '../errors';
|
||||
import * as types from '../types';
|
||||
import { WKLauncher, LauncherLaunchOptions, createBrowserFetcher } from './wkLauncher';
|
||||
import { WKBrowser } from './wkBrowser';
|
||||
|
||||
@ -52,11 +53,8 @@ export class WKPlaywright {
|
||||
return this._launcher.executablePath();
|
||||
}
|
||||
|
||||
get devices(): any {
|
||||
const result = DeviceDescriptors.slice();
|
||||
for (const device of DeviceDescriptors)
|
||||
result[device.name] = device;
|
||||
return result;
|
||||
get devices(): types.Devices {
|
||||
return DeviceDescriptors;
|
||||
}
|
||||
|
||||
get errors(): any {
|
||||
|
Loading…
Reference in New Issue
Block a user