Bug 1469683 - 3. Make sure cached session is closed after crash; r=esawin
authorJim Chen <nchen@mozilla.com>
Wed, 20 Jun 2018 16:46:21 -0400
changeset 423132 c9487350a119359a14bce87083e34930ba6258df
parent 423131 13ff68c7707d414ea98096933b322025a75ad871
child 423133 5cc046f4654100da7d01a0e44aa069331860f784
push id65366
push usernchen@mozilla.com
push dateWed, 20 Jun 2018 20:50:25 +0000
treeherderautoland@c9487350a119 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1469683
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1469683 - 3. Make sure cached session is closed after crash; r=esawin If @IgnoreCrash is specified, assume there has been a crash and therefore wait for the cached session to close at the end of the test, so that the closing operation doesn't carry over to the next test. MozReview-Commit-ID: KrMfHgIiELQ
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
--- 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
@@ -1396,18 +1396,30 @@ public class GeckoSessionTestRule extend
             mCallRecordHandler = null;
         }
     }
 
     /**
      * Internal method to perform callback checks at the end of a test.
      */
     public void performTestEndCheck() {
+        if (sCachedSession != null && mIgnoreCrash) {
+            // Make sure the cached session has been closed by crashes.
+            while (sCachedSession.isOpen()) {
+                loopUntilIdle(mTimeoutMillis);
+            }
+        }
+
         mWaitScopeDelegates.clearAndAssert();
         mTestScopeDelegates.clearAndAssert();
+
+        if (sCachedSession != null && mReuseSession) {
+            assertThat("Cached session should be open",
+                       sCachedSession.isOpen(), equalTo(true));
+        }
     }
 
     protected void cleanupSession(final GeckoSession session) {
         final Tab tab = (mRDPTabs != null) ? mRDPTabs.get(session) : null;
         if (tab != null) {
             if (session.isOpen()) {
                 tab.getPromises().detach();
                 tab.detach();
@@ -1419,35 +1431,31 @@ public class GeckoSessionTestRule extend
             session.close();
         }
     }
 
     protected boolean isUsingSession(final GeckoSession session) {
         return session.equals(mMainSession) || mSubSessions.contains(session);
     }
 
-    protected void deleteCrashDumps() {
+    protected static void deleteCrashDumps() {
         File dumpDir = new File(sRuntime.getProfileDir(), "minidumps");
         for (final File dump : dumpDir.listFiles()) {
             dump.delete();
         }
     }
 
     protected void cleanupStatement() throws Throwable {
         mWaitScopeDelegates.clear();
         mTestScopeDelegates.clear();
 
         for (final GeckoSession session : mSubSessions) {
             cleanupSession(session);
         }
 
-        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 {
             cleanupSession(mMainSession);
         }
 
         if (mIgnoreCrash) {