mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +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
|
||||
function background_update(aCallback) {
|
||||
var installCount = 0;
|
||||
var backgroundCheckCompleted = false;
|
||||
|
||||
AddonManager.addInstallListener({
|
||||
onNewInstall: function(aInstall) {
|
||||
@ -371,19 +372,30 @@ function background_update(aCallback) {
|
||||
|
||||
onInstallEnded: function(aInstall) {
|
||||
installCount--;
|
||||
// Wait until all started installs have completed
|
||||
if (installCount)
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
Services.obs.addObserver(function() {
|
||||
Services.obs.removeObserver(arguments.callee, "addons-background-update-complete");
|
||||
backgroundCheckCompleted = true;
|
||||
|
||||
// If any new installs have started then we'll call the callback once they
|
||||
// are completed
|
||||
if (installCount)
|
||||
return;
|
||||
|
||||
if (!installCount)
|
||||
do_execute_soon(aCallback);
|
||||
}, "addons-background-update-complete", false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user