Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

firefox-profile

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firefox-profile - npm Package Compare versions

Comparing version 2.0.0 to 3.1.0-alpha.1

.prettierrc

138

CHANGELOG.md

@@ -0,217 +1,217 @@

# 3.0.0
Drop support for node 6 and 8. Now tested against 10, 12 and 14.
# 2.0.0
* WebExtensions with package.json should not be classified as JetPack addon, thanks to @photonios
- WebExtensions with package.json should not be classified as JetPack addon, thanks to @photonios
# 1.3.1
* fix regExp for parsing `user_pref`, thanks to @hbenl
- fix regExp for parsing `user_pref`, thanks to @hbenl
# 1.3.0
* update deps
- update deps
# 1.2.0
* update deps
* drop support for node 4 (travis tests)
- update deps
- drop support for node 4 (travis tests)
# 1.1.0
* update deps (big jump)
* test with nodejs 8
- update deps (big jump)
- test with nodejs 8
# 1.0.3
* more TS typing fixes
- more TS typing fixes
# 1.0.2
* fix TS typings and example in README
- fix TS typings and example in README
# 1.0.1
* Update async from 2.3.0 to 2.4.1 (thanks @EsrefDurna)
- Update async from 2.3.0 to 2.4.1 (thanks @EsrefDurna)
# 1.0.0
* BREAKING CHANGE: handle errors in `encoded(cb)` callback function
- BREAKING CHANGE: handle errors in `encoded(cb)` callback function
# 0.5.0
* Make sure to load user settings if existing profile (thanks @lutostag)
* Drop support for node 0.12
- Make sure to load user settings if existing profile (thanks @lutostag)
- Drop support for node 0.12
# 0.4.9
* better tmp folder cleanup (thanks @Foxhind)
- better tmp folder cleanup (thanks @Foxhind)
# 0.4.8
* fix `archiver.bulk()` deprecation warning (thanks @zdglagola)
- fix `archiver.bulk()` deprecation warning (thanks @zdglagola)
# 0.4.7
* remove `os.tmpDir` deprecation warning (thanks @pdehaan)
- remove `os.tmpDir` deprecation warning (thanks @pdehaan)
# 0.4.6
* (better) fix ctl-c exit
- (better) fix ctl-c exit
# 0.4.5 - DO NOT USE - BROKEN
* fix ctl-c exit
- fix ctl-c exit
# 0.4.4
* package update: node-uuid --> uuid
- package update: node-uuid --> uuid
# 0.4.3
* add webexension support (thanks @hbenl)
* add Typescript (thanks @hbenl)
* updated dependencies versions
- add webexension support (thanks @hbenl)
- add Typescript (thanks @hbenl)
- updated dependencies versions
# 0.4.2
* add `encode` method to make it compatible with `selenium-webdriver`
- add `encode` method to make it compatible with `selenium-webdriver`
# 0.4.1
* fix CLI empty profile creation
- fix CLI empty profile creation
# 0.4.0
* remove [`wrench`](https://github.com/ryanmcgrath/wrench-js) dependency (no longer maintained), replaced by [`fs-extra`](https://github.com/jprichardson/node-fs-extra)
* updated package versions
- remove [`wrench`](https://github.com/ryanmcgrath/wrench-js) dependency (no longer maintained), replaced by [`fs-extra`](https://github.com/jprichardson/node-fs-extra)
- updated package versions
# 0.3.13
* updated package versions
- updated package versions
# 0.3.12
* bugfix with unziped extensions
* CI now against node 0.12 and 4.4
* updated package versions
- bugfix with unziped extensions
- CI now against node 0.12 and 4.4
- updated package versions
# 0.3.11
* added a cli to create or copy profile
- added a cli to create or copy profile
# 0.3.10
* added .npmignore
- added .npmignore
# 0.3.9
* updated package versions
- updated package versions
# 0.3.8
* user preferences parsing fix (thanks @cadorn)
* updated package versions
- user preferences parsing fix (thanks @cadorn)
- updated package versions
# 0.3.7
* updated package versions
- updated package versions
# 0.3.6
* updated package versions
- updated package versions
# 0.3.5
* updated package versions
- updated package versions
# 0.3.4
* updated package versions
* fixes SIGINT and exit process (thanks @XrXr)
- updated package versions
- fixes SIGINT and exit process (thanks @XrXr)
# 0.3.3
* minor fixes, added tests for ProfileFinder
- minor fixes, added tests for ProfileFinder
# 0.3.2
* modify some callbacks to follow the standard `(err, resp)`
- modify some callbacks to follow the standard `(err, resp)`
# 0.3.1
* ability to specify a destination directory
- ability to specify a destination directory
# 0.2.13
* normalize extension path (thanks @halo2376)
- normalize extension path (thanks @halo2376)
# 0.2.12
* catching profileDir delete errors on exit
- catching profileDir delete errors on exit
# 0.2.10
* made most of the fs calls asynchronous
- made most of the fs calls asynchronous
# 0.2.9
* support for jetpack extensions (jpm now in beta) (thanks @jsantell)
- support for jetpack extensions (jpm now in beta) (thanks @jsantell)
# 0.2.8
* updated package versions.
* dropping support for nodejs 0.8.
- updated package versions.
- dropping support for nodejs 0.8.
# 0.2.7
* updated package versions + fixed coverage report
- updated package versions + fixed coverage report
# 0.2.6
* deps version update
- deps version update
# 0.2.5
* fixed packed extension (thanks @jsantell)
* allowed support for the new jetpack extensions that use package.json instead of install.rdf (thanks @jsantell)
- fixed packed extension (thanks @jsantell)
- allowed support for the new jetpack extensions that use package.json instead of install.rdf (thanks @jsantell)
# 0.2.4
* updatePreferences() call is no longer required, it is automatically called by encoded() if needed
- updatePreferences() call is no longer required, it is automatically called by encoded() if needed
# 0.2.3
* update package versions (archiver)
- update package versions (archiver)
# 0.2.2
* fixed other Windows path issues (contribution from [testingBot](https://github.com/testingbot))
- fixed other Windows path issues (contribution from [testingBot](https://github.com/testingbot))
# 0.2.1
* setAcceptUntrustedCerts and setAssumeUntrustedCertIssuer now expects real boolean (contribution from [testingBot](https://github.com/testingbot))
- setAcceptUntrustedCerts and setAssumeUntrustedCertIssuer now expects real boolean (contribution from [testingBot](https://github.com/testingbot))
# 0.2.0
* Fixed Windows support
- Fixed Windows support
# 0.1.1
* fixed potential EMFILE when installing multiple extensions (contribution from https://github.com/circusbred)
- fixed potential EMFILE when installing multiple extensions (contribution from https://github.com/circusbred)
# 0.1.0
* more unit tests, added integration tests, saucelabs
- more unit tests, added integration tests, saucelabs
# 0.0.4
* added addExtensions(array, callback) method
* EMFILE bug fix
* added basic tests for encoded()
- added addExtensions(array, callback) method
- EMFILE bug fix
- added basic tests for encoded()
# 0.0.3
* encoded is now asynchronous (adm-zip to node-archiver constraints to zip profile)
- encoded is now asynchronous (adm-zip to node-archiver constraints to zip profile)

@@ -7,15 +7,14 @@ /**

var os = require('os'),
path = require('path'),
fs = require('fs-extra'),
// third-party
parseString = require('xml2js').parseString,
AdmZip = require('adm-zip'),
archiver = require('archiver'),
uuid = require('uuid'),
async = require('async'),
getID = require('jetpack-id'),
_ = require('lodash'),
path = require('path'),
fs = require('fs-extra'),
// third-party
parseString = require('xml2js').parseString,
AdmZip = require('adm-zip'),
archiver = require('archiver'),
uuid = require('uuid'),
async = require('async'),
getID = require('jetpack-id'),
_ = require('lodash'),
Finder = require('./profile_finder');
Finder = require('./profile_finder');
var config = {

@@ -47,3 +46,3 @@ // from python... Not used

'dom.disable_open_during_load': 'false',
'extensions.autoDisableScopes' : 10,
'extensions.autoDisableScopes': 10,
'extensions.logging.enabled': 'true',

@@ -75,7 +74,7 @@ 'extensions.update.enabled': 'false',

'browser.dom.window.dump.enabled': 'true',
'webdriver_accept_untrusted_certs': 'true',
'webdriver_enable_native_events': 'true',
'webdriver_assume_untrusted_issuer': 'true',
webdriver_accept_untrusted_certs: 'true',
webdriver_enable_native_events: 'true',
webdriver_assume_untrusted_issuer: 'true',
'dom.max_script_run_time': '30',
}
},
};

@@ -89,3 +88,3 @@

if (_.isString(opts)) {
return {profileDirectory: opts};
return { profileDirectory: opts };
}

@@ -119,3 +118,3 @@ return opts || {};

var opts = parseOptions(options),
hasDestDir = !!opts.destinationDirectory;
hasDestDir = !!opts.destinationDirectory;
this.profileDir = opts.profileDirectory;

@@ -135,3 +134,3 @@ this.defaultPreferences = _.clone(config.DEFAULT_PREFERENCES);

clobber: true,
filter: isNotLockFile
filter: isNotLockFile,
});

@@ -148,3 +147,3 @@ this.profileDir = tmpDir;

var self = this;
this.onExit = function() {
this.onExit = function () {
if (self._deleteOnExit) {

@@ -155,3 +154,3 @@ self._cleanOnExit();

this.onSigInt = function() {
this.onSigInt = function () {
process.exit(130);

@@ -164,14 +163,24 @@ };

function deleteParallel(files, cb) {
async.parallel(files.map(function(file) {
return function(next) { fs.remove(file, next); };
}), function () {
cb && cb();
});
async.parallel(
files.map(function (file) {
return function (next) {
fs.remove(file, next);
};
}),
function () {
cb && cb();
}
);
}
FirefoxProfile.prototype._copy = function(profileDirectory, cb) {
fs.copy(profileDirectory, this.profileDir, {
clobber: true,
filter: isNotLockFile
}, cb);
FirefoxProfile.prototype._copy = function (profileDirectory, cb) {
fs.copy(
profileDirectory,
this.profileDir,
{
clobber: true,
filter: isNotLockFile,
},
cb
);
};

@@ -190,10 +199,13 @@

FirefoxProfile.copy = function(options, cb) {
FirefoxProfile.copy = function (options, cb) {
var opts = parseOptions(options);
if (!opts.profileDirectory) {
cb && cb(new Error('firefoxProfile: .copy() requires profileDirectory option'));
cb &&
cb(new Error('firefoxProfile: .copy() requires profileDirectory option'));
return;
}
var profile = new FirefoxProfile({destinationDirectory: opts.destinationDirectory});
profile._copy(opts.profileDirectory, function() {
var profile = new FirefoxProfile({
destinationDirectory: opts.destinationDirectory,
});
profile._copy(opts.profileDirectory, function () {
cb && cb(null, profile);

@@ -211,15 +223,25 @@ });

*/
FirefoxProfile.copyFromUserProfile = function(opts, cb) {
FirefoxProfile.copyFromUserProfile = function (opts, cb) {
if (!opts.name) {
cb && cb(new Error('firefoxProfile: .copyFromUserProfile() requires a name options'));
cb &&
cb(
new Error(
'firefoxProfile: .copyFromUserProfile() requires a name options'
)
);
return;
}
var finder = new Finder(opts.userProfilePath);
finder.getPath(opts.name, function(err, profilePath) {
if (err) { cb(err); return; }
FirefoxProfile.copy({
destinationDirectory: opts.destinationDirectory,
profileDirectory: profilePath
}, cb);
finder.getPath(opts.name, function (err, profilePath) {
if (err) {
cb(err);
return;
}
FirefoxProfile.copy(
{
destinationDirectory: opts.destinationDirectory,
profileDirectory: profilePath,
},
cb
);
});

@@ -236,3 +258,3 @@ };

*/
FirefoxProfile.prototype.deleteDir = function(cb) {
FirefoxProfile.prototype.deleteDir = function (cb) {
var self = this;

@@ -242,3 +264,3 @@ process.removeListener('exit', self.onExit);

this.shouldDeleteOnExit(false);
fs.exists(this.profileDir, function(doesExists) {
fs.exists(this.profileDir, function (doesExists) {
if (!doesExists) {

@@ -248,3 +270,3 @@ cb && cb();

}
fs.remove(self.profileDir, function() {
fs.remove(self.profileDir, function () {
cb && cb();

@@ -263,4 +285,3 @@ });

*/
FirefoxProfile.prototype._cleanOnExit = function() {
FirefoxProfile.prototype._cleanOnExit = function () {
if (fs.existsSync(this.profileDir)) {

@@ -270,3 +291,7 @@ try {

} catch (e) {
console.warn('[firefox-profile] cannot delete profileDir on exit', this.profileDir, e);
console.warn(
'[firefox-profile] cannot delete profileDir on exit',
this.profileDir,
e
);
}

@@ -285,3 +310,3 @@ }

*/
FirefoxProfile.prototype.shouldDeleteOnExit = function(bool) {
FirefoxProfile.prototype.shouldDeleteOnExit = function (bool) {
this._deleteOnExit = bool;

@@ -295,3 +320,3 @@ };

*/
FirefoxProfile.prototype.willDeleteOnExit = function() {
FirefoxProfile.prototype.willDeleteOnExit = function () {
return this._deleteOnExit;

@@ -313,3 +338,3 @@ };

*/
FirefoxProfile.prototype.setPreference = function(key, value) {
FirefoxProfile.prototype.setPreference = function (key, value) {
var cleanValue = '';

@@ -320,3 +345,3 @@ if (value === true) {

cleanValue = 'false';
} else if (typeof(value) === 'string') {
} else if (typeof value === 'string') {
cleanValue = '"' + value.replace('\n', '\\n') + '"';

@@ -335,4 +360,4 @@ } else {

* @param {function} callback - the callback function to call when the extension is added
*/
FirefoxProfile.prototype.addExtension = function(extension, cb) {
*/
FirefoxProfile.prototype.addExtension = function (extension, cb) {
this._installExtension(extension, cb);

@@ -346,14 +371,12 @@ };

* @param {function} callback - the callback function to call when the extension is added
*/
*/
FirefoxProfile.prototype.addExtensions = function(extensions, cb) {
FirefoxProfile.prototype.addExtensions = function (extensions, cb) {
var self = this,
functions = extensions.map(function(extension) {
return function(callback) {
self.addExtension(path.normalize(extension), callback);
};
});
functions = extensions.map(function (extension) {
return function (callback) {
self.addExtension(path.normalize(extension), callback);
};
});
async.parallel(functions, cb);
};

@@ -368,3 +391,3 @@

*/
FirefoxProfile.prototype.updatePreferences = function() {
FirefoxProfile.prototype.updatePreferences = function () {
this._writeUserPrefs(this.defaultPreferences);

@@ -386,3 +409,5 @@ };

FirefoxProfile.prototype.canAcceptUntrustedCerts = function () {
return this._sanitizePref(this.defaultPreferences['webdriver_accept_untrusted_certs']);
return this._sanitizePref(
this.defaultPreferences['webdriver_accept_untrusted_certs']
);
};

@@ -404,4 +429,6 @@

*/
FirefoxProfile.prototype.canAssumeUntrustedCertIssuer = function () {
return this._sanitizePref(this.defaultPreferences['webdriver_assume_untrusted_issuer']);
FirefoxProfile.prototype.canAssumeUntrustedCertIssuer = function () {
return this._sanitizePref(
this.defaultPreferences['webdriver_assume_untrusted_issuer']
);
};

@@ -424,3 +451,5 @@

FirefoxProfile.prototype.nativeEventsEnabled = function () {
return this._sanitizePref(this.defaultPreferences['webdriver_enable_native_events']);
return this._sanitizePref(
this.defaultPreferences['webdriver_enable_native_events']
);
};

@@ -444,8 +473,11 @@

*/
FirefoxProfile.prototype.encoded = function(cb) {
FirefoxProfile.prototype.encoded = function (cb) {
try {
var self = this,
tmpFolder = this._createTempFolder(),
zipStream = fs.createWriteStream(path.join(tmpFolder,'profile.zip')),
archive = archiver('zip', { forceUTC: true });
tmpFolder = this._createTempFolder(),
zipStream = fs.createWriteStream(path.join(tmpFolder, 'profile.zip'), {
emitClose: true,
forceUTC: true,
}),
archive = archiver('zip', { forceUTC: true });

@@ -458,13 +490,23 @@ if (this._preferencesModified) {

});
archive.on('error', function (err) {
// throw error
cb(err);
});
zipStream.on('close', function() {
fs.readFile(path.join(tmpFolder,'profile.zip'), function(err, content) {
zipStream.on('close', function () {
fs.readFile(path.join(tmpFolder, 'profile.zip'), function (err, content) {
cb(null, content.toString('base64'));
deleteParallel([path.join(tmpFolder,'profile.zip'), tmpFolder]);
deleteParallel([path.join(tmpFolder, 'profile.zip'), tmpFolder]);
});
});
archive.pipe(zipStream);
archive.glob('**', {
cwd: self.profileDir, expand: true
}, {});
archive.glob(
'**',
{
cwd: self.profileDir,
expand: true,
},
{}
);
archive.finalize();

@@ -478,6 +520,6 @@ } catch (e) {

var ffValues = {
'direct': 0,
'manual': 1,
'pac': 2,
'system': 3
direct: 0,
manual: 1,
pac: 2,
system: 3,
};

@@ -526,3 +568,3 @@

*/
FirefoxProfile.prototype.setProxy = function(proxy) {
FirefoxProfile.prototype.setProxy = function (proxy) {
if (!proxy || !proxy.proxyType) {

@@ -533,15 +575,14 @@ throw new Error('firefoxProfile: not a valid proxy type');

switch (proxy.proxyType) {
case 'manual':
if (proxy.noProxy) {
this.setPreference('network.proxy.no_proxies_on', proxy.noProxy);
}
this._setManualProxyPreference('ftp', proxy.ftpProxy);
this._setManualProxyPreference('http', proxy.httpProxy);
this._setManualProxyPreference('ssl', proxy.sslProxy);
this._setManualProxyPreference('socks', proxy.socksProxy);
break;
case 'pac':
this.setPreference('network.proxy.autoconfig_url', proxy.autoconfigUrl);
break;
case 'manual':
if (proxy.noProxy) {
this.setPreference('network.proxy.no_proxies_on', proxy.noProxy);
}
this._setManualProxyPreference('ftp', proxy.ftpProxy);
this._setManualProxyPreference('http', proxy.httpProxy);
this._setManualProxyPreference('ssl', proxy.sslProxy);
this._setManualProxyPreference('socks', proxy.socksProxy);
break;
case 'pac':
this.setPreference('network.proxy.autoconfig_url', proxy.autoconfigUrl);
break;
}

@@ -551,15 +592,15 @@ };

// private
FirefoxProfile.prototype._writeUserPrefs = function(userPrefs) {
FirefoxProfile.prototype._writeUserPrefs = function (userPrefs) {
var content = '';
Object.keys(userPrefs).forEach(function(val) {
content = content + 'user_pref("' + val +'", ' + userPrefs[val] + ');\n';
Object.keys(userPrefs).forEach(function (val) {
content = content + 'user_pref("' + val + '", ' + userPrefs[val] + ');\n';
});
fs.writeFileSync(this.userPrefs, content); // defaults to utf8 (node 0.8 compat)
fs.writeFileSync(this.userPrefs, content); // defaults to utf8 (node 0.8 compat)
};
FirefoxProfile.prototype._readExistingUserjs = function() {
FirefoxProfile.prototype._readExistingUserjs = function () {
var self = this,
regExp = /user_pref\(['"](.*)["'],\s*(.*)\)/,
contentLines = fs.readFileSync(this.userPrefs, "utf8").split('\n');
contentLines.forEach(function(line) {
regExp = /user_pref\(['"](.*)["'],\s*(.*)\)/,
contentLines = fs.readFileSync(this.userPrefs, 'utf8').split('\n');
contentLines.forEach(function (line) {
var found = line.match(regExp);

@@ -572,3 +613,3 @@ if (found) {

FirefoxProfile.prototype._installExtension = function(addon, cb) {
FirefoxProfile.prototype._installExtension = function (addon, cb) {
// from python... not needed. specify full path instead when calling addExtension

@@ -578,5 +619,5 @@ // if (addon === config.WEBDRIVER_EXT) {

// }
var tmpDir = null, // to unzip xpi
xpiFile = null,
self = this;
var tmpDir = null, // to unzip xpi
xpiFile = null,
self = this;

@@ -592,3 +633,3 @@ if (addon.slice(-4) === '.xpi') {

// find out the addon id
this._addonDetails(addon, function(addonDetails) {
this._addonDetails(addon, function (addonDetails) {
var addonId = getID(addonDetails);

@@ -601,63 +642,70 @@ var unpack = addonDetails.unpack === undefined ? true : addonDetails.unpack;

var addonPath = path.join(self.extensionsDir, path.sep, addonId);
async.series([
// creates extensionsDir
function(next) {
fs.exists(self.extensionsDir, function(exists) {
if (!exists) {
fs.mkdir(self.extensionsDir, function() {
async.series(
[
// creates extensionsDir
function (next) {
fs.exists(self.extensionsDir, function (exists) {
if (!exists) {
fs.mkdir(self.extensionsDir, function () {
next();
});
return;
}
// already exists
next();
});
},
function (next) {
if (!unpack && xpiFile) {
fs.copy(xpiFile, addonPath + '.xpi', function () {
next();
});
return;
} else {
// copy it!
fs.mkdir(addonPath, function () {
fs.copy(
addon,
addonPath,
{
clobber: true,
},
function () {
next();
}
);
});
}
// already exists
next();
});
},
function(next) {
if (!unpack && xpiFile) {
fs.copy(xpiFile, addonPath + '.xpi', function() { next(); });
} else {
// copy it!
fs.mkdir(addonPath, function() {
fs.copy(addon, addonPath, {
clobber: true
}, function() {
},
function (next) {
if (tmpDir) {
fs.remove(tmpDir, function () {
next();
});
});
}
},
function (next) {
if (tmpDir) {
fs.remove(tmpDir, function() {
} else {
next();
});
} else {
next();
}
}
},
],
function () {
// done!
cb && cb(null, addonDetails);
}
], function() {
// done!
cb && cb(null, addonDetails);
});
);
});
};
FirefoxProfile.prototype._addonDetails = function(addonPath, cb) {
FirefoxProfile.prototype._addonDetails = function (addonPath, cb) {
var details = {
'id': null,
'name': null,
'unpack': true,
'version': null,
'isNative': false
}, self = this;
id: null,
name: null,
unpack: true,
version: null,
isNative: false,
},
self = this;
function getNamespaceId(doc, url) {
var namespaces = doc[Object.keys(doc)[0]].$,
pref = null
;
Object.keys(namespaces).forEach(function(prefix) {
pref = null;
Object.keys(namespaces).forEach(function (prefix) {
if (namespaces[prefix] === url) {

@@ -675,9 +723,9 @@ pref = prefix.replace('xmlns:', '');

doc = fs.readFileSync(path.join(addonPath, 'install.rdf'));
}
// If not found, this is probably a webextension, so parse
// the `manifest.json` file for addon details
catch (e) {
} catch (e) {
// If not found, this is probably a webextension, so parse
// the `manifest.json` file for addon details
try {
var webExtManifest = JSON.parse(fs.readFileSync(
path.join(addonPath, 'manifest.json')));
var webExtManifest = JSON.parse(
fs.readFileSync(path.join(addonPath, 'manifest.json'))
);
details.unpack = false;

@@ -690,3 +738,5 @@

// see: https://bugzilla.mozilla.org/show_bug.cgi?id=1255564
details.id = ((webExtManifest.browser_specific_settings || {}).gecko || {}).id;
details.id = (
(webExtManifest.browser_specific_settings || {}).gecko || {}
).id;
if (!details.id) {

@@ -729,25 +779,25 @@ details.id = ((webExtManifest.applications || {}).gecko || {}).id;

}
Object.keys(description.$).forEach(function(attr) {
Object.keys(description.$).forEach(function (attr) {
if (details[attr.replace(em + ':', '')] !== undefined) {
details[attr.replace(em + ':', '')] = description.$[attr];
}
});
Object.keys(description).forEach(function(attr) {
Object.keys(description).forEach(function (attr) {
if (details[attr.replace(em + ':', '')] !== undefined) {
// to convert boolean strings into booleans
details[attr.replace(em + ':', '')] = self._sanitizePref(description[attr][0]);
details[attr.replace(em + ':', '')] = self._sanitizePref(
description[attr][0]
);
}
});
cb && cb(details);
});
};
FirefoxProfile.prototype._createTempFolder = function(suffix) {
FirefoxProfile.prototype._createTempFolder = function (suffix) {
suffix = suffix || '';
var folderName = path.resolve(path.join(os.tmpdir(), uuid.v4() + suffix + path.sep));
var folderName = path.resolve(
path.join(os.tmpdir(), uuid.v4() + suffix + path.sep)
);
fs.mkdirSync(folderName);

@@ -757,3 +807,3 @@ return folderName;

FirefoxProfile.prototype._sanitizePref = function(val) {
FirefoxProfile.prototype._sanitizePref = function (val) {
if (val === 'true') {

@@ -764,4 +814,3 @@ return true;

return false;
}
else {
} else {
return val;

@@ -771,3 +820,3 @@ }

FirefoxProfile.prototype._setManualProxyPreference = function(key, setting) {
FirefoxProfile.prototype._setManualProxyPreference = function (key, setting) {
if (!setting || setting === '') {

@@ -779,3 +828,6 @@ return;

if (hostDetails[1]) {
this.setPreference('network.proxy.' + key + '_port', parseInt(hostDetails[1], 10));
this.setPreference(
'network.proxy.' + key + '_port',
parseInt(hostDetails[1], 10)
);
}

@@ -782,0 +834,0 @@ };

{
"name": "firefox-profile",
"version": "2.0.0",
"version": "3.1.0-alpha.1",
"description": "firefox profile for selenium WebDriverJs, admc/wd or any other node selenium driver that supports capabilities",

@@ -80,4 +80,4 @@ "main": "lib/firefox_profile",

"grunt-mocha-cov": "^0.4.0",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "0.0.1",
"mocha": "^8.1.3",
"mocha-lcov-reporter": "1.3.0",
"request": "^2.88.0",

@@ -90,3 +90,3 @@ "sinon": "~1.12.x",

"adm-zip": "~0.4.x",
"archiver": "~2.1.0",
"archiver": "~5.0.2",
"async": "~2.5.0",

@@ -93,0 +93,0 @@ "fs-extra": "~4.0.2",

@@ -22,16 +22,13 @@ # firefox-profile-js

This class allows you to:
This package allows you to:
* create a firefox profile
* use an existing profile (by specifying a path)
* use an existing user profile (by specifying a name)
* add extensions to your profile,
* specify proxy settings,
* set the user preferences...
- create a firefox profile
- use an existing profile (by specifying a path)
- use an existing user profile (by specifying a name)
- add extensions to your profile,
- specify proxy settings,
- set the user preferences...
More info on user preferences [here](http://kb.mozillazine.org/User.js_file).
It also contains a [command line interface](#command-line-interface) that allows to copy or create profiles.

@@ -59,8 +56,8 @@

* create a profile
* modify the profile:
* setPreference(key, value)
* addExtension(path/To/Extenstion.xpi) or addExtension(path/To/Unpacked/Extension/)
* create firefox capabilities and set the 'firefox_profile' capability
* attach the capabilitites to your webdriver
- create a profile
- modify the profile:
- setPreference(key, value)
- addExtension(path/To/Extenstion.xpi) or addExtension(path/To/Unpacked/Extension/)
- create firefox capabilities and set the 'firefox_profile' capability
- attach the capabilitites to your webdriver

@@ -70,3 +67,3 @@ ### I wanna see it!

```js
/******************************************************************
/******************************************************************
* with old version selenium webdriverJs

@@ -78,34 +75,30 @@ * WARNING: does not work with recent version of selenium-webdriver node bindings, which expect an instance of selenium-webdriver Firefox Profile page (`require('selenium-webdriver/firefox').Profile` or similar)

/******************************************************************/
var webdriver = require('selenium-webdriver');
var webdriver = require("selenium-webdriver");
// create profile
var FirefoxProfile = require('firefox-profile');
var myProfile = new FirefoxProfile();
// create profile
var FirefoxProfile = require("firefox-profile");
var myProfile = new FirefoxProfile();
// you can add an extension by specifying the path to the xpi file
// or to the unzipped extension directory
myProfile.addExtension('test/extensions/firebug-1.12.4-fx.xpi', function() {
var capabilities = webdriver.Capabilities.firefox();
// you can add an extension by specifying the path to the xpi file
// or to the unzipped extension directory
myProfile.addExtension("test/extensions/firebug-1.12.4-fx.xpi", function () {
var capabilities = webdriver.Capabilities.firefox();
// you can set firefox preferences BEFORE calling encoded()
myProfile.setPreference('browser.newtab.url', 'http://saadtazi.com');
// attach your newly created profile
myProfile.encoded(function(err, encodedProfile) {
capabilities.set('firefox_profile', encodedProfile);
// you can set firefox preferences BEFORE calling encoded()
myProfile.setPreference("browser.newtab.url", "http://saadtazi.com");
// start the browser
var wd = new webdriver.Builder().
withCapabilities(capabilities).
build();
// woot!
wd.get('http://en.wikipedia.org');
});
});
// attach your newly created profile
/**************************************************
myProfile.encoded(function (err, encodedProfile) {
capabilities.set("firefox_profile", encodedProfile);
// start the browser
var wd = new webdriver.Builder().withCapabilities(capabilities).build();
// woot!
wd.get("http://en.wikipedia.org");
});
});
/**************************************************
/* with admc/wd

@@ -115,42 +108,42 @@ /* installs firebug, and make it active by default

var FirefoxProfile = require('firefox-profile'),
wd = require('wd');
var FirefoxProfile = require("firefox-profile"),
wd = require("wd");
// set some userPrefs if needed
// Note: make sure you call encoded() after setting some userPrefs
var fp = new FirefoxProfile();
// activate and open firebug by default for all sites
fp.setPreference('extensions.firebug.allPagesActivation', 'on');
// activate the console panel
fp.setPreference('extensions.firebug.console.enableSites', true);
// show the console panel
fp.setPreference('extensions.firebug.defaultPanelName', 'console');
// done with prefs?
fp.updatePreferences();
// set some userPrefs if needed
// Note: make sure you call encoded() after setting some userPrefs
var fp = new FirefoxProfile();
// activate and open firebug by default for all sites
fp.setPreference("extensions.firebug.allPagesActivation", "on");
// activate the console panel
fp.setPreference("extensions.firebug.console.enableSites", true);
// show the console panel
fp.setPreference("extensions.firebug.defaultPanelName", "console");
// done with prefs?
fp.updatePreferences();
// you can install multiple extensions at the same time
fp.addExtensions(['./test/extensions/firebug-1.12.4-fx.xpi'], function() {
fp.encoded(function(err, zippedProfile) {
if (err) {
console.error('oops, an error occured:', err);
return;
}
browser = wd.promiseChainRemote();
// firefox 46-
//browser.init({
// browserName:'firefox',
// // set firefox_profile capabilities HERE!!!!
// firefox_profile: zippedProfile
//}).
// firefox 47+
browser.init({
browserName:'firefox',
marionette: true,
'moz:firefoxOptions': {
profile: zippedProfile
}
})
// woOot!!
get('http://en.wikipedia.org');
});
// you can install multiple extensions at the same time
fp.addExtensions(["./test/extensions/firebug-1.12.4-fx.xpi"], function () {
fp.encoded(function (err, zippedProfile) {
if (err) {
console.error("oops, an error occured:", err);
return;
}
browser = wd.promiseChainRemote();
// firefox 46-
//browser.init({
// browserName:'firefox',
// // set firefox_profile capabilities HERE!!!!
// firefox_profile: zippedProfile
//}).
// firefox 47+
browser.init({
browserName: "firefox",
marionette: true,
"moz:firefoxOptions": {
profile: zippedProfile,
},
});
// woOot!!
get("http://en.wikipedia.org");
});
});

@@ -183,3 +176,3 @@ ```

It can be regenerated using ``grunt docs``.
It can be regenerated using `grunt docs`.
Requires [apidox](https://github.com/codeactual/apidox) - listed in devDependencies.

@@ -201,8 +194,8 @@

* ~~add documentation and comments~~
* ~~write tests~~
* ~~fix bugs~~
* ~~write more tests~~
* fix more bugs
* ~~clean tmp directory on process 'exit' and 'SIGINT'~~
- ~~add documentation and comments~~
- ~~write tests~~
- ~~fix bugs~~
- ~~write more tests~~
- fix more bugs
- ~~clean tmp directory on process 'exit' and 'SIGINT'~~

@@ -209,0 +202,0 @@ ## Disclaimer

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc