From 05f6ac1478d639a39cb489ec2e3cb5a0e43d86f9 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Wed, 11 Mar 2020 00:29:37 +0100 Subject: [PATCH] device descriptors --- docs/api.md | 4 ++-- index.d.ts | 1 + utils/generate_types/overrides.d.ts | 8 +++++--- utils/generate_types/test/test.ts | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/api.md b/docs/api.md index b072f13c1a55d7..e375385e00bd7c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -3510,10 +3510,10 @@ ResourceType will be one of the following: `document`, `stylesheet`, `image`, `m #### response.buffer() -- returns: > Promise which resolves to a buffer with response body. +- returns: <[Promise]<[Buffer]>> Promise which resolves to a buffer with response body. #### response.finished() -- returns: Waits for this response to finish, throws when corresponding request failed. +- returns: <[Promise]> Waits for this response to finish, throws when corresponding request failed. #### response.frame() - returns: <[Frame]> A [Frame] that initiated this response. diff --git a/index.d.ts b/index.d.ts index daf0fd366f1537..e1813773fb179c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -22,3 +22,4 @@ export const chromium: types.BrowserType; export const firefox: types.BrowserType; export const errors: types.BrowserTypeErrors; export const selectors: types.Selectors; +export const devices: types.Devices; diff --git a/utils/generate_types/overrides.d.ts b/utils/generate_types/overrides.d.ts index a9f65826637dd1..5aed0719f8a341 100644 --- a/utils/generate_types/overrides.d.ts +++ b/utils/generate_types/overrides.d.ts @@ -19,8 +19,8 @@ import { EventEmitter } from 'events'; /** * Can be converted to JSON */ -interface Serializable {} -interface ConnectionTransport {} +type Serializable = {} +type ConnectionTransport = {} type Boxed = { [Index in keyof Args]: Args[Index] | JSHandle }; type PageFunction = string | ((...args: Args) => R | Promise); @@ -125,4 +125,6 @@ export interface ChromiumSession { method: T, params?: Protocol.CommandParameters[T] ): Promise; -} \ No newline at end of file +} + +export type Devices = {[name: string]: {viewport: BrowserNewContextOptionsViewport, userAgent: string}}; diff --git a/utils/generate_types/test/test.ts b/utils/generate_types/test/test.ts index 874ca94032d9ef..a6649f00011c9a 100644 --- a/utils/generate_types/test/test.ts +++ b/utils/generate_types/test/test.ts @@ -518,6 +518,7 @@ playwright.chromium.launch().then(async browser => { (async () => { playwright.chromium.connect; playwright.errors.TimeoutError; + const iPhone = playwright.devices['iPhone']; // Must be a function that evaluates to a selector engine instance. const createTagNameEngine = () => ({