Bug 1318724 - Increase the HTTP connection timeout for WebDriver tests, r=ato draft
authorJames Graham <james@hoppipolla.co.uk>
Thu, 23 Mar 2017 18:19:45 +0000
changeset 503910 83d9d8f3dfb82acec527654eb596ffca6aba22a4
parent 503909 01c87b267ce3e82c0bc2410728a83649fabece91
child 550542 eb83d7631e64a3aa84dae52e044b06d40b1623b6
push id50699
push userbmo:james@hoppipolla.co.uk
push dateThu, 23 Mar 2017 19:10:38 +0000
reviewersato
bugs1318724
milestone55.0a1
Bug 1318724 - Increase the HTTP connection timeout for WebDriver tests, r=ato The 5s timeout was not enough for debug builds. I don't really see a reason to use something other than the default socket timeout here. MozReview-Commit-ID: Fm5lgSI3lFb
testing/web-platform/tests/tools/webdriver/webdriver/client.py
testing/web-platform/tests/tools/webdriver/webdriver/transport.py
--- a/testing/web-platform/tests/tools/webdriver/webdriver/client.py
+++ b/testing/web-platform/tests/tools/webdriver/webdriver/client.py
@@ -313,18 +313,17 @@ class UserPrompt(object):
     @command
     def text(self, value):
         body = {"value": list(value)}
         self.session.send_session_command("POST", "alert/text", body=body)
 
 
 class Session(object):
     def __init__(self, host, port, url_prefix="/", desired_capabilities=None,
-                 required_capabilities=None, timeout=transport.HTTP_TIMEOUT,
-                 extension=None):
+                 required_capabilities=None, extension=None, timeout=None):
         self.transport = transport.HTTPWireProtocol(
             host, port, url_prefix, timeout=timeout)
         self.desired_capabilities = desired_capabilities
         self.required_capabilities = required_capabilities
         self.session_id = None
         self.timeouts = None
         self.window = None
         self.find = None
--- a/testing/web-platform/tests/tools/webdriver/webdriver/transport.py
+++ b/testing/web-platform/tests/tools/webdriver/webdriver/transport.py
@@ -1,17 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import httplib
 import json
 import urlparse
 
-HTTP_TIMEOUT = 5
 
 class Response(object):
     """Describes an HTTP response received from a remote en"Describes an HTTP
     response received from a remote end whose body has been read and parsed as
     appropriate."""
     def __init__(self, status, body):
         self.status = status
         self.body = body
@@ -42,22 +41,23 @@ class Response(object):
             # SpecID: dfn-send-a-response
             #
             # > 4. If data is not null, let response's body be a JSON Object
             #      with a key `value` set to the JSON Serialization of data.
             assert "value" in body
 
         return cls(status, body)
 
+
 class HTTPWireProtocol(object):
     """Transports messages (commands and responses) over the WebDriver
     wire protocol.
     """
 
-    def __init__(self, host, port, url_prefix="/", timeout=HTTP_TIMEOUT):
+    def __init__(self, host, port, url_prefix="/", timeout=None):
         """Construct interface for communicating with the remote server.
 
         :param url: URL of remote WebDriver server.
         :param wait: Duration to wait for remote to appear.
         """
 
         self.host = host
         self.port = port
@@ -89,18 +89,22 @@ class HTTPWireProtocol(object):
         if isinstance(body, unicode):
             body = body.encode("utf-8")
 
         if headers is None:
             headers = {}
 
         url = self.url_prefix + url
 
+        kwargs = {}
+        if self._timeout is not None:
+            kwargs["timeout"] = self._timeout
+
         conn = httplib.HTTPConnection(
-            self.host, self.port, strict=True, timeout=self._timeout)
+            self.host, self.port, strict=True, **kwargs)
         conn.request(method, url, body, headers)
 
         try:
             response = Response.from_http_response(conn.getresponse())
         finally:
             conn.close()
 
         return response