From d8104ef3e834610835c9cb663eea7659a7e3eaa9 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Tue, 7 Apr 2020 22:49:15 +0200 Subject: [PATCH] update(puppeteer): `product` option support - product option support as per 2.1 - version bump - test updated https://github.com/puppeteer/puppeteer/releases/tag/v2.1.0 https://github.com/puppeteer/puppeteer/pull/5137/ Thanks! --- types/puppeteer/index.d.ts | 17 ++++++++++++++++- types/puppeteer/puppeteer-tests.ts | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index b2c7dacf259c54b..b08e8fde62a571f 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for puppeteer 2.0 +// Type definitions for puppeteer 2.1 // Project: https://github.com/GoogleChrome/puppeteer#readme // Definitions by: Marvin Hagemeister // Christopher Deutsch @@ -8,6 +8,7 @@ // Jason Kaczmarsky // Dave Cardwell // Andrés Ortiz +// Piotr Błażejewicz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 @@ -42,6 +43,8 @@ export type SerializableOrJSHandle = Serializable | JSHandle; export type Platform = "mac" | "win32" | "win64" | "linux"; +export type Product = "chrome" | "firefox"; + /** Defines `$eval` and `$$eval` for Page, Frame and ElementHandle. */ export interface Evalable { /** @@ -2029,6 +2032,12 @@ export interface Target { } export interface LaunchOptions extends ChromeArgOptions, BrowserOptions, Timeoutable { + /** + * Which browser to launch. + * At this time, this is either `chrome` or `firefox`. See also `PUPPETEER_PRODUCT`. + * @default 'chrome' + */ + product?: Product; /** * Path to a Chromium executable to run instead of bundled Chromium. If * executablePath is a relative path, then it is resolved relative to current @@ -2213,6 +2222,7 @@ export interface BrowserFetcher { download(revision: string, progressCallback?: (downloadBytes: number, totalBytes: number) => void): Promise; localRevisions(): Promise; platform(): Platform; + product(): Product; remove(revision: string): Promise; revisionInfo(revision: string): RevisionInfo; } @@ -2228,6 +2238,7 @@ export interface RevisionInfo { url: string; /** whether the revision is locally available on disk */ local: boolean; + product: Product; } export interface FetcherOptions { @@ -2237,6 +2248,10 @@ export interface FetcherOptions { path?: string; /** Possible values are: `mac`, `win32`, `win64`, `linux`. Defaults to the current platform. */ platform?: Platform; + /** + * @default 'chrome' + */ + product?: Product; } /** Attaches Puppeteer to an existing Chromium instance */ diff --git a/types/puppeteer/puppeteer-tests.ts b/types/puppeteer/puppeteer-tests.ts index 3171c9b0330c4db..d6a0da7600a1b2c 100644 --- a/types/puppeteer/puppeteer-tests.ts +++ b/types/puppeteer/puppeteer-tests.ts @@ -213,6 +213,22 @@ puppeteer.launch().then(async browser => { browser.close(); })(); +// `product` support +(async () => { + await puppeteer.launch({ + product: 'chrome', + }); + await puppeteer.launch({ + product: 'firefox', + }); + const options: puppeteer.FetcherOptions = { + product: 'firefox', + }; + const browserFetcher = puppeteer.createBrowserFetcher(options); + browserFetcher.product(); // $ExpectType Product + browserFetcher.revisionInfo('revision').product; // $ExpectType Product +})(); + // Launching with default viewport disabled (async () => { await puppeteer.launch({