Bug 1279243 - Add quit_in_app() to marionette driver. r=maja_zf
authorAndré Reinald <areinald@mozilla.com>
Tue, 19 Jul 2016 17:13:43 +0200
changeset 305911 2bb2126f4034aff15d68dd0d16eff0d861d47601
parent 305910 ad5230005e910448a8d1dc01083bdb86e5e2e6bf
child 305912 6f2f0028e8d56e3ebda4658ccc00c3765e40209c
push id30474
push usercbook@mozilla.com
push dateThu, 21 Jul 2016 14:25:10 +0000
treeherdermozilla-central@6b180266ac16 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1279243
milestone50.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 1279243 - Add quit_in_app() to marionette driver. r=maja_zf MozReview-Commit-ID: 4O1hnYVsUWX
testing/marionette/client/marionette_driver/marionette.py
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -725,17 +725,17 @@ class Marionette(object):
 
         else:
             error = obj["error"]
             message = obj["message"]
             stacktrace = obj["stacktrace"]
 
         raise errors.lookup(error)(message, stacktrace=stacktrace)
 
-    def _reset_timeouts(self):
+    def reset_timeouts(self):
         if self.timeout is not None:
             self.timeouts(self.TIMEOUT_SEARCH, self.timeout)
             self.timeouts(self.TIMEOUT_SCRIPT, self.timeout)
             self.timeouts(self.TIMEOUT_PAGE, self.timeout)
         else:
             self.timeouts(self.TIMEOUT_PAGE, 30000)
 
     def check_for_crash(self):
@@ -1005,17 +1005,34 @@ class Marionette(object):
             if not pref_exists:
                 break
         self.set_context(self.CONTEXT_CONTENT)
         if not pref_exists:
             self.delete_session()
             self.instance.restart(prefs)
             self.raise_for_port(self.wait_for_port())
             self.start_session()
-            self._reset_timeouts()
+            self.reset_timeouts()
+
+    def quit_in_app(self):
+        """
+        This will terminate the currently running instance.
+        """
+        if not self.instance:
+            raise errors.MarionetteException("quit_in_app can only be called "
+                                             "on gecko instances launched by Marionette")
+        # Values here correspond to constants in nsIAppStartup.
+        # See http://mzl.la/1X0JZsC
+        restart_flags = [
+            "eForceQuit",
+            "eRestart",
+        ]
+        self._send_message("quitApplication", {"flags": restart_flags})
+        self.client.close()
+        self.raise_for_port(self.wait_for_port())
 
     def restart(self, clean=False, in_app=False):
         """
         This will terminate the currently running instance, and spawn a new instance
         with the same profile and then reuse the session id when creating a session again.
 
         : param clean: If False the same profile will be used after the restart. Note
                        that the in app initiated restart always maintains the same
@@ -1025,31 +1042,24 @@ class Marionette(object):
                         by killing the process.
         """
         if not self.instance:
             raise errors.MarionetteException("restart can only be called "
                                              "on gecko instances launched by Marionette")
         if in_app:
             if clean:
                 raise ValueError
-            # Values here correspond to constants in nsIAppStartup.
-            # See http://mzl.la/1X0JZsC
-            restart_flags = [
-                "eForceQuit",
-                "eRestart",
-            ]
-            self._send_message("quitApplication", {"flags": restart_flags})
-            self.client.close()
+            self.quit_in_app()
         else:
             self.delete_session()
             self.instance.restart(clean=clean)
+            self.raise_for_port(self.wait_for_port())
 
-        self.raise_for_port(self.wait_for_port())
         self.start_session(session_id=self.session_id)
-        self._reset_timeouts()
+        self.reset_timeouts()
 
         if in_app:
             # 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.
             self.instance.runner.process_handler.check_for_detached(self.session['processId'])
 
     def absolute_url(self, relative_url):