Bug 1428740 - Improve Marionette unit tests for parent and content crashes. r=maja_zf

For parent process crashes a Wait().until() condition was added, which is
not necessary because if the parent (chrome) process dies, the browser
window will be gone immediately, and the IOError is thrown directly.

Further the tests should check that the correct type of crash is shown
in the IOError exceptions.

MozReview-Commit-ID: JC90CObZQ3r

--HG--
extra : rebase_source : 050fea4217c9ad95a84e20b6d5d92b42a89c3521
This commit is contained in:
Henrik Skupin 2018-01-08 11:37:41 +01:00
Родитель e45676c4eb
Коммит 8850686c20
1 изменённых файлов: 14 добавлений и 28 удалений

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

@ -3,6 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import glob
import os
import shutil
from marionette_driver import Wait
@ -42,7 +43,8 @@ class MockMozCrash(object):
except TimeoutException:
minidump_files = []
shutil.rmtree(dump_directory)
if os.path.isdir(dump_directory):
shutil.rmtree(dump_directory)
return len(minidump_files)
else:
@ -105,13 +107,8 @@ class BaseCrashTestCase(MarionetteTestCase):
class TestCrash(BaseCrashTestCase):
def test_crash_chrome_process(self):
with self.assertRaises(IOError):
self.crash(chrome=True)
Wait(self.marionette, timeout=self.socket_timeout,
ignored_exceptions=NoSuchWindowException).until(
lambda _: self.marionette.get_url(),
message="Expected IOError exception for content crash not raised."
)
self.assertRaisesRegexp(IOError, "Process crashed",
self.crash, chrome=True)
# A crash results in a non zero exit code
self.assertNotIn(self.marionette.instance.runner.returncode, (None, 0))
@ -128,12 +125,11 @@ class TestCrash(BaseCrashTestCase):
@run_if_e10s("Content crashes only exist in e10s mode")
def test_crash_content_process(self):
# With MOZ_CRASHREPORTER_SHUTDOWN each window of the browser will be
# closed in case of a content crash. So the "unload" handler fires for
# the current window, which causes the command to return early.
# To check for an IOError, further commands have to be executed until
# Firefox has been shutdown.
with self.assertRaises(IOError):
# For a content process crash and MOZ_CRASHREPORTER_SHUTDOWN set the top
# browsing context will be gone first. As such the raised NoSuchWindowException
# has to be ignored. To check for the IOError, further commands have to
# be executed until the process is gone.
with self.assertRaisesRegexp(IOError, "Content process crashed"):
self.crash(chrome=False)
Wait(self.marionette, timeout=self.socket_timeout,
ignored_exceptions=NoSuchWindowException).until(
@ -164,13 +160,8 @@ class TestCrashInSetUp(BaseCrashTestCase):
def setUp(self):
super(TestCrashInSetUp, self).setUp()
with self.assertRaises(IOError):
self.crash(chrome=True)
Wait(self.marionette, timeout=self.socket_timeout,
ignored_exceptions=NoSuchWindowException).until(
lambda _: self.marionette.get_url(),
message="Expected IOError exception for content crash not raised."
)
self.assertRaisesRegexp(IOError, "Process crashed",
self.crash, chrome=True)
# A crash results in a non zero exit code
self.assertNotIn(self.marionette.instance.runner.returncode, (None, 0))
@ -187,13 +178,8 @@ class TestCrashInTearDown(BaseCrashTestCase):
def tearDown(self):
try:
with self.assertRaises(IOError):
self.crash(chrome=True)
Wait(self.marionette, timeout=self.socket_timeout,
ignored_exceptions=NoSuchWindowException).until(
lambda _: self.marionette.get_url(),
message="Expected IOError exception for content crash not raised."
)
self.assertRaisesRegexp(IOError, "Process crashed",
self.crash, chrome=True)
# A crash results in a non zero exit code
self.assertNotIn(self.marionette.instance.runner.returncode, (None, 0))