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

update(puppeteer): product option support #43716

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 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 @@ -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 {
/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2213,6 +2222,7 @@ export interface BrowserFetcher {
download(revision: string, progressCallback?: (downloadBytes: number, totalBytes: number) => void): Promise<RevisionInfo>;
localRevisions(): Promise<string[]>;
platform(): Platform;
product(): Product;
remove(revision: string): Promise<void>;
revisionInfo(revision: string): RevisionInfo;
}
Expand All @@ -2228,6 +2238,7 @@ export interface RevisionInfo {
url: string;
/** whether the revision is locally available on disk */
local: boolean;
product: Product;
}

export interface FetcherOptions {
Expand All @@ -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 */
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 Product
browserFetcher.revisionInfo('revision').product; // $ExpectType Product
})();

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