diff options
| author | Igor Minar | 2014-01-04 23:42:44 -0800 | 
|---|---|---|
| committer | Igor Minar | 2014-01-10 02:25:36 -0800 | 
| commit | a9cccbe14f1bd9048f5dab4443f58c804d4259a1 (patch) | |
| tree | b86682b041de5051fa2a1a354d1685e72d8a483e /test/ng/httpBackendSpec.js | |
| parent | 36c9e42de2d78af39600c588b06f2a52199ee8b6 (diff) | |
| download | angular.js-a9cccbe14f1bd9048f5dab4443f58c804d4259a1.tar.bz2 | |
fix($http): return responseText on IE8 for requests with responseType set
Closes #4464
Closes #4738
Closes #5636
Diffstat (limited to 'test/ng/httpBackendSpec.js')
| -rw-r--r-- | test/ng/httpBackendSpec.js | 44 | 
1 files changed, 34 insertions, 10 deletions
| diff --git a/test/ng/httpBackendSpec.js b/test/ng/httpBackendSpec.js index 92781f9a..2a3f6012 100644 --- a/test/ng/httpBackendSpec.js +++ b/test/ng/httpBackendSpec.js @@ -264,21 +264,45 @@ describe('$httpBackend', function() {    }); -  it('should set responseType and return xhr.response', function() { -    $backend('GET', '/whatever', null, callback, {}, null, null, 'blob'); +  describe('responseType', function() { -    var xhrInstance = MockXhr.$$lastInstance; -    expect(xhrInstance.responseType).toBe('blob'); +    it('should set responseType and return xhr.response', function() { +      $backend('GET', '/whatever', null, callback, {}, null, null, 'blob'); -    callback.andCallFake(function(status, response) { -      expect(response).toBe(xhrInstance.response); +      var xhrInstance = MockXhr.$$lastInstance; +      expect(xhrInstance.responseType).toBe('blob'); + +      callback.andCallFake(function(status, response) { +        expect(response).toBe(xhrInstance.response); +      }); + +      xhrInstance.response = {some: 'object'}; +      xhrInstance.readyState = 4; +      xhrInstance.onreadystatechange(); + +      expect(callback).toHaveBeenCalledOnce();      }); -    xhrInstance.response = {some: 'object'}; -    xhrInstance.readyState = 4; -    xhrInstance.onreadystatechange(); -    expect(callback).toHaveBeenCalledOnce(); +    it('should read responseText if response was not defined', function() { +      //  old browsers like IE8, don't support responseType, so they always respond with responseText + +      $backend('GET', '/whatever', null, callback, {}, null, null, 'blob'); + +      var xhrInstance = MockXhr.$$lastInstance; +      var responseText = '{"some": "object"}'; +      expect(xhrInstance.responseType).toBe('blob'); + +      callback.andCallFake(function(status, response) { +        expect(response).toBe(responseText); +      }); + +      xhrInstance.responseText = responseText; +      xhrInstance.readyState = 4; +      xhrInstance.onreadystatechange(); + +      expect(callback).toHaveBeenCalledOnce(); +    });    }); | 
