Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 3d1512b

Browse files
SQUASH ME: feat($httpBackend): JSONP requests now require trusted resource
1 parent da74d2d commit 3d1512b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

test/ng/httpSpec.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -1044,27 +1044,25 @@ describe('$http', function() {
10441044
describe('jsonp trust', function() {
10451045
it('should throw error if the url is not a trusted resource', function() {
10461046
var success, error;
1047-
$http({method: 'JSONP', url: 'http://example.org/path?cb=JSON_CALLBACK', callback: callback}).catch(
1047+
$http({method: 'JSONP', url: 'http://example.org/path?cb=JSON_CALLBACK'}).catch(
10481048
function(e) { error = e; }
10491049
);
10501050
$rootScope.$digest();
10511051
expect(error.message).toContain('[$sce:insecurl]');
10521052
});
10531053

1054-
it('should not throw error if the url is an explicitly trusted resource', function() {
1055-
expect(function() {
1056-
$httpBackend.expect('JSONP', 'http://example.org/path?cb=JSON_CALLBACK').respond('');
1057-
$http({ method: 'JSONP', url: $sce.trustAsResourceUrl('http://example.org/path?cb=JSON_CALLBACK'), callback: callback});
1058-
}).not.toThrow();
1054+
it('should accept an explicitly trusted resource url', function() {
1055+
$httpBackend.expect('JSONP', 'http://example.org/path?cb=JSON_CALLBACK').respond('');
1056+
$http({ method: 'JSONP', url: $sce.trustAsResourceUrl('http://example.org/path?cb=JSON_CALLBACK')});
10591057
});
10601058

1061-
it('jsonp() should accept explictly trusted urls', inject(['$sce', function($sce) {
1059+
it('jsonp() should accept explictly trusted urls', function() {
10621060
$httpBackend.expect('JSONP', '/url').respond('');
10631061
$http({method: 'JSONP', url: $sce.trustAsResourceUrl('/url')});
10641062

10651063
$httpBackend.expect('JSONP', '/url?a=b').respond('');
10661064
$http({method: 'JSONP', url: $sce.trustAsResourceUrl('/url'), params: {a: 'b'}});
1067-
}]));
1065+
});
10681066
});
10691067

10701068
describe('callbacks', function() {

0 commit comments

Comments
 (0)