firefox-profile
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -0,1 +1,6 @@ | ||
# 0.2.4 | ||
* updatePreferences() call is no longer required, it is automatically called by encoded() if needed | ||
# 0.2.3 | ||
@@ -2,0 +7,0 @@ |
@@ -74,3 +74,5 @@ Constructor | ||
Any modification to the user preference needs to be persisted using this.updatePreferences() | ||
Any modification to the user preference can be persisted using this.updatePreferences() | ||
If this.setPreference() is called before calling this.encoded(), then this.updatePreferences() | ||
is automatically called. | ||
For a comprehensive list of preference keys, see http://kb.mozillazine.org/About:config_entries | ||
@@ -117,2 +119,5 @@ | ||
updatePreferences() is automatically called when encoded() is called | ||
(if needed = if setPreference() was called before calling encoded()) | ||
<sub>Go: [TOC](#tableofcontents) | [FirefoxProfile.prototype](#toc_firefoxprofileprototype)</sub> | ||
@@ -119,0 +124,0 @@ |
@@ -95,2 +95,5 @@ 'use strict'; | ||
this._deleteOnExit = true; | ||
// can be turned to false when debugging | ||
this._deleteZippedProfile = true; | ||
this._preferencesModified = false; | ||
if (!this.profileDir) { | ||
@@ -163,3 +166,5 @@ this.profileDir = this._createTempFolder(); | ||
* | ||
* Any modification to the user preference needs to be persisted using this.updatePreferences() | ||
* Any modification to the user preference can be persisted using this.updatePreferences() | ||
* If this.setPreference() is called before calling this.encoded(), then this.updatePreferences() | ||
* is automatically called. | ||
* For a comprehensive list of preference keys, see http://kb.mozillazine.org/About:config_entries | ||
@@ -184,2 +189,3 @@ * | ||
this.defaultPreferences[key] = cleanValue; | ||
this._preferencesModified = true; | ||
}; | ||
@@ -219,2 +225,5 @@ | ||
* | ||
* updatePreferences() is automatically called when encoded() is called | ||
* (if needed = if setPreference() was called before calling encoded()) | ||
* | ||
*/ | ||
@@ -299,4 +308,11 @@ FirefoxProfile.prototype.updatePreferences = function() { | ||
if (this._preferencesModified) { | ||
this.updatePreferences(); | ||
} | ||
zipStream.on('close', function() { | ||
cb(fs.readFileSync(path.join(tmpFolder,'profile.zip')).toString('base64')); | ||
if (self._deleteZippedProfile) { | ||
fs.unlinkSync(path.join(tmpFolder,'profile.zip')); | ||
fs.rmdirSync(tmpFolder); | ||
} | ||
}); | ||
@@ -303,0 +319,0 @@ archive.pipe(zipStream); |
{ | ||
"name": "firefox-profile", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"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", |
@@ -40,4 +40,4 @@ # firefox-profile-js | ||
* addExtension(path/To/Extenstion.xpi) or addExtension(path/To/Unpacked/Extension/) | ||
* create firefox capabilities and set the 'firefox_profile' capability to profile.encoded() | ||
* attach the capabilitites to your webdriver (using withCapabilities) | ||
* create firefox capabilities and set the 'firefox_profile' capability | ||
* attach the capabilitites to your webdriver | ||
@@ -61,4 +61,7 @@ ### I wanna see it! | ||
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'); | ||
@@ -70,8 +73,2 @@ // attach your newly created profile | ||
// you can set firefox preferences | ||
myProfile.setPreference('browser.newtab.url', 'http://saadtazi.com'); | ||
// it is required to create or update user.js | ||
// only needed if you set some preferences | ||
myProfile.updatePreferences(); | ||
@@ -97,2 +94,3 @@ // start the browser | ||
// set some userPrefs if needed | ||
// Note: make sure you call encoded() after setting some userPrefs | ||
var fp = new FirefoxProfile(); | ||
@@ -105,3 +103,3 @@ // activate and open firebug by default for all sites | ||
fp.setPreference('extensions.firebug.defaultPanelName', 'console'); | ||
fp.updatePreferences(); | ||
// you can install multiple extensions at the same time | ||
@@ -108,0 +106,0 @@ fp.addExtensions(['./test/extensions/firebug-1.12.4-fx.xpi'], function() { |
@@ -11,7 +11,7 @@ /*jshint camelcase:false*/ | ||
fs = require('fs'), | ||
testProfiles = require('./test_profiles') | ||
// sinon = require('sinon'), | ||
// sinonChai = require("sinon-chai") | ||
; | ||
testProfiles = require('./test_profiles'), | ||
sinon = require('sinon'), | ||
sinonChai = require('sinon-chai'); | ||
chai.use(sinonChai); | ||
@@ -98,3 +98,3 @@ | ||
expect(fp.defaultPreferences).to.have.property('network.proxy.socks', '"socks-proxy-server"'); | ||
expect(fp.defaultPreferences).to.have.property('network.proxy.socks_port', '"9999"'); | ||
expect(fp.defaultPreferences).to.have.property('network.proxy.socks_port', '"9999"'); | ||
}); | ||
@@ -143,11 +143,26 @@ | ||
describe('#encoded', function() { | ||
var spy; | ||
beforeEach(function() { | ||
spy = sinon.spy(fp, 'updatePreferences'); | ||
}); | ||
afterEach(function() { | ||
spy.restore(); | ||
}); | ||
it('should work with a brand new profile', function(done) { | ||
fp.encoded(function(zippedProfile) { | ||
expect(zippedProfile).to.be.equal(testProfiles.brandNewProfile.expectedZip); | ||
fp.encoded(function(zippedProfileString) { | ||
expect(zippedProfileString).to.be.equal(testProfiles.brandNewProfile.expectedZip); | ||
done(); | ||
}); | ||
// encoded() results is not constant for more 'complex' profiles | ||
// other encoded tests are done in test/spec/ tests | ||
}); | ||
it('should call updatePreferences if preferences were modified', function(done) { | ||
fp.encoded(function() { | ||
expect(spy).to.not.have.been.called; | ||
fp.setPreference('test.string.value', 'test string\nvalue'); | ||
fp.encoded(function() { | ||
expect(spy).to.have.been.called; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -154,0 +169,0 @@ |
@@ -56,3 +56,4 @@ /*jshint camelcase:false*/ | ||
fp.setPreference('extensions.firebug.defaultPanelName', 'console'); | ||
fp.updatePreferences(); | ||
// calling updatePreferences is now optional | ||
// fp.updatePreferences(); | ||
fp.addExtensions(testProfile.extensions, function() { | ||
@@ -59,0 +60,0 @@ fp.encoded(function(zippedProfile) { |
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
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
2280491
862
149