mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 22:05:44 +00:00
Bug 665780 - "Racy code in background_update of test_blocklistchange.js". r=rs
--HG-- extra : rebase_source : f2062288a65527eb0605f94f38e731306b807f53
This commit is contained in:
parent
bf73757e39
commit
aff5447fec
@ -363,6 +363,7 @@ function load_blocklist(aFile, aCallback) {
|
|||||||
// to complete
|
// to complete
|
||||||
function background_update(aCallback) {
|
function background_update(aCallback) {
|
||||||
var installCount = 0;
|
var installCount = 0;
|
||||||
|
var backgroundCheckCompleted = false;
|
||||||
|
|
||||||
AddonManager.addInstallListener({
|
AddonManager.addInstallListener({
|
||||||
onNewInstall: function(aInstall) {
|
onNewInstall: function(aInstall) {
|
||||||
@ -371,20 +372,31 @@ function background_update(aCallback) {
|
|||||||
|
|
||||||
onInstallEnded: function(aInstall) {
|
onInstallEnded: function(aInstall) {
|
||||||
installCount--;
|
installCount--;
|
||||||
|
// Wait until all started installs have completed
|
||||||
if (installCount)
|
if (installCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AddonManager.removeInstallListener(this);
|
AddonManager.removeInstallListener(this);
|
||||||
|
|
||||||
|
// If the background check hasn't yet completed then let that call the
|
||||||
|
// callback when it is done
|
||||||
|
if (!backgroundCheckCompleted)
|
||||||
|
return;
|
||||||
|
|
||||||
do_execute_soon(aCallback);
|
do_execute_soon(aCallback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Services.obs.addObserver(function() {
|
Services.obs.addObserver(function() {
|
||||||
Services.obs.removeObserver(arguments.callee, "addons-background-update-complete");
|
Services.obs.removeObserver(arguments.callee, "addons-background-update-complete");
|
||||||
|
backgroundCheckCompleted = true;
|
||||||
|
|
||||||
if (!installCount)
|
// If any new installs have started then we'll call the callback once they
|
||||||
do_execute_soon(aCallback);
|
// are completed
|
||||||
|
if (installCount)
|
||||||
|
return;
|
||||||
|
|
||||||
|
do_execute_soon(aCallback);
|
||||||
}, "addons-background-update-complete", false);
|
}, "addons-background-update-complete", false);
|
||||||
|
|
||||||
AddonManagerPrivate.backgroundUpdateCheck();
|
AddonManagerPrivate.backgroundUpdateCheck();
|
||||||
|
Loading…
Reference in New Issue
Block a user