Bug 1387092 - Add support for proxyType "direct". r=ato
The webdriver spec has been updated a while ago and renamed the proxyType
for not using a proxy from "noProxy" to "direct".
MozReview-Commit-ID: FjDIK8XCba8
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
@@ -6,16 +6,17 @@ from marionette_driver.errors import Ses
from marionette_harness import MarionetteTestCase
# Unlike python 3, python 2 doesn't have a proper implementation of realpath or
# samefile for Windows. However this function, which does exactly what we want,
# was added to python 2 to fix an issue with tcl installations and symlinks.
from FixTk import convert_path
+
class TestCapabilities(MarionetteTestCase):
def setUp(self):
super(TestCapabilities, self).setUp()
self.caps = self.marionette.session_capabilities
with self.marionette.using_context("chrome"):
self.appinfo = self.marionette.execute_script("""
return {
@@ -77,23 +78,19 @@ class TestCapabilities(MarionetteTestCas
def test_we_get_valid_uuid4_when_creating_a_session(self):
self.assertNotIn("{", self.marionette.session_id,
"Session ID has {{}} in it: {}".format(
self.marionette.session_id))
class TestCapabilityMatching(MarionetteTestCase):
- allowed = [None, "*"]
- disallowed = ["", 42, True, {}, []]
def setUp(self):
MarionetteTestCase.setUp(self)
- self.browser_name = self.marionette.session_capabilities["browserName"]
- self.platform_name = self.marionette.session_capabilities["platformName"]
self.delete_session()
def delete_session(self):
if self.marionette.session is not None:
self.marionette.delete_session()
def test_accept_insecure_certs(self):
for value in ["", 42, {}, []]:
@@ -117,27 +114,27 @@ class TestCapabilityMatching(MarionetteT
self.marionette.start_session({"pageLoadStrategy": None})
self.assertEqual(self.marionette.session_capabilities["pageLoadStrategy"], "normal")
for value in ["", "EAGER", True, 42, {}, []]:
print("invalid strategy {}".format(value))
with self.assertRaisesRegexp(SessionNotCreatedException, "InvalidArgumentError"):
self.marionette.start_session({"pageLoadStrategy": value})
- def test_proxy_default(self):
+ def test_proxy_none_by_default(self):
self.marionette.start_session()
self.assertNotIn("proxy", self.marionette.session_capabilities)
- def test_proxy_desired(self):
- self.marionette.start_session({"proxy": {"proxyType": "manual"}})
+ 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"], "manual")
- self.assertEqual(self.marionette.get_pref("network.proxy.type"), 1)
+ self.assertEqual(self.marionette.session_capabilities["proxy"]["proxyType"], "direct")
+ self.assertEqual(self.marionette.get_pref("network.proxy.type"), 0)
- def test_proxy_required(self):
+ def test_proxy_type_manual(self):
self.marionette.start_session({"proxy": {"proxyType": "manual"}})
self.assertIn("proxy", self.marionette.session_capabilities)
self.assertEqual(self.marionette.session_capabilities["proxy"]["proxyType"], "manual")
self.assertEqual(self.marionette.get_pref("network.proxy.type"), 1)
def test_timeouts(self):
timeouts = {u"implicit": 123, u"pageLoad": 456, u"script": 789}
caps = {"timeouts": timeouts}
--- a/testing/marionette/session.js
+++ b/testing/marionette/session.js
@@ -125,16 +125,24 @@ session.Proxy = class {
*
* @return {boolean}
* True if proxy settings were updated as a result of calling this
* function, or false indicating that this function acted as
* a no-op.
*/
init() {
switch (this.proxyType) {
+ case "autodetect":
+ Preferences.set("network.proxy.type", 4);
+ return true;
+
+ case "direct":
+ Preferences.set("network.proxy.type", 0);
+ return true;
+
case "manual":
Preferences.set("network.proxy.type", 1);
if (this.httpProxy && this.httpProxyPort) {
Preferences.set("network.proxy.http", this.httpProxy);
Preferences.set("network.proxy.http_port", this.httpProxyPort);
}
if (this.sslProxy && this.sslProxyPort) {
Preferences.set("network.proxy.ssl", this.sslProxy);
@@ -154,28 +162,20 @@ session.Proxy = class {
return true;
case "pac":
Preferences.set("network.proxy.type", 2);
Preferences.set(
"network.proxy.autoconfig_url", this.proxyAutoconfigUrl);
return true;
- case "autodetect":
- Preferences.set("network.proxy.type", 4);
- return true;
-
case "system":
Preferences.set("network.proxy.type", 5);
return true;
- case "noproxy":
- Preferences.set("network.proxy.type", 0);
- return true;
-
default:
return false;
}
}
toString() { return "[object session.Proxy]"; }
/**