mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: regression in --user-data-dir handling (#8060)
This commit is contained in:
parent
7e1794cdb2
commit
85decdc28d
@ -123,10 +123,6 @@ class ChromeLauncher implements ProductLauncher {
|
||||
|
||||
if (userDataDirIndex !== -1) {
|
||||
userDataDir = chromeArguments[userDataDirIndex].split('=')[1];
|
||||
if (!fs.existsSync(userDataDir)) {
|
||||
throw new Error(`Chrome user data dir not found at '${userDataDir}'`);
|
||||
}
|
||||
|
||||
isTempUserDataDir = false;
|
||||
} else {
|
||||
userDataDir = await mkdtempAsync(
|
||||
|
@ -276,6 +276,31 @@ describe('Launcher specs', function () {
|
||||
// This might throw. See https://github.com/puppeteer/puppeteer/issues/2778
|
||||
await rmAsync(userDataDir).catch(() => {});
|
||||
});
|
||||
itChromeOnly('userDataDir argument with non-existent dir', async () => {
|
||||
const { isChrome, puppeteer, defaultBrowserOptions } = getTestState();
|
||||
|
||||
const userDataDir = await mkdtempAsync(TMP_FOLDER);
|
||||
await rmAsync(userDataDir);
|
||||
const options = Object.assign({}, defaultBrowserOptions);
|
||||
if (isChrome) {
|
||||
options.args = [
|
||||
...(defaultBrowserOptions.args || []),
|
||||
`--user-data-dir=${userDataDir}`,
|
||||
];
|
||||
} else {
|
||||
options.args = [
|
||||
...(defaultBrowserOptions.args || []),
|
||||
'-profile',
|
||||
userDataDir,
|
||||
];
|
||||
}
|
||||
const browser = await puppeteer.launch(options);
|
||||
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
|
||||
await browser.close();
|
||||
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
|
||||
// This might throw. See https://github.com/puppeteer/puppeteer/issues/2778
|
||||
await rmAsync(userDataDir).catch(() => {});
|
||||
});
|
||||
it('userDataDir option should restore state', async () => {
|
||||
const { server, puppeteer, defaultBrowserOptions } = getTestState();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user