aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-05-20 18:09:46 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-05-29 20:32:59 +0300
commit6df669f0fb87cd9975a18bf6bbe3c3548afa4fee (patch)
tree470bf8eb18553095d862870ddb66949b343bc850 /test
parent7475d5debeb7c53158921ed40f6c2fdb25a2cc86 (diff)
downloadjquery-6df669f0fb87cd9975a18bf6bbe3c3548afa4fee.tar.gz
jquery-6df669f0fb87cd9975a18bf6bbe3c3548afa4fee.zip
Event: remove outdated originalEvent hack
Closes gh-2335 Ref 7475d5debeb7c53158921ed40f6c2fdb25a2cc86
Diffstat (limited to 'test')
-rw-r--r--test/unit/event.js65
1 files changed, 49 insertions, 16 deletions
diff --git a/test/unit/event.js b/test/unit/event.js
index 981e6702f..ba3d9481a 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -2694,35 +2694,68 @@ test( "preventDefault() on focusin does not throw exception", function( assert )
.focus();
} );
-test( "jQuery.event.simulate() event has no originalEvent", function( assert ) {
- expect( 1 );
+test( "Donor event interference", function( assert ) {
+ assert.expect( 10 );
- 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 );
-} );
+ var html = "<div id='donor-outer'>" +
+ "<form id='donor-form'>" +
+ "<input id='donor-input' type='radio' />" +
+ "</form>" +
+ "</div>";
-test( "Donor event interference", function( assert ) {
- assert.expect( 4 );
+ jQuery( "#qunit-fixture" ).append( html );
- jQuery( "#donor-outer" ).on( "click", function() {
+ jQuery( "#donor-outer" ).on( "click", function( event ) {
assert.ok( true, "click bubbled to outer div" );
+ assert.equal( typeof event.originalEvent, "object", "make sure originalEvent exist" );
+ assert.equal( event.type, "click", "make sure event type is correct" );
} );
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" );
+ assert.equal( event.type, "click", "make sure event type is correct" );
+ assert.equal( typeof event.originalEvent, "object", "make sure originalEvent exist" );
} );
jQuery( "#donor-input" ).on( "change", function( event ) {
+ assert.equal( typeof event.originalEvent, "object", "make sure originalEvent exist" );
+ assert.equal( event.type, "change", "make sure event type is correct" );
assert.ok( true, "got a change event from the input" );
event.stopPropagation();
} );
- jQuery( "#donor-input" )[0].click();
+ jQuery( "#donor-input" )[ 0 ].click();
+} );
+
+test( "originalEvent property for Chrome, Safari and FF of simualted event", function( assert ) {
+ var userAgent = window.navigator.userAgent;
+
+ if ( !(/chrome/i.test( userAgent ) ||
+ /firefox/i.test( userAgent ) ||
+ /safari/i.test( userAgent ) ) ) {
+ assert.expect( 1 );
+ assert.ok( true, "Assertions should run only in Chrome, Safari and FF" );
+ return;
+ }
+
+ assert.expect( 4 );
+
+ var html = "<div id='donor-outer'>" +
+ "<form id='donor-form'>" +
+ "<input id='donor-input' type='radio' />" +
+ "</form>" +
+ "</div>";
+
+ jQuery( "#qunit-fixture" ).append( html );
+
+ jQuery( "#donor-outer" ).on( "focusin", function( event ) {
+ assert.ok( true, "focusin bubbled to outer div" );
+ assert.equal( event.originalEvent.type, "focus",
+ "make sure originalEvent type is correct" );
+ assert.equal( event.type, "focusin", "make sure type is correct" );
+ } );
+ jQuery( "#donor-input" ).on( "focus", function() {
+ assert.ok( true, "got a focus event from the input" );
+ } );
+ jQuery( "#donor-input" ).trigger( "focus" );
} );
// This tests are unreliable in Firefox