Bug 1299414 - Always reset timeout parameters for a new session. r=ato
authorHenrik Skupin <mail@hskupin.info>
Mon, 28 Nov 2016 15:26:33 +0100
changeset 324523 b6d9e6164194487be1e365726a51cf04f1f64f28
parent 324522 0c9297cc0e465f5fbfabf8aba64daac9edd8baca
child 324524 6b09c6adcfa5066a4a76241d3b8c037274d0a4b7
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersato
bugs1299414
milestone53.0a1
Bug 1299414 - Always reset timeout parameters for a new session. r=ato MozReview-Commit-ID: 7ubF630qNo7
testing/marionette/client/marionette_driver/marionette.py
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
@@ -1090,17 +1090,16 @@ class Marionette(object):
                     break
 
         if not pref_exists:
             context = self._send_message("getContext", key="value")
             self.delete_session()
             self.instance.restart(prefs)
             self.raise_for_port()
             self.start_session()
-            self.timeout.reset()
 
             # Restore the context as used before the restart
             self.set_context(context)
 
     def _request_in_app_shutdown(self, shutdown_flags=None):
         """Terminate the currently running instance from inside the application.
 
         :param shutdown_flags: If specified use additional flags for the shutdown
@@ -1139,18 +1138,16 @@ class Marionette(object):
                        by killing the process.
         :param callback: If provided and `in_app` is True, the callback will
                          be used to trigger the shutdown.
         """
         if not self.instance:
             raise errors.MarionetteException("quit() can only be called "
                                              "on Gecko instances launched by Marionette")
 
-        self.timeout.reset()
-
         if in_app:
             if callable(callback):
                 self._send_message("acceptConnections", {"value": False})
                 callback()
             else:
                 self._request_in_app_shutdown()
 
             # Ensure to explicitely mark the session as deleted
@@ -1206,17 +1203,16 @@ class Marionette(object):
                     raise exc, "Requested restart of the application was aborted", tb
 
         else:
             self.delete_session()
             self.instance.restart(clean=clean)
             self.raise_for_port()
 
         self.start_session(session_id=session_id)
-        self.timeout.reset()
 
         # Restore the context as used before the restart
         self.set_context(context)
 
         if in_app and self.session.get("processId"):
             # In some cases Firefox restarts itself by spawning into a new process group.
             # As long as mozprocess cannot track that behavior (bug 1284864) we assist by
             # informing about the new process id.
--- a/testing/marionette/harness/marionette/tests/unit/test_timeouts.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_timeouts.py
@@ -48,16 +48,35 @@ class TestTimeouts(MarionetteTestCase):
 
     def test_search_timeout_found(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         button = self.marionette.find_element(By.ID, "createDivButton")
         button.click()
         self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "newDiv")
 
+    def test_reset_timeout(self):
+        timeouts = [getattr(self.marionette.timeout, f) for f in (
+            'implicit', 'page_load', 'script',)]
+
+        def do_check(callback):
+            for timeout in timeouts:
+                timeout = 10000
+                self.assertEqual(timeout, 10000)
+            callback()
+            for timeout in timeouts:
+                self.assertNotEqual(timeout, 10000)
+
+        def callback_quit():
+            self.marionette.quit()
+            self.marionette.start_session()
+
+        do_check(self.marionette.restart)
+        do_check(callback_quit)
+
     def test_execute_async_timeout_settimeout(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         self.marionette.timeout.script = 1
         self.assertRaises(ScriptTimeoutException, self.marionette.execute_async_script, "var x = 1;")
 
     def test_no_timeout_settimeout(self):
         test_html = self.marionette.absolute_url("test.html")