From f316078c34865f277207bf8cab9b39be767df959 Mon Sep 17 00:00:00 2001 From: Felipe Gomes Date: Tue, 24 Sep 2013 01:57:08 -0300 Subject: [PATCH] Bug 900954 - Make some tests in test_AddonRepository_cache.js wait for data flushed to disk instead of the update-complete notification. r=bmcbride --- .../xpcshell/test_AddonRepository_cache.js | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js index 600f3d81b3f0..5202c5d0d16d 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js @@ -406,18 +406,8 @@ const WITH_EXTENSION_CACHE = [{ /* * Trigger an AddonManager background update check - * - * @param aCallback - * Callback to call once the background update is complete */ -function trigger_background_update(aCallback) { - Services.obs.addObserver({ - observe: function(aSubject, aTopic, aData) { - Services.obs.removeObserver(this, "addons-background-update-complete"); - do_execute_soon(aCallback); - } - }, "addons-background-update-complete", false); - +function trigger_background_update() { gInternalManager.notify(null); } @@ -707,15 +697,21 @@ function run_test_13() { check_database_exists(true); Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERF, GETADDONS_EMPTY); - trigger_background_update(function() { - // Database should have been deleted - check_database_exists(false); + Services.obs.addObserver({ + observe: function(aSubject, aTopic, aData) { + Services.obs.removeObserver(this, "addons-background-update-complete"); - AddonManager.getAddonsByIDs(ADDON_IDS, function(aAddons) { - check_results(aAddons, WITHOUT_CACHE); - do_execute_soon(run_test_14); - }); - }); + // Database should have been deleted with the background update. + check_database_exists(false); + + AddonManager.getAddonsByIDs(ADDON_IDS, function(aAddons) { + check_results(aAddons, WITHOUT_CACHE); + do_execute_soon(run_test_14); + }); + } + }, "addons-background-update-complete", false); + + trigger_background_update(); } // Tests that the XPI add-ons have the correct properties if caching is @@ -740,12 +736,14 @@ function run_test_14() { function run_test_15() { Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERF, GETADDONS_RESULTS); - trigger_background_update(function() { + waitForFlushedData(function() { AddonManager.getAddonsByIDs(ADDON_IDS, function(aAddons) { check_results(aAddons, WITH_CACHE); do_execute_soon(run_test_16); }); }); + + trigger_background_update(); } // Tests that restarting the manager does not change the checked properties @@ -764,11 +762,13 @@ function run_test_16() { function run_test_17() { Services.prefs.setCharPref(PREF_GETADDONS_CACHE_TYPES, "foo,bar,extension,baz"); - trigger_background_update(function() { + waitForFlushedData(function() { AddonManager.getAddonsByIDs(ADDON_IDS, function(aAddons) { check_results(aAddons, WITH_EXTENSION_CACHE); end_test(); }); }); + + trigger_background_update(); }