зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1465480 - Throw away cached session if there was a crash r=jchen
If a content process crashes during a test, throw away the cached session since it may be in an inconsistent state. MozReview-Commit-ID: 9bqWNeJjYd5
This commit is contained in:
Родитель
4f1fa4bc6e
Коммит
686081d31b
|
@ -1132,6 +1132,7 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
|||
mClosedSession = false;
|
||||
mWithDevTools = false;
|
||||
mReuseSession = true;
|
||||
mIgnoreCrash = false;
|
||||
|
||||
applyAnnotations(Arrays.asList(description.getTestClass().getAnnotations()), settings);
|
||||
applyAnnotations(description.getAnnotations(), settings);
|
||||
|
@ -1164,10 +1165,6 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
|||
ignore = mCallRecordHandler.handleCall(method, args);
|
||||
}
|
||||
|
||||
if (!mIgnoreCrash && sOnCrash.equals(method)) {
|
||||
throw new RuntimeException("Content process crashed");
|
||||
}
|
||||
|
||||
final boolean isExternalDelegate =
|
||||
!DEFAULT_DELEGATES.contains(method.getDeclaringClass());
|
||||
|
||||
|
@ -1185,6 +1182,11 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
|||
args[0], instanceOf(GeckoSession.class));
|
||||
session = (GeckoSession) args[0];
|
||||
}
|
||||
|
||||
if (sOnCrash.equals(method) && !mIgnoreCrash && isUsingSession(session)) {
|
||||
throw new RuntimeException("Content process crashed");
|
||||
}
|
||||
|
||||
records.add(new CallRecord(session, method, args));
|
||||
|
||||
call = waitDelegates.prepareMethodCall(session, method);
|
||||
|
@ -1249,6 +1251,10 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
|||
runtimeSettingsBuilder.build());
|
||||
}
|
||||
|
||||
if (sCachedSession != null && !sCachedSession.isOpen()) {
|
||||
sCachedSession = null;
|
||||
}
|
||||
|
||||
final boolean useDefaultSession = !mClosedSession && mDefaultSettings.equals(settings);
|
||||
if (useDefaultSession && mReuseSession && sCachedSession != null) {
|
||||
mMainSession = sCachedSession;
|
||||
|
@ -1364,8 +1370,11 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
|||
protected void cleanupSession(final GeckoSession session) {
|
||||
final Tab tab = (mRDPTabs != null) ? mRDPTabs.get(session) : null;
|
||||
if (tab != null) {
|
||||
tab.getPromises().detach();
|
||||
tab.detach();
|
||||
if (session.isOpen()) {
|
||||
tab.getPromises().detach();
|
||||
tab.detach();
|
||||
}
|
||||
|
||||
mRDPTabs.remove(session);
|
||||
}
|
||||
if (session.isOpen()) {
|
||||
|
@ -1373,6 +1382,10 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean isUsingSession(final GeckoSession session) {
|
||||
return session.equals(mMainSession) || mSubSessions.contains(session);
|
||||
}
|
||||
|
||||
protected void cleanupStatement() throws Throwable {
|
||||
mWaitScopeDelegates.clear();
|
||||
mTestScopeDelegates.clear();
|
||||
|
@ -1380,7 +1393,12 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
|||
for (final GeckoSession session : mSubSessions) {
|
||||
cleanupSession(session);
|
||||
}
|
||||
if (mMainSession.equals(sCachedSession)) {
|
||||
|
||||
if (sCachedSession != null && mReuseSession && !mIgnoreCrash) {
|
||||
assertThat("Cached session should be open", sCachedSession.isOpen(), equalTo(true));
|
||||
}
|
||||
|
||||
if (mMainSession.isOpen() && mMainSession.equals(sCachedSession)) {
|
||||
// We have to detach the Promises object, but keep the Tab itself.
|
||||
sCachedRDPTab.getPromises().detach();
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче