aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVojta Jina2011-08-10 16:03:26 +0200
committerIgor Minar2011-11-30 11:03:42 -0500
commite9b57f9df8eb4aaa2c1657d303c78dc68828091b (patch)
treebb85fffe84a3e6c091e855b9ec202a7a1294ccf5
parent45f47ff6cd264dcd347e6df92c9ef39b0ae8aaba (diff)
downloadangular.js-e9b57f9df8eb4aaa2c1657d303c78dc68828091b.tar.bz2
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).
-rw-r--r--src/service/browser.js2
-rw-r--r--src/service/xhr.js2
-rw-r--r--test/service/browserSpecs.js4
3 files changed, 4 insertions, 4 deletions
diff --git a/src/service/browser.js b/src/service/browser.js
index 65a63f62..49bfe99e 100644
--- a/src/service/browser.js
+++ b/src/service/browser.js
@@ -109,7 +109,7 @@ function Browser(window, document, body, XHR, $log, $sniffer) {
if (window[callbackId].data) {
completeOutstandingRequest(callback, 200, window[callbackId].data);
} else {
- completeOutstandingRequest(callback);
+ completeOutstandingRequest(callback, -2);
}
delete window[callbackId];
body[0].removeChild(script);
diff --git a/src/service/xhr.js b/src/service/xhr.js
index 7970622b..e9421caf 100644
--- a/src/service/xhr.js
+++ b/src/service/xhr.js
@@ -165,7 +165,7 @@
function() {
element(':button:contains("Invalid JSONP")').click();
element(':button:contains("fetch")').click();
- expect(binding('code')).toBe('code=');
+ expect(binding('code')).toBe('code=-2');
expect(binding('response')).toBe('response=Request failed');
});
</doc:scenario>
diff --git a/test/service/browserSpecs.js b/test/service/browserSpecs.js
index 41f17f2a..a3ec6486 100644
--- a/test/service/browserSpecs.js
+++ b/test/service/browserSpecs.js
@@ -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);
var script = scripts[0];
expect(typeof script.onload).toBe('function');
expect(typeof script.onerror).toBe('function');
script.onerror();
- expect(log).toEqual('undefined:undefined;');
+ expect(log).toEqual('-2:undefined;');
});