Bug 1308453 - Backwards compat for old Marionette:timeouts API; r?whimboo draft
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 17 Oct 2016 15:38:28 +0100
changeset 426013 c7460f5f1bf4ed9c505c74082347ca6d1e9c7261
parent 426004 7c8216f48c38a8498f251fe044509b930af44de6
child 534057 53bf4ea85b4d859367878461cb5ffd70738351dc
push id32580
push userbmo:ato@mozilla.com
push dateMon, 17 Oct 2016 15:33:25 +0000
reviewerswhimboo
bugs1308453, 1302707
milestone52.0a1
Bug 1308453 - Backwards compat for old Marionette:timeouts API; r?whimboo Since the Marionette Python client is being used for upgrade tests it needs to remain backwards compatible with earlier Gecko versions. Bug 1302707 changed the Marionette:timeouts API, and this patch addresses the fallout caused by that. When sending the new command format and it returns with an error, we try again with the old format if the error message contained "Not a Number". This is not ideal, but a natural consequence of poor error typing in the past. We can remove this workaround when Firefox 51 becomes the stable train. MozReview-Commit-ID: JxQAuKnojPB
testing/marionette/client/marionette_driver/marionette.py
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1229,45 +1229,66 @@ class Marionette(object):
         If a script does not return in the specified amount of time,
         a ScriptTimeoutException is raised.
 
         :param timeout: The maximum number of milliseconds an asynchronous
             script can run without causing an ScriptTimeoutException to
             be raised
 
         """
-        self._send_message("timeouts", {"script": timeout})
+        try:
+            self._send_message("timeouts", {"script": timeout})
+        except errors.MarionetteException as e:
+            # remove when 52.0a is stable
+            if "Not a Number" in e.message:
+                self._send_message("timeouts", {"type": "script", "ms": timeout})
+            else:
+                raise e
 
     def set_search_timeout(self, timeout):
         """Sets a timeout for the find methods.
 
         When searching for an element using
         either :class:`Marionette.find_element` or
         :class:`Marionette.find_elements`, the method will continue
         trying to locate the element for up to timeout ms. This can be
         useful if, for example, the element you're looking for might
         not exist immediately, because it belongs to a page which is
         currently being loaded.
 
         :param timeout: Timeout in milliseconds.
 
         """
-        self._send_message("timeouts", {"implicit": timeout})
+        try:
+            self._send_message("timeouts", {"implicit": timeout})
+        except errors.MarionetteException as e:
+            # remove when 52.0a is stable
+            if "Not a Number" in e.message:
+                self._send_message("timeouts", {"type": "implicit", "ms": timeout})
+            else:
+                raise e
 
     def set_page_load_timeout(self, timeout):
         """Sets a timeout for loading pages.
 
         A page load timeout specifies the amount of time the Marionette
         instance should wait for a page load operation to complete. A
         ``TimeoutException`` is returned if this limit is exceeded.
 
         :param timeout: Timeout in milliseconds.
 
         """
-        self._send_message("timeouts", {"page load": timeout})
+        try:
+            self._send_message("timeouts", {"page load": timeout})
+        except errors.MarionetteException as e:
+            # remove when 52.0a is stable
+            if "Not a Number" in e.message:
+                self._send_message("timeouts", {"type": "page load", "ms": timeout})
+            else:
+                raise e
 
     @property
     def current_window_handle(self):
         """Get the current window's handle.
 
         Returns an opaque server-assigned identifier to this window
         that uniquely identifies it within this Marionette instance.
         This can be used to switch to this window at a later point.