Bug 1078153 - capture the callback in a generated function object to prevent it becomes dead during GC. r=khuey

This commit is contained in:
JW Wang 2014-10-27 01:31:00 +01:00
parent 3426bbc46f
commit 4b2793e9b0

View File

@ -1400,21 +1400,18 @@ SpecialPowersAPI.prototype = {
var self = this;
let count = 0;
function doPreciseGCandCC() {
function scheduledGCCallback() {
function genGCCallback(cb) {
return function() {
self.getDOMWindowUtils(win).cycleCollect();
if (++count < 2) {
doPreciseGCandCC();
Cu.schedulePreciseGC(genGCCallback(cb));
} else {
callback();
cb();
}
}
Cu.schedulePreciseGC(scheduledGCCallback);
}
doPreciseGCandCC();
Cu.schedulePreciseGC(genGCCallback(callback));
},
setGCZeal: function(zeal) {