Bug 1342162 - Make timeout API in client backwards compatible; r?whimboo draft
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 23 Mar 2017 16:22:34 +0000
changeset 504638 caf3a63560a9c00e8418b633a6f01367b23342cb
parent 504637 61b4450ef610cb36e6ed585ee6b20807b51f23be
child 550683 70afe1457564bb56e53e557bd6480e1cc7e7f163
push id50830
push userbmo:ato@mozilla.com
push dateFri, 24 Mar 2017 13:57:45 +0000
reviewerswhimboo
bugs1342162
milestone55.0a1
Bug 1342162 - Make timeout API in client backwards compatible; r?whimboo This makes the session timeout duration configuration API backwards compatible with earlier Firefoxen. As Marionette changes to accept pageLoad, we must still continue to allow "page load" as a key for as long as the Marionette Python client is used for Firefox upgrade tests. MozReview-Commit-ID: Ln4D3bY2d7f
testing/marionette/client/marionette_driver/timeout.py
--- a/testing/marionette/client/marionette_driver/timeout.py
+++ b/testing/marionette/client/marionette_driver/timeout.py
@@ -31,17 +31,20 @@ class Timeouts(object):
         ms = sec * 1000
         try:
             self._marionette._send_message("setTimeouts", {name: ms})
         except errors.UnknownCommandException:
             # remove when 55 is stable
             self._marionette._send_message("timeouts", {"type": name, "ms": ms})
 
     def _get(self, name):
-        ms = self._marionette._send_message("getTimeouts", key=name)
+        ts = self._marionette._send_message("getTimeouts")
+        if name not in ts:
+            raise KeyError()
+        ms = ts[name]
         return ms / 1000
 
     @property
     def script(self):
         """Get the session's script timeout.  This specifies the time
         to wait for injected scripts to finished before interrupting
         them. It is by default 30 seconds.
 
@@ -58,25 +61,33 @@ class Timeouts(object):
 
     @property
     def page_load(self):
         """Get the session's page load timeout.  This specifies the time
         to wait for the page loading to complete.  It is by default 5
         minutes (or 300 seconds).
 
         """
-        return self._get("pageLoad")
+        # remove fallback when Firefox 56 is stable
+        try:
+            return self._get("pageLoad")
+        except KeyError:
+            return self._get("page load")
 
     @page_load.setter
     def page_load(self, sec):
         """Set the session's page load timeout.  This specifies the time
         to wait for the page loading to complete.
 
         """
-        self._set("pageLoad", sec)
+        # remove fallback when Firefox 56 is stable
+        try:
+            self._set("pageLoad", sec)
+        except errors.InvalidArgumentException:
+            return self._set("page load", sec)
 
     @property
     def implicit(self):
         """Get the session's implicit wait timeout.  This specifies the
         time to wait for the implicit element location strategy when
         retrieving elements.  It is by default disabled (0 seconds).
 
         """