File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -652,7 +652,7 @@ Raven.prototype = {
652652 } ) ;
653653
654654 if ( 'XMLHttpRequest' in window ) {
655- fill ( XMLHttpRequest . prototype , 'open ' , function ( origOpen ) {
655+ fill ( XMLHttpRequest . prototype , 'send ' , function ( origSend ) {
656656 return function ( data ) { // preserve arity
657657 var xhr = this ;
658658 'onreadystatechange onload onerror onprogress' . replace ( / \w + / g, function ( prop ) {
@@ -662,7 +662,7 @@ Raven.prototype = {
662662 } , true /* noUndo */ ) ; // don't track filled methods on XHR instances
663663 }
664664 } ) ;
665- origOpen . apply ( this , arguments ) ;
665+ origSend . apply ( this , arguments ) ;
666666 } ;
667667 } ) ;
668668 }
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