Skip to content

Commit

Permalink
LukeIS: an attempting at reverting 17633, just sessionstore.js becaus…
Browse files Browse the repository at this point in the history
…e it is causing nativeEvents failures

r17995
  • Loading branch information
lukeis committed Oct 23, 2012
1 parent 9c5e07b commit dd717bf
Showing 1 changed file with 31 additions and 59 deletions.
90 changes: 31 additions & 59 deletions javascript/firefox-driver/js/sessionstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,112 +98,83 @@ wdSessionStoreService.prototype.createSession = function(response, desiredCaps,
wrappedSession.setId(id);

fxdriver.logging.configure(
desiredCaps['loggingPrefs'],
desiredCaps['webdriver.logging.profiler.enabled']
/* REVERT of 17633 Conflict resolution, this was not chosen *
this.extractCapabilitySetting_('loggingPrefs', desiredCaps, requiredCaps),
this.extractCapabilitySetting_('webdriver.logging.profiler.enabled',
desiredCaps, requiredCaps));
*/
);

fxdriver.proxy.configure(this.extractCapabilitySetting_('proxy', desiredCaps,
requiredCaps));
fxdriver.proxy.configure(desiredCaps['proxy']);
fxdriver.modals.configure(desiredCaps['unexpectedAlertBehaviour']);

fxdriver.modals.configure(
this.extractCapabilitySetting_('unexpectedAlertBehaviour', desiredCaps,
requiredCaps));

this.configure_(response, desiredCaps, requiredCaps, driver);
this.configure_(response, requiredCaps, driver);
this.sessions_[id] = session;
return session;
};

/**
* Extract the setting for a capability.
*
* If a capability is defined both among desired capabilities and among
* required capabilities the required setting has priority.
*
* @private
* @param {!string} name The name of the capability.
* @param {!Object.<*>} desiredCaps The desired capabilities.
* @param {Object.<*>} requiredCaps The required capabilities.
* @return {*} The setting for the capability.
*/
wdSessionStoreService.prototype.extractCapabilitySetting_ = function(name,
desiredCaps, requiredCaps) {
var setting = desiredCaps[name];
if (requiredCaps && requiredCaps[name] !== undefined) {
setting = requiredCaps[name];
}
return setting;
};

/**
/**
* Read-only capabilities for FirefoxDriver and their default values.
* @type {!Object.<string, boolean>}
* @const
* @private
*/
wdSessionStoreService.READ_ONLY_CAPABILITIES_ = {
'javascriptEnabled': true,
'takesScreenshot': true,
'handlesAlerts': true,
'cssSelectorsEnabled': true,
'rotatable': false
};

/**
* Read-write capabilities for FirefoxDriver corresponding to (boolean)
* profile preferences. NB! the native events capability is not mapped to a
* Firefox preferences.
* @type {!Object.<string, string>}
* @const
*/
wdSessionStoreService.CAPABILITY_PREFERENCE_MAPPING = {
'webStorageEnabled': 'dom.storage.enabled',
'applicationCacheEnabled': 'browser.cache.offline.enable',
'databaseEnabled': 'dom.indexedDB.enabled',
'locationContextEnabled': 'geo.enabled',
'browserConnectionEnabled': 'dom.network.enabled',
'acceptSslCerts': 'webdriver_accept_untrusted_certs',
'nativeEvents' : 'webdriver_enable_native_events'
*/
wdSessionStoreService.READ_ONLY_CAPABILITIES_ = {
'javascriptEnabled':true,
'takesScreenshot':true,
'handlesAlerts':true,
'cssSelectorsEnabled':true,
'rotatable':false
};
// TODO: Don't save firefox specific capability acceptSslCerts as preferences.

/**
* @param {!Response} response The object to send the command response in.
* @param {!Object.<*>} desiredCaps A map describing desired capabilities.
* @param {Object.<*>} requiredCaps A map describing required capabilities.
* @param {!FirefoxDriver} driver The driver instance.
* @private
*/
wdSessionStoreService.prototype.configure_ = function(response, desiredCaps,
requiredCaps, driver) {
fxdriver.logging.info('Setting preferences based on required capabilities');
/* REVERT of 17633 Conflict resolution, this was not chosen *
this.configureCapabilities_(desiredCaps, driver);
*/

if (!requiredCaps) {
return;
}
var checkSettingsForReadOnlyCapabilities = function(value, key) {

var prefStore = fxdriver.moz.getService("@mozilla.org/preferences-service;1",
"nsIPrefBranch");

goog.object.forEach(requiredCaps, function(value, key) {
if (!goog.isBoolean(value)) {
return;
}
if (key in wdSessionStoreService.READ_ONLY_CAPABILITIES_ &&
value != wdSessionStoreService.READ_ONLY_CAPABILITIES_[key]) {
var msg = 'Required capability ' + key + ' cannot be set to ' + value;
fxdriver.logging.info(msg);
response.sendError(new WebDriverError(bot.ErrorCode.SESSION_NOT_CREATED,

response.sendError(new WebDriverError(bot.ErrorCode.SESSION_NOT_CREATED,
msg));
wdSession.quitBrowser(0);
}
};
});
/* REVERT of 17633 Conflict resolution, this was not chosen *
goog.object.forEach(requiredCaps, checkSettingsForReadOnlyCapabilities);
this.configureCapabilities_(requiredCaps, driver);
*/
};

/* REVERT of 17633 Conflict resolution, this was not chosen *
/**
* @param {!Object.<*>} capabilities A map describing capabilities.
* @param {!FirefoxDriver} driver The driver instance.
* @private
*/
*
wdSessionStoreService.prototype.configureCapabilities_ = function(capabilities,
driver) {
var prefStore = fxdriver.moz.getService('@mozilla.org/preferences-service;1',
Expand All @@ -223,6 +194,7 @@ wdSessionStoreService.prototype.configureCapabilities_ = function(capabilities,
}
});
};
*/


/**
Expand Down

0 comments on commit dd717bf

Please sign in to comment.