Bug 1469683 - 2. Make child crashes throw special exception; r?esawin
Make child crashes throw ChildCrashException instead of the generic
RuntimeException, which can mean a variety of errors such as timeout.
MozReview-Commit-ID: H0E6gipkTxg
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt
@@ -2,16 +2,17 @@
* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
package org.mozilla.geckoview.test
import org.mozilla.geckoview.GeckoSession
import org.mozilla.geckoview.GeckoSessionSettings
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
+import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.ChildCrashedException
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.ClosedSessionAtStart
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.IgnoreCrash
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.NullDelegate
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.RejectedPromiseException
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.ReuseSession
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.Setting
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.TimeoutException
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.TimeoutMillis
@@ -1659,17 +1660,17 @@ class GeckoSessionTestRuleTest : BaseSes
mainSession.loadUri(CONTENT_CRASH_URL)
mainSession.waitUntilCalled(object : Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onCrash(session: GeckoSession) = Unit
})
}
- @Test(expected = RuntimeException::class)
+ @Test(expected = ChildCrashedException::class)
@ReuseSession(false)
fun contentCrashFails() {
assumeThat(sessionRule.env.isMultiprocess, equalTo(true))
assumeThat(sessionRule.env.shouldShutdownOnCrash(), equalTo(false))
// Cannot test x86 debug builds due to Gecko's "ah_crap_handler"
// that waits for debugger to attach during a SIGSEGV.
assumeThat(sessionRule.env.isDebugBuild && sessionRule.env.cpuArch == "x86",
equalTo(false))
--- 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
@@ -338,16 +338,22 @@ public class GeckoSessionTestRule extend
}
public static class TimeoutException extends RuntimeException {
public TimeoutException(final String detailMessage) {
super(detailMessage);
}
}
+ public static class ChildCrashedException extends RuntimeException {
+ public ChildCrashedException(final String detailMessage) {
+ super(detailMessage);
+ }
+ }
+
public static class RejectedPromiseException extends RuntimeException {
private final Object mReason;
/* package */ RejectedPromiseException(final Object reason) {
super(String.valueOf(reason));
mReason = reason;
}
@@ -1192,17 +1198,17 @@ public class GeckoSessionTestRule extend
session = (GeckoSession) args[0];
}
if (sOnCrash.equals(method) && !mIgnoreCrash && isUsingSession(session)) {
if (env.shouldShutdownOnCrash()) {
sRuntime.shutdown();
}
- throw new RuntimeException("Content process crashed");
+ throw new ChildCrashedException("Child process crashed");
}
records.add(new CallRecord(session, method, args));
call = waitDelegates.prepareMethodCall(session, method);
if (call == null) {
call = testDelegates.prepareMethodCall(session, method);
}