1 module("Mouse Events");
3 // test each of the following events
6 "mouseover","mouseout",
7 "mousedown","mouseup","mousemove"
9 // test each event type
10 test( '"'+ type +'"', function(){
13 // custom event properties
15 pageX: Math.round( Math.random() * 500 ),
16 pageY: Math.round( Math.random() * 500 ),
17 ctrlKey: Math.round( Math.random() ) ? true : false,
18 altKey: Math.round( Math.random() ) ? true : false,
19 shiftKey: Math.round( Math.random() ) ? true : false,
20 button: Math.round( Math.random() * 2 )
23 $div = $('<div/>').appendTo( document.body );
24 // test the document too for bubbling
25 $div.add( document ).bind( type, function( ev ){
27 equals( ev.currentTarget, this, "event.currentTarget");
28 equals( ev.target, $div[0], "event.target" );
29 equals( ev.type, type, "event.type" );
30 equals( ev.pageX, props.pageX, "event.pageX" );
31 equals( ev.pageY, props.pageY, "event.pageY" );
32 equals( ev.ctrlKey, props.ctrlKey, "event.ctrlKey" );
33 equals( ev.altKey, props.altKey, "event.altKey" );
34 equals( ev.shiftKey, props.shiftKey, "event.shiftKey" );
35 equals( ev.metaKey, props.metaKey, "event.metaKey" );
36 equals( ev.button, props.button, "event.button" );
37 equals( ev.bubbles, props.bubbles, "event.bubbles" );
40 // make sure that metaKey and ctrlKey are equal
41 props.metaKey = props.ctrlKey;
42 // fire the event with bubbling
44 $div.fire( type, props );
46 // fire the event without bubbling
47 props.bubbles = false;
48 $div.fire( type, props );
51 $( document ).unbind( type );