@@ -1252,6 +1252,122 @@ for (var idx in frames) {
1252
1252
) ;
1253
1253
} ) ;
1254
1254
1255
+ it ( 'should not fail with click or keypress handler with no callback' , function ( done ) {
1256
+ var iframe = this . iframe ;
1257
+
1258
+ iframeExecute (
1259
+ iframe ,
1260
+ done ,
1261
+ function ( ) {
1262
+ setTimeout ( function ( ) {
1263
+ Sentry . captureMessage ( 'test' ) ;
1264
+ } , 1000 ) ;
1265
+
1266
+ var input = document . getElementsByTagName ( 'input' ) [ 0 ] ;
1267
+ input . addEventListener ( 'click' , undefined ) ;
1268
+ input . addEventListener ( 'keypress' , undefined ) ;
1269
+
1270
+ var click = new MouseEvent ( 'click' ) ;
1271
+ input . dispatchEvent ( click ) ;
1272
+
1273
+ var keypress = new KeyboardEvent ( 'keypress' ) ;
1274
+ input . dispatchEvent ( keypress ) ;
1275
+ } ,
1276
+ function ( sentryData ) {
1277
+ if ( IS_LOADER ) {
1278
+ // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
1279
+ assert . lengthOf ( sentryData , 1 ) ;
1280
+ return done ( ) ;
1281
+ }
1282
+
1283
+ var breadcrumbs = iframe . contentWindow . sentryBreadcrumbs ;
1284
+
1285
+ assert . equal ( breadcrumbs . length , 2 ) ;
1286
+
1287
+ assert . equal ( breadcrumbs [ 0 ] . category , 'ui.click' ) ;
1288
+ assert . equal ( breadcrumbs [ 0 ] . message , 'body > form#foo-form > input[name="foo"]' ) ;
1289
+
1290
+ assert . equal ( breadcrumbs [ 1 ] . category , 'ui.input' ) ;
1291
+ assert . equal ( breadcrumbs [ 1 ] . message , 'body > form#foo-form > input[name="foo"]' ) ;
1292
+
1293
+ // There should be no expection, if there is one it means we threw it
1294
+ assert . isUndefined ( sentryData [ 0 ] . exception ) ;
1295
+
1296
+ done ( ) ;
1297
+ }
1298
+ ) ;
1299
+ } ) ;
1300
+
1301
+ it ( 'should not fail with custom event' , function ( done ) {
1302
+ var iframe = this . iframe ;
1303
+
1304
+ iframeExecute (
1305
+ iframe ,
1306
+ done ,
1307
+ function ( ) {
1308
+ setTimeout ( function ( ) {
1309
+ Sentry . captureMessage ( 'test' ) ;
1310
+ } , 1000 ) ;
1311
+
1312
+ var input = document . getElementsByTagName ( 'input' ) [ 0 ] ;
1313
+ input . addEventListener ( 'build' , function ( evt ) {
1314
+ evt . stopPropagation ( ) ;
1315
+ } ) ;
1316
+
1317
+ var customEvent = new CustomEvent ( 'build' , { detail : 1 } ) ;
1318
+ input . dispatchEvent ( customEvent ) ;
1319
+ } ,
1320
+ function ( sentryData ) {
1321
+ if ( IS_LOADER ) {
1322
+ // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
1323
+ assert . lengthOf ( sentryData , 1 ) ;
1324
+ return done ( ) ;
1325
+ }
1326
+
1327
+ var breadcrumbs = iframe . contentWindow . sentryBreadcrumbs ;
1328
+ // There should be no expection, if there is one it means we threw it
1329
+ assert . isUndefined ( sentryData [ 0 ] . exception ) ;
1330
+ assert . equal ( breadcrumbs . length , 0 ) ;
1331
+
1332
+ done ( ) ;
1333
+ }
1334
+ ) ;
1335
+ } ) ;
1336
+
1337
+ it ( 'should not fail with custom event and handler with no callback' , function ( done ) {
1338
+ var iframe = this . iframe ;
1339
+
1340
+ iframeExecute (
1341
+ iframe ,
1342
+ done ,
1343
+ function ( ) {
1344
+ setTimeout ( function ( ) {
1345
+ Sentry . captureMessage ( 'test' ) ;
1346
+ } , 1000 ) ;
1347
+
1348
+ var input = document . getElementsByTagName ( 'input' ) [ 0 ] ;
1349
+ input . addEventListener ( 'build' , undefined ) ;
1350
+
1351
+ var customEvent = new CustomEvent ( 'build' , { detail : 1 } ) ;
1352
+ input . dispatchEvent ( customEvent ) ;
1353
+ } ,
1354
+ function ( sentryData ) {
1355
+ if ( IS_LOADER ) {
1356
+ // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
1357
+ assert . lengthOf ( sentryData , 1 ) ;
1358
+ return done ( ) ;
1359
+ }
1360
+
1361
+ var breadcrumbs = iframe . contentWindow . sentryBreadcrumbs ;
1362
+ // There should be no expection, if there is one it means we threw it
1363
+ assert . isUndefined ( sentryData [ 0 ] . exception ) ;
1364
+ assert . equal ( breadcrumbs . length , 0 ) ;
1365
+
1366
+ done ( ) ;
1367
+ }
1368
+ ) ;
1369
+ } ) ;
1370
+
1255
1371
it ( 'should record a mouse click on element WITH click handler present' , function ( done ) {
1256
1372
var iframe = this . iframe ;
1257
1373
@@ -1278,7 +1394,7 @@ for (var idx in frames) {
1278
1394
} ,
1279
1395
function ( sentryData ) {
1280
1396
if ( IS_LOADER ) {
1281
- // The async loader doesn't wrap fetch , but we should receive the event without breadcrumbs
1397
+ // The async loader doesn't wrap event listeners , but we should receive the event without breadcrumbs
1282
1398
assert . lengthOf ( sentryData , 1 ) ;
1283
1399
return done ( ) ;
1284
1400
}
@@ -1311,7 +1427,7 @@ for (var idx in frames) {
1311
1427
} ,
1312
1428
function ( sentryData ) {
1313
1429
if ( IS_LOADER ) {
1314
- // The async loader doesn't wrap fetch , but we should receive the event without breadcrumbs
1430
+ // The async loader doesn't wrap event listeners , but we should receive the event without breadcrumbs
1315
1431
assert . lengthOf ( sentryData , 1 ) ;
1316
1432
return done ( ) ;
1317
1433
}
@@ -1353,7 +1469,7 @@ for (var idx in frames) {
1353
1469
} ,
1354
1470
function ( sentryData ) {
1355
1471
if ( IS_LOADER ) {
1356
- // The async loader doesn't wrap fetch , but we should receive the event without breadcrumbs
1472
+ // The async loader doesn't wrap event listeners , but we should receive the event without breadcrumbs
1357
1473
assert . lengthOf ( sentryData , 1 ) ;
1358
1474
return done ( ) ;
1359
1475
}
@@ -1393,7 +1509,7 @@ for (var idx in frames) {
1393
1509
} ,
1394
1510
function ( sentryData ) {
1395
1511
if ( IS_LOADER ) {
1396
- // The async loader doesn't wrap fetch , but we should receive the event without breadcrumbs
1512
+ // The async loader doesn't wrap event listeners , but we should receive the event without breadcrumbs
1397
1513
assert . lengthOf ( sentryData , 1 ) ;
1398
1514
return done ( ) ;
1399
1515
}
@@ -1427,7 +1543,7 @@ for (var idx in frames) {
1427
1543
} ,
1428
1544
function ( sentryData ) {
1429
1545
if ( IS_LOADER ) {
1430
- // The async loader doesn't wrap fetch , but we should receive the event without breadcrumbs
1546
+ // The async loader doesn't wrap event listeners , but we should receive the event without breadcrumbs
1431
1547
assert . lengthOf ( sentryData , 1 ) ;
1432
1548
return done ( ) ;
1433
1549
}
@@ -1499,7 +1615,7 @@ for (var idx in frames) {
1499
1615
} ,
1500
1616
function ( sentryData ) {
1501
1617
if ( IS_LOADER ) {
1502
- // The async loader doesn't wrap fetch , but we should receive the event without breadcrumbs
1618
+ // The async loader doesn't wrap event listeners , but we should receive the event without breadcrumbs
1503
1619
assert . lengthOf ( sentryData , 1 ) ;
1504
1620
return done ( ) ;
1505
1621
}
@@ -1542,7 +1658,7 @@ for (var idx in frames) {
1542
1658
} ,
1543
1659
function ( sentryData ) {
1544
1660
if ( IS_LOADER ) {
1545
- // The async loader doesn't wrap fetch , but we should receive the event without breadcrumbs
1661
+ // The async loader doesn't wrap event listeners , but we should receive the event without breadcrumbs
1546
1662
assert . lengthOf ( sentryData , 1 ) ;
1547
1663
return done ( ) ;
1548
1664
}
0 commit comments