@@ -2694,35 +2694,68 @@ test( "preventDefault() on focusin does not throw exception", function( assert )
2694
2694
. focus ( ) ;
2695
2695
} ) ;
2696
2696
2697
- test ( "jQuery.event.simulate() event has no originalEvent " , function ( assert ) {
2698
- expect ( 1 ) ;
2697
+ test ( "Donor event interference " , function ( assert ) {
2698
+ assert . expect ( 10 ) ;
2699
2699
2700
- var done = assert . async ( ) ,
2701
- input = jQuery ( "<input>" )
2702
- . on ( "click" , function ( event ) {
2703
- assert . strictEqual ( "originalEvent" in event , false ,
2704
- "originalEvent not present on simulated event" ) ;
2705
- done ( ) ;
2706
- } ) ;
2707
-
2708
- jQuery . event . simulate ( "click" , input [ 0 ] , new jQuery . Event ( ) , true ) ;
2709
- } ) ;
2700
+ var html = "<div id='donor-outer'>" +
2701
+ "<form id='donor-form'>" +
2702
+ "<input id='donor-input' type='radio' />" +
2703
+ "</form>" +
2704
+ "</div>" ;
2710
2705
2711
- test ( "Donor event interference" , function ( assert ) {
2712
- assert . expect ( 4 ) ;
2706
+ jQuery ( "#qunit-fixture" ) . append ( html ) ;
2713
2707
2714
- jQuery ( "#donor-outer" ) . on ( "click" , function ( ) {
2708
+ jQuery ( "#donor-outer" ) . on ( "click" , function ( event ) {
2715
2709
assert . ok ( true , "click bubbled to outer div" ) ;
2710
+ assert . equal ( typeof event . originalEvent , "object" , "make sure originalEvent exist" ) ;
2711
+ assert . equal ( event . type , "click" , "make sure event type is correct" ) ;
2716
2712
} ) ;
2717
2713
jQuery ( "#donor-input" ) . on ( "click" , function ( event ) {
2718
2714
assert . ok ( true , "got a click event from the input" ) ;
2719
2715
assert . ok ( ! event . isPropagationStopped ( ) , "propagation says it's not stopped" ) ;
2716
+ assert . equal ( event . type , "click" , "make sure event type is correct" ) ;
2717
+ assert . equal ( typeof event . originalEvent , "object" , "make sure originalEvent exist" ) ;
2720
2718
} ) ;
2721
2719
jQuery ( "#donor-input" ) . on ( "change" , function ( event ) {
2720
+ assert . equal ( typeof event . originalEvent , "object" , "make sure originalEvent exist" ) ;
2721
+ assert . equal ( event . type , "change" , "make sure event type is correct" ) ;
2722
2722
assert . ok ( true , "got a change event from the input" ) ;
2723
2723
event . stopPropagation ( ) ;
2724
2724
} ) ;
2725
- jQuery ( "#donor-input" ) [ 0 ] . click ( ) ;
2725
+ jQuery ( "#donor-input" ) [ 0 ] . click ( ) ;
2726
+ } ) ;
2727
+
2728
+ test ( "originalEvent property for Chrome, Safari and FF of simualted event" , function ( assert ) {
2729
+ var userAgent = window . navigator . userAgent ;
2730
+
2731
+ if ( ! ( / c h r o m e / i. test ( userAgent ) ||
2732
+ / f i r e f o x / i. test ( userAgent ) ||
2733
+ / s a f a r i / i. test ( userAgent ) ) ) {
2734
+ assert . expect ( 1 ) ;
2735
+ assert . ok ( true , "Assertions should run only in Chrome, Safari and FF" ) ;
2736
+ return ;
2737
+ }
2738
+
2739
+ assert . expect ( 4 ) ;
2740
+
2741
+ var html = "<div id='donor-outer'>" +
2742
+ "<form id='donor-form'>" +
2743
+ "<input id='donor-input' type='radio' />" +
2744
+ "</form>" +
2745
+ "</div>" ;
2746
+
2747
+ jQuery ( "#qunit-fixture" ) . append ( html ) ;
2748
+
2749
+ jQuery ( "#donor-outer" ) . on ( "focusin" , function ( event ) {
2750
+ assert . ok ( true , "focusin bubbled to outer div" ) ;
2751
+ assert . equal ( event . originalEvent . type , "focus" ,
2752
+ "make sure originalEvent type is correct" ) ;
2753
+ assert . equal ( event . type , "focusin" , "make sure type is correct" ) ;
2754
+ } ) ;
2755
+ jQuery ( "#donor-input" ) . on ( "focus" , function ( ) {
2756
+ assert . ok ( true , "got a focus event from the input" ) ;
2757
+ } ) ;
2758
+ jQuery ( "#donor-input" ) . trigger ( "focus" ) ;
2726
2759
} ) ;
2727
2760
2728
2761
// This tests are unreliable in Firefox
0 commit comments