diff options
Diffstat (limited to 'test/ng')
| -rw-r--r-- | test/ng/animateSpec.js | 2 | ||||
| -rw-r--r-- | test/ng/cacheFactorySpec.js | 2 | ||||
| -rwxr-xr-x | test/ng/compileSpec.js | 54 | ||||
| -rw-r--r-- | test/ng/controllerSpec.js | 2 | ||||
| -rw-r--r-- | test/ng/directive/booleanAttrsSpec.js | 10 | ||||
| -rw-r--r-- | test/ng/directive/inputSpec.js | 4 | ||||
| -rw-r--r-- | test/ng/directive/ngRepeatSpec.js | 10 | ||||
| -rw-r--r-- | test/ng/directive/ngSrcSpec.js | 12 | ||||
| -rw-r--r-- | test/ng/directive/selectSpec.js | 2 | ||||
| -rw-r--r-- | test/ng/interpolateSpec.js | 16 | ||||
| -rw-r--r-- | test/ng/locationSpec.js | 10 | ||||
| -rw-r--r-- | test/ng/parseSpec.js | 116 | ||||
| -rw-r--r-- | test/ng/rootScopeSpec.js | 12 | ||||
| -rw-r--r-- | test/ng/sceSpecs.js | 76 |
14 files changed, 164 insertions, 164 deletions
diff --git a/test/ng/animateSpec.js b/test/ng/animateSpec.js index 2e9034e4..79115c1e 100644 --- a/test/ng/animateSpec.js +++ b/test/ng/animateSpec.js @@ -44,7 +44,7 @@ describe("$animate", function() { module(function($animateProvider) { expect(function() { $animateProvider.register('abc', null); - }).toThrow("[$animate:notcsel] Expecting class selector starting with '.' got 'abc'."); + }).toThrowMinErr("$animate", "notcsel", "Expecting class selector starting with '.' got 'abc'."); }); inject(); }); diff --git a/test/ng/cacheFactorySpec.js b/test/ng/cacheFactorySpec.js index c398a55e..b1a018da 100644 --- a/test/ng/cacheFactorySpec.js +++ b/test/ng/cacheFactorySpec.js @@ -15,7 +15,7 @@ describe('$cacheFactory', function() { it('should complain if the cache id is being reused', inject(function($cacheFactory) { $cacheFactory('cache1'); expect(function() { $cacheFactory('cache1'); }). - toThrow("[$cacheFactory:iid] CacheId 'cache1' is already taken!"); + toThrowMinErr("$cacheFactory", "iid", "CacheId 'cache1' is already taken!"); })); diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index ba94c48b..28dc57fe 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -632,11 +632,11 @@ describe('$compile', function() { inject(function($compile) { expect(function() { $compile('<p no-root-elem></p>'); - }).toThrow("[$compile:tplrt] Template for directive 'noRootElem' must have exactly one root element. "); + }).toThrowMinErr("$compile", "tplrt", "Template for directive 'noRootElem' must have exactly one root element. "); expect(function() { $compile('<p multi-root-elem></p>'); - }).toThrow("[$compile:tplrt] Template for directive 'multiRootElem' must have exactly one root element. "); + }).toThrowMinErr("$compile", "tplrt", "Template for directive 'multiRootElem' must have exactly one root element. "); // ws is ok expect(function() { @@ -748,7 +748,7 @@ describe('$compile', function() { expect(function() { $templateCache.put('http://example.com/should-not-load.html', 'Should not load even if in cache.'); $compile('<div class="crossDomainTemplate"></div>')($rootScope); - }).toThrow('[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/should-not-load.html'); + }).toThrowMinErr('$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/should-not-load.html'); })); it('should load cross domain templates when trusted', inject( @@ -1011,7 +1011,7 @@ describe('$compile', function() { expect(function() { $httpBackend.flush(); - }).toThrow('[$compile:tpload] Failed to load template: hello.html'); + }).toThrowMinErr('$compile', 'tpload', 'Failed to load template: hello.html'); expect(sortedHtml(element)).toBe('<div><b class="hello"></b></div>'); } )); @@ -1031,7 +1031,7 @@ describe('$compile', function() { inject(function($compile){ expect(function() { $compile('<div><div class="sync async"></div></div>'); - }).toThrow('[$compile:multidir] Multiple directives [sync, async] asking for template on: '+ + }).toThrowMinErr('$compile', 'multidir', 'Multiple directives [sync, async] asking for template on: '+ '<div class="sync async">'); }); }); @@ -1215,14 +1215,14 @@ describe('$compile', function() { $compile('<p template></p>'); $rootScope.$digest(); expect($exceptionHandler.errors.pop().message). - toBe("[$compile:tplrt] Template for directive 'template' must have exactly one root element. template.html"); + toMatch(/\[\$compile:tplrt\] Template for directive 'template' must have exactly one root element\. template\.html/); // multi root $templateCache.put('template.html', '<div></div><div></div>'); $compile('<p template></p>'); $rootScope.$digest(); expect($exceptionHandler.errors.pop().message). - toBe("[$compile:tplrt] Template for directive 'template' must have exactly one root element. template.html"); + toMatch(/\[\$compile:tplrt\] Template for directive 'template' must have exactly one root element\. template\.html/); // ws is ok $templateCache.put('template.html', ' <div></div> \n'); @@ -1482,7 +1482,7 @@ describe('$compile', function() { function($rootScope, $compile) { expect(function(){ $compile('<div class="iscope-a; scope-b"></div>'); - }).toThrow('[$compile:multidir] Multiple directives [iscopeA, scopeB] asking for isolated scope on: ' + + }).toThrowMinErr('$compile', 'multidir', 'Multiple directives [iscopeA, scopeB] asking for isolated scope on: ' + '<div class="iscope-a; scope-b ng-isolate-scope ng-scope">'); }) ); @@ -1492,7 +1492,7 @@ describe('$compile', function() { function($rootScope, $compile) { expect(function(){ $compile('<div class="iscope-a; iscope-b"></div>'); - }).toThrow('[$compile:multidir] Multiple directives [iscopeA, iscopeB] asking for isolated scope on: ' + + }).toThrowMinErr('$compile', 'multidir', 'Multiple directives [iscopeA, iscopeB] asking for isolated scope on: ' + '<div class="iscope-a; iscope-b ng-isolate-scope ng-scope">'); }) ); @@ -2110,7 +2110,7 @@ describe('$compile', function() { componentScope.ref = 'ignore me'; expect($rootScope.$apply). - toThrow("[$compile:nonassign] Expression ''hello ' + name' used with directive 'myComponent' is non-assignable!"); + toThrowMinErr("$compile", "nonassign", "Expression ''hello ' + name' used with directive 'myComponent' is non-assignable!"); expect(componentScope.ref).toBe('hello world'); // reset since the exception was rethrown which prevented phase clearing $rootScope.$$phase = null; @@ -2186,7 +2186,7 @@ describe('$compile', function() { it('should throw on unknown definition', inject(function() { expect(function() { compile('<div><span bad-declaration>'); - }).toThrow("[$compile:iscp] Invalid isolate scope definition for directive 'badDeclaration'. Definition: {... attr: 'xxx' ...}"); + }).toThrowMinErr("$compile", "iscp", "Invalid isolate scope definition for directive 'badDeclaration'. Definition: {... attr: 'xxx' ...}"); })); it('should expose a $$isolateBindings property onto the scope', inject(function() { @@ -2329,7 +2329,7 @@ describe('$compile', function() { inject(function(log, $compile, $rootScope) { expect(function() { $compile('<div main><div dep></div></div>')($rootScope); - }).toThrow("[$compile:ctreq] Controller 'main', required by directive 'dep', can't be found!"); + }).toThrowMinErr("$compile", "ctreq", "Controller 'main', required by directive 'dep', can't be found!"); }); }); @@ -2724,7 +2724,7 @@ describe('$compile', function() { inject(function($compile) { expect(function() { $compile('<div class="first second"></div>'); - }).toThrow('[$compile:multidir] Multiple directives [first, second] asking for transclusion on: ' + + }).toThrowMinErr('$compile', 'multidir', 'Multiple directives [first, second] asking for transclusion on: ' + '<div class="first second ng-isolate-scope ng-scope">'); }); }); @@ -3147,18 +3147,18 @@ describe('$compile', function() { $rootScope.onClickJs = ""; expect(function() { $compile('<button onclick="{{onClickJs}}"></script>')($rootScope); - }).toThrow( - "[$compile:nodomevents] Interpolations for HTML DOM event attributes are disallowed. " + + }).toThrowMinErr( + "$compile", "nodomevents", "Interpolations for HTML DOM event attributes are disallowed. " + "Please use the ng- versions (such as ng-click instead of onclick) instead."); expect(function() { $compile('<button ONCLICK="{{onClickJs}}"></script>')($rootScope); - }).toThrow( - "[$compile:nodomevents] Interpolations for HTML DOM event attributes are disallowed. " + + }).toThrowMinErr( + "$compile", "nodomevents", "Interpolations for HTML DOM event attributes are disallowed. " + "Please use the ng- versions (such as ng-click instead of onclick) instead."); expect(function() { $compile('<button ng-attr-onclick="{{onClickJs}}"></script>')($rootScope); - }).toThrow( - "[$compile:nodomevents] Interpolations for HTML DOM event attributes are disallowed. " + + }).toThrowMinErr( + "$compile", "nodomevents", "Interpolations for HTML DOM event attributes are disallowed. " + "Please use the ng- versions (such as ng-click instead of onclick) instead."); })); @@ -3181,8 +3181,8 @@ describe('$compile', function() { it('should clear out src attributes for a different domain', inject(function($compile, $rootScope, $sce) { element = $compile('<iframe src="{{testUrl}}"></iframe>')($rootScope); $rootScope.testUrl = "http://a.different.domain.example.com"; - expect(function() { $rootScope.$apply() }).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + + expect(function() { $rootScope.$apply() }).toThrowMinErr( + "$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "http://a.different.domain.example.com"); })); @@ -3190,8 +3190,8 @@ describe('$compile', function() { it('should clear out JS src attributes', inject(function($compile, $rootScope, $sce) { element = $compile('<iframe src="{{testUrl}}"></iframe>')($rootScope); $rootScope.testUrl = "javascript:alert(1);"; - expect(function() { $rootScope.$apply() }).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + + expect(function() { $rootScope.$apply() }).toThrowMinErr( + "$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "javascript:alert(1);"); })); @@ -3199,8 +3199,8 @@ describe('$compile', function() { it('should clear out non-resource_url src attributes', inject(function($compile, $rootScope, $sce) { element = $compile('<iframe src="{{testUrl}}"></iframe>')($rootScope); $rootScope.testUrl = $sce.trustAsUrl("javascript:doTrustedStuff()"); - expect($rootScope.$apply).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + + expect($rootScope.$apply).toThrowMinErr( + "$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: javascript:doTrustedStuff()"); })); @@ -3347,7 +3347,7 @@ describe('$compile', function() { '<div>' + '<span foo-start></span>' + '</div>'); - }).toThrow("[$compile:uterdir] Unterminated attribute, found 'foo-start' but no matching 'foo-end' found."); + }).toThrowMinErr("$compile", "uterdir", "Unterminated attribute, found 'foo-start' but no matching 'foo-end' found."); }); }); @@ -3365,7 +3365,7 @@ describe('$compile', function() { '<div>' + '<span foo-start><span foo-end></span></span>' + '</div>'); - }).toThrow("[$compile:uterdir] Unterminated attribute, found 'foo-start' but no matching 'foo-end' found."); + }).toThrowMinErr("$compile", "uterdir", "Unterminated attribute, found 'foo-start' but no matching 'foo-end' found."); }); }); diff --git a/test/ng/controllerSpec.js b/test/ng/controllerSpec.js index 6446ecf9..2a9922c6 100644 --- a/test/ng/controllerSpec.js +++ b/test/ng/controllerSpec.js @@ -131,7 +131,7 @@ describe('$controller', function() { expect(function() { $controller('a.b.FooCtrl as foo'); - }).toThrow("[$controller:noscp] Cannot export controller 'a.b.FooCtrl' as 'foo'! No $scope object provided via `locals`."); + }).toThrowMinErr("$controller", "noscp", "Cannot export controller 'a.b.FooCtrl' as 'foo'! No $scope object provided via `locals`."); }); }); diff --git a/test/ng/directive/booleanAttrsSpec.js b/test/ng/directive/booleanAttrsSpec.js index 82639051..83bc75e5 100644 --- a/test/ng/directive/booleanAttrsSpec.js +++ b/test/ng/directive/booleanAttrsSpec.js @@ -93,7 +93,7 @@ describe('boolean attr directives', function() { expect(function() { $compile('<select multiple="{{isMultiple}}"></select>') - }).toThrow('[$compile:selmulti] Binding to the \'multiple\' attribute is not supported. ' + + }).toThrowMinErr('$compile', 'selmulti', 'Binding to the \'multiple\' attribute is not supported. ' + 'Element: <select multiple="{{isMultiple}}">'); })); @@ -137,8 +137,8 @@ describe('ngSrc', function() { expect(function() { var element = $compile('<div ng-src="some/{{id}}"></div>')($rootScope); dealoc(element); - }).toThrow( - "[$interpolate:noconcat] Error while interpolating: some/{{id}}\nStrict " + + }).toThrowMinErr( + "$interpolate", "noconcat", "Error while interpolating: some/{{id}}\nStrict " + "Contextual Escaping disallows interpolations that concatenate multiple expressions " + "when a trusted value is required. See http://docs.angularjs.org/api/ng.$sce"); })); @@ -162,8 +162,8 @@ describe('ngSrc', function() { $rootScope.id = $sce.trustAsUrl('http://somewhere'); }); element.attr('src'); - }).toThrow( - "[$interpolate:interr] Can't interpolate: {{id}}\nError: [$sce:insecurl] Blocked " + + }).toThrowMinErr( + "$interpolate", "interr", "Can't interpolate: {{id}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: http://somewhere"); })); diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index a69a4195..facc2b80 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -43,7 +43,7 @@ describe('NgModelController', function() { } expect(exception.message). - toMatch(/^\[ngModel:nonassign\] Expression '1\+2' is non\-assignable\. Element: <input( value="")? ng-model="1\+2">$/); + toMatch(/^\[ngModel:nonassign\] Expression '1\+2' is non\-assignable\. Element: <input( value="")? ng-model="1\+2">/); })); @@ -457,7 +457,7 @@ describe('input', function() { expect(function() { compileInput('<input type="text" ng-model="throw \'\'">'); scope.$digest(); - }).toThrow("[$parse:syntax] Syntax Error: Token '''' is an unexpected token at column 7 of the expression [throw ''] starting at ['']."); + }).toThrowMinErr("$parse", "syntax", "Syntax Error: Token '''' is an unexpected token at column 7 of the expression [throw ''] starting at ['']."); }); diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index 35b9f897..fc41bc6d 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -77,7 +77,7 @@ describe('ngRepeat', function() { expect(element.find('li').length).toEqual(3); expect(element.text()).toEqual('x;y;x;'); }); - + it('should iterate over an array-like class', function() { function Collection() {} Collection.prototype = new Array(); @@ -350,7 +350,7 @@ describe('ngRepeat', function() { element = jqLite('<ul><li ng-repeat="i dont parse"></li></ul>'); $compile(element)(scope); expect($exceptionHandler.errors.shift()[0].message). - toBe("[ngRepeat:iexp] Expected expression in form of '_item_ in _collection_[ track by _id_]' but got 'i dont parse'."); + toMatch(/^\[ngRepeat:iexp\] Expected expression in form of '_item_ in _collection_\[ track by _id_\]' but got 'i dont parse'\./); }); @@ -358,7 +358,7 @@ describe('ngRepeat', function() { element = jqLite('<ul><li ng-repeat="i dont parse in foo"></li></ul>'); $compile(element)(scope); expect($exceptionHandler.errors.shift()[0].message). - toBe("[ngRepeat:iidexp] '_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got 'i dont parse'."); + toMatch(/^\[ngRepeat:iidexp\] '_item_' in '_item_ in _collection_' should be an identifier or '\(_key_, _value_\)' expression, but got 'i dont parse'\./); }); @@ -773,7 +773,7 @@ describe('ngRepeat', function() { scope.items = [a, a, a]; scope.$digest(); expect($exceptionHandler.errors.shift().message). - toEqual("[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: item in items, Duplicate key: object:003"); + toMatch(/^\[ngRepeat:dupes\] Duplicates in a repeater are not allowed\. Use 'track by' expression to specify unique keys\. Repeater: item in items, Duplicate key: object:003/); // recover scope.items = [a]; @@ -793,7 +793,7 @@ describe('ngRepeat', function() { scope.items = [d, d, d]; scope.$digest(); expect($exceptionHandler.errors.shift().message). - toEqual("[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: item in items, Duplicate key: object:009"); + toMatch(/^\[ngRepeat:dupes\] Duplicates in a repeater are not allowed\. Use 'track by' expression to specify unique keys\. Repeater: item in items, Duplicate key: object:009/); // recover scope.items = [a]; diff --git a/test/ng/directive/ngSrcSpec.js b/test/ng/directive/ngSrcSpec.js index 2fb99eab..3dc00257 100644 --- a/test/ng/directive/ngSrcSpec.js +++ b/test/ng/directive/ngSrcSpec.js @@ -26,8 +26,8 @@ describe('ngSrc', function() { it('should error on src attributes for a different domain', inject(function($compile, $rootScope) { element = $compile('<iframe ng-src="{{testUrl}}"></iframe>')($rootScope); $rootScope.testUrl = "http://a.different.domain.example.com"; - expect(function() { $rootScope.$apply() }).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + + expect(function() { $rootScope.$apply() }).toThrowMinErr( + "$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "http://a.different.domain.example.com"); })); @@ -35,8 +35,8 @@ describe('ngSrc', function() { it('should error on JS src attributes', inject(function($compile, $rootScope) { element = $compile('<iframe ng-src="{{testUrl}}"></iframe>')($rootScope); $rootScope.testUrl = "javascript:alert(1);"; - expect(function() { $rootScope.$apply() }).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + + expect(function() { $rootScope.$apply() }).toThrowMinErr( + "$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "javascript:alert(1);"); })); @@ -44,8 +44,8 @@ describe('ngSrc', function() { it('should error on non-resource_url src attributes', inject(function($compile, $rootScope, $sce) { element = $compile('<iframe ng-src="{{testUrl}}"></iframe>')($rootScope); $rootScope.testUrl = $sce.trustAsUrl("javascript:doTrustedStuff()"); - expect($rootScope.$apply).toThrow( - "[$interpolate:interr] Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + + expect($rootScope.$apply).toThrowMinErr( + "$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " + "loading resource from url not allowed by $sceDelegate policy. URL: " + "javascript:doTrustedStuff()"); })); diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 5be7eb65..5906ce99 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -494,7 +494,7 @@ describe('select', function() { it('should throw when not formated "? for ? in ?"', function() { expect(function() { compile('<select ng-model="selected" ng-options="i dont parse"></select>'); - }).toThrowMatching(/^\[ngOptions:iexp\] Expected expression in form of/); + }).toThrowMinErr('ngOptions', 'iexp', /Expected expression in form of/); }); diff --git a/test/ng/interpolateSpec.js b/test/ng/interpolateSpec.js index d74b764a..60612329 100644 --- a/test/ng/interpolateSpec.js +++ b/test/ng/interpolateSpec.js @@ -32,7 +32,7 @@ describe('$interpolate', function() { }; expect(function () { $interpolate('{{err()}}')($rootScope); - }).toThrow("[$interpolate:interr] Can't interpolate: {{err()}}\nError: oops"); + }).toThrowMinErr("$interpolate", "interr", "Can't interpolate: {{err()}}\nError: oops"); })); it('should stop interpolation when encountering an exception', inject(function($interpolate, $compile, $rootScope) { @@ -43,7 +43,7 @@ describe('$interpolate', function() { $compile(dom)($rootScope); expect(function () { $rootScope.$apply(); - }).toThrow("[$interpolate:interr] Can't interpolate: {{err()}}\nError: oops"); + }).toThrowMinErr("$interpolate", "interr", "Can't interpolate: {{err()}}\nError: oops"); expect(dom[0].innerHTML).toEqual('2'); expect(dom[1].innerHTML).toEqual('{{err()}}'); expect(dom[2].innerHTML).toEqual('{{1 + 2}}'); @@ -107,8 +107,8 @@ describe('$interpolate', function() { var bar = sce.trustAsCss("bar"); expect(function() { return $interpolate('{{foo}}{{bar}}', true, sce.CSS)( - {foo: foo, bar: bar}); }).toThrow( - "[$interpolate:noconcat] Error while interpolating: {{foo}}{{bar}}\n" + + {foo: foo, bar: bar}); }).toThrowMinErr( + "$interpolate", "noconcat", "Error while interpolating: {{foo}}{{bar}}\n" + "Strict Contextual Escaping disallows interpolations that concatenate multiple " + "expressions when a trusted value is required. See " + "http://docs.angularjs.org/api/ng.$sce"); @@ -203,14 +203,14 @@ describe('$interpolate', function() { var isTrustedContext = true; expect(function() { $interpolate('constant/{{var}}', true, isTrustedContext); - }).toThrow( - "[$interpolate:noconcat] Error while interpolating: constant/{{var}}\nStrict " + + }).toThrowMinErr( + "$interpolate", "noconcat", "Error while interpolating: constant/{{var}}\nStrict " + "Contextual Escaping disallows interpolations that concatenate multiple expressions " + "when a trusted value is required. See http://docs.angularjs.org/api/ng.$sce"); expect(function() { $interpolate('{{foo}}{{bar}}', true, isTrustedContext); - }).toThrow( - "[$interpolate:noconcat] Error while interpolating: {{foo}}{{bar}}\nStrict " + + }).toThrowMinErr( + "$interpolate", "noconcat", "Error while interpolating: {{foo}}{{bar}}\nStrict " + "Contextual Escaping disallows interpolations that concatenate multiple expressions " + "when a trusted value is required. See http://docs.angularjs.org/api/ng.$sce"); })); diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index a07b516b..a60f1609 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -88,10 +88,10 @@ describe('$location', function() { it('search() should throw error an incorrect argument', function() { expect(function() { url.search(null); - }).toThrow('[$location:isrcharg] The first argument of the `$location#search()` call must be a string or an object.'); + }).toThrowMinErr('$location', 'isrcharg', 'The first argument of the `$location#search()` call must be a string or an object.'); expect(function() { url.search(undefined); - }).toThrow('[$location:isrcharg] The first argument of the `$location#search()` call must be a string or an object.'); + }).toThrowMinErr('$location', 'isrcharg', 'The first argument of the `$location#search()` call must be a string or an object.'); }); @@ -219,7 +219,7 @@ describe('$location', function() { expect(function() { url.$$parse('http://other.server.org/path#/path'); - }).toThrow('[$location:ipthprfx] Invalid url "http://other.server.org/path#/path", missing path prefix "http://server.org/base/".'); + }).toThrowMinErr('$location', 'ipthprfx', 'Invalid url "http://other.server.org/path#/path", missing path prefix "http://server.org/base/".'); }); @@ -228,7 +228,7 @@ describe('$location', function() { expect(function() { url.$$parse('http://server.org/path#/path'); - }).toThrow('[$location:ipthprfx] Invalid url "http://server.org/path#/path", missing path prefix "http://server.org/base/".'); + }).toThrowMinErr('$location', 'ipthprfx', 'Invalid url "http://server.org/path#/path", missing path prefix "http://server.org/base/".'); }); @@ -341,7 +341,7 @@ describe('$location', function() { it('should throw error when invalid hashbang prefix given', function() { expect(function() { url.$$parse('http://www.server.org:1234/base#/path'); - }).toThrow('[$location:ihshprfx] Invalid url "http://www.server.org:1234/base#/path", missing hash prefix "#!".'); + }).toThrowMinErr('$location', 'ihshprfx', 'Invalid url "http://www.server.org:1234/base#/path", missing hash prefix "#!".'); }); diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js index 568a3b15..f9a80fb6 100644 --- a/test/ng/parseSpec.js +++ b/test/ng/parseSpec.js @@ -156,11 +156,11 @@ describe('parser', function() { it('should throws exception for invalid exponent', function() { expect(function() { lex("0.5E-"); - }).toThrow(new Error('[$parse:lexerr] Lexer Error: Invalid exponent at column 4 in expression [0.5E-].')); + }).toThrowMinErr('$parse', 'lexerr', 'Lexer Error: Invalid exponent at column 4 in expression [0.5E-].'); expect(function() { lex("0.5E-A"); - }).toThrow(new Error('[$parse:lexerr] Lexer Error: Invalid exponent at column 4 in expression [0.5E-A].')); + }).toThrowMinErr('$parse', 'lexerr', 'Lexer Error: Invalid exponent at column 4 in expression [0.5E-A].'); }); it('should tokenize number starting with a dot', function() { @@ -171,7 +171,7 @@ describe('parser', function() { it('should throw error on invalid unicode', function() { expect(function() { lex("'\\u1''bla'"); - }).toThrow(new Error("[$parse:lexerr] Lexer Error: Invalid unicode escape [\\u1''b] at column 2 in expression ['\\u1''bla'].")); + }).toThrowMinErr("$parse", "lexerr", "Lexer Error: Invalid unicode escape [\\u1''b] at column 2 in expression ['\\u1''bla']."); }); }); @@ -304,7 +304,7 @@ describe('parser', function() { expect(function() { scope.$eval("1|nonexistent"); - }).toThrow(new Error("[$injector:unpr] Unknown provider: nonexistentFilterProvider <- nonexistentFilter")); + }).toThrowMinErr('$injector', 'unpr', 'Unknown provider: nonexistentFilterProvider <- nonexistentFilter'); scope.offset = 3; expect(scope.$eval("'abcd'|substring:1:offset")).toEqual("bc"); @@ -492,7 +492,7 @@ describe('parser', function() { it('should throw exception on non-closed bracket', function() { expect(function() { scope.$eval('[].count('); - }).toThrow('[$parse:ueoe] Unexpected end of expression: [].count('); + }).toThrowMinErr('$parse', 'ueoe', 'Unexpected end of expression: [].count('); }); it('should evaluate double negation', function() { @@ -558,86 +558,86 @@ describe('parser', function() { it('should NOT allow access to Function constructor in getter', function() { expect(function() { scope.$eval('{}.toString.constructor'); - }).toThrow(new Error( - '[$parse:isecfld] Referencing "constructor" field in Angular expressions is disallowed! ' + - 'Expression: {}.toString.constructor')); + }).toThrowMinErr( + '$parse', 'isecfld', 'Referencing "constructor" field in Angular expressions is disallowed! ' + + 'Expression: {}.toString.constructor'); expect(function() { scope.$eval('{}.toString.constructor("alert(1)")'); - }).toThrow(new Error( - '[$parse:isecfld] Referencing "constructor" field in Angular expressions is disallowed! ' + - 'Expression: {}.toString.constructor("alert(1)")')); + }).toThrowMinErr( + '$parse', 'isecfld', 'Referencing "constructor" field in Angular expressions is disallowed! ' + + 'Expression: {}.toString.constructor("alert(1)")'); expect(function() { scope.$eval('[].toString.constructor.foo'); - }).toThrow(new Error( - '[$parse:isecfld] Referencing "constructor" field in Angular expressions is disallowed! ' + - 'Expression: [].toString.constructor.foo')); + }).toThrowMinErr( + '$parse', 'isecfld', 'Referencing "constructor" field in Angular expressions is disallowed! ' + + 'Expression: [].toString.constructor.foo'); expect(function() { scope.$eval('{}.toString["constructor"]'); - }).toThrow(new Error( - '[$parse:isecfn] Referencing Function in Angular expressions is disallowed! ' + - 'Expression: {}.toString["constructor"]')); + }).toThrowMinErr( + '$parse', 'isecfn', 'Referencing Function in Angular expressions is disallowed! ' + + 'Expression: {}.toString["constructor"]'); expect(function() { scope.$eval('{}["toString"]["constructor"]'); - }).toThrow(new Error( - '[$parse:isecfn] Referencing Function in Angular expressions is disallowed! ' + - 'Expression: {}["toString"]["constructor"]')); + }).toThrowMinErr( + '$parse', 'isecfn', 'Referencing Function in Angular expressions is disallowed! ' + + 'Expression: {}["toString"]["constructor"]'); scope.a = []; expect(function() { scope.$eval('a.toString.constructor', scope); - }).toThrow(new Error( - '[$parse:isecfld] Referencing "constructor" field in Angular expressions is disallowed! ' + - 'Expression: a.toString.constructor')); + }).toThrowMinErr( + '$parse', 'isecfld', 'Referencing "constructor" field in Angular expressions is disallowed! ' + + 'Expression: a.toString.constructor'); expect(function() { scope.$eval('a.toString["constructor"]', scope); - }).toThrow(new Error( - '[$parse:isecfn] Referencing Function in Angular expressions is disallowed! ' + - 'Expression: a.toString["constructor"]')); + }).toThrowMinErr( + '$parse', 'isecfn', 'Referencing Function in Angular expressions is disallowed! ' + + 'Expression: a.toString["constructor"]'); }); it('should NOT allow access to Function constructor in setter', function() { expect(function() { scope.$eval('{}.toString.constructor = 1'); - }).toThrow(new Error( - '[$parse:isecfld] Referencing "constructor" field in Angular expressions is disallowed! ' + - 'Expression: {}.toString.constructor = 1')); + }).toThrowMinErr( + '$parse', 'isecfld', 'Referencing "constructor" field in Angular expressions is disallowed! ' + + 'Expression: {}.toString.constructor = 1'); expect(function() { scope.$eval('{}.toString.constructor.a = 1'); - }).toThrow(new Error( - '[$parse:isecfld] Referencing "constructor" field in Angular expressions is disallowed! ' + - 'Expression: {}.toString.constructor.a = 1')); + }).toThrowMinErr( + '$parse', 'isecfld', 'Referencing "constructor" field in Angular expressions is disallowed! ' + + 'Expression: {}.toString.constructor.a = 1'); expect(function() { scope.$eval('{}.toString["constructor"]["constructor"] = 1'); - }).toThrow(new Error( - '[$parse:isecfn] Referencing Function in Angular expressions is disallowed! ' + - 'Expression: {}.toString["constructor"]["constructor"] = 1')); + }).toThrowMinErr( + '$parse', 'isecfn', 'Referencing Function in Angular expressions is disallowed! ' + + 'Expression: {}.toString["constructor"]["constructor"] = 1'); scope.key1 = "const"; scope.key2 = "ructor"; expect(function() { scope.$eval('{}.toString[key1 + key2].foo = 1'); - }).toThrow(new Error( - '[$parse:isecfn] Referencing Function in Angular expressions is disallowed! ' + - 'Expression: {}.toString[key1 + key2].foo = 1')); + }).toThrowMinErr( + '$parse', 'isecfn', 'Referencing Function in Angular expressions is disallowed! ' + + 'Expression: {}.toString[key1 + key2].foo = 1'); expect(function() { scope.$eval('{}.toString["constructor"]["a"] = 1'); - }).toThrow(new Error( - '[$parse:isecfn] Referencing Function in Angular expressions is disallowed! ' + - 'Expression: {}.toString["constructor"]["a"] = 1')); + }).toThrowMinErr( + '$parse', 'isecfn', 'Referencing Function in Angular expressions is disallowed! ' + + 'Expression: {}.toString["constructor"]["a"] = 1'); scope.a = []; expect(function() { scope.$eval('a.toString.constructor = 1', scope); - }).toThrow(new Error( - '[$parse:isecfld] Referencing "constructor" field in Angular expressions is disallowed! ' + - 'Expression: a.toString.constructor = 1')); + }).toThrowMinErr( + '$parse', 'isecfld', 'Referencing "constructor" field in Angular expressions is disallowed! ' + + 'Expression: a.toString.constructor = 1'); }); @@ -645,9 +645,9 @@ describe('parser', function() { scope.foo = { "bar": Function }; expect(function() { scope.$eval('foo["bar"]'); - }).toThrow(new Error( - '[$parse:isecfn] Referencing Function in Angular expressions is disallowed! ' + - 'Expression: foo["bar"]')); + }).toThrowMinErr( + '$parse', 'isecfn', 'Referencing Function in Angular expressions is disallowed! ' + + 'Expression: foo["bar"]'); }); }); @@ -661,14 +661,14 @@ describe('parser', function() { // index operator. expect(function() { scope.$eval('foo.constructor()', scope) - }).toThrow(new Error( - '[$parse:isecfld] Referencing "constructor" field in Angular expressions is disallowed! ' + - 'Expression: foo.constructor()')); + }).toThrowMinErr( + '$parse', 'isecfld', 'Referencing "constructor" field in Angular expressions is disallowed! ' + + 'Expression: foo.constructor()'); expect(function() { scope.$eval('foo["constructor"]()', scope) - }).toThrow(new Error( - '[$parse:isecfn] Referencing Function in Angular expressions is disallowed! ' + - 'Expression: foo["constructor"]()')); + }).toThrowMinErr( + '$parse', 'isecfn', 'Referencing Function in Angular expressions is disallowed! ' + + 'Expression: foo["constructor"]()'); // User defined value assigned to constructor. scope.foo.constructor = function constructor() { @@ -677,9 +677,9 @@ describe('parser', function() { // Dot operator should still block it. expect(function() { scope.$eval('foo.constructor()', scope) - }).toThrow(new Error( - '[$parse:isecfld] Referencing "constructor" field in Angular expressions is disallowed! ' + - 'Expression: foo.constructor()')); + }).toThrowMinErr( + '$parse', 'isecfld', 'Referencing "constructor" field in Angular expressions is disallowed! ' + + 'Expression: foo.constructor()'); // However, the index operator should allow it. expect(scope.$eval('foo["constructor"]()', scope)).toBe('custom constructor'); }); @@ -864,10 +864,10 @@ describe('parser', function() { })); - it('should evaluate a resolved primitive type promise and set its value', inject(function($parse) { + it('should evaluate a resolved primitive type promise and set its value', inject(function($parse) { scope.greeting = promise; deferred.resolve('Salut!'); - + var getter = $parse('greeting'); expect(getter(scope)).toBe(undefined); diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index 049258cf..ddd83088 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -215,7 +215,7 @@ describe('Scope', function() { expect(function() { $rootScope.$digest(); - }).toThrow('[$rootScope:infdig] 100 $digest() iterations reached. Aborting!\n'+ + }).toThrowMinErr('$rootScope', 'infdig', '100 $digest() iterations reached. Aborting!\n'+ 'Watchers fired in the last 5 iterations: ' + '[["a; newVal: 96; oldVal: 95","b; newVal: 97; oldVal: 96"],' + '["a; newVal: 97; oldVal: 96","b; newVal: 98; oldVal: 97"],' + @@ -299,7 +299,7 @@ describe('Scope', function() { $rootScope.$watch('name', function() { expect(function() { $rootScope.$digest(); - }).toThrow('[$rootScope:inprog] $digest already in progress'); + }).toThrowMinErr('$rootScope', 'inprog', '$digest already in progress'); callCount++; }); $rootScope.name = 'a'; @@ -796,7 +796,7 @@ describe('Scope', function() { $rootScope.$apply(function() { $rootScope.$apply(); }); - }).toThrow('[$rootScope:inprog] $apply already in progress'); + }).toThrowMinErr('$rootScope', 'inprog', '$apply already in progress'); })); @@ -808,7 +808,7 @@ describe('Scope', function() { $rootScope.$apply(); }); }); - }).toThrow('[$rootScope:inprog] $digest already in progress'); + }).toThrowMinErr('$rootScope', 'inprog', '$digest already in progress'); })); @@ -818,7 +818,7 @@ describe('Scope', function() { childScope1.$watch('x', function() { childScope1.$apply(); }); - expect(function() { childScope1.$apply(); }).toThrow('[$rootScope:inprog] $digest already in progress'); + expect(function() { childScope1.$apply(); }).toThrowMinErr('$rootScope', 'inprog', '$digest already in progress'); })); @@ -835,7 +835,7 @@ describe('Scope', function() { expect(function() { childScope2.$apply(function() { childScope2.x = 'something'; - }); }).toThrow('[$rootScope:inprog] $digest already in progress'); + }); }).toThrowMinErr('$rootScope', 'inprog', '$digest already in progress'); })); }); }); diff --git a/test/ng/sceSpecs.js b/test/ng/sceSpecs.js index 9be794fb..75c1fbaa 100644 --- a/test/ng/sceSpecs.js +++ b/test/ng/sceSpecs.js @@ -41,8 +41,8 @@ describe('SCE', function() { try { $window.msie = true; if (expectException) { - expect(constructSce).toThrow( - '[$sce:iequirks] Strict Contextual Escaping does not support Internet Explorer ' + + expect(constructSce).toThrowMinErr( + '$sce', 'iequirks', 'Strict Contextual Escaping does not support Internet Explorer ' + 'version < 9 in quirks mode. You can fix this by adding the text <!doctype html> to ' + 'the top of your HTML document. See http://docs.angularjs.org/api/ng.$sce for more ' + 'information.'); @@ -88,13 +88,13 @@ describe('SCE', function() { var wrappedValue = $sce.trustAs($sce.HTML, originalValue); expect(typeof wrappedValue).toBe('object'); expect($sce.getTrusted($sce.HTML, wrappedValue)).toBe('original_value'); - expect(function() { $sce.getTrusted($sce.CSS, wrappedValue); }).toThrow( - '[$sce:unsafe] Attempting to use an unsafe value in a safe context.'); + expect(function() { $sce.getTrusted($sce.CSS, wrappedValue); }).toThrowMinErr( + '$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.'); wrappedValue = $sce.trustAs($sce.CSS, originalValue); expect(typeof wrappedValue).toBe('object'); expect($sce.getTrusted($sce.CSS, wrappedValue)).toBe('original_value'); - expect(function() { $sce.getTrusted($sce.HTML, wrappedValue); }).toThrow( - '[$sce:unsafe] Attempting to use an unsafe value in a safe context.'); + expect(function() { $sce.getTrusted($sce.HTML, wrappedValue); }).toThrowMinErr( + '$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.'); wrappedValue = $sce.trustAs($sce.URL, originalValue); expect(typeof wrappedValue).toBe('object'); expect($sce.getTrusted($sce.URL, wrappedValue)).toBe('original_value'); @@ -104,19 +104,19 @@ describe('SCE', function() { })); it('should NOT wrap non-string values', inject(function($sce) { - expect(function() { $sce.trustAsCss(123); }).toThrow( - '[$sce:itype] Attempted to trust a non-string value in a content requiring a string: ' + + expect(function() { $sce.trustAsCss(123); }).toThrowMinErr( + '$sce', 'itype', 'Attempted to trust a non-string value in a content requiring a string: ' + 'Context: css'); })); it('should NOT wrap unknown contexts', inject(function($sce) { - expect(function() { $sce.trustAs('unknown1' , '123'); }).toThrow( - '[$sce:icontext] Attempted to trust a value in invalid context. Context: unknown1; Value: 123'); + expect(function() { $sce.trustAs('unknown1' , '123'); }).toThrowMinErr( + '$sce', 'icontext', 'Attempted to trust a value in invalid context. Context: unknown1; Value: 123'); })); it('should NOT wrap undefined context', inject(function($sce) { - expect(function() { $sce.trustAs(undefined, '123'); }).toThrow( - '[$sce:icontext] Attempted to trust a value in invalid context. Context: undefined; Value: 123'); + expect(function() { $sce.trustAs(undefined, '123'); }).toThrowMinErr( + '$sce', 'icontext', 'Attempted to trust a value in invalid context. Context: undefined; Value: 123'); })); it('should wrap undefined into undefined', inject(function($sce) { @@ -156,8 +156,8 @@ describe('SCE', function() { it('should NOT unwrap values when the type is different', inject(function($sce) { var originalValue = "originalValue"; var wrappedValue = $sce.trustAs($sce.HTML, originalValue); - expect(function () { $sce.getTrusted($sce.CSS, wrappedValue); }).toThrow( - '[$sce:unsafe] Attempting to use an unsafe value in a safe context.'); + expect(function () { $sce.getTrusted($sce.CSS, wrappedValue); }).toThrowMinErr( + '$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.'); })); it('should NOT unwrap values that had not been wrapped', inject(function($sce) { @@ -167,8 +167,8 @@ describe('SCE', function() { }; } var wrappedValue = new TrustedValueHolder("originalValue"); - expect(function() { return $sce.getTrusted($sce.HTML, wrappedValue) }).toThrow( - '[$sce:unsafe] Attempting to use an unsafe value in a safe context.'); + expect(function() { return $sce.getTrusted($sce.HTML, wrappedValue) }).toThrowMinErr( + '$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.'); })); it('should implement toString on trusted values', inject(function($sce) { @@ -224,16 +224,16 @@ describe('SCE', function() { var exprFn = $sce.parseAs($sce.HTML, 'foo'); expect(function() { return exprFn({}, {'foo': true}) - }).toThrow( - '[$sce:unsafe] Attempting to use an unsafe value in a safe context.'); + }).toThrowMinErr( + '$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.'); })); it('should NOT return trusted values of the wrong type from expression function', inject(function($sce) { var exprFn = $sce.parseAs($sce.HTML, 'foo'); expect(function() { return exprFn({}, {'foo': $sce.trustAs($sce.JS, '123')}) - }).toThrow( - '[$sce:unsafe] Attempting to use an unsafe value in a safe context.'); + }).toThrowMinErr( + '$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.'); })); it('should return trusted values from expression function', inject(function($sce) { @@ -249,8 +249,8 @@ describe('SCE', function() { expect(function() { // mismatched types. $sce.parseAsCss('foo')({}, {'foo': $sce.trustAsHtml('1')}); - }).toThrow( - '[$sce:unsafe] Attempting to use an unsafe value in a safe context.'); + }).toThrowMinErr( + '$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.'); })); }); @@ -279,8 +279,8 @@ describe('SCE', function() { whiteList: [], blackList: [] }, function($sce) { - expect(function() { $sce.getTrustedResourceUrl('#'); }).toThrow( - '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: #'); + expect(function() { $sce.getTrustedResourceUrl('#'); }).toThrowMinErr( + '$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: #'); })); it('should match against normalized urls', runTest( @@ -288,8 +288,8 @@ describe('SCE', function() { whiteList: [/^foo$/], blackList: [] }, function($sce) { - expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrow( - '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); + expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrowMinErr( + '$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); })); it('should support custom regex', runTest( @@ -298,8 +298,8 @@ describe('SCE', function() { blackList: [] }, function($sce) { expect($sce.getTrustedResourceUrl('http://example.com/foo')).toEqual('http://example.com/foo'); - expect(function() { $sce.getTrustedResourceUrl('https://example.com/foo'); }).toThrow( - '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: https://example.com/foo'); + expect(function() { $sce.getTrustedResourceUrl('https://example.com/foo'); }).toThrowMinErr( + '$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: https://example.com/foo'); })); it('should support the special string "self" in whitelist', runTest( @@ -315,8 +315,8 @@ describe('SCE', function() { whiteList: [/.*/], blackList: ['self'] }, function($sce) { - expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrow( - '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); + expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrowMinErr( + '$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); })); it('should have blacklist override the whitelist', runTest( @@ -324,8 +324,8 @@ describe('SCE', function() { whiteList: ['self'], blackList: ['self'] }, function($sce) { - expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrow( - '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); + expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrowMinErr( + '$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo'); })); it('should support multiple items in both lists', runTest( @@ -336,18 +336,18 @@ describe('SCE', function() { expect($sce.getTrustedResourceUrl('same_domain')).toEqual('same_domain'); expect($sce.getTrustedResourceUrl('http://example.com/1')).toEqual('http://example.com/1'); expect($sce.getTrustedResourceUrl('http://example.com/2')).toEqual('http://example.com/2'); - expect(function() { $sce.getTrustedResourceUrl('http://example.com/3'); }).toThrow( - '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/3'); - expect(function() { $sce.getTrustedResourceUrl('open_redirect'); }).toThrow( - '[$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: open_redirect'); + expect(function() { $sce.getTrustedResourceUrl('http://example.com/3'); }).toThrowMinErr( + '$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/3'); + expect(function() { $sce.getTrustedResourceUrl('open_redirect'); }).toThrowMinErr( + '$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: open_redirect'); })); }); describe('sanitizing html', function() { describe('when $sanitize is NOT available', function() { it('should throw an exception for getTrusted(string) values', inject(function($sce) { - expect(function() { $sce.getTrustedHtml('<b></b>'); }).toThrow( - '[$sce:unsafe] Attempting to use an unsafe value in a safe context.'); + expect(function() { $sce.getTrustedHtml('<b></b>'); }).toThrowMinErr( + '$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.'); })); }); |
