From 3f510fc3b6fb9fc7607b29b4ca6e8382740e794f Mon Sep 17 00:00:00 2001 From: Agi Sferro Date: Fri, 20 Dec 2019 02:12:02 +0000 Subject: [PATCH] Bug 1605246 - Kill main process if child process dies during tests. r=snorp Right now we only detect `onCrash` on mochitests/reftests and `onKill` on junit tests. This change makes it so we wait for both on every type of test. Differential Revision: https://phabricator.services.mozilla.com/D57895 --HG-- extra : moz-landing-system : lando --- .../geckoview/test/TestRunnerActivity.java | 15 ++++++++++++--- .../geckoview/test/rule/GeckoSessionTestRule.java | 6 +++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java index 8dd4c094610b..ac7bc0a07611 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java @@ -120,6 +120,12 @@ public class TestRunnerActivity extends Activity { }; private GeckoSession.ContentDelegate mContentDelegate = new GeckoSession.ContentDelegate() { + private void onContentProcessGone() { + if (System.getenv("MOZ_CRASHREPORTER_SHUTDOWN") != null) { + sRuntime.shutdown(); + } + } + @Override public void onTitleChange(GeckoSession session, String title) { @@ -152,9 +158,12 @@ public class TestRunnerActivity extends Activity { @Override public void onCrash(GeckoSession session) { - if (System.getenv("MOZ_CRASHREPORTER_SHUTDOWN") != null) { - sRuntime.shutdown(); - } + onContentProcessGone(); + } + + @Override + public void onKill(GeckoSession session) { + onContentProcessGone(); } @Override diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java index 15a1d0fb42fa..394f32792af0 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java @@ -98,6 +98,7 @@ public class GeckoSessionTestRule implements TestRule { private static final Method sOnPageStop; private static final Method sOnNewSession; private static final Method sOnCrash; + private static final Method sOnKill; static { try { @@ -108,6 +109,8 @@ public class GeckoSessionTestRule implements TestRule { sOnNewSession = GeckoSession.NavigationDelegate.class.getMethod( "onNewSession", GeckoSession.class, String.class); sOnCrash = GeckoSession.ContentDelegate.class.getMethod( + "onCrash", GeckoSession.class); + sOnKill = GeckoSession.ContentDelegate.class.getMethod( "onKill", GeckoSession.class); } catch (final NoSuchMethodException e) { throw new RuntimeException(e); @@ -1031,7 +1034,8 @@ public class GeckoSessionTestRule implements TestRule { session = (GeckoSession) args[0]; } - if (sOnCrash.equals(method) && !mIgnoreCrash && isUsingSession(session)) { + if ((sOnCrash.equals(method) || sOnKill.equals(method)) + && !mIgnoreCrash && isUsingSession(session)) { if (env.shouldShutdownOnCrash()) { getRuntime().shutdown(); }