Bug 1152761 - Fix intermittent failure fixes in test_looprooms.js. Ensure we wait for all conditions to complete before moving on. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Wed, 06 May 2015 12:47:14 +0100
changeset 273934 5cffb3b5b2fbc663a7e2fd75bee25449bc3f5e67
parent 273933 08e566362fc9c84e76c2586a7e843851330aade4
child 273935 1e6108d642bfb2092c60c94a52623765f73d31ab
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1152761
milestone40.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 1152761 - Fix intermittent failure fixes in test_looprooms.js. Ensure we wait for all conditions to complete before moving on. r=mikedeboer
browser/components/loop/test/xpcshell/test_looprooms.js
--- a/browser/components/loop/test/xpcshell/test_looprooms.js
+++ b/browser/components/loop/test/xpcshell/test_looprooms.js
@@ -458,57 +458,63 @@ add_task(function* test_refresh() {
 // Test if push updates function as expected.
 add_task(function* test_roomUpdates() {
   gExpectedUpdates.push("_nxD4V4FflQ");
   gExpectedLeaves["_nxD4V4FflQ"] = [
     "2a1787a6-4a73-43b5-ae3e-906ec1e763cb",
     "781f012b-f1ea-4ce1-9105-7cfc36fb4ec7"
   ];
   roomsPushNotification("1", kChannelGuest);
-  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedLeaves).length === 0);
+  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedLeaves).length === 0 &&
+    gExpectedUpdates.length === 0);
 
   gExpectedUpdates.push("_nxD4V4FflQ");
   gExpectedJoins["_nxD4V4FflQ"] = ["2a1787a6-4a73-43b5-ae3e-906ec1e763cb"];
   roomsPushNotification("2", kChannelGuest);
-  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedJoins).length === 0);
+  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedJoins).length === 0 &&
+    gExpectedUpdates.length === 0);
 
   gExpectedUpdates.push("_nxD4V4FflQ");
   gExpectedJoins["_nxD4V4FflQ"] = ["781f012b-f1ea-4ce1-9105-7cfc36fb4ec7"];
   gExpectedLeaves["_nxD4V4FflQ"] = ["2a1787a6-4a73-43b5-ae3e-906ec1e763cb"];
   roomsPushNotification("3", kChannelGuest);
-  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedLeaves).length === 0);
+  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedLeaves).length === 0 &&
+    Object.getOwnPropertyNames(gExpectedJoins).length === 0 &&
+    gExpectedUpdates.length === 0);
 
   gExpectedUpdates.push("_nxD4V4FflQ");
   gExpectedJoins["_nxD4V4FflQ"] = [
     "2a1787a6-4a73-43b5-ae3e-906ec1e763cb",
     "5de6281c-6568-455f-af08-c0b0a973100e"];
   roomsPushNotification("4", kChannelGuest);
-  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedJoins).length === 0);
+  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedJoins).length === 0 &&
+    gExpectedUpdates.length === 0);
 });
 
 // Test if push updates' channelIDs are respected.
-add_task(function* () {
+add_task(function* test_channelIdsRespected() {
   function badRoomJoin() {
     Assert.ok(false, "Unexpected 'joined' event emitted!");
   }
-  LoopRooms.on("join", onRoomLeft);
+  LoopRooms.on("join", badRoomJoin);
   roomsPushNotification("4", kChannelFxA);
   LoopRooms.off("join", badRoomJoin);
 
   // Set the userProfile to look like we're logged into FxA.
   MozLoopServiceInternal.fxAOAuthTokenData = { token_type: "bearer" };
   MozLoopServiceInternal.fxAOAuthProfile = { email: "fake@invalid.com" };
 
   gExpectedUpdates.push("_nxD4V4FflQ");
   gExpectedLeaves["_nxD4V4FflQ"] = [
     "2a1787a6-4a73-43b5-ae3e-906ec1e763cb",
     "5de6281c-6568-455f-af08-c0b0a973100e"
   ];
   roomsPushNotification("3", kChannelFxA);
-  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedLeaves).length === 0);
+  yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedLeaves).length === 0 &&
+    gExpectedUpdates.length === 0);
 });
 
 // Test if joining a room as Guest works as expected.
 add_task(function* test_joinRoomGuest() {
   MozLoopServiceInternal.fxAOAuthTokenData = null;
   MozLoopServiceInternal.fxAOAuthProfile = null;
 
   let roomToken = "_nxD4V4FflQ";