Skip to content

Commit

Permalink
update(puppeteer): product option support
Browse files Browse the repository at this point in the history
- product option support as per 2.1
- version bump
- test updated

https://github.com/puppeteer/puppeteer/releases/tag/v2.1.0
puppeteer/puppeteer#5137

Thanks!
  • Loading branch information
peterblazejewicz committed Apr 7, 2020
1 parent 26470d8 commit 4d4ca94
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
15 changes: 14 additions & 1 deletion 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 <https://github.com/marvinhagemeister>
// Christopher Deutsch <https://github.com/cdeutsch>
Expand All @@ -8,6 +8,7 @@
// Jason Kaczmarsky <https://github.com/JasonKaz>
// Dave Cardwell <https://github.com/davecardwell>
// Andrés Ortiz <https://github.com/angrykoala>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0

Expand Down Expand Up @@ -2029,6 +2030,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?: 'chrome' | 'firefox';
/**
* Path to a Chromium executable to run instead of bundled Chromium. If
* executablePath is a relative path, then it is resolved relative to current
Expand Down Expand Up @@ -2213,6 +2220,7 @@ export interface BrowserFetcher {
download(revision: string, progressCallback?: (downloadBytes: number, totalBytes: number) => void): Promise<RevisionInfo>;
localRevisions(): Promise<string[]>;
platform(): Platform;
product(): 'chrome' | 'firefox';
remove(revision: string): Promise<void>;
revisionInfo(revision: string): RevisionInfo;
}
Expand All @@ -2228,6 +2236,7 @@ export interface RevisionInfo {
url: string;
/** whether the revision is locally available on disk */
local: boolean;
product: 'chrome' | 'firefox';
}

export interface FetcherOptions {
Expand All @@ -2237,6 +2246,10 @@ export interface FetcherOptions {
path?: string;
/** Possible values are: `mac`, `win32`, `win64`, `linux`. Defaults to the current platform. */
platform?: Platform;
/**
* @default 'chrome'
*/
product?: 'chrome' | 'firefox';
}

/** Attaches Puppeteer to an existing Chromium instance */
Expand Down
16 changes: 16 additions & 0 deletions types/puppeteer/puppeteer-tests.ts
Expand Up @@ -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 "chrome" | "firefox"
browserFetcher.revisionInfo('revision').product; // $ExpectType "chrome" | "firefox"
})();

// Launching with default viewport disabled
(async () => {
await puppeteer.launch({
Expand Down

0 comments on commit 4d4ca94

Please sign in to comment.