Bug 1161537 - Intermittent test_dev_mode_activity.html | Got error: undefined - expected PASS. a=lizzard
authorFabrice Desré <fabrice@mozilla.com>
Fri, 15 May 2015 14:46:27 -0700
changeset 274689 2d4cc42757490e9da63609b2c645a5e9693727d1
parent 274688 5875bfb6ae2e1d066c5bc1bad6ec9b1731f67c90
child 274690 427f3b03a66243ed93628d1119834701322566ff
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)
reviewerslizzard
bugs1161537
milestone40.0a2
Bug 1161537 - Intermittent test_dev_mode_activity.html | Got error: undefined - expected PASS. a=lizzard
dom/activities/ActivitiesService.jsm
dom/activities/tests/mochi/test_dev_mode_activity.html
--- a/dom/activities/ActivitiesService.jsm
+++ b/dom/activities/ActivitiesService.jsm
@@ -422,23 +422,26 @@ let Activities = {
       case "Activity:PostResult":
         this.trySendAndCleanup(msg.id, "Activity:FireSuccess", msg);
         break;
       case "Activity:PostError":
         this.trySendAndCleanup(msg.id, "Activity:FireError", msg);
         break;
 
       case "Activities:Register":
-        let self = this;
         this.db.add(msg,
           function onSuccess(aEvent) {
+            debug("Activities:Register:OK");
+            Services.obs.notifyObservers(null, "new-activity-registered-success", null);
             mm.sendAsyncMessage("Activities:Register:OK", null);
           },
           function onError(aEvent) {
             msg.error = "REGISTER_ERROR";
+            debug("Activities:Register:KO");
+            Services.obs.notifyObservers(null, "new-activity-registered-failure", null);
             mm.sendAsyncMessage("Activities:Register:KO", msg);
           });
         break;
       case "Activities:Unregister":
         this.db.remove(msg);
         break;
       case "Activities:UnregisterAll":
         this.db.removeAll(msg);
--- a/dom/activities/tests/mochi/test_dev_mode_activity.html
+++ b/dom/activities/tests/mochi/test_dev_mode_activity.html
@@ -179,18 +179,24 @@ function finish() {
 function continueTest() {
   try {
     gGenerator.next();
   } catch (e if e instanceof StopIteration) {
     finish();
   }
 }
 
+var obsService = Cc["@mozilla.org/observer-service;1"]
+                   .getService(Ci.nsIObserverService);
+
+obsService.addObserver(continueTest, "new-activity-registered-success", false);
+obsService.addObserver(continueTest, "new-activity-registered-failure", false);
+
 /**
-  * Test exporting and importing hosted and packaged apps.
+  * Test dev mode activity.
   */
 function runTest() {
   SpecialPowers.setAllAppsLaunchable(true);
 
   SpecialPowers.autoConfirmAppInstall(continueTest);
   yield undefined;
 
   SpecialPowers.autoConfirmAppUninstall(continueTest);
@@ -222,51 +228,57 @@ function runTest() {
   yield undefined;
 
   // Install the system app.
   request = installSystemApp();
   yield undefined;
   var systemApp = request.result;
   ok(systemApp, "systemApp is non-null");
 
+  // yielding for the activity install observer.
+  yield undefined;
+
   activity = new MozActivity({ name: "import-app" });
   activity.onerror = function() {
     ok(true, "2) No dev mode, system app installed");
     continueTest();
   }
   activity.onsuccess = unexpectedSuccess("2) No dev mode, system app installed");
   yield undefined;
 
   // 3) No dev mode, system app and other app installed (failure).
   request = installOtherApp();
   yield undefined;
   var otherApp = request.result;
   ok(otherApp, "otherApp is non-null");
 
+  // yielding for the activity install observer.
+  yield undefined;
+
   activity = new MozActivity({ name: "import-app" });
   activity.onerror = function() {
     ok(true, "3) No dev mode, system app and other app installed");
     continueTest();
   }
   activity.onsuccess = unexpectedSuccess("3) No dev mode, system app and other app installed");
   yield undefined;
 
-  // 4) Dev mode, no system app installed.
+  // 4) Dev mode, system app and other app installed.
   SpecialPowers.pushPrefEnv(
         {'set': [["dom.apps.developer_mode", true]]},
         continueTest);
   yield undefined;
 
   activity = new MozActivity({ name: "import-app" });
   activity.onsuccess = function() {
     ok(true, "4) Dev mode, system app and other app installed");
     continueTest();
   }
-  activity.onerror = function(aError) {
-    ok(false, "Got error: " + aError.name);
+  activity.onerror = function(aEvent) {
+    ok(false, "4) Got error: " + aEvent.error.name);
     finish();
   }
   yield undefined;
 
   // Cleanup
   uninstall(systemApp);
   yield undefined;