mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 23:34:42 +00:00
fix($browser.xhr): respond with internal -2 status on jsonp error
If jsonp is not successfull, we return internal status -2. This internal status should by normalized by $xhr into 0, but $xhr needs to distinguish between jsonp-error/abort/timeout (all status 0).
This commit is contained in:
parent
45f47ff6cd
commit
e9b57f9df8
3 changed files with 4 additions and 4 deletions
|
|
@ -109,7 +109,7 @@ function Browser(window, document, body, XHR, $log, $sniffer) {
|
||||||
if (window[callbackId].data) {
|
if (window[callbackId].data) {
|
||||||
completeOutstandingRequest(callback, 200, window[callbackId].data);
|
completeOutstandingRequest(callback, 200, window[callbackId].data);
|
||||||
} else {
|
} else {
|
||||||
completeOutstandingRequest(callback);
|
completeOutstandingRequest(callback, -2);
|
||||||
}
|
}
|
||||||
delete window[callbackId];
|
delete window[callbackId];
|
||||||
body[0].removeChild(script);
|
body[0].removeChild(script);
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@
|
||||||
function() {
|
function() {
|
||||||
element(':button:contains("Invalid JSONP")').click();
|
element(':button:contains("Invalid JSONP")').click();
|
||||||
element(':button:contains("fetch")').click();
|
element(':button:contains("fetch")').click();
|
||||||
expect(binding('code')).toBe('code=');
|
expect(binding('code')).toBe('code=-2');
|
||||||
expect(binding('response')).toBe('response=Request failed');
|
expect(binding('response')).toBe('response=Request failed');
|
||||||
});
|
});
|
||||||
</doc:scenario>
|
</doc:scenario>
|
||||||
|
|
|
||||||
|
|
@ -147,14 +147,14 @@ describe('browser', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should call callback when script fails to load', function() {
|
it('should call callback with status -2 when script fails to load', function() {
|
||||||
browser.xhr('JSONP', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
|
browser.xhr('JSONP', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
|
||||||
var script = scripts[0];
|
var script = scripts[0];
|
||||||
expect(typeof script.onload).toBe('function');
|
expect(typeof script.onload).toBe('function');
|
||||||
expect(typeof script.onerror).toBe('function');
|
expect(typeof script.onerror).toBe('function');
|
||||||
script.onerror();
|
script.onerror();
|
||||||
|
|
||||||
expect(log).toEqual('undefined:undefined;');
|
expect(log).toEqual('-2:undefined;');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue