Bug 1174941: Remove all capabilities from desired capabilities if they are in the session capabilitiesand in requiredCapabilities; r=ato

--HG--
extra : commitid : 49h1HhlE4h
extra : rebase_source : fd01b68b9b34414fa5fd84e7fb592d0c22a1e60f
This commit is contained in:
David Burns 2015-06-19 15:44:25 +01:00
Родитель 74f8ab42da
Коммит 720ba26e14
2 изменённых файлов: 28 добавлений и 5 удалений

Просмотреть файл

@ -57,6 +57,14 @@ class TestCapabilities(MarionetteTestCase):
caps = self.marionette.session_capabilities
self.assertIn("somethingAwesome", caps)
def test_we_dont_overwrite_server_capabilities(self):
self.marionette.delete_session()
capabilities = { "desiredCapabilities": {"browserName": "ChocolateCake"}}
self.marionette.start_session(capabilities)
caps = self.marionette.session_capabilities
self.assertEqual(caps["browserName"], self.appinfo["name"],
"This should have appname not ChocolateCake")
def test_we_can_pass_in_required_capabilities_on_session_start(self):
self.marionette.delete_session()
capabilities = { "requiredCapabilities": {"browserName": self.appinfo["name"]}}

Просмотреть файл

@ -602,18 +602,33 @@ GeckoDriver.prototype.getSessionCapabilities = function(cmd, resp) {
*/
GeckoDriver.prototype.setSessionCapabilities = function(newCaps) {
const copy = (from, to={}) => {
let errors = {};
let errors = [];
// Remove any duplicates between required and desired in favour of the
// required capabilities
if (from !== null && from.desiredCapabilities) {
for (let cap in from.requiredCapabilities) {
if (from.desiredCapabilities[cap]) {
delete from.desiredCapabilities[cap];
}
}
// Let's remove the sessionCapabilities from desired capabilities
for (let cap in this.sessionCapabilities) {
if (from.desiredCapabilities && from.desiredCapabilities[cap]) {
delete from.desiredCapabilities[cap];
}
}
}
for (let key in from) {
if (key === "desiredCapabilities") {
// Keeping desired capabilities separate for now so that we can keep
// backwards compatibility
to = copy(from[key], to);
} else if (key === "requiredCapabilities") {
for (let caps in from[key]) {
if (from[key][caps] !== this.sessionCapabilities[caps]) {
errors[caps] = from[key][caps] + " does not equal " +
this.sessionCapabilities[caps];
errors.push(from[key][caps] + " does not equal " +
this.sessionCapabilities[caps]) ;
}
}
}