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) {
|
if (userDataDirIndex !== -1) {
|
||||||
userDataDir = chromeArguments[userDataDirIndex].split('=')[1];
|
userDataDir = chromeArguments[userDataDirIndex].split('=')[1];
|
||||||
if (!fs.existsSync(userDataDir)) {
|
|
||||||
throw new Error(`Chrome user data dir not found at '${userDataDir}'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
isTempUserDataDir = false;
|
isTempUserDataDir = false;
|
||||||
} else {
|
} else {
|
||||||
userDataDir = await mkdtempAsync(
|
userDataDir = await mkdtempAsync(
|
||||||
|
@ -276,6 +276,31 @@ describe('Launcher specs', function () {
|
|||||||
// This might throw. See https://github.com/puppeteer/puppeteer/issues/2778
|
// This might throw. See https://github.com/puppeteer/puppeteer/issues/2778
|
||||||
await rmAsync(userDataDir).catch(() => {});
|
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 () => {
|
it('userDataDir option should restore state', async () => {
|
||||||
const { server, puppeteer, defaultBrowserOptions } = getTestState();
|
const { server, puppeteer, defaultBrowserOptions } = getTestState();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user