From f59bbf4014644dec6f395713e8403939aebe06ea Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Fri, 13 Jan 2023 11:57:48 +0100 Subject: [PATCH] fix: firefox revision resolution should not update chrome revision (#9507) Drive-by: don't override options in PuppeteerNode if they are provided. Closes #9461 --- .../puppeteer-core/src/node/FirefoxLauncher.ts | 2 +- .../puppeteer-core/src/node/ProductLauncher.ts | 14 ++++++++++++++ .../puppeteer-core/src/node/PuppeteerNode.ts | 17 ++++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/puppeteer-core/src/node/FirefoxLauncher.ts b/packages/puppeteer-core/src/node/FirefoxLauncher.ts index fa245913643..c65d7b50220 100644 --- a/packages/puppeteer-core/src/node/FirefoxLauncher.ts +++ b/packages/puppeteer-core/src/node/FirefoxLauncher.ts @@ -194,7 +194,7 @@ export class FirefoxLauncher extends ProductLauncher { }); const localRevisions = browserFetcher.localRevisions(); if (localRevisions[0]) { - this.puppeteer.configuration.browserRevision = localRevisions[0]; + this.actualBrowserRevision = localRevisions[0]; } } return this.resolveExecutablePath(); diff --git a/packages/puppeteer-core/src/node/ProductLauncher.ts b/packages/puppeteer-core/src/node/ProductLauncher.ts index 5c4619585b5..62ef808f237 100644 --- a/packages/puppeteer-core/src/node/ProductLauncher.ts +++ b/packages/puppeteer-core/src/node/ProductLauncher.ts @@ -38,6 +38,11 @@ export class ProductLauncher { */ puppeteer: PuppeteerNode; + /** + * @internal + */ + protected actualBrowserRevision?: string; + /** * @internal */ @@ -65,6 +70,15 @@ export class ProductLauncher { 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 */ diff --git a/packages/puppeteer-core/src/node/PuppeteerNode.ts b/packages/puppeteer-core/src/node/PuppeteerNode.ts index ca16645ee18..6c96c862229 100644 --- a/packages/puppeteer-core/src/node/PuppeteerNode.ts +++ b/packages/puppeteer-core/src/node/PuppeteerNode.ts @@ -217,7 +217,11 @@ export class PuppeteerNode extends Puppeteer { * @internal */ 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 = {} ): BrowserFetcher { const downloadPath = this.defaultDownloadPath; - if (downloadPath) { + if (!options.path && downloadPath) { options.path = downloadPath; } if (!options.path) { 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; } - if (this.configuration.downloadHost) { + if (!('host' in options) && this.configuration.downloadHost) { options.host = this.configuration.downloadHost; } - if (this.configuration.defaultProduct) { + if (!('product' in options) && this.configuration.defaultProduct) { options.product = this.configuration.defaultProduct; } return new BrowserFetcher(options as BrowserFetcherOptions);