Bug 1299414 - Always reset timeout parameters for a new session. draft
authorHenrik Skupin <mail@hskupin.info>
Mon, 28 Nov 2016 15:26:33 +0100
changeset 444659 ec76e95bf4e5eb590b17b8e0a80fbd9fd5d19f65
parent 444478 05328d3102efd4d5fc0696489734d7771d24459f
child 538345 6243ed4a8c050f1f82afa2d82bf9064a5449bb9a
push id37318
push userbmo:hskupin@gmail.com
push dateMon, 28 Nov 2016 14:28:10 +0000
bugs1299414
milestone53.0a1
Bug 1299414 - Always reset timeout parameters for a new session. 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")