Bug 1161537 - Intermittent test_dev_mode_activity.html | Got error: undefined - expected PASS. a=lizzard
--- 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;