timeoutTimer = setTimeout(function(){ aborted=true//IE9 may still call readystatechange xhr.abort("timeout") var e = new Error("XMLHttpRequest timeout") e.code = "ETIMEDOUT" errorFunc(e) }, options.timeout )
it('should be able to abort xhr when calling end w/ callback', function (done) { var operation = 'create'; var xhr = this.fetcher [operation](resource) .params(params) .body(body) .clientConfig(config) .end(callback(operation, function (err) { if (err) { // in this case, an error is good // we want the error to be thrown then request is aborted done(); } })); expect(xhr.abort).to.exist; xhr.abort(); });
timeoutTimer = setTimeout(function(){ xhr.abort("timeout"); }, options.timeout+2 );