@@ -258,18 +258,18 @@ Raven.prototype = {
258258 if ( func . __raven__ ) {
259259 return func ;
260260 }
261+
262+ // If this has already been wrapped in the past, return that
263+ if ( func . __raven_wrapper__ ) {
264+ return func . __raven_wrapper__ ;
265+ }
261266 } catch ( e ) {
262- // Just accessing the __raven__ prop in some Selenium environments
267+ // Just accessing custom props in some Selenium environments
263268 // can cause a "Permission denied" exception (see raven-js#495).
264269 // Bail on wrapping and return the function as-is (defers to window.onerror).
265270 return func ;
266271 }
267272
268- // If this has already been wrapped in the past, return that
269- if ( func . __raven_wrapper__ ) {
270- return func . __raven_wrapper__ ;
271- }
272-
273273 function wrapped ( ) {
274274 var args = [ ] , i = arguments . length ,
275275 deep = ! options || options && options . deep !== false ;
@@ -864,7 +864,11 @@ Raven.prototype = {
864864 } , wrappedBuiltIns ) ;
865865 fill ( proto , 'removeEventListener' , function ( orig ) {
866866 return function ( evt , fn , capture , secure ) {
867- fn = fn && ( fn . __raven_wrapper__ ? fn . __raven_wrapper__ : fn ) ;
867+ try {
868+ fn = fn && ( fn . __raven_wrapper__ ? fn . __raven_wrapper__ : fn ) ;
869+ } catch ( e ) {
870+ // ignore, accessing __raven_wrapper__ will throw in some Selenium environments
871+ }
868872 return orig . call ( this , evt , fn , capture , secure ) ;
869873 } ;
870874 } , wrappedBuiltIns ) ;
0 commit comments