mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 13:45:36 +03:00
fix(types): add missing properties to DeviceDescriptor (#3332)
This commit is contained in:
parent
83ac3f43f3
commit
c9409bf1b3
8
utils/generate_types/overrides.d.ts
vendored
8
utils/generate_types/overrides.d.ts
vendored
@ -168,7 +168,13 @@ export interface CDPSession {
|
|||||||
): Promise<Protocol.CommandReturnValues[T]>;
|
): 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 {
|
export namespace errors {
|
||||||
|
|
||||||
|
@ -714,11 +714,17 @@ playwright.chromium.launch().then(async browser => {
|
|||||||
{
|
{
|
||||||
playwright.devices['my device'] = {
|
playwright.devices['my device'] = {
|
||||||
userAgent: 'foo',
|
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 iPhone = playwright.devices['iPhone 11'];
|
||||||
const assertion: AssertType<string, typeof iPhone.userAgent> = true;
|
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);
|
const agents = playwright.devices.map(x => x.userAgent);
|
||||||
|
Loading…
Reference in New Issue
Block a user