@@ -1252,6 +1252,122 @@ for (var idx in frames) {
12521252 ) ;
12531253 } ) ;
12541254
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+
12551371 it ( 'should record a mouse click on element WITH click handler present' , function ( done ) {
12561372 var iframe = this . iframe ;
12571373
@@ -1278,7 +1394,7 @@ for (var idx in frames) {
12781394 } ,
12791395 function ( sentryData ) {
12801396 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
12821398 assert . lengthOf ( sentryData , 1 ) ;
12831399 return done ( ) ;
12841400 }
@@ -1311,7 +1427,7 @@ for (var idx in frames) {
13111427 } ,
13121428 function ( sentryData ) {
13131429 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
13151431 assert . lengthOf ( sentryData , 1 ) ;
13161432 return done ( ) ;
13171433 }
@@ -1353,7 +1469,7 @@ for (var idx in frames) {
13531469 } ,
13541470 function ( sentryData ) {
13551471 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
13571473 assert . lengthOf ( sentryData , 1 ) ;
13581474 return done ( ) ;
13591475 }
@@ -1393,7 +1509,7 @@ for (var idx in frames) {
13931509 } ,
13941510 function ( sentryData ) {
13951511 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
13971513 assert . lengthOf ( sentryData , 1 ) ;
13981514 return done ( ) ;
13991515 }
@@ -1427,7 +1543,7 @@ for (var idx in frames) {
14271543 } ,
14281544 function ( sentryData ) {
14291545 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
14311547 assert . lengthOf ( sentryData , 1 ) ;
14321548 return done ( ) ;
14331549 }
@@ -1499,7 +1615,7 @@ for (var idx in frames) {
14991615 } ,
15001616 function ( sentryData ) {
15011617 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
15031619 assert . lengthOf ( sentryData , 1 ) ;
15041620 return done ( ) ;
15051621 }
@@ -1542,7 +1658,7 @@ for (var idx in frames) {
15421658 } ,
15431659 function ( sentryData ) {
15441660 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
15461662 assert . lengthOf ( sentryData , 1 ) ;
15471663 return done ( ) ;
15481664 }
0 commit comments