зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
74f8ab42da
Коммит
720ba26e14
|
@ -57,6 +57,14 @@ class TestCapabilities(MarionetteTestCase):
|
||||||
caps = self.marionette.session_capabilities
|
caps = self.marionette.session_capabilities
|
||||||
self.assertIn("somethingAwesome", caps)
|
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):
|
def test_we_can_pass_in_required_capabilities_on_session_start(self):
|
||||||
self.marionette.delete_session()
|
self.marionette.delete_session()
|
||||||
capabilities = { "requiredCapabilities": {"browserName": self.appinfo["name"]}}
|
capabilities = { "requiredCapabilities": {"browserName": self.appinfo["name"]}}
|
||||||
|
|
|
@ -602,18 +602,33 @@ GeckoDriver.prototype.getSessionCapabilities = function(cmd, resp) {
|
||||||
*/
|
*/
|
||||||
GeckoDriver.prototype.setSessionCapabilities = function(newCaps) {
|
GeckoDriver.prototype.setSessionCapabilities = function(newCaps) {
|
||||||
const copy = (from, to={}) => {
|
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) {
|
for (let key in from) {
|
||||||
if (key === "desiredCapabilities") {
|
if (key === "desiredCapabilities") {
|
||||||
// Keeping desired capabilities separate for now so that we can keep
|
|
||||||
// backwards compatibility
|
|
||||||
to = copy(from[key], to);
|
to = copy(from[key], to);
|
||||||
} else if (key === "requiredCapabilities") {
|
} else if (key === "requiredCapabilities") {
|
||||||
for (let caps in from[key]) {
|
for (let caps in from[key]) {
|
||||||
if (from[key][caps] !== this.sessionCapabilities[caps]) {
|
if (from[key][caps] !== this.sessionCapabilities[caps]) {
|
||||||
errors[caps] = from[key][caps] + " does not equal " +
|
errors.push(from[key][caps] + " does not equal " +
|
||||||
this.sessionCapabilities[caps];
|
this.sessionCapabilities[caps]) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче