1 module("Mutation Events");
3 // test each of the following events
5 "DOMSubtreeModified","DOMNodeInserted",
6 "DOMNodeRemoved","DOMNodeRemovedFromDocument",
7 "DOMNodeInsertedIntoDocument","DOMAttrModified",
8 "DOMCharacterDataModified"
10 // test each event type
11 test( '"'+ type +'"', function(){
14 // custom event properties
16 //keyCode: Math.round( Math.random() * 256 ),
17 //charCode: Math.round( Math.random() * 256 ),
18 ctrlKey: Math.round( Math.random() ) ? true : false,
19 altKey: Math.round( Math.random() ) ? true : false,
20 shiftKey: Math.round( Math.random() ) ? true : false
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" );
31 equals( ev.ctrlKey, props.ctrlKey, "event.ctrlKey" );
32 equals( ev.altKey, props.altKey, "event.altKey" );
33 equals( ev.shiftKey, props.shiftKey, "event.shiftKey" );
34 equals( ev.metaKey, props.metaKey, "event.metaKey" );
35 equals( ev.bubbles, props.bubbles, "event.bubbles" );
38 // make sure that metaKey and ctrlKey are equal
39 props.metaKey = props.ctrlKey;
40 // fire the event with bubbling
42 $div.fire( type, props );
44 // fire the event without bubbling
45 props.bubbles = false;
46 $div.fire( type, props );
49 $( document ).unbind( type );