Bug 773161 - Intermittent browser_gcli_addon.js | Test timed out. r=jwalker

This commit is contained in:
Michael Ratcliffe 2012-09-04 12:43:58 +01:00
Родитель 1ced5033ce
Коммит 5a63936a11
2 изменённых файлов: 22 добавлений и 1 удалений

Просмотреть файл

@ -4,7 +4,7 @@
const { classes: Cc, interfaces: Ci, utils: Cu } = Components; const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
let EXPORTED_SYMBOLS = [ ]; let EXPORTED_SYMBOLS = [ "Flags" ];
Cu.import("resource:///modules/devtools/gcli.jsm"); Cu.import("resource:///modules/devtools/gcli.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@ -13,6 +13,12 @@ Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm"); "resource://gre/modules/AddonManager.jsm");
// We need to use an object in which to store any flags because a primitive
// would remain undefined.
let Flags = {
addonsLoaded: false
};
/** /**
* 'addon' command. * 'addon' command.
*/ */
@ -286,5 +292,6 @@ AddonManager.getAllAddons(function addonAsync(aAddons) {
return promise; return promise;
} }
}); });
Flags.addonsLoaded = true;
Services.obs.notifyObservers(null, "gcli_addon_commands_ready", null); Services.obs.notifyObservers(null, "gcli_addon_commands_ready", null);
}); });

Просмотреть файл

@ -3,6 +3,9 @@
// Tests that the addon commands works as they should // Tests that the addon commands works as they should
let imported = {};
Components.utils.import("resource:///modules/devtools/CmdAddon.jsm", imported);
function test() { function test() {
DeveloperToolbarTest.test("about:blank", [ GAT_test ]); DeveloperToolbarTest.test("about:blank", [ GAT_test ]);
} }
@ -10,6 +13,7 @@ function test() {
function GAT_test() { function GAT_test() {
var GAT_ready = DeveloperToolbarTest.checkCalled(function() { var GAT_ready = DeveloperToolbarTest.checkCalled(function() {
Services.obs.removeObserver(GAT_ready, "gcli_addon_commands_ready", false); Services.obs.removeObserver(GAT_ready, "gcli_addon_commands_ready", false);
info("gcli_addon_commands_ready notification received, running tests");
helpers.setInput('addon list dictionary'); helpers.setInput('addon list dictionary');
helpers.check({ helpers.check({
@ -91,4 +95,14 @@ function GAT_test() {
}); });
Services.obs.addObserver(GAT_ready, "gcli_addon_commands_ready", false); Services.obs.addObserver(GAT_ready, "gcli_addon_commands_ready", false);
if (imported.Flags.addonsLoaded) {
info("The getAllAddons command has already completed and we have missed ");
info("the notification. Let's send the gcli_addon_commands_ready ");
info("notification ourselves.");
Services.obs.notifyObservers(null, "gcli_addon_commands_ready", null);
} else {
info("gcli_addon_commands_ready notification has not yet been received.");
}
} }