File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -221,7 +221,14 @@ Raven.prototype = {
221221 }
222222
223223 // 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).
225232 return func ;
226233 }
227234
Original file line number Diff line number Diff line change @@ -1729,6 +1729,19 @@ describe('Raven (public API)', function() {
17291729 } , error ) ;
17301730 } ) ;
17311731
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+
17321745 } ) ;
17331746
17341747 describe ( '.context' , function ( ) {
You can’t perform that action at this time.
0 commit comments