This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file treeCollapse file tree 2 files changed+34
-1
lines changedFilter options
+34
-1
lines changed Original file line number Diff line number Diff line change
@@ -2079,6 +2079,20 @@ if(window.jasmine || window.mocha) {
2079
2079
*
2080
2080
* @param {...Function} fns any number of functions which will be injected using the injector.
2081
2081
*/
2082
+
2083
+
2084
+
2085
+
var ErrorAddingDeclarationLocationStack = function(e, errorForStack) {
2086
+
this.message = e.message;
2087
+
this.name = e.name;
2088
+
if (e.line) this.line = e.line;
2089
+
if (e.sourceId) this.sourceId = e.sourceId;
2090
+
if (e.stack && errorForStack)
2091
+
this.stack = e.stack + '\n' + errorForStack.stack;
2092
+
if (e.stackArray) this.stackArray = e.stackArray;
2093
+
};
2094
+
ErrorAddingDeclarationLocationStack.prototype.toString = Error.prototype.toString;
2095
+
2082
2096
window.inject = angular.mock.inject = function() {
2083
2097
var blockFns = Array.prototype.slice.call(arguments, 0);
2084
2098
var errorForStack = new Error('Declaration Location');
@@ -2099,7 +2113,9 @@ if(window.jasmine || window.mocha) {
2099
2113
injector.invoke(blockFns[i] || angular.noop, this);
2100
2114
/* jshint +W040 */
2101
2115
} catch (e) {
2102
-
if(e.stack && errorForStack) e.stack += '\n' + errorForStack.stack;
2116
+
if (e.stack && errorForStack) {
2117
+
throw new ErrorAddingDeclarationLocationStack(e, errorForStack);
2118
+
}
2103
2119
throw e;
2104
2120
} finally {
2105
2121
errorForStack = null;
Original file line number Diff line number Diff line change
@@ -862,6 +862,23 @@ describe('ngMock', function() {
862
862
expect(log).toEqual('module;inject;')
863
863
});
864
864
});
865
+
866
+
// We don't run the following tests on IE8.
867
+
// IE8 throws "Object does not support this property or method." error,
868
+
// when thrown from a function defined on window (which `inject` is).
869
+
if (msie <= 8) return;
870
+
871
+
it('should not change thrown Errors', function() {
872
+
expect(function(){
873
+
throw new Error('test message');
874
+
}).toThrow('test message');
875
+
});
876
+
877
+
it('should not change thrown strings', function(){
878
+
expect(function(){
879
+
throw 'test message';
880
+
}).toThrow('test message');
881
+
});
865
882
});
866
883
});
867
884
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4