This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngMock window.inject() does not get current stack trace correctly on PhantomJS and IE10+ #13591
Labels
Milestone
Comments
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Dec 19, 2015
Angular's ngMock inject() function, when called outside of a test spec context will not directly call the provided callback but will instead return a wrapper function to call the provided function at a later time, presumably while in some test spec context. And if that is the case, Angular would like to include the information on the inject() calling location to be included in the thrown error's stack trace information, so it manually appends it to the ones included in the actual error's stack trace. The added test makes sure this functionality works as expected. Closes angular#13591
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Dec 20, 2015
Angular's ngMock inject() function, when called outside of a test spec context will not directly call the provided callback but will instead return a wrapper function to call the provided function at a later time, presumably while in some test spec context. And if that is the case, Angular would like to include the information on the inject() calling location to be included in the thrown error's stack trace information, so it manually appends it to the ones included in the actual error's stack trace. The added test makes sure this functionality works as expected. Closes angular#13591
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Dec 20, 2015
Angular's ngMock inject() function, when called outside of a test spec context will not directly call the provided callback but will instead return a wrapper function to call the provided function at a later time, presumably while in some test spec context. And if that is the case, Angular would like to include the information on the inject() calling location to be included in the thrown error's stack trace information, so it manually appends it to the ones included in the actual error's stack trace. The added test makes sure this functionality: - works as expected in browsers supporting JavaScript stack trace collection, e.g. Chrome, Firefox, IE10+, Opera & PhantomJS - does not add any bogus stack track information in browsers that do not support JavaScript stack trace collection, e.g. IE8 or IE9 Closes angular#13591
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Dec 20, 2015
Angular's ngMock inject() function, when called outside of a test spec context will not directly call the provided callback but will instead return a wrapper function to call the provided function at a later time, presumably while in some test spec context. And if that is the case, Angular would like to include the information on the inject() calling location to be included in the thrown error's stack trace information, so it manually appends it to the ones included in the actual error's stack trace. The added test makes sure this functionality: - works as expected in browsers supporting JavaScript stack trace collection, e.g. Chrome, Firefox, IE10+, Opera & PhantomJS - does not add any bogus stack track information in browsers that do not support JavaScript stack trace collection, e.g. IE8 or IE9 Closes angular#13591
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Dec 20, 2015
Angular's ngMock inject() function, when called outside of a test spec context will not directly call the provided callback but will instead return a wrapper function to call the provided function at a later time, presumably while in some test spec context. And if that is the case, Angular would like to include the information on the inject() calling location to be included in the thrown error's stack trace information, so it manually appends it to the ones included in the actual error's stack trace. The added test makes sure this functionality: - works as expected in browsers supporting JavaScript stack trace collection, e.g. Chrome, Firefox, IE10+, Opera & PhantomJS - does not add any bogus stack track information in browsers that do not support JavaScript stack trace collection, e.g. IE8 or IE9 Closes angular#13591
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Dec 20, 2015
Angular's ngMock inject() function, when called outside of a test spec context will not directly call the provided callback but will instead return a wrapper function to call the provided function at a later time, presumably while in some test spec context. And if that is the case, Angular would like to include the information on the inject() calling location to be included in the thrown error's stack trace information, so it manually appends it to the ones included in the actual error's stack trace. The added test makes sure this functionality: - works as expected in browsers supporting JavaScript stack trace collection, e.g. Chrome, Firefox, IE10+, Opera & PhantomJS - does not add any bogus stack track information in browsers that do not support JavaScript stack trace collection, e.g. IE8 or IE9 Closes angular#13591
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Dec 20, 2015
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Dec 20, 2015
ping? |
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Apr 8, 2016
Angular's ngMock inject() function, when called outside of a test spec context will not directly call the provided callback but will instead return a wrapper function to call the provided function at a later time, presumably while in some test spec context. And if that is the case, Angular would like to include the information on the inject() calling location to be included in the thrown error's stack trace information, so it manually appends it to the ones included in the actual error's stack trace. The added test makes sure this functionality: - works as expected in browsers supporting JavaScript stack trace collection, e.g. Chrome, Firefox, IE10+, Opera & PhantomJS - does not add any bogus stack track information in browsers that do not support JavaScript stack trace collection, e.g. IE8 or IE9 Closes angular#13591
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Apr 8, 2016
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Apr 8, 2016
Angular's ngMock inject() function, when called outside of a test spec context will not directly call the provided callback but will instead return a wrapper function to call the provided function at a later time, presumably while in some test spec context. And if that is the case, Angular would like to include the information on the inject() calling location to be included in the thrown error's stack trace information, so it manually appends it to the ones included in the actual error's stack trace. The added test makes sure this functionality: - works as expected in browsers supporting JavaScript stack trace collection, e.g. Chrome, Firefox, IE10+, Opera & PhantomJS - does not add any bogus stack track information in browsers that do not support JavaScript stack trace collection, e.g. IE8 or IE9 Closes angular#13591
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Apr 8, 2016
gkalpak
pushed a commit
that referenced
this issue
Apr 9, 2016
…omJS Add support for collecting current stack trace information in browsers (e.g. IE10+, PhantomJS) that do not automatically store the current stack trace information in a newly created `Error` object's `stack` property, but only add it there once the `Error` gets thrown. The original implementation works fine in Firefox & Chrome, but fails on IE10+ and PhantomJS where it, for example, breaks Karma's error reporting in cases when an exception is thrown in a test like the following: ``` it('the holy crusade', inject(function() { var x = {}; x.holyGrail(); })); ``` In this case, the ngMock `inject()` implementation would incorrectly add the word `undefined` at the end of the collected error stack trace information, thus causing the main error description to be reported back to Karma as `undefined`. The added test makes sure this functionality: - works as expected in browsers supporting JavaScript stack trace collection, e.g. Chrome, Firefox, IE10+, Opera & PhantomJS - does not add any bogus stack track information in browsers that do not support JavaScript stack trace collection, e.g. IE9 Fixes #13591 Closes #13592 Closes #13593
gkalpak
pushed a commit
that referenced
this issue
Apr 9, 2016
…omJS Add support for collecting current stack trace information in browsers (e.g. IE10+, PhantomJS) that do not automatically store the current stack trace information in a newly created `Error` object's `stack` property, but only add it there once the `Error` gets thrown. The original implementation works fine in Firefox & Chrome, but fails on IE10+ and PhantomJS where it, for example, breaks Karma's error reporting in cases when an exception is thrown in a test like the following: ``` it('the holy crusade', inject(function() { var x = {}; x.holyGrail(); })); ``` In this case, the ngMock `inject()` implementation would incorrectly add the word `undefined` at the end of the collected error stack trace information, thus causing the main error description to be reported back to Karma as `undefined`. The added test makes sure this functionality: - works as expected in browsers supporting JavaScript stack trace collection, e.g. Chrome, Firefox, IE10+, Opera & PhantomJS - does not add any bogus stack track information in browsers that do not support JavaScript stack trace collection, e.g. IE9 Fixes #13591 Closes #13592 Closes #13593
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Apr 11, 2016
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Apr 11, 2016
jurko-gospodnetic
added a commit
to jurko-gospodnetic/angular.js
that referenced
this issue
Apr 11, 2016
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Overview of the Issue
ngMock
window.inject()
function collects the current stack trace by expecting to find it in a locally createdError
object'sstack
property. This however does not hold true in case when using a browser that fills anError
object'sstack
information only when that object gets thrown.Motivation for or Use Case
The bug was found while researching why karma reports invalid error information when using PhantomJS in cases like this:
where the ngMock
inject()
implementation would incorrectly add the wordundefined
(read too early from theError
object'sstack
property) to the end of the collected error stack trace information, thus causing the main error description (gotten by parsing the collected error stack trace information, assuming it has specific structure) to be reported back to karma asundefined
.Angular Version(s)
1.4.8
master
version still has the exact same code so should be affected by the same bugBrowsers and Operating System
Ubuntu 15.10
, but should not be OS specificReproduce the Error
Here's a test for the angular ngMock test suite that can be used to reproduce the error:
Note that this whole functionality is completely untested and, at least to me, seems buggy or unfinished, but I'll open separate issues for that, while this one is targeted specifically to the error stack information constructed in
ngMock
'swindow.inject()
.Suggest a Fix
Error
object in question, throw it and catch it in case it does not already havestack
information stored on itThe text was updated successfully, but these errors were encountered: