File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -615,10 +615,10 @@ Raven.prototype = {
615615 }
616616 } ) ;
617617
618- var origOpen ;
618+ var origSend ;
619619 if ( 'XMLHttpRequest' in window ) {
620- origOpen = XMLHttpRequest . prototype . open ;
621- fill ( XMLHttpRequest . prototype , 'open ' , function ( origOpen ) {
620+ origSend = XMLHttpRequest . prototype . send ;
621+ fill ( XMLHttpRequest . prototype , 'send ' , function ( origOpen ) {
622622 return function ( data ) { // preserve arity
623623 var xhr = this ;
624624 'onreadystatechange onload onerror onprogress' . replace ( / \w + / g, function ( prop ) {
@@ -628,7 +628,7 @@ Raven.prototype = {
628628 } , true /* noUndo */ ) ; // don't track filled methods on XHR instances
629629 }
630630 } ) ;
631- origOpen . apply ( this , arguments ) ;
631+ origSend . apply ( this , arguments ) ;
632632 } ;
633633 } ) ;
634634 }
Original file line number Diff line number Diff line change @@ -244,12 +244,20 @@ describe('integration', function () {
244244
245245 iframeExecute ( iframe , done ,
246246 function ( ) {
247- setTimeout ( done ) ;
248247 var xhr = new XMLHttpRequest ( ) ;
248+
249+ // intentionally assign event handlers *after* XMLHttpRequest.prototype.open,
250+ // since this is what jQuery does
251+ // https://github.com/jquery/jquery/blob/master/src/ajax/xhr.js#L37
252+
253+ xhr . open ( 'GET' , 'example.json' )
249254 xhr . onreadystatechange = function ( ) {
255+ setTimeout ( done ) ;
256+ // replace onreadystatechange with no-op so exception doesn't
257+ // fire more than once as XHR changes loading state
258+ xhr . onreadystatechange = function ( ) { } ;
250259 foo ( ) ;
251260 } ;
252- xhr . open ( 'GET' , 'example.json' ) ;
253261 xhr . send ( ) ;
254262 } ,
255263 function ( ) {
You can’t perform that action at this time.
0 commit comments