Commit 38f087b5 authored by timmywil's avatar timmywil

Add a way to fire native events using dispatchEvent/fireEvent in testinit.js;...

Add a way to fire native events using dispatchEvent/fireEvent in testinit.js; fixes failing click test in FF3.6
parent fa0e801f
...@@ -44,6 +44,20 @@ function t(a,b,c) { ...@@ -44,6 +44,20 @@ function t(a,b,c) {
same(f, q.apply(q,c), a + " (" + b + ")"); same(f, q.apply(q,c), a + " (" + b + ")");
} }
var fireNative;
if ( document.createEvent ) {
fireNative = function( node, type ) {
var event = document.createEvent('HTMLEvents');
event.initEvent( type, true, true );
node.dispatchEvent( event );
};
} else {
fireNative = function( node, type ) {
var event = document.createEventObject();
node.fireEvent( 'on' + type, event );
};
}
/** /**
* Add random number to url to stop IE from caching * Add random number to url to stop IE from caching
* *
......
...@@ -2482,7 +2482,8 @@ test("fixHooks extensions", function() { ...@@ -2482,7 +2482,8 @@ test("fixHooks extensions", function() {
// Ensure the property doesn't exist // Ensure the property doesn't exist
$fixture.bind( "click", function( event ) { $fixture.bind( "click", function( event ) {
ok( !("blurrinessLevel" in event), "event.blurrinessLevel does not exist" ); ok( !("blurrinessLevel" in event), "event.blurrinessLevel does not exist" );
})[0].click(); });
fireNative( $fixture[0], 'click' );
$fixture.unbind( "click" ); $fixture.unbind( "click" );
jQuery.event.fixHooks.click = { jQuery.event.fixHooks.click = {
...@@ -2495,7 +2496,8 @@ test("fixHooks extensions", function() { ...@@ -2495,7 +2496,8 @@ test("fixHooks extensions", function() {
// Trigger a native click and ensure the property is set // Trigger a native click and ensure the property is set
$fixture.bind( "click", function( event ) { $fixture.bind( "click", function( event ) {
equals( event.blurrinessLevel, 42, "event.blurrinessLevel was set" ); equals( event.blurrinessLevel, 42, "event.blurrinessLevel was set" );
})[0].click(); });
fireNative( $fixture[0], 'click' );
delete jQuery.event.fixHooks.click; delete jQuery.event.fixHooks.click;
$fixture.unbind( "click" ).remove(); $fixture.unbind( "click" ).remove();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment