mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1366784 - Force quit the application if requested quit or restart doesn't happen. r=maja_zf
In case a quit or restart is requested, but eg. the in_app callback doesn't really trigger a shutdown of the application, Marionette has to force close it after the default shutdown timeout. This is necessary because "acceptConnections" is set to false and no further connection could be made to the still running application. MozReview-Commit-ID: GwSeYyjI6M9 --HG-- extra : rebase_source : 52a9b0dcc2b8b7710925f25ec48f4ad5b5e96c64
This commit is contained in:
parent
a8a8b628cd
commit
1f73453256
@ -1086,7 +1086,15 @@ class Marionette(object):
|
||||
self.delete_session(send_request=False, reset_session_id=True)
|
||||
|
||||
# Give the application some time to shutdown
|
||||
self.instance.runner.wait(timeout=self.DEFAULT_SHUTDOWN_TIMEOUT)
|
||||
returncode = self.instance.runner.wait(timeout=self.DEFAULT_SHUTDOWN_TIMEOUT)
|
||||
if returncode is None:
|
||||
# This will force-close the application without sending any other message.
|
||||
self.cleanup()
|
||||
|
||||
message = ("Process killed because a requested application quit did not happen "
|
||||
"within {}s. Check gecko.log for errors.")
|
||||
raise IOError(message.format(self.DEFAULT_SHUTDOWN_TIMEOUT))
|
||||
|
||||
else:
|
||||
self.delete_session(reset_session_id=True)
|
||||
self.instance.close()
|
||||
@ -1127,7 +1135,8 @@ class Marionette(object):
|
||||
self.delete_session(send_request=False, reset_session_id=True)
|
||||
|
||||
try:
|
||||
self.raise_for_port()
|
||||
timeout = self.DEFAULT_SHUTDOWN_TIMEOUT + self.DEFAULT_STARTUP_TIMEOUT
|
||||
self.raise_for_port(timeout=timeout)
|
||||
except socket.timeout:
|
||||
if self.instance.runner.returncode is not None:
|
||||
exc, val, tb = sys.exc_info()
|
||||
@ -1137,7 +1146,7 @@ class Marionette(object):
|
||||
else:
|
||||
self.delete_session()
|
||||
self.instance.restart(clean=clean)
|
||||
self.raise_for_port()
|
||||
self.raise_for_port(timeout=self.DEFAULT_STARTUP_TIMEOUT)
|
||||
|
||||
self.start_session(session_id=session_id)
|
||||
|
||||
|
@ -161,6 +161,19 @@ class TestQuitRestart(MarionetteTestCase):
|
||||
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
|
||||
"about:")
|
||||
|
||||
def test_in_app_restart_with_callback_no_shutdown(self):
|
||||
try:
|
||||
timeout_startup = self.marionette.DEFAULT_STARTUP_TIMEOUT
|
||||
timeout_shutdown = self.marionette.DEFAULT_SHUTDOWN_TIMEOUT
|
||||
self.marionette.DEFAULT_SHUTDOWN_TIMEOUT = 5
|
||||
self.marionette.DEFAULT_STARTUP_TIMEOUT = 5
|
||||
|
||||
with self.assertRaisesRegexp(IOError, "the connection to Marionette server is lost"):
|
||||
self.marionette.restart(in_app=True, callback=lambda: False)
|
||||
finally:
|
||||
self.marionette.DEFAULT_STARTUP_TIMEOUT = timeout_startup
|
||||
self.marionette.DEFAULT_SHUTDOWN_TIMEOUT = timeout_shutdown
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_in_app_quit(self):
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
@ -192,6 +205,16 @@ class TestQuitRestart(MarionetteTestCase):
|
||||
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
|
||||
"about:")
|
||||
|
||||
def test_in_app_quit_with_callback_no_shutdown(self):
|
||||
try:
|
||||
timeout = self.marionette.DEFAULT_SHUTDOWN_TIMEOUT
|
||||
self.marionette.DEFAULT_SHUTDOWN_TIMEOUT = 10
|
||||
|
||||
with self.assertRaisesRegexp(IOError, "a requested application quit did not happen"):
|
||||
self.marionette.quit(in_app=True, callback=lambda: False)
|
||||
finally:
|
||||
self.marionette.DEFAULT_SHUTDOWN_TIMEOUT = timeout
|
||||
|
||||
@skip("Bug 1363368 - Wrong window handles after in_app restarts")
|
||||
def test_reset_context_after_quit_by_set_context(self):
|
||||
if self.marionette.session_capabilities["platformName"] != "windows_nt":
|
||||
|
Loading…
Reference in New Issue
Block a user