File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -221,7 +221,14 @@ Raven.prototype = {
221
221
}
222
222
223
223
// We don't wanna wrap it twice!
224
- if ( func . __raven__ ) {
224
+ try {
225
+ if ( func . __raven__ ) {
226
+ return func ;
227
+ }
228
+ } catch ( e ) {
229
+ // Just accessing the __raven__ prop in some Selenium environments
230
+ // can cause a "Permission denied" exception (see raven-js#495).
231
+ // Bail on wrapping and return the function as-is (defers to window.onerror).
225
232
return func ;
226
233
}
227
234
Original file line number Diff line number Diff line change @@ -1729,6 +1729,19 @@ describe('Raven (public API)', function() {
1729
1729
} , error ) ;
1730
1730
} ) ;
1731
1731
1732
+ it ( 'should return input funciton as-is if accessing __raven__ prop throws exception' , function ( ) {
1733
+ // see raven-js#495
1734
+ var fn = function ( ) { } ;
1735
+ Object . defineProperty ( fn , '__raven__' , {
1736
+ get : function ( ) {
1737
+ throw new Error ( 'Permission denied' )
1738
+ }
1739
+ } ) ;
1740
+ assert . throw ( function ( ) { fn . __raven__ ; } , 'Permission denied' ) ;
1741
+ var wrapped = Raven . wrap ( fn ) ;
1742
+ assert . equal ( fn , wrapped ) ;
1743
+ } ) ;
1744
+
1732
1745
} ) ;
1733
1746
1734
1747
describe ( '.context' , function ( ) {
You can’t perform that action at this time.
0 commit comments