From f3086d7c973b0cabf776fdcaff44252754de0a5f Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Tue, 13 Oct 2020 12:59:58 +0200 Subject: [PATCH] fix(launcher): support relative userDataDir on headless Windows (#6506) Launching headless with a relative `userDataDir` hangs on Windows. Fix by calling `path.resolve` (idempotent) to add an absolute path instead in `defaultArgs`. Issues: #3453 --- src/node/Launcher.ts | 3 ++- test/launcher.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node/Launcher.ts b/src/node/Launcher.ts index 49a111e0996..dbc6fb1391d 100644 --- a/src/node/Launcher.ts +++ b/src/node/Launcher.ts @@ -189,7 +189,8 @@ class ChromeLauncher implements ProductLauncher { args = [], userDataDir = null, } = options; - if (userDataDir) chromeArguments.push(`--user-data-dir=${userDataDir}`); + if (userDataDir) + chromeArguments.push(`--user-data-dir=${path.resolve(userDataDir)}`); if (devtools) chromeArguments.push('--auto-open-devtools-for-tabs'); if (headless) { chromeArguments.push('--headless', '--hide-scrollbars', '--mute-audio'); diff --git a/test/launcher.spec.ts b/test/launcher.spec.ts index 32ab3d9b402..cb402c7ea9b 100644 --- a/test/launcher.spec.ts +++ b/test/launcher.spec.ts @@ -306,7 +306,7 @@ describe('Launcher specs', function () { '--headless' ); expect(puppeteer.defaultArgs({ userDataDir: 'foo' })).toContain( - '--user-data-dir=foo' + `--user-data-dir=${path.resolve('foo')}` ); } else if (isFirefox) { expect(puppeteer.defaultArgs()).toContain('--headless'); @@ -330,7 +330,7 @@ describe('Launcher specs', function () { '-profile' ); expect(puppeteer.defaultArgs({ userDataDir: 'foo' })).toContain( - 'foo' + path.resolve('foo') ); } });