diff options
| author | Gonzalo Ruiz de Villa | 2013-11-13 21:24:15 +0100 | 
|---|---|---|
| committer | Igor Minar | 2013-11-21 23:09:46 -0800 | 
| commit | 6f1050df4fa885bd59ce85adbef7350ea93911a3 (patch) | |
| tree | 57b2dcbfe7575bbd659384fb777a3f23f5e3c61b /test/ng | |
| parent | 4d16472b918a3482942d76f1e273a5aa01f65e83 (diff) | |
| download | angular.js-6f1050df4fa885bd59ce85adbef7350ea93911a3.tar.bz2 | |
fix(httpBackend): should not read response data when request is aborted
When a request is aborted, it makes no sense to read the response headers or text.
Also in IE9, trying to read data (either response headers or text) from an aborted request
throws an Error c00c023f.
Fixes #4913
Closes #4940
Diffstat (limited to 'test/ng')
| -rw-r--r-- | test/ng/httpBackendSpec.js | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/test/ng/httpBackendSpec.js b/test/ng/httpBackendSpec.js index b262d8a2..cc73ea8e 100644 --- a/test/ng/httpBackendSpec.js +++ b/test/ng/httpBackendSpec.js @@ -118,6 +118,25 @@ describe('$httpBackend', function() {      });    }); +  it('should not try to read response data when request is aborted', function() { +    callback.andCallFake(function(status, response, headers) { +      expect(status).toBe(-1); +      expect(response).toBe(null); +      expect(headers).toBe(null); +    }); +    $backend('GET', '/url', null, callback, {}, 2000); +    xhr = MockXhr.$$lastInstance; +    spyOn(xhr, 'abort'); + +    fakeTimeout.flush(); +    expect(xhr.abort).toHaveBeenCalledOnce(); + +    xhr.status = 0; +    xhr.readyState = 4; +    xhr.onreadystatechange(); +    expect(callback).toHaveBeenCalledOnce(); +  }); +    it('should abort request on timeout', function() {      callback.andCallFake(function(status, response) {        expect(status).toBe(-1); | 
