Socket
Socket
Sign inDemoInstall

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 0.3.2 to 0.3.3

test/profile_finder.js

6

CHANGELOG.md

@@ -0,4 +1,8 @@

# 0.3.3
* minor fixes, added tests for ProfileFinder
# 0.3.2
* modify some callback to follow the standard `(err, resp)`
* modify some callbacks to follow the standard `(err, resp)`

@@ -5,0 +9,0 @@ # 0.3.1

@@ -9,2 +9,3 @@ Firefox Profile

- <a name="toc_firefoxprofilecopyoptions"></a>[FirefoxProfile.copy](#firefoxprofilecopyoptions)
- <a name="toc_firefoxprofilecopyfromuserprofile"></a>[FirefoxProfile.copyFromUserProfile](#firefoxprofilecopyfromuserprofile)
- <a name="toc_firefoxprofileprototypedeletedira"></a><a name="toc_firefoxprofileprototype"></a>[FirefoxProfile.prototype.deleteDir](#firefoxprofileprototypedeletedira)

@@ -58,2 +59,8 @@ - <a name="toc_firefoxprofileprototype_cleanonexit"></a>[FirefoxProfile.prototype._cleanOnExit](#firefoxprofileprototype_cleanonexit)

# FirefoxProfile.copyFromUserProfile()
> copy a profile from the current user profile
<sub>Go: [TOC](#tableofcontents) | [FirefoxProfile](#toc_firefoxprofile)</sub>
<a name="firefoxprofileprototype"></a>

@@ -60,0 +67,0 @@

@@ -7,2 +7,3 @@ module.exports = function(grunt) {

var coverallsRepoToken = process.env.COVERALLS_REPO_TOKEN,

@@ -34,2 +35,3 @@ coveralls = { serviceName: 'travis-ci' };

options: {
require: './test/require',
files: ['test/*.js', 'test/**/*.js', '!test/extensions/**/*.js']

@@ -36,0 +38,0 @@ }

15

lib/firefox_profile.js

@@ -142,3 +142,3 @@ /**

});
};
}

@@ -189,7 +189,16 @@ function deleteParallel(files, cb) {

/**
* copy a profile from the current user profile
*
* @params {Object} opts an object with the following properties:
* - name: property is mandatory.
* - userProfilePath optional and passed to Finder constructor.
* - destinationDirectory optional
*/
FirefoxProfile.copyFromUserProfile = function(opts, cb) {
if (!opts.name) {
cb && cb(new Error('firefoxProfile: .copyFromUserProfile() requires a name options'));
return;
}
var finder = new Finder();
var finder = new Finder(opts.userProfilePath);
finder.getPath(opts.name, function(err, profilePath) {

@@ -205,4 +214,2 @@ if (err) { cb(err); return; }

/**

@@ -209,0 +216,0 @@ * Deletes the profile directory asynchronously.

@@ -10,16 +10,6 @@ 'use strict';

/**
* ProfileFinder constructor
*
* @params directory String optional - the user directory that contains `profiles.ini` file
*/
function ProfileFinder(directory) {
this.directory = directory || this.locateUserDirectory();
this.hasReadProfiles = false;
this.profiles = [];
}
ProfileFinder.prototype.locateUserDirectory = function() {
function locateUserDirectory(platform) {
var userDir;
switch (os.platform()) {
switch (platform || os.platform()) {
case 'darwin':

@@ -36,6 +26,31 @@ userDir = path.join(process.env.HOME, '/Library/Application Support/Firefox');

return userDir;
};
}
/**
* ProfileFinder constructor
*
* @params directory String optional - the user directory that contains `profiles.ini` file.
* It uses ProfileFinder.locateUserDirectory() if not provided
*/
function ProfileFinder(directory) {
this.directory = directory || ProfileFinder.locateUserDirectory();
this.hasReadProfiles = false;
this.profiles = [];
}
/**
* returns default user profile folder
*
*/
ProfileFinder.locateUserDirectory = locateUserDirectory;
/**
* Reads profiles info and stores it in this.profiles.
*
* @params function cb - callbabk(err, profiles)
*
*/
ProfileFinder.prototype.readProfiles = function(cb) {
if (this.hasReadProfiles) { cb(this.profiles); }
if (this.hasReadProfiles) { cb(null, this.profiles); }

@@ -49,6 +64,13 @@ var self = this;

self.hasReadProfiles = true;
cb(self.profiles);
cb(null, self.profiles);
});
};
/**
* returns the path to the requested profile
*
* @params String name - the name of the requested profile
* @params function cb - callbabk(err, profiles)
*
*/
ProfileFinder.prototype.getPath = function(name, cb) {

@@ -55,0 +77,0 @@ var self = this;

{
"name": "firefox-profile",
"version": "0.3.2",
"version": "0.3.3",
"description": "firefox profile for selenium WebDriverJs, admc/wd or any other node selenium driver that supports capabilities",

@@ -5,0 +5,0 @@ "main": "lib/firefox_profile",

@@ -17,2 +17,3 @@ # firefox-profile-js

* use an existing profile (by specifying a path)
* use an existing user profile (by specifying a name)
* add extensions to your profile,

@@ -19,0 +20,0 @@ * specify proxy settings,

/*jshint camelcase:false*/
/*global describe:false, it:false, before, beforeEach:false, afterEach:false*/
/*global sinon:false, testProfiles, expect, describe:false, it:false, before, beforeEach:false, afterEach:false*/
'use strict';
var chai = require('chai'),
path = require('path'),
expect = chai.expect,
var path = require('path'),
FirefoxProfile = require('../lib/firefox_profile'),
fs = require('fs'),
testProfiles = require('./test_profiles'),
sinon = require('sinon'),
sinonChai = require('sinon-chai');
fs = require('fs');
chai.use(sinonChai);
// chai.use(require('sinon-chai'));
chai.use(require('chai-fs'));
describe('firefox_profile', function() {

@@ -81,2 +70,10 @@ var fp;

it('should return an error if no profileDirectory is provided', function(done) {
FirefoxProfile.copy({noProfileDirectory: true}, function(err) {
expect(err).to.be.an.instanceof(Error);
done();
});
});
it('should copy the profile into destinationDirectory if specified', function(done) {

@@ -98,2 +95,43 @@ FirefoxProfile.copy({ profileDirectory: testProfiles.emptyProfile.path,

describe('#Firefox.copyFromUserProfile', function() {
it('lock files should not be copied over', function(done) {
FirefoxProfile.copyFromUserProfile({
userProfilePath: __dirname,
name: 'default'
}, function(err, fp) {
expect(fs.statSync(fp.profileDir).isDirectory()).to.be.true;
['.parentlock', 'lock', 'parent.lock'].forEach(function(lockFile) {
expect(fs.existsSync(path.join(fp.profileDir, lockFile))).to.be.false;
});
expect(fs.existsSync(path.join(fp.profileDir, 'empty.file'))).to.be.true;
fp.deleteDir(done);
});
});
it('should return an error if no name is provided', function(done) {
FirefoxProfile.copyFromUserProfile({noName: true}, function(err) {
expect(err).to.be.an.instanceof(Error);
done();
});
});
it('should copy the profile into destinationDirectory if specified', function(done) {
FirefoxProfile.copyFromUserProfile({
userProfilePath: __dirname,
name: 'default',
destinationDirectory: testProfiles.dest
}, function(err, fp) {
expect(fp.profileDir).to.be.equal(testProfiles.dest);
expect(fs.statSync(fp.profileDir).isDirectory()).to.be.true;
['.parentlock', 'lock', 'parent.lock'].forEach(function(lockFile) {
expect(fs.existsSync(path.join(fp.profileDir, lockFile))).to.be.false;
});
expect(fs.existsSync(path.join(fp.profileDir, 'empty.file'))).to.be.true;
done();
});
});
});
describe('#setPreference', function() {

@@ -100,0 +138,0 @@ describe('should correctly store string values', function() {

/*jshint camelcase:false*/
/*global describe:false, it:false, after:false, before:false*/
/*global describe:false, it:false, after:false */
'use strict';
var chai = require('chai'),
chaiAsPromised = require('chai-as-promised'),
wd = require('wd'),
var wd = require('wd'),
request = require('request'),

@@ -14,18 +12,6 @@ browser,

chai.use(chaiAsPromised);
chai.should();
var username = process.env.SAUCE_USERNAME || 'SAUCE_USERNAME',
accessKey = process.env.SAUCE_ACCESS_KEY || 'SAUCE_ACCESS_KEY',
jobId = process.env.TRAVIS_JOB_ID || 'JOB_ID';
accessKey = process.env.SAUCE_ACCESS_KEY || 'SAUCE_ACCESS_KEY';
// console.log(username, accessKey);
// having browser init in before() generates this error... Why?
// Error: Not JSON response
// at webdriver._newError (/Users/saadtazi/Projects/firefox-profile-js/node_modules/wd/lib/webdriver.js:76:13)
// at /Users/saadtazi/Projects/firefox-profile-js/node_modules/wd/lib/webdriver.js:144:23
// at Request._callback (/Users/saadtazi/Projects/firefox-profile-js/node_modules/wd/lib/webdriver.js:367:5)
// at Request.self.callback (/Users/saadtazi/Projects/firefox-profile-js/node_modules/wd/node_modules/request/index.js:148:22)
// before(function(done) {done();})
after(function(done) {

@@ -42,3 +28,3 @@ this.timeout(0);

json: {passed: passed, public: 'public'}
}, function(err, response, body) {
}, function(/*err, response, body*/) {
//console.log('request:: ', body);

@@ -93,4 +79,5 @@ cb();

// because table method is probably added to the regular console
/*jshint evil:true */
.eval('console.table').then(function(res) {
res.should.contain('function');
expect(res).to.contain('function');
if (browser.sessionID) {

@@ -97,0 +84,0 @@ sendStatusToSauceLabs(browser.sessionID, true, function() { done(); });

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