@@ -173,6 +173,7 @@ describe('integration', function () {
173
173
iframeExecute ( iframe , done ,
174
174
function ( ) {
175
175
setTimeout ( done ) ;
176
+ debugger ;
176
177
177
178
var div = document . createElement ( 'div' ) ;
178
179
document . body . appendChild ( div ) ;
@@ -297,6 +298,145 @@ describe('integration', function () {
297
298
}
298
299
) ;
299
300
} ) ;
301
+ } ) ;
302
+
303
+ describe ( 'breadcrumbs' , function ( ) {
304
+ it ( 'should record a mouse click on element WITH click handler present' , function ( done ) {
305
+ var iframe = this . iframe ;
306
+
307
+ iframeExecute ( iframe , done ,
308
+ function ( ) {
309
+ setTimeout ( done ) ;
310
+
311
+ // some browsers trigger onpopstate for load / reset breadcrumb state
312
+ Raven . _breadcrumbs = [ ] ;
313
+
314
+ // add an event listener to the input. we want to make sure that
315
+ // our breadcrumbs still work even if the page has an event listener
316
+ // on an element that cancels event bubbling
317
+ var input = document . getElementsByTagName ( 'input' ) [ 0 ] ;
318
+ var clickHandler = function ( evt ) {
319
+ evt . stopPropagation ( ) ; // don't bubble
320
+ } ;
321
+ input . addEventListener ( 'click' , clickHandler ) ;
322
+
323
+ // click <input/>
324
+ var evt = document . createEvent ( 'MouseEvent' ) ;
325
+ evt . initMouseEvent (
326
+ "click" ,
327
+ true /* bubble */ ,
328
+ true /* cancelable */ ,
329
+ window ,
330
+ null ,
331
+ 0 , 0 , 0 , 0 , /* coordinates */
332
+ false , false , false , false , /* modifier keys */
333
+ 0 /*left*/ ,
334
+ null
335
+ ) ;
336
+ input . dispatchEvent ( evt ) ;
337
+ } ,
338
+ function ( ) {
339
+ var Raven = iframe . contentWindow . Raven ,
340
+ breadcrumbs = Raven . _breadcrumbs ;
341
+
342
+ assert . equal ( breadcrumbs . length , 1 ) ;
343
+
344
+ assert . equal ( breadcrumbs [ 0 ] . type , 'ui_event' ) ;
345
+ // NOTE: attributes re-ordered. should this be expected?
346
+ assert . equal ( breadcrumbs [ 0 ] . data . target , '<input id="bar" name="foo" placeholder="lol" />' ) ;
347
+ assert . equal ( breadcrumbs [ 0 ] . data . type , 'click' ) ;
348
+ }
349
+ ) ;
350
+ } ) ;
351
+
352
+ it ( 'should record a mouse click on element WITHOUT click handler present' , function ( done ) {
353
+ var iframe = this . iframe ;
354
+
355
+ iframeExecute ( iframe , done ,
356
+ function ( ) {
357
+ setTimeout ( done ) ;
358
+
359
+ // some browsers trigger onpopstate for load / reset breadcrumb state
360
+ Raven . _breadcrumbs = [ ] ;
361
+
362
+ // click <input/>
363
+ var evt = document . createEvent ( 'MouseEvent' ) ;
364
+ evt . initMouseEvent (
365
+ "click" ,
366
+ true /* bubble */ ,
367
+ true /* cancelable */ ,
368
+ window ,
369
+ null ,
370
+ 0 , 0 , 0 , 0 , /* coordinates */
371
+ false , false , false , false , /* modifier keys */
372
+ 0 /*left*/ ,
373
+ null
374
+ ) ;
375
+
376
+ var input = document . getElementsByTagName ( 'input' ) [ 0 ] ;
377
+ input . dispatchEvent ( evt ) ;
378
+ } ,
379
+ function ( ) {
380
+ var Raven = iframe . contentWindow . Raven ,
381
+ breadcrumbs = Raven . _breadcrumbs ;
382
+
383
+ assert . equal ( breadcrumbs . length , 1 ) ;
384
+
385
+ assert . equal ( breadcrumbs [ 0 ] . type , 'ui_event' ) ;
386
+ // NOTE: attributes re-ordered. should this be expected?
387
+ assert . equal ( breadcrumbs [ 0 ] . data . target , '<input id="bar" name="foo" placeholder="lol" />' ) ;
388
+ assert . equal ( breadcrumbs [ 0 ] . data . type , 'click' ) ;
389
+ }
390
+ ) ;
391
+ } ) ;
392
+
393
+ it ( 'should only record a SINGLE mouse click for a tree of elements with event listeners' , function ( done ) {
394
+ var iframe = this . iframe ;
395
+
396
+ iframeExecute ( iframe , done ,
397
+ function ( ) {
398
+ setTimeout ( done ) ;
399
+
400
+ // some browsers trigger onpopstate for load / reset breadcrumb state
401
+ Raven . _breadcrumbs = [ ] ;
402
+
403
+ var clickHandler = function ( evt ) {
404
+ //evt.stopPropagation();
405
+ } ;
406
+ document . getElementById ( 'a' ) . addEventListener ( 'click' , clickHandler ) ;
407
+ document . getElementById ( 'b' ) . addEventListener ( 'click' , clickHandler ) ;
408
+ document . getElementById ( 'c' ) . addEventListener ( 'click' , clickHandler ) ;
409
+
410
+ // click <input/>
411
+ var evt = document . createEvent ( 'MouseEvent' ) ;
412
+ evt . initMouseEvent (
413
+ "click" ,
414
+ true /* bubble */ ,
415
+ true /* cancelable */ ,
416
+ window ,
417
+ null ,
418
+ 0 , 0 , 0 , 0 , /* coordinates */
419
+ false , false , false , false , /* modifier keys */
420
+ 0 /*left*/ ,
421
+ null
422
+ ) ;
423
+
424
+ var input = document . getElementById ( 'a' ) ; // leaf node
425
+ input . dispatchEvent ( evt ) ;
426
+ } ,
427
+ function ( ) {
428
+ var Raven = iframe . contentWindow . Raven ,
429
+ breadcrumbs = Raven . _breadcrumbs ;
430
+
431
+ assert . equal ( breadcrumbs . length , 1 ) ;
432
+
433
+ assert . equal ( breadcrumbs [ 0 ] . type , 'ui_event' ) ;
434
+ // NOTE: attributes re-ordered. should this be expected?
435
+ assert . equal ( breadcrumbs [ 0 ] . data . target , '<div id="a" />' ) ;
436
+ assert . equal ( breadcrumbs [ 0 ] . data . type , 'click' ) ;
437
+ }
438
+ ) ;
439
+ } ) ;
300
440
301
441
it ( 'should record history.[pushState|back] changes as navigation breadcrumbs' , function ( done ) {
302
442
var iframe = this . iframe ;
0 commit comments