Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set browser preferences correctly #308

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/chrome-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ class Launcher {
return;
}

const preferenceFile = `${this.userDataDir}/Preferences`;
const profileDir = `${this.userDataDir}/Default`;
if (!this.fs.existsSync(profileDir)) {
this.fs.mkdirSync(profileDir, {recursive: true});
}

const preferenceFile = `${profileDir}/Preferences`;
try {
if (this.fs.existsSync(preferenceFile)) {
// overwrite existing file
Expand Down
6 changes: 4 additions & 2 deletions test/chrome-launcher-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ describe('Launcher', () => {
const existStub = stub().returns(true)
const readFileStub = stub().returns(JSON.stringify({ some: 'prefs' }))
const writeFileStub = stub()
const fs = {...fsMock, rmdirSync: spy(), readFileSync: readFileStub, writeFileSync: writeFileStub, existsSync: existStub };
const mkdirStub = stub()
const fs = {...fsMock, rmdir: spy(), readFileSync: readFileStub, writeFileSync: writeFileStub, existsSync: existStub, mkdirSync: mkdirStub };
const chromeInstance =
new Launcher({prefs: {'download.default_directory': '/some/dir'}}, {fs: fs as any});

Expand All @@ -89,7 +90,8 @@ describe('Launcher', () => {
const existStub = stub().returns(false)
const readFileStub = stub().returns(Buffer.from(JSON.stringify({ some: 'prefs' })))
const writeFileStub = stub()
const fs = {...fsMock, rmdirSync: spy(), readFileSync: readFileStub, writeFileSync: writeFileStub, existsSync: existStub };
const mkdirStub = stub()
const fs = {...fsMock, rmdir: spy(), readFileSync: readFileStub, writeFileSync: writeFileStub, existsSync: existStub, mkdirSync: mkdirStub };
const chromeInstance =
new Launcher({prefs: {'download.default_directory': '/some/dir'}}, {fs: fs as any});

Expand Down
Loading