nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jquery.event.drag-new / fire / test / mutation.js
1 module("Mutation Events");
2
3 // test each of the following events
4 $.each([
5         "DOMSubtreeModified","DOMNodeInserted",
6         "DOMNodeRemoved","DOMNodeRemovedFromDocument",
7         "DOMNodeInsertedIntoDocument","DOMAttrModified",
8         "DOMCharacterDataModified"
9 ],function( i, type ){
10         // test each event type
11         test( '"'+ type +'"', function(){
12                 expect( 0 );
13                 
14                 // custom event properties
15                 var props = {
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 
21                 },
22                 // new test element
23                 $div = $('<div/>').appendTo( document.body );
24                 // test the document too for bubbling
25                 $div.add( document ).bind( type, function( ev ){
26                         
27                         equals( ev.currentTarget, this, "event.currentTarget");
28                         equals( ev.target, $div[0], "event.target" );
29                         equals( ev.type, type, "event.type" );
30         
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" );
36                 });
37                 
38                 // make sure that metaKey and ctrlKey are equal
39                 props.metaKey = props.ctrlKey;
40                 // fire the event with bubbling
41                 props.bubbles = true;
42                 $div.fire( type, props );
43                 
44                 // fire the event without bubbling
45                 props.bubbles = false;
46                 $div.fire( type, props );
47         
48                 // cleanup
49                 $( document ).unbind( type );
50                 $div.remove();
51         });
52 });