diff options
| author | Tobias Bosch | 2014-01-02 14:37:48 -0800 | 
|---|---|---|
| committer | Tobias Bosch | 2014-01-02 14:37:48 -0800 | 
| commit | 4f57236614415eea919221ea5f99c4d8689b3267 (patch) | |
| tree | 558b8feae310f5bcb72b84ad57e45db9c82e48a2 /test/ng/httpBackendSpec.js | |
| parent | 50bf029625d603fc652f0f413e709f43803743db (diff) | |
| download | angular.js-4f57236614415eea919221ea5f99c4d8689b3267.tar.bz2 | |
fix($httpBackend): Ignore multiple calls to onreadystatechange with readyState=4
On mobile webkit `onreadystatechange` might by called multiple times
with `readyState===4`  caused by xhrs that are resolved while the app is
in the background.
 Fixes #5426.
Diffstat (limited to 'test/ng/httpBackendSpec.js')
| -rw-r--r-- | test/ng/httpBackendSpec.js | 12 | 
1 files changed, 12 insertions, 0 deletions
| diff --git a/test/ng/httpBackendSpec.js b/test/ng/httpBackendSpec.js index 8c843d2a..5a392538 100644 --- a/test/ng/httpBackendSpec.js +++ b/test/ng/httpBackendSpec.js @@ -90,6 +90,18 @@ describe('$httpBackend', function() {      expect(callback).toHaveBeenCalledOnce();    }); +  // onreadystatechange might by called multiple times +  // with readyState === 4 on mobile webkit caused by +  // xhrs that are resolved while the app is in the background (see #5426). +  it('should remove onreadystatechange when it is called with readyState=4 to ignore multiple calls', function() { +    $backend('GET', 'URL', null, callback); +    xhr = MockXhr.$$lastInstance; + +    xhr.status = 200; +    xhr.readyState = 4; +    xhr.onreadystatechange(); +    expect(xhr.onreadystatechange).toBeUndefined(); +  });    it('should set only the requested headers', function() {      $backend('POST', 'URL', null, noop, {'X-header1': 'value1', 'X-header2': 'value2'}); | 
