diff options
author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2015-05-12 15:30:05 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-05-29 19:56:06 +0300 |
commit | 7475d5debeb7c53158921ed40f6c2fdb25a2cc86 (patch) | |
tree | 2062d66d554bd7aeef83b1d1d538a2631fb53651 /test/unit/event.js | |
parent | 3c9277086742fe3a38a268ef97184be34e294655 (diff) | |
download | jquery-7475d5debeb7c53158921ed40f6c2fdb25a2cc86.tar.gz jquery-7475d5debeb7c53158921ed40f6c2fdb25a2cc86.zip |
Event: Remove fake originalEvent from jQuery.Event.simulate
Fixes gh-2300
Closes gh-2303
Diffstat (limited to 'test/unit/event.js')
-rw-r--r-- | test/unit/event.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index a84ec087a..981e6702f 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2671,6 +2671,60 @@ test( ".off() removes the expando when there's no more data", function() { } }); +test( "preventDefault() on focusin does not throw exception", function( assert ) { + expect( 1 ); + + var done = assert.async(), + input = jQuery( "<input/>" ).appendTo( "#form" ); + input + .on( "focusin", function( event ) { + var exceptionCaught; + + try { + event.preventDefault(); + } catch ( theException ) { + exceptionCaught = theException; + } + + assert.strictEqual( exceptionCaught, undefined, + "Preventing default on focusin throws no exception" ); + + done(); + } ) + .focus(); +} ); + +test( "jQuery.event.simulate() event has no originalEvent", function( assert ) { + expect( 1 ); + + var done = assert.async(), + input = jQuery( "<input>" ) + .on( "click", function( event ) { + assert.strictEqual( "originalEvent" in event, false, + "originalEvent not present on simulated event" ); + done(); + } ); + + jQuery.event.simulate( "click", input[ 0 ], new jQuery.Event(), true ); +} ); + +test( "Donor event interference", function( assert ) { + assert.expect( 4 ); + + jQuery( "#donor-outer" ).on( "click", function() { + assert.ok( true, "click bubbled to outer div" ); + } ); + jQuery( "#donor-input" ).on( "click", function( event ) { + assert.ok( true, "got a click event from the input" ); + assert.ok( !event.isPropagationStopped(), "propagation says it's not stopped" ); + } ); + jQuery( "#donor-input" ).on( "change", function( event ) { + assert.ok( true, "got a change event from the input" ); + event.stopPropagation(); + } ); + jQuery( "#donor-input" )[0].click(); +} ); + // This tests are unreliable in Firefox if ( !(/firefox/i.test( window.navigator.userAgent )) ) { test( "Check order of focusin/focusout events", 2, function() { |