From d63d97e19489f2ec992b6c98255c66eda53928b4 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Thu, 8 Sep 2022 10:08:33 +0200 Subject: [PATCH] fix: launching firefox with executable path should not expect projectRoot Closes #8919 --- package.json | 11 +++++------ scripts/test-install.sh | 28 ++++++++++++++++++++++++++++ src/node/FirefoxLauncher.ts | 4 +++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index ef1bf03e1bde2..994cdc5251aad 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "puppeteer", + "name": "puppeteer-core", "version": "17.1.2", "description": "A high-level API to control headless Chrome over the DevTools Protocol", "keywords": [ @@ -9,12 +9,12 @@ "automation" ], "type": "commonjs", - "main": "./lib/cjs/puppeteer/puppeteer.js", + "main": "./lib/cjs/puppeteer/puppeteer-core.js", "exports": { ".": { "types": "./lib/types.d.ts", - "import": "./lib/esm/puppeteer/puppeteer.js", - "require": "./lib/cjs/puppeteer/puppeteer.js" + "import": "./lib/esm/puppeteer/puppeteer-core.js", + "require": "./lib/cjs/puppeteer/puppeteer-core.js" }, "./*": { "import": "./*", @@ -40,7 +40,6 @@ "lint": "run-s lint:prettier lint:eslint", "lint:prettier": "prettier --check .", "lint:eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet -f codeframe . || eslint --ext js --ext ts .)", - "install": "node install.js", "generate:sources": "tsx utils/generate_sources.ts", "generate:artifacts": "tsx utils/generate_artifacts.ts", "generate:markdown": "tsx utils/generate_docs.ts", @@ -141,4 +140,4 @@ "tsx": "3.8.2", "typescript": "4.7.4" } -} +} \ No newline at end of file diff --git a/scripts/test-install.sh b/scripts/test-install.sh index 15d1a552dee6d..a0804a3649730 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -127,3 +127,31 @@ echo '{"type":"module"}' >>$TMPDIR/package.json npm install --loglevel silent "${tarball}" node --input-type="module" --eval="import puppeteer from 'puppeteer-core'" node --input-type="module" --eval="import 'puppeteer-core/lib/esm/puppeteer/revisions.js';" + +echo "Testing... Puppeteer Core launch with executablePath" +TMPDIR="$(mktemp -d)" +cd $TMPDIR +echo '{"type":"module"}' >>$TMPDIR/package.json +npm install --loglevel silent "${tarball}" +# The test tries to launch the node process because +# real browser are not downloaded by puppeteer-core. +# The expected error is "Failed to launch the browser process" +# so the test verifies that it does not fail for other reasons. +node --input-type="module" --eval=" +import puppeteer from 'puppeteer-core'; +(async () => { + puppeteer.launch({ + product: 'firefox', + executablePath: 'node' + }).catch(error => error.message.includes('Failed to launch the browser process') ? process.exit(0) : process.exit(1)); +})(); +" +node --input-type="module" --eval=" +import puppeteer from 'puppeteer-core'; +(async () => { + puppeteer.launch({ + product: 'chrome', + executablePath: 'node' + }).catch(error => error.message.includes('Failed to launch the browser process') ? process.exit(0) : process.exit(1)); +})(); +" diff --git a/src/node/FirefoxLauncher.ts b/src/node/FirefoxLauncher.ts index c27f1b8d8b374..7f36fb42f016e 100644 --- a/src/node/FirefoxLauncher.ts +++ b/src/node/FirefoxLauncher.ts @@ -113,7 +113,9 @@ export class FirefoxLauncher implements ProductLauncher { firefoxArguments.push(userDataDir); } - await this._updateRevision(); + if (!this._isPuppeteerCore) { + await this._updateRevision(); + } let firefoxExecutable = executablePath; if (!executablePath) { const {missingText, executablePath} = resolveExecutablePath(this);