Bug 738554 - Fix a couple of race conditions where we could start listening for events after they occur. r=mfinkle
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 23 Mar 2012 11:43:10 -0400
changeset 92020 932cf6043b9b1f792ee7003c006eb15ecb8cf7e7
parent 92019 b0fa8e8ffbc0bc9e6c2e9b0e3b3aa22f9f3c529b
child 92021 882fc7645a590e1bbfcb6f2e32e492de482889e9
push idunknown
push userunknown
push dateunknown
reviewersmfinkle
bugs738554
milestone13.0a2
Bug 738554 - Fix a couple of race conditions where we could start listening for events after they occur. r=mfinkle
mobile/android/base/tests/testAboutPage.java.in
mobile/android/base/tests/testBookmark.java.in
--- a/mobile/android/base/tests/testAboutPage.java.in
+++ b/mobile/android/base/tests/testAboutPage.java.in
@@ -27,21 +27,25 @@ public class testAboutPage extends BaseT
         // Look for the 'More' menu if this device/OS uses it
         if (mSolo.waitForText("^More$")) {
             mSolo.clickOnText("^More$");
         }
 
         mSolo.waitForText("^Settings$");
         mSolo.clickOnText("^Settings$");
 
+        // Set up listeners to catch the page load we're about to do
+        Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
+        Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
+
         // Tap on the "About Xxxx" setting
         mSolo.waitForText("About (Fennec|Nightly|Aurora|Firefox)");
         mSolo.clickOnText("About (Fennec|Nightly|Aurora|Firefox)");
 
         // Wait for the new tab and page to load
-        mActions.expectGeckoEvent("Tab:Added").blockForEvent();
-        mActions.expectGeckoEvent("DOMContentLoaded").blockForEvent();
+        tabEventExpecter.blockForEvent();
+        contentEventExpecter.blockForEvent();
 
         // Grab the title to make sure the about: page was loaded
         awesomebar = mDriver.findElement(getActivity(), "awesome_bar");
         mAsserter.ok(awesomebar.getText().matches("About (Fennec|Nightly|Aurora|Firefox)"), "page title match", "about: page title is correct");
     }
 }
--- a/mobile/android/base/tests/testBookmark.java.in
+++ b/mobile/android/base/tests/testBookmark.java.in
@@ -28,20 +28,20 @@ public class testBookmark extends BaseTe
 
         mAsserter.ok(bookmarksList != null, "checking that bookmarks list exists", "bookmarks list exists");
 
         // No folders should be visible if no desktop bookmarks exist
         mAsserter.is(bookmarksList.getChildCount(), 2,
             "bookmarks list has 2 children (the bookmark we added and the hidden header)");
 
         // Click on the bookmark we created (the first item is the header view)
+        // and wait for the bookmarked page to load
+        Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
         mSolo.clickInList(2);
-
-        // Wait for the bookmarked page to load
-        mActions.expectGeckoEvent("DOMContentLoaded").blockForEvent();
+        contentEventExpecter.blockForEvent();
 
         // Clean up the bookmark we created
         cleanUpBookmark();
     }
 
     private ListView openBookmarksList() {
         Activity awesomeBarActivity = clickOnAwesomeBar();