firefox-profile
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -0,1 +1,6 @@ | ||
# 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) | ||
# 0.2.4 | ||
@@ -2,0 +7,0 @@ |
@@ -5,3 +5,3 @@ 'use strict'; | ||
path = require('path'), | ||
fs = require('fs'), | ||
fs = require('fs-extra'), | ||
parseString = require('xml2js').parseString, | ||
@@ -94,3 +94,3 @@ // third-party | ||
this.profileDir = profileDirectory; | ||
// if true, the profile folder is deleted after | ||
// if true, the profile folder is deleted after | ||
this._deleteOnExit = true; | ||
@@ -113,3 +113,3 @@ // can be turned to false when debugging | ||
this.userPrefs = path.join(this.profileDir, 'user.js'); | ||
// delete on process.exit()... | ||
@@ -129,4 +129,4 @@ var self = this; | ||
/** | ||
* Deletes the profile directory. | ||
* | ||
* Deletes the profile directory. | ||
* | ||
* Call it only if you do not need the profile. Otherwise use at your own risk. | ||
@@ -150,3 +150,3 @@ * this function is automatically called by default (= if willDeleteOnExit() returns true) | ||
* * if the constructor is called with param (path to profile dir): the dir is copied at init and the copy is deleted on exit | ||
* | ||
* | ||
* @param {boolean} true | ||
@@ -160,3 +160,3 @@ */ | ||
* returns true if the profile directory will be deleted on process.exit() | ||
* | ||
* | ||
* @return {boolean} true if (default) | ||
@@ -178,3 +178,3 @@ */ | ||
* @param {boolean|string} value | ||
* @see about:config http://kb.mozillazine.org/About:config_entries | ||
@@ -199,3 +199,3 @@ */ | ||
* Add an extension to the profile. | ||
* | ||
* | ||
* @param {string} path - path to a xpi extension file or a unziped extension folder | ||
@@ -210,3 +210,3 @@ * @param {function} callback - the callback function to call when the extension is added | ||
* Add mutliple extension to the profile. | ||
* | ||
* | ||
* @param {string} path - path to a xpi extension file or a unziped extension folder | ||
@@ -224,4 +224,4 @@ * @param {function} callback - the callback function to call when the extension is added | ||
async.parallel(functions, cb); | ||
}; | ||
@@ -242,3 +242,3 @@ | ||
* @return {string} path of the profile extension directory | ||
* | ||
* | ||
*/ | ||
@@ -251,3 +251,3 @@ FirefoxProfile.prototype.path = function () { | ||
* @return {boolean} true if webdriver can accept untrusted certificates | ||
* | ||
* | ||
*/ | ||
@@ -262,3 +262,3 @@ FirefoxProfile.prototype.canAcceptUntrustedCerts = function () { | ||
* @param {boolean} true to accept untrusted certificates, false otherwise. | ||
* | ||
* | ||
*/ | ||
@@ -271,3 +271,3 @@ FirefoxProfile.prototype.setAcceptUntrustedCerts = function (val) { | ||
* @return {boolean} true if webdriver can assume untrusted certificate issuer | ||
* | ||
* | ||
*/ | ||
@@ -282,3 +282,3 @@ FirefoxProfile.prototype.canAssumeUntrustedCertIssuer = function () { | ||
* @param {boolean} true to make webdriver assume untrusted issuer. | ||
* | ||
* | ||
*/ | ||
@@ -291,3 +291,3 @@ FirefoxProfile.prototype.setAssumeUntrustedCertIssuer = function (val) { | ||
* @return {boolean} true if native events are enabled | ||
* | ||
* | ||
*/ | ||
@@ -302,3 +302,3 @@ FirefoxProfile.prototype.nativeEventsEnabled = function () { | ||
* @param {boolean} boolean true to enable native events. | ||
* | ||
* | ||
*/ | ||
@@ -312,3 +312,3 @@ FirefoxProfile.prototype.setNativeEventsEnabled = function (val) { | ||
* for use with remote WebDriver JSON wire protocol | ||
* | ||
* | ||
* @param {Function} function a callback function with first params as a zipped, base64 encoded string of the profile directory | ||
@@ -352,3 +352,3 @@ */ | ||
* for other values, only the proxy.type pref will be set | ||
* | ||
* | ||
* @param {Object} object a proxy object. Mandatary attribute: proxyType | ||
@@ -399,4 +399,3 @@ */ | ||
FirefoxProfile.prototype._installExtension = function(addon, cb, unpack) { | ||
unpack = unpack || true; | ||
FirefoxProfile.prototype._installExtension = function(addon, cb) { | ||
// from python... not needed. specify full path instead when calling addExtension | ||
@@ -409,3 +408,3 @@ // if (addon === config.WEBDRIVER_EXT) { | ||
self = this; | ||
if (addon.slice(-4) === '.xpi') { | ||
@@ -415,8 +414,10 @@ tmpDir = this._createTempFolder(addon.split(path.sep).slice(-1)); | ||
zip.extractAllTo(tmpDir, true); | ||
xpiFile = addon, | ||
xpiFile = addon; | ||
addon = tmpDir; | ||
} | ||
// find out the addon id | ||
this._addonDetails(addon, function(addonDetails) { | ||
var addonId = addonDetails.id; | ||
var unpack = addonDetails.unpack === undefined ? true : addonDetails.unpack; | ||
@@ -431,4 +432,4 @@ if (!addonId) { | ||
} | ||
if (!unpack && !addonDetails.unpack && xpiFile) { | ||
fs.createReadStream(addon).pipe(addonPath + '.xpi'); | ||
if (!unpack && xpiFile) { | ||
fs.copySync(xpiFile, addonPath + '.xpi'); | ||
} else { | ||
@@ -469,3 +470,23 @@ // copy it! | ||
} | ||
var doc = fs.readFileSync(path.join(addonPath, 'install.rdf')); | ||
// Attempt to parse the `install.rdf` inside the extension | ||
var doc; | ||
try { | ||
doc = fs.readFileSync(path.join(addonPath, 'install.rdf')); | ||
} | ||
// If not found, this is probably a jetpack style addon, so parse | ||
// the `package.json` file for addon details | ||
catch (e) { | ||
var manifest = require(path.join(addonPath, 'package.json')); | ||
// Jetpack addons are packed by default | ||
details.unpack = false; | ||
Object.keys(details).forEach(function (prop) { | ||
if (manifest[prop] !== undefined) { | ||
details[prop] = manifest[prop]; | ||
} | ||
}); | ||
cb && cb(details); | ||
return; | ||
} | ||
parseString(doc, function (err, doc) { | ||
@@ -472,0 +493,0 @@ var em = getNamespaceId(doc, 'http://www.mozilla.org/2004/em-rdf#'), |
{ | ||
"name": "firefox-profile", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "firefox profile for selenium WebDriverJs, admc/wd or any other node selenium driver that supports capabilities", | ||
@@ -39,2 +39,5 @@ "main": "lib/firefox_profile", | ||
"url": "https://github.com/circusbred" | ||
}, | ||
{ "name": "Jordan Santell", | ||
"url": "http://jsantell.com" | ||
}], | ||
@@ -63,4 +66,5 @@ "devDependencies": { | ||
"lazystream": "~0.1.0", | ||
"async": "~0.2.9" | ||
"async": "~0.2.9", | ||
"fs-extra": "~0.8.1" | ||
} | ||
} |
@@ -29,4 +29,4 @@ /*jshint camelcase:false*/ | ||
// will remove the onexit() call (that deletes the dir folder) | ||
// prevents warning: | ||
// possible EventEmitter memory leak detected. | ||
// prevents warning: | ||
// possible EventEmitter memory leak detected. | ||
// X listeners added. Use emitter.setMaxListeners() to increase limit. | ||
@@ -108,8 +108,8 @@ fp.deleteDir(); | ||
expect(fp.defaultPreferences).to.have.property('network.proxy.autoconfig_url', '"http://url-to-proxy-auto-config"'); | ||
}); | ||
}); | ||
describe('#updatePreferences', function() { | ||
@@ -171,3 +171,3 @@ // compat node 0.8 & 0.10 | ||
it('should correctly retrieve addon details from rdf that does not use namespace', function(done) { | ||
fp._addonDetails(path.join(__dirname, 'extensions/test.no-namespace-template.xpi'), function(extDetails) { | ||
@@ -195,2 +195,14 @@ expect(extDetails).to.be.eql({ | ||
}); | ||
it('should correctly retrieve addon details from addon that does not use install.rdf', function(done) { | ||
fp._addonDetails(path.join(__dirname, 'extensions/test.jetpack-template.xpi'), function(extDetails) { | ||
expect(extDetails).to.be.eql({ | ||
id: 'jetpack-addon@test.test', | ||
name: 'Jetpack-addon-test', | ||
unpack: false, | ||
version: '0.0.1' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -216,2 +228,18 @@ | ||
}); | ||
it('should unzip extensions in profile folder for jetpack addons' , function(done) { | ||
fp.addExtension(path.join(__dirname, 'extensions/jetpack-extension.xpi'), function() { | ||
var exensionDir = path.join(fp.profileDir, 'extensions', 'jetpack-addon@test.test.xpi'); | ||
expect(fs.statSync(exensionDir).isDirectory()).to.be.false; | ||
done(); | ||
}); | ||
}); | ||
it('should not unzip extensions in profile folder when unpack is false' , function(done) { | ||
fp.addExtension(path.join(__dirname, 'extensions/packed-extension.xpi'), function() { | ||
var exensionDir = path.join(fp.profileDir, 'extensions', 'packed-extension@test.test.xpi'); | ||
expect(fs.statSync(exensionDir).isFile()).to.be.true; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -218,0 +246,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2286352
31
906
8
7
+ Addedfs-extra@~0.8.1
+ Addedfs-extra@0.8.1(transitive)
+ Addedjsonfile@1.1.1(transitive)
+ Addedmkdirp@0.3.5(transitive)
+ Addedncp@0.4.2(transitive)