From 3d1512b2b2ad5f95b88d3d9b1bb323ce970e537c Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 20 Sep 2016 18:41:22 +0100 Subject: [PATCH] SQUASH ME: feat($httpBackend): JSONP requests now require trusted resource --- test/ng/httpSpec.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index eed435692746..f846ab661b7e 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -1044,27 +1044,25 @@ describe('$http', function() { describe('jsonp trust', function() { it('should throw error if the url is not a trusted resource', function() { var success, error; - $http({method: 'JSONP', url: 'http://example.org/path?cb=JSON_CALLBACK', callback: callback}).catch( + $http({method: 'JSONP', url: 'http://example.org/path?cb=JSON_CALLBACK'}).catch( function(e) { error = e; } ); $rootScope.$digest(); expect(error.message).toContain('[$sce:insecurl]'); }); - it('should not throw error if the url is an explicitly trusted resource', function() { - expect(function() { - $httpBackend.expect('JSONP', 'http://example.org/path?cb=JSON_CALLBACK').respond(''); - $http({ method: 'JSONP', url: $sce.trustAsResourceUrl('http://example.org/path?cb=JSON_CALLBACK'), callback: callback}); - }).not.toThrow(); + it('should accept an explicitly trusted resource url', function() { + $httpBackend.expect('JSONP', 'http://example.org/path?cb=JSON_CALLBACK').respond(''); + $http({ method: 'JSONP', url: $sce.trustAsResourceUrl('http://example.org/path?cb=JSON_CALLBACK')}); }); - it('jsonp() should accept explictly trusted urls', inject(['$sce', function($sce) { + it('jsonp() should accept explictly trusted urls', function() { $httpBackend.expect('JSONP', '/url').respond(''); $http({method: 'JSONP', url: $sce.trustAsResourceUrl('/url')}); $httpBackend.expect('JSONP', '/url?a=b').respond(''); $http({method: 'JSONP', url: $sce.trustAsResourceUrl('/url'), params: {a: 'b'}}); - }])); + }); }); describe('callbacks', function() {