Bug 1316622 - Rename Marionette command timeouts to setTimeouts; r?automatedtester,whimboo draft
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 10 Nov 2016 18:29:55 +0000
changeset 440368 a22c7f4ca534fb9ec824ab1a418a1a58b9f74d5e
parent 440252 13f49da109ea460665ad27c8497cb1489548450c
child 440369 de03cd8be07e582bd92ba7fce10d31b4aad1a825
push id36214
push userbmo:ato@mozilla.com
push dateThu, 17 Nov 2016 13:46:37 +0000
reviewersautomatedtester, whimboo
bugs1316622
milestone53.0a1
Bug 1316622 - Rename Marionette command timeouts to setTimeouts; r?automatedtester,whimboo This renames the `Marionette:timeouts` command to `Marionette:setTimeouts`. It should be fine to make this backwards incompatible change as the `Marionette.set_script_timeout`, `Marionette.set_search_timeout`, and `Marionette.set_page_load_timeout` commands all have existing try...except behaviour for another backwards incompatible change in Firefox 52. MozReview-Commit-ID: 58RrXhE2tN3
testing/marionette/client/marionette_driver/marionette.py
testing/marionette/driver.js
testing/marionette/harness/marionette/tests/unit/test_timeouts.py
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1312,17 +1312,17 @@ class Marionette(object):
         a ScriptTimeoutException is raised.
 
         :param timeout: The maximum number of milliseconds an asynchronous
             script can run without causing an ScriptTimeoutException to
             be raised
 
         """
         try:
-            self._send_message("timeouts", {"script": timeout})
+            self._send_message("setTimeouts", {"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):
@@ -1335,17 +1335,17 @@ class Marionette(object):
         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.
 
         """
         try:
-            self._send_message("timeouts", {"implicit": timeout})
+            self._send_message("setTimeouts", {"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):
@@ -1354,17 +1354,17 @@ class Marionette(object):
         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.
 
         """
         try:
-            self._send_message("timeouts", {"page load": timeout})
+            self._send_message("setTimeouts", {"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
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1542,28 +1542,36 @@ GeckoDriver.prototype.switchToFrame = fu
           this.curBrowser.frameManager.switchToFrame(winId, frameId);
 
       yield registerBrowsers;
       yield browserListening;
     }
   }
 };
 
+GeckoDriver.prototype.getTimeouts = function(cmd, resp) {
+  return {
+    "implicit": this.searchTimeout,
+    "script": this.scriptTimeout,
+    "page load": this.pageTimeout,
+  };
+};
+
 /**
  * Set timeout for page loading, searching, and scripts.
  *
  * @param {Object.<string, number>}
  *     Dictionary of timeout types and their new value, where all timeout
  *     types are optional.
  *
  * @throws {InvalidArgumentError}
  *     If timeout type key is unknown, or the value provided with it is
  *     not an integer.
  */
-GeckoDriver.prototype.timeouts = function(cmd, resp) {
+GeckoDriver.prototype.setTimeouts = function(cmd, resp) {
   // backwards compatibility with old API
   // that accepted a dictionary {type: <string>, ms: <number>}
   let timeouts = {};
   if (typeof cmd.parameters == "object" &&
       "type" in cmd.parameters &&
       "ms" in cmd.parameters) {
     logger.warn("Using deprecated data structure for setting timeouts");
     timeouts = {[cmd.parameters.type]: parseInt(cmd.parameters.ms)};
@@ -2808,17 +2816,19 @@ GeckoDriver.prototype.commands = {
   "sayHello": GeckoDriver.prototype.sayHello,
   "newSession": GeckoDriver.prototype.newSession,
   "getSessionCapabilities": GeckoDriver.prototype.getSessionCapabilities,
   "log": GeckoDriver.prototype.log,
   "getLogs": GeckoDriver.prototype.getLogs,
   "setContext": GeckoDriver.prototype.setContext,
   "getContext": GeckoDriver.prototype.getContext,
   "executeScript": GeckoDriver.prototype.executeScript,
-  "timeouts": GeckoDriver.prototype.timeouts,
+  "getTimeouts": GeckoDriver.prototype.getTimeouts,
+  "timeouts": GeckoDriver.prototype.setTimeouts,  // deprecated until Firefox 55
+  "setTimeouts": GeckoDriver.prototype.setTimeouts,
   "singleTap": GeckoDriver.prototype.singleTap,
   "actionChain": GeckoDriver.prototype.actionChain,
   "multiAction": GeckoDriver.prototype.multiAction,
   "executeAsyncScript": GeckoDriver.prototype.executeAsyncScript,
   "executeJSScript": GeckoDriver.prototype.executeJSScript,
   "findElement": GeckoDriver.prototype.findElement,
   "findElements": GeckoDriver.prototype.findElements,
   "clickElement": GeckoDriver.prototype.clickElement,
--- a/testing/marionette/harness/marionette/tests/unit/test_timeouts.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_timeouts.py
@@ -75,9 +75,13 @@ class TestTimeouts(MarionetteTestCase):
             self.assertRaises(InvalidArgumentException, self.marionette.set_script_timeout, val)
             self.assertRaises(InvalidArgumentException, self.marionette.set_page_load_timeout, val)
 
     def test_compat_input_types(self):
         # When using the spec-incompatible input format which we have
         # for backwards compatibility, it should be possible to send ms
         # as a string type and have the server parseInt it to an integer.
         body = {"type": "script", "ms": "30000"}
+        self.marionette._send_message("setTimeouts", body)
+
+    def test_deprecated_set_timeouts_command(self):
+        body = {"implicit": 3000}
         self.marionette._send_message("timeouts", body)