aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/httpBackendSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/ng/httpBackendSpec.js')
-rw-r--r--test/ng/httpBackendSpec.js38
1 files changed, 35 insertions, 3 deletions
diff --git a/test/ng/httpBackendSpec.js b/test/ng/httpBackendSpec.js
index cc73ea8e..0748d116 100644
--- a/test/ng/httpBackendSpec.js
+++ b/test/ng/httpBackendSpec.js
@@ -292,7 +292,7 @@ describe('$httpBackend', function() {
script.readyState = 'complete';
script.onreadystatechange();
} else {
- script.onload()
+ script.onload();
}
expect(callback).toHaveBeenCalledOnce();
@@ -313,7 +313,7 @@ describe('$httpBackend', function() {
script.readyState = 'complete';
script.onreadystatechange();
} else {
- script.onload()
+ script.onload();
}
expect(callbacks[callbackId]).toBeUndefined();
@@ -321,6 +321,38 @@ describe('$httpBackend', function() {
});
+ if(msie<=8) {
+
+ it('should attach onreadystatechange handler to the script object', function() {
+ $backend('JSONP', 'http://example.org/path?cb=JSON_CALLBACK', null, noop);
+
+ expect(fakeDocument.$$scripts[0].onreadystatechange).toEqual(jasmine.any(Function));
+
+ var script = fakeDocument.$$scripts[0];
+
+ script.readyState = 'complete';
+ script.onreadystatechange();
+
+ expect(script.onreadystatechange).toBe(null);
+ });
+
+ } else {
+
+ it('should attach onload and onerror handlers to the script object', function() {
+ $backend('JSONP', 'http://example.org/path?cb=JSON_CALLBACK', null, noop);
+
+ expect(fakeDocument.$$scripts[0].onload).toEqual(jasmine.any(Function));
+ expect(fakeDocument.$$scripts[0].onerror).toEqual(jasmine.any(Function));
+
+ var script = fakeDocument.$$scripts[0];
+ script.onload();
+
+ expect(script.onload).toBe(null);
+ expect(script.onerror).toBe(null);
+ });
+
+ }
+
it('should call callback with status -2 when script fails to load', function() {
callback.andCallFake(function(status, response) {
expect(status).toBe(-2);
@@ -335,7 +367,7 @@ describe('$httpBackend', function() {
script.readyState = 'complete';
script.onreadystatechange();
} else {
- script.onload()
+ script.onload();
}
expect(callback).toHaveBeenCalledOnce();
});