Bug 1411197 - Quit/Restart without a callable callback shouldn't perform a shutdown. r=maja_zf

MozReview-Commit-ID: 9qCdmGKFocB

--HG--
extra : rebase_source : 46dcf7d8091c47b05d08959b270953fa63ed7aed
This commit is contained in:
Henrik Skupin 2017-10-27 15:42:31 +02:00
Родитель be1fc528af
Коммит 7a65183aea
2 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@ -1096,7 +1096,10 @@ class Marionette(object):
cause = None
if in_app:
if callable(callback):
if callback is not None:
if not callable(callback):
raise ValueError("Specified callback '{}' is not callable".format(callback))
self._send_message("acceptConnections", {"value": False})
callback()
else:
@ -1148,7 +1151,10 @@ class Marionette(object):
if clean:
raise ValueError("An in_app restart cannot be triggered with the clean flag set")
if callable(callback):
if callback is not None:
if not callable(callback):
raise ValueError("Specified callback '{}' is not callable".format(callback))
self._send_message("acceptConnections", {"value": False})
callback()
else:

Просмотреть файл

@ -223,7 +223,11 @@ class TestQuitRestart(MarionetteTestCase):
finally:
self.marionette.quit(clean=True)
def test_in_app_restart_with_callback_no_shutdown(self):
def test_in_app_restart_with_callback_not_callable(self):
with self.assertRaisesRegexp(ValueError, "is not callable"):
self.marionette.restart(in_app=True, callback=4)
def test_in_app_restart_with_callback_missing_shutdown(self):
try:
timeout_startup = self.marionette.DEFAULT_STARTUP_TIMEOUT
timeout_shutdown = self.marionette.DEFAULT_SHUTDOWN_TIMEOUT
@ -269,7 +273,7 @@ class TestQuitRestart(MarionetteTestCase):
self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"),
"about:")
def test_in_app_quit_with_callback_no_shutdown(self):
def test_in_app_quit_with_callback_missing_shutdown(self):
try:
timeout = self.marionette.DEFAULT_SHUTDOWN_TIMEOUT
self.marionette.DEFAULT_SHUTDOWN_TIMEOUT = 10
@ -279,6 +283,10 @@ class TestQuitRestart(MarionetteTestCase):
finally:
self.marionette.DEFAULT_SHUTDOWN_TIMEOUT = timeout
def test_in_app_quit_with_callback_not_callable(self):
with self.assertRaisesRegexp(ValueError, "is not callable"):
self.marionette.restart(in_app=True, callback=4)
@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":