@@ -405,6 +405,7 @@ describe('integration', function () {
405
405
assert . equal ( breadcrumbs . length , 1 ) ;
406
406
407
407
assert . equal ( breadcrumbs [ 0 ] . type , 'http' ) ;
408
+ assert . equal ( breadcrumbs [ 0 ] . category , 'xhr' ) ;
408
409
assert . equal ( breadcrumbs [ 0 ] . data . method , 'GET' ) ;
409
410
// NOTE: not checking status code because we seem to get
410
411
// statusCode 0/undefined from Phantom when fetching
@@ -441,6 +442,46 @@ describe('integration', function () {
441
442
) ;
442
443
} ) ;
443
444
445
+ it ( 'should record a fetch request' , function ( done ) {
446
+ var iframe = this . iframe ;
447
+
448
+ iframeExecute ( iframe , done ,
449
+ function ( ) {
450
+ // some browsers trigger onpopstate for load / reset breadcrumb state
451
+ Raven . _breadcrumbs = [ ] ;
452
+
453
+ fetch ( '/test/integration/example.json' ) . then ( function ( ) {
454
+ setTimeout ( done ) ;
455
+ } , function ( ) {
456
+ setTimeout ( done ) ;
457
+ } ) ;
458
+ } ,
459
+ function ( ) {
460
+ var Raven = iframe . contentWindow . Raven ,
461
+ breadcrumbs = Raven . _breadcrumbs ;
462
+
463
+ if ( 'fetch' in window ) {
464
+ assert . equal ( breadcrumbs . length , 1 ) ;
465
+
466
+ assert . equal ( breadcrumbs [ 0 ] . type , 'http' ) ;
467
+ assert . equal ( breadcrumbs [ 0 ] . category , 'fetch' ) ;
468
+ assert . equal ( breadcrumbs [ 0 ] . data . method , 'GET' ) ;
469
+ } else {
470
+ // otherwise we use a fetch polyfill based on xhr
471
+ assert . equal ( breadcrumbs . length , 2 ) ;
472
+
473
+ assert . equal ( breadcrumbs [ 0 ] . type , 'http' ) ;
474
+ assert . equal ( breadcrumbs [ 0 ] . category , 'fetch' ) ;
475
+ assert . equal ( breadcrumbs [ 0 ] . data . method , 'GET' ) ;
476
+
477
+ assert . equal ( breadcrumbs [ 1 ] . type , 'http' ) ;
478
+ assert . equal ( breadcrumbs [ 1 ] . category , 'xhr' ) ;
479
+ assert . equal ( breadcrumbs [ 1 ] . data . method , 'GET' ) ;
480
+ }
481
+ }
482
+ ) ;
483
+ } ) ;
484
+
444
485
it ( 'should record a mouse click on element WITH click handler present' , function ( done ) {
445
486
var iframe = this . iframe ;
446
487
0 commit comments