fix(types): add missing properties to DeviceDescriptor (#3332)

This commit is contained in:
Joel Einbinder 2020-08-06 15:45:13 -07:00 committed by GitHub
parent 83ac3f43f3
commit c9409bf1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -168,7 +168,13 @@ export interface CDPSession {
): Promise<Protocol.CommandReturnValues[T]>;
}
type DeviceDescriptor = {viewport: BrowserNewContextOptionsViewport, userAgent: string};
type DeviceDescriptor = {
viewport: BrowserNewContextOptionsViewport;
userAgent: string;
deviceScaleFactor: number;
isMobile: boolean;
hasTouch: boolean;
};
export namespace errors {

View File

@ -714,11 +714,17 @@ playwright.chromium.launch().then(async browser => {
{
playwright.devices['my device'] = {
userAgent: 'foo',
viewport: {height: 123, width: 456}
viewport: {height: 123, width: 456},
deviceScaleFactor: 1,
hasTouch: false,
isMobile: true,
};
const iPhone = playwright.devices['iPhone 11'];
const assertion: AssertType<string, typeof iPhone.userAgent> = true;
const numberAssertion: AssertType<number, typeof iPhone.viewport.width> = true;
const widthAssertion: AssertType<number, typeof iPhone.viewport.width> = true;
const deviceScaleFactorAssertion: AssertType<number, typeof iPhone.deviceScaleFactor> = true;
const hasTouchAssertion: AssertType<boolean, typeof iPhone.hasTouch> = true;
const isMobileAssertion: AssertType<boolean, typeof iPhone.isMobile> = true;
}
{
const agents = playwright.devices.map(x => x.userAgent);