Bug 1391016 - "proxyAutoconfigUrl" is required for proxyType "pac".
MozReview-Commit-ID: DC43PmCAWBn
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
@@ -125,16 +125,24 @@ class TestCapabilityMatching(MarionetteT
def test_invalid_proxy_type(self):
with self.assertRaises(SessionNotCreatedException):
self.marionette.start_session({"proxy": {"proxyAutoconfigUrl": None}})
with self.assertRaises(SessionNotCreatedException):
self.marionette.start_session({"proxy": {"proxyType": None}})
+ def test_proxy_type_pac_invalid_url(self):
+ with self.assertRaises(SessionNotCreatedException):
+ self.marionette.start_session({"proxy": {"proxyType": "pac"}})
+
+ with self.assertRaises(SessionNotCreatedException):
+ self.marionette.start_session({"proxy": {"proxyType": "pac",
+ "proxyAutoconfigUrl": None}})
+
def test_proxy_type_direct(self):
self.marionette.start_session({"proxy": {"proxyType": "direct"}})
self.assertIn("proxy", self.marionette.session_capabilities)
self.assertEqual(self.marionette.session_capabilities["proxy"]["proxyType"], "direct")
self.assertEqual(self.marionette.get_pref("network.proxy.type"), 0)
def test_proxy_type_manual(self):
self.marionette.start_session({"proxy": {"proxyType": "manual"}})
--- a/testing/marionette/session.js
+++ b/testing/marionette/session.js
@@ -208,41 +208,45 @@ session.Proxy = class {
return p;
}
assert.object(json);
assert.in("proxyType", json);
p.proxyType = assert.string(json.proxyType);
- if (json.proxyType == "manual") {
- if (typeof json.httpProxy != "undefined") {
- p.httpProxy = assert.string(json.httpProxy);
- p.httpProxyPort = assert.positiveInteger(json.httpProxyPort);
- }
+ switch (p.proxyType) {
+ case "manual":
+ if (typeof json.httpProxy != "undefined") {
+ p.httpProxy = assert.string(json.httpProxy);
+ p.httpProxyPort = assert.positiveInteger(json.httpProxyPort);
+ }
- if (typeof json.sslProxy != "undefined") {
- p.sslProxy = assert.string(json.sslProxy);
- p.sslProxyPort = assert.positiveInteger(json.sslProxyPort);
- }
+ if (typeof json.sslProxy != "undefined") {
+ p.sslProxy = assert.string(json.sslProxy);
+ p.sslProxyPort = assert.positiveInteger(json.sslProxyPort);
+ }
- if (typeof json.ftpProxy != "undefined") {
- p.ftpProxy = assert.string(json.ftpProxy);
- p.ftpProxyPort = assert.positiveInteger(json.ftpProxyPort);
- }
+ if (typeof json.ftpProxy != "undefined") {
+ p.ftpProxy = assert.string(json.ftpProxy);
+ p.ftpProxyPort = assert.positiveInteger(json.ftpProxyPort);
+ }
- if (typeof json.socksProxy != "undefined") {
- p.socksProxy = assert.string(json.socksProxy);
- p.socksProxyPort = assert.positiveInteger(json.socksProxyPort);
- p.socksProxyVersion = assert.positiveInteger(json.socksProxyVersion);
- }
- }
+ if (typeof json.socksProxy != "undefined") {
+ p.socksProxy = assert.string(json.socksProxy);
+ p.socksProxyPort = assert.positiveInteger(json.socksProxyPort);
+ p.socksProxyVersion = assert.positiveInteger(
+ json.socksProxyVersion);
+ }
- if (typeof json.proxyAutoconfigUrl != "undefined") {
- p.proxyAutoconfigUrl = assert.string(json.proxyAutoconfigUrl);
+ break;
+
+ case "pac":
+ p.proxyAutoconfigUrl = assert.string(json.proxyAutoconfigUrl);
+ break;
}
return p;
}
};
/** WebDriver session capabilities representation. */
session.Capabilities = class extends Map {