Test case details

Preparation Code

<script>   if (!Function.prototype.bind) {     Function.prototype.bind = function(context) {       var fn = this;       return function() {         return fn.apply(context, arguments);       }     }   }   var obj = {     c: function() {       return Math.sin(1);     }   }   obj.closure = function(cb) {     var that = this;     setTimeout(function() {       that.c();       cb();     }, 0);   }   obj.bind = function(cb) {     setTimeout((function() {       this.c();       cb();     }).bind(this), 0);   }   obj.cached = (function(cb) {     var f = (function(cb) {       this.c();       cb();     }).bind(obj);     return function(cb) {       setTimeout(f, 0, cb);     }   })(); </script>

Test cases

Test #1

// async test obj.closure(function() {   deferred.resolve(); });

Test #2

// async test obj.bind(function() {   deferred.resolve(); });

Test #3

// async test obj.cached(function() {   deferred.resolve(); })