Don't allow calling the same done callback multiple times

[finishes #62585700][fixes #523]
This commit is contained in:
Greg Cobb and Sheel Choksi
2014-02-25 18:03:52 -08:00
parent 5aac3e3292
commit 640f94a1bd
3 changed files with 50 additions and 4 deletions

View File

@@ -1,5 +1,15 @@
getJasmineRequireObj().QueueRunner = function(j$) {
function once(fn) {
var called = false;
return function() {
if (!called) {
called = true;
fn();
}
};
}
function QueueRunner(attrs) {
this.fns = attrs.fns || [];
this.onComplete = attrs.onComplete || function() {};
@@ -47,10 +57,10 @@ getJasmineRequireObj().QueueRunner = function(j$) {
var clearTimeout = function () {
Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeoutId]]);
},
next = function () {
next = once(function () {
clearTimeout(timeoutId);
self.run(fns, iterativeIndex + 1);
},
}),
timeoutId;
if (self.enforceTimeout()) {