fix: firefox revision resolution should not update chrome revision (#9507)

Drive-by: don't override options in PuppeteerNode if they are provided.

Closes #9461
This commit is contained in:
Alex Rudenko 2023-01-13 11:57:48 +01:00 committed by GitHub
parent 47f51c8a7d
commit f59bbf4014
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 6 deletions

View File

@ -194,7 +194,7 @@ export class FirefoxLauncher extends ProductLauncher {
}); });
const localRevisions = browserFetcher.localRevisions(); const localRevisions = browserFetcher.localRevisions();
if (localRevisions[0]) { if (localRevisions[0]) {
this.puppeteer.configuration.browserRevision = localRevisions[0]; this.actualBrowserRevision = localRevisions[0];
} }
} }
return this.resolveExecutablePath(); return this.resolveExecutablePath();

View File

@ -38,6 +38,11 @@ export class ProductLauncher {
*/ */
puppeteer: PuppeteerNode; puppeteer: PuppeteerNode;
/**
* @internal
*/
protected actualBrowserRevision?: string;
/** /**
* @internal * @internal
*/ */
@ -65,6 +70,15 @@ export class ProductLauncher {
throw new Error('Not implemented'); throw new Error('Not implemented');
} }
/**
* Set only for Firefox, after the launcher resolves the `latest` revision to
* the actual revision.
* @internal
*/
getActualBrowserRevision(): string | undefined {
return this.actualBrowserRevision;
}
/** /**
* @internal * @internal
*/ */

View File

@ -217,7 +217,11 @@ export class PuppeteerNode extends Puppeteer {
* @internal * @internal
*/ */
get browserRevision(): string { get browserRevision(): string {
return this.configuration.browserRevision ?? this.defaultBrowserRevision!; return (
this.#_launcher?.getActualBrowserRevision() ??
this.configuration.browserRevision ??
this.defaultBrowserRevision!
);
} }
/** /**
@ -292,19 +296,22 @@ export class PuppeteerNode extends Puppeteer {
options: Partial<BrowserFetcherOptions> = {} options: Partial<BrowserFetcherOptions> = {}
): BrowserFetcher { ): BrowserFetcher {
const downloadPath = this.defaultDownloadPath; const downloadPath = this.defaultDownloadPath;
if (downloadPath) { if (!options.path && downloadPath) {
options.path = downloadPath; options.path = downloadPath;
} }
if (!options.path) { if (!options.path) {
throw new Error('A `path` must be specified for `puppeteer-core`.'); throw new Error('A `path` must be specified for `puppeteer-core`.');
} }
if (this.configuration.experiments?.macArmChromiumEnabled) { if (
!('useMacOSARMBinary' in options) &&
this.configuration.experiments?.macArmChromiumEnabled
) {
options.useMacOSARMBinary = true; options.useMacOSARMBinary = true;
} }
if (this.configuration.downloadHost) { if (!('host' in options) && this.configuration.downloadHost) {
options.host = this.configuration.downloadHost; options.host = this.configuration.downloadHost;
} }
if (this.configuration.defaultProduct) { if (!('product' in options) && this.configuration.defaultProduct) {
options.product = this.configuration.defaultProduct; options.product = this.configuration.defaultProduct;
} }
return new BrowserFetcher(options as BrowserFetcherOptions); return new BrowserFetcher(options as BrowserFetcherOptions);