Bug 1308453 - Backwards compat for old Marionette:timeouts API; r=whimboo
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 17 Oct 2016 15:38:28 +0100
changeset 318220 bf8f968120761dc2afa09249fe3cdee26f344bf5
parent 318219 ff86d2b6fb5f7c5c10fc5e6ba2f2b87e120dfaec
child 318221 8e234deee964dd0b1196f3c25f2b630e72f9a77d
push id33221
push useratolfsen@mozilla.com
push dateMon, 17 Oct 2016 16:14:55 +0000
treeherderautoland@bf8f96812076 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1308453, 1302707
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
@@ -1275,45 +1275,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.