Bug 1387092 - Add support for proxyType "direct". r=ato
authorHenrik Skupin <mail@hskupin.info>
Tue, 15 Aug 2017 19:23:33 +0200
changeset 647049 52c0c3d1c0b30e344c66bbd38d7134fc27045862
parent 647048 a9732755601920d47aa95b3d599cddaede3f29e1
child 647050 a9a6206bf9380fe37ee6e3a5d7483dcb1c184d2d
push id74288
push userhikezoe@mozilla.com
push dateWed, 16 Aug 2017 00:19:57 +0000
reviewersato
bugs1387092
milestone57.0a1
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
testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
testing/marionette/session.js
testing/marionette/test_session.js
--- 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]"; }
 
   /**
--- a/testing/marionette/test_session.js
+++ b/testing/marionette/test_session.js
@@ -139,19 +139,19 @@ add_test(function test_Proxy_init() {
   equal(Preferences.get("network.proxy.type"), 4);
 
   // system
   p = new session.Proxy();
   p.proxyType = "system";
   ok(p.init());
   equal(Preferences.get("network.proxy.type"), 5);
 
-  // noproxy
+  // direct
   p = new session.Proxy();
-  p.proxyType = "noproxy";
+  p.proxyType = "direct";
   ok(p.init());
   equal(Preferences.get("network.proxy.type"), 0);
 
   run_next_test();
 });
 
 add_test(function test_Proxy_toString() {
   equal(new session.Proxy().toString(), "[object session.Proxy]");