Bug 1142734 - Using Timer.jsm and adding some logs to jetpack-addon-harness.js r=mossop

This commit is contained in:
Erik Vold 2015-06-06 19:21:15 -07:00
parent 495f9a5f98
commit c82545f26f

View File

@ -9,6 +9,7 @@ if (Cc === undefined) {
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/Timer.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
@ -74,10 +75,18 @@ function installAddon(url) {
resolve(addon);
},
onDownloadCancelled: function(install) {
reject("Download cancelled: " + install.error);
},
onDownloadFailed: function(install) {
reject("Download failed: " + install.error);
},
onInstallCancelled: function(install) {
reject("Install cancelled: " + install.error);
},
onInstallFailed: function(install) {
reject("Install failed: " + install.error);
}
@ -96,10 +105,11 @@ function uninstallAddon(oldAddon) {
if (addon.id != oldAddon.id)
return;
dump("TEST-INFO | jetpack-addon-harness.js | Uninstalled test add-on " + addon.id + "\n");
// Some add-ons do async work on uninstall, we must wait for that to
// complete
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.init(resolve, 500, timer.TYPE_ONE_SHOT);
setTimeout(resolve, 500);
}
});
@ -119,13 +129,13 @@ function waitForResults() {
}
// Runs tests for the add-on available at URL.
let testAddon = Task.async(function*({ url, expected }) {
let testAddon = Task.async(function*({ url }) {
dump("TEST-INFO | jetpack-addon-harness.js | Installing test add-on " + realPath(url) + "\n");
let addon = yield installAddon(url);
let results = yield waitForResults();
dump("TEST-INFO | jetpack-addon-harness.js | Uninstalling test add-on " + realPath(url) + "\n");
dump("TEST-INFO | jetpack-addon-harness.js | Uninstalling test add-on " + addon.id + "\n");
yield uninstallAddon(addon);
dump("TEST-INFO | jetpack-addon-harness.js | Testing add-on " + realPath(url) + " is complete\n");
@ -197,6 +207,8 @@ function testInit() {
}
if (config.closeWhenDone) {
dump("TEST-INFO | jetpack-addon-harness.js | Shutting down.\n");
const appStartup = Cc['@mozilla.org/toolkit/app-startup;1'].
getService(Ci.nsIAppStartup);
appStartup.quit(appStartup.eAttemptQuit);
@ -208,6 +220,7 @@ function testInit() {
return finish();
let filename = fileNames.shift();
dump("TEST-INFO | jetpack-addon-harness.js | Starting test add-on " + realPath(filename.url) + "\n");
testAddon(filename).then(results => {
passed += results.passed;
failed += results.failed;