Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion utils/generate_types/overrides.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
10 changes: 8 additions & 2 deletions utils/generate_types/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down