cjohansen/Sinon.JS — pull request #160 by jankopriva (2012-07-16 08:44:05+00:00)
Title: sinon.js can catch itself in endless loop while filling stub prototype with asynch methods

Browser can loop endlessly due to this code:

// create asynchronous versions of callsArg* and yields* methods
for (var method in proto) {
if (proto.hasOwnProperty(method) && method.match(/^(callsArg|yields)/) {
proto[method + 'Async'] = (function (syncFnName) {
return function () {
this.callbackAsync = true;
return this[syncFnName].apply(this, arguments);
};
})(method);
}
}

Here, a new method with name 'methodAsync' is added to the prototype every time a good match is found, causing the for loop to loop forever.