Skip to content

Commit 9a0156d

Browse files
petebacondarwingkalpak
authored andcommitted
test($log): fix up to work with Safari 9
On Safari 9.0.2, you are not allowed to write to `sourceUrl` or `line` on a native Error object. This commit uses a custom error instead.
1 parent 5730c66 commit 9a0156d

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

test/ng/logSpec.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,26 @@ describe('$log', function() {
144144
describe('$log.error', function() {
145145
var e, $log, errorArgs;
146146

147+
function TestError() {
148+
Error.prototype.constructor.apply(this, arguments);
149+
this.message = undefined;
150+
this.sourceURL = undefined;
151+
this.line = undefined;
152+
this.stack = undefined;
153+
}
154+
TestError.prototype = Object.create(Error.prototype);
155+
TestError.prototype.constructor = TestError;
156+
147157
beforeEach(function() {
148-
e = new Error('');
149-
e.message = undefined;
150-
e.sourceURL = undefined;
151-
e.line = undefined;
152-
e.stack = undefined;
153-
154-
$log = new $LogProvider().$get[1]({console:{error:function() {
155-
errorArgs = [].slice.call(arguments, 0);
156-
}}});
158+
e = new TestError('');
159+
var mockWindow = {
160+
console: {
161+
error: function() {
162+
errorArgs = [].slice.call(arguments, 0);
163+
}
164+
}
165+
};
166+
$log = new $LogProvider().$get[1](mockWindow);
157167
});
158168

159169

0 commit comments

Comments
 (0)