.unbind() without any arguments now also unbinds namespaced events. fixes #4609 and...
[jquery.git] / test / unit / event.js
1 module("event");
2
3 test("bind(), with data", function() {
4         expect(3);
5         var handler = function(event) {
6                 ok( event.data, "bind() with data, check passed data exists" );
7                 equals( event.data.foo, "bar", "bind() with data, Check value of passed data" );
8         };
9         jQuery("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler);
10
11         ok( !jQuery.data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
12 });
13
14 test("bind(), with data, trigger with data", function() {
15         expect(4);
16         var handler = function(event, data) {
17                 ok( event.data, "check passed data exists" );
18                 equals( event.data.foo, "bar", "Check value of passed data" );
19                 ok( data, "Check trigger data" );
20                 equals( data.bar, "foo", "Check value of trigger data" );
21         };
22         jQuery("#firstp").bind("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]).unbind("click", handler);
23 });
24
25 test("bind(), multiple events at once", function() {
26         expect(2);
27         var clickCounter = 0,
28                 mouseoverCounter = 0;
29         var handler = function(event) {
30                 if (event.type == "click")
31                         clickCounter += 1;
32                 else if (event.type == "mouseover")
33                         mouseoverCounter += 1;
34         };
35         jQuery("#firstp").bind("click mouseover", handler).trigger("click").trigger("mouseover");
36         equals( clickCounter, 1, "bind() with multiple events at once" );
37         equals( mouseoverCounter, 1, "bind() with multiple events at once" );
38 });
39
40 test("bind(), no data", function() {
41         expect(1);
42         var handler = function(event) {
43                 ok ( !event.data, "Check that no data is added to the event object" );
44         };
45         jQuery("#firstp").bind("click", handler).trigger("click");
46 });
47
48 test("bind(), iframes", function() {
49         // events don't work with iframes, see #939 - this test fails in IE because of contentDocument
50         // var doc = document.getElementById("iframe").contentDocument;
51         // 
52         // doc.body.innerHTML = "<input type='text'/>";
53         //
54         // var input = doc.getElementsByTagName("input")[0];
55         //
56         // jQuery(input).bind("click",function() {
57         //      ok( true, "Binding to element inside iframe" );
58         // }).click();
59 });
60
61 test("bind(), trigger change on select", function() {
62         expect(3);
63         var counter = 0;
64         function selectOnChange(event) {
65                 equals( event.data, counter++, "Event.data is not a global event object" );
66         };
67         jQuery("#form select").each(function(i){
68                 jQuery(this).bind('change', i, selectOnChange);
69         }).trigger('change');
70 });
71
72 test("bind(), namespaced events, cloned events", function() {
73         expect(6);
74
75         jQuery("#firstp").bind("custom.test",function(e){
76                 ok(true, "Custom event triggered");
77         });
78
79         jQuery("#firstp").bind("click",function(e){
80                 ok(true, "Normal click triggered");
81         });
82
83         jQuery("#firstp").bind("click.test",function(e){
84                 ok(true, "Namespaced click triggered");
85         });
86
87         // Trigger both bound fn (2)
88         jQuery("#firstp").trigger("click");
89
90         // Trigger one bound fn (1)
91         jQuery("#firstp").trigger("click.test");
92
93         // Remove only the one fn
94         jQuery("#firstp").unbind("click.test");
95
96         // Trigger the remaining fn (1)
97         jQuery("#firstp").trigger("click");
98
99         // Remove the remaining fn
100         jQuery("#firstp").unbind(".test");
101
102         // Trigger the remaining fn (0)
103         jQuery("#firstp").trigger("custom");
104
105         // using contents will get comments regular, text, and comment nodes
106         jQuery("#nonnodes").contents().bind("tester", function () {
107                 equals(this.nodeType, 1, "Check node,textnode,comment bind just does real nodes" );
108         }).trigger("tester");
109
110         // Make sure events stick with appendTo'd elements (which are cloned) #2027
111         jQuery("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("p");
112         ok( jQuery("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
113 });
114
115 test("bind(), multi-namespaced events", function() {
116         expect(6);
117         
118         var order = [
119                 "click.test.abc",
120                 "click.test.abc",
121                 "click.test",
122                 "click.test.abc",
123                 "click.test",
124                 "custom.test2"
125         ];
126         
127         function check(name, msg){
128                 same(name, order.shift(), msg);
129         }
130
131         jQuery("#firstp").bind("custom.test",function(e){
132                 check("custom.test", "Custom event triggered");
133         });
134
135         jQuery("#firstp").bind("custom.test2",function(e){
136                 check("custom.test2", "Custom event triggered");
137         });
138
139         jQuery("#firstp").bind("click.test",function(e){
140                 check("click.test", "Normal click triggered");
141         });
142
143         jQuery("#firstp").bind("click.test.abc",function(e){
144                 check("click.test.abc", "Namespaced click triggered");
145         });
146
147         // Trigger both bound fn (1)
148         jQuery("#firstp").trigger("click.test.abc");
149
150         // Trigger one bound fn (1)
151         jQuery("#firstp").trigger("click.abc");
152
153         // Trigger two bound fn (2)
154         jQuery("#firstp").trigger("click.test");
155
156         // Remove only the one fn
157         jQuery("#firstp").unbind("click.abc");
158
159         // Trigger the remaining fn (1)
160         jQuery("#firstp").trigger("click");
161
162         // Remove the remaining fn
163         jQuery("#firstp").unbind(".test");
164
165         // Trigger the remaining fn (1)
166         jQuery("#firstp").trigger("custom");
167 });
168
169 test("unbind(type)", function() {
170         expect( 0 );
171         
172         var $elem = jQuery("#firstp"),
173                 message;
174
175         function error(){
176                 ok( false, message );
177         }
178         
179         message = "unbind passing function";
180         $elem.bind('error', error).unbind('error',error).triggerHandler('error');
181         
182         message = "unbind all from event";
183         $elem.bind('error', error).unbind('error').triggerHandler('error');
184         
185         message = "unbind all";
186         $elem.bind('error', error).unbind().triggerHandler('error');
187         
188         message = "unbind many with function";
189         $elem.bind('error error2',error)
190                  .unbind('error error2', error )
191                  .trigger('error').triggerHandler('error2');
192
193         message = "unbind many"; // #3538
194         $elem.bind('error error2',error)
195                  .unbind('error error2')
196                  .trigger('error').triggerHandler('error2');
197         
198         message = "unbind without a type or handler";
199         $elem.bind("error error2.test",error)
200                  .unbind()
201                  .trigger("error").triggerHandler("error2");
202 });
203
204 test("unbind(eventObject)", function() {
205         expect(4);
206         
207         var $elem = jQuery("#firstp"),
208                 num;
209
210         function assert( expected ){
211                 num = 0;
212                 $elem.trigger('foo').triggerHandler('bar');
213                 equals( num, expected, "Check the right handlers are triggered" );
214         }
215         
216         $elem
217                 // This handler shouldn't be unbound
218                 .bind('foo', function(){
219                         num += 1;
220                 })
221                 .bind('foo', function(e){
222                         $elem.unbind( e )
223                         num += 2;
224                 })
225                 // Neither this one
226                 .bind('bar', function(){
227                         num += 4;
228                 });
229                 
230         assert( 7 );
231         assert( 5 );
232         
233         $elem.unbind('bar');
234         assert( 1 );
235         
236         $elem.unbind(); 
237         assert( 0 );
238 });
239
240 test("trigger() shortcuts", function() {
241         expect(6);
242         jQuery('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {
243                 var close = jQuery('spanx', this); // same with jQuery(this).find('span');
244                 equals( close.length, 0, "Context element does not exist, length must be zero" );
245                 ok( !close[0], "Context element does not exist, direct access to element must return undefined" );
246                 return false;
247         }).click();
248         
249         jQuery("#check1").click(function() {
250                 ok( true, "click event handler for checkbox gets fired twice, see #815" );
251         }).click();
252         
253         var counter = 0;
254         jQuery('#firstp')[0].onclick = function(event) {
255                 counter++;
256         };
257         jQuery('#firstp').click();
258         equals( counter, 1, "Check that click, triggers onclick event handler also" );
259         
260         var clickCounter = 0;
261         jQuery('#simon1')[0].onclick = function(event) {
262                 clickCounter++;
263         };
264         jQuery('#simon1').click();
265         equals( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );
266         
267         jQuery('<img />').load(function(){
268                 ok( true, "Trigger the load event, using the shortcut .load() (#2819)");
269         }).load();
270 });
271
272 test("trigger() bubbling", function() {
273         expect(14);
274
275         var doc = 0, html = 0, body = 0, main = 0, ap = 0;
276
277         jQuery(document).bind("click", function(e){ if ( e.target !== document) { doc++; } });
278         jQuery("html").bind("click", function(e){ html++; });
279         jQuery("body").bind("click", function(e){ body++; });
280         jQuery("#main").bind("click", function(e){ main++; });
281         jQuery("#ap").bind("click", function(){ ap++; return false; });
282
283         jQuery("html").trigger("click");
284         equals( doc, 1, "HTML bubble" );
285         equals( html, 1, "HTML bubble" );
286
287         jQuery("body").trigger("click");
288         equals( doc, 2, "Body bubble" );
289         equals( html, 2, "Body bubble" );
290         equals( body, 1, "Body bubble" );
291
292         jQuery("#main").trigger("click");
293         equals( doc, 3, "Main bubble" );
294         equals( html, 3, "Main bubble" );
295         equals( body, 2, "Main bubble" );
296         equals( main, 1, "Main bubble" );
297
298         jQuery("#ap").trigger("click");
299         equals( doc, 3, "ap bubble" );
300         equals( html, 3, "ap bubble" );
301         equals( body, 2, "ap bubble" );
302         equals( main, 1, "ap bubble" );
303         equals( ap, 1, "ap bubble" );
304 });
305
306 test("trigger(type, [data], [fn])", function() {
307         expect(11);
308
309         var handler = function(event, a, b, c) {
310                 equals( event.type, "click", "check passed data" );
311                 equals( a, 1, "check passed data" );
312                 equals( b, "2", "check passed data" );
313                 equals( c, "abc", "check passed data" );
314                 return "test";
315         };
316
317         var $elem = jQuery("#firstp");
318
319         // Simulate a "native" click
320         $elem[0].click = function(){
321                 ok( true, "Native call was triggered" );
322         };
323
324         // Triggers handlrs and native
325         // Trigger 5
326         $elem.bind("click", handler).trigger("click", [1, "2", "abc"]);
327
328         // Simulate a "native" click
329         $elem[0].click = function(){
330                 ok( false, "Native call was triggered" );
331         };
332
333         // Trigger only the handlers (no native)
334         // Triggers 5
335         equals( $elem.triggerHandler("click", [1, "2", "abc"]), "test", "Verify handler response" );
336
337         var pass = true;
338         try {
339                 jQuery('#form input:first').hide().trigger('focus');
340         } catch(e) {
341                 pass = false;
342         }
343         ok( pass, "Trigger focus on hidden element" );
344 });
345
346 test("trigger(eventObject, [data], [fn])", function() {
347         expect(25);
348         
349         var $parent = jQuery('<div id="par" />').hide().appendTo('body'),
350                 $child = jQuery('<p id="child">foo</p>').appendTo( $parent );
351         
352         var event = jQuery.Event("noNew");      
353         ok( event != window, "Instantiate jQuery.Event without the 'new' keyword" );
354         equals( event.type, "noNew", "Verify its type" );
355         
356         equals( event.isDefaultPrevented(), false, "Verify isDefaultPrevented" );
357         equals( event.isPropagationStopped(), false, "Verify isPropagationStopped" );
358         equals( event.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );
359         
360         event.preventDefault();
361         equals( event.isDefaultPrevented(), true, "Verify isDefaultPrevented" );
362         event.stopPropagation();
363         equals( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
364         
365         event.isPropagationStopped = function(){ return false };
366         event.stopImmediatePropagation();
367         equals( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
368         equals( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
369         
370         $parent.bind('foo',function(e){
371                 // Tries bubbling
372                 equals( e.type, 'foo', 'Verify event type when passed passing an event object' );
373                 equals( e.target.id, 'child', 'Verify event.target when passed passing an event object' );
374                 equals( e.currentTarget.id, 'par', 'Verify event.target when passed passing an event object' );
375                 equals( e.secret, 'boo!', 'Verify event object\'s custom attribute when passed passing an event object' );
376         });
377         
378         // test with an event object
379         event = new jQuery.Event("foo");
380         event.secret = 'boo!';
381         $child.trigger(event);
382         
383         // test with a literal object
384         $child.trigger({type:'foo', secret:'boo!'});
385         
386         $parent.unbind();
387
388         function error(){
389                 ok( false, "This assertion shouldn't be reached");
390         }
391         
392         $parent.bind('foo', error );
393         
394         $child.bind('foo',function(e, a, b, c ){
395                 equals( arguments.length, 4, "Check arguments length");
396                 equals( a, 1, "Check first custom argument");
397                 equals( b, 2, "Check second custom argument");
398                 equals( c, 3, "Check third custom argument");
399                 
400                 equals( e.isDefaultPrevented(), false, "Verify isDefaultPrevented" );
401                 equals( e.isPropagationStopped(), false, "Verify isPropagationStopped" );
402                 equals( e.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );
403                 
404                 // Skips both errors
405                 e.stopImmediatePropagation();
406                 
407                 return "result";
408         });
409         
410         // We should add this back in when we want to test the order
411         // in which event handlers are iterated.
412         //$child.bind('foo', error );
413         
414         event = new jQuery.Event("foo");
415         $child.trigger( event, [1,2,3] ).unbind();
416         equals( event.result, "result", "Check event.result attribute");
417         
418         // Will error if it bubbles
419         $child.triggerHandler('foo');
420         
421         $child.unbind();
422         $parent.unbind().remove();
423 });
424
425 test("jQuery.Event.currentTarget", function(){
426         expect(1);
427         
428         var counter = 0,
429                 $elem = jQuery('<button>a</button>').click(function(e){
430                 equals( e.currentTarget, this, "Check currentTarget on "+(counter++?"native":"fake") +" event" );
431         });
432         
433         // Fake event
434         $elem.trigger('click');
435         
436         // Cleanup
437         $elem.unbind();
438 });
439
440 test("toggle(Function, Function, ...)", function() {
441         expect(11);
442         
443         var count = 0,
444                 fn1 = function(e) { count++; },
445                 fn2 = function(e) { count--; },
446                 preventDefault = function(e) { e.preventDefault() },
447                 link = jQuery('#mark');
448         link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
449         equals( count, 1, "Check for toggle(fn, fn)" );
450
451         jQuery("#firstp").toggle(function () {
452                 equals(arguments.length, 4, "toggle correctly passes through additional triggered arguments, see #1701" )
453         }, function() {}).trigger("click", [ 1, 2, 3 ]);
454
455         var first = 0;
456         jQuery("#simon1").one("click", function() {
457                 ok( true, "Execute event only once" );
458                 jQuery(this).toggle(function() {
459                         equals( first++, 0, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
460                 }, function() {
461                         equals( first, 1, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
462                 });
463                 return false;
464         }).click().click().click();
465         
466         var turn = 0;
467         var fns = [
468                 function(){
469                         turn = 1;
470                 },
471                 function(){
472                         turn = 2;
473                 },
474                 function(){
475                         turn = 3;
476                 }
477         ];
478         
479         var $div = jQuery("<div>&nbsp;</div>").toggle( fns[0], fns[1], fns[2] );
480         $div.click();
481         equals( turn, 1, "Trying toggle with 3 functions, attempt 1 yields 1");
482         $div.click();
483         equals( turn, 2, "Trying toggle with 3 functions, attempt 2 yields 2");
484         $div.click();
485         equals( turn, 3, "Trying toggle with 3 functions, attempt 3 yields 3");
486         $div.click();
487         equals( turn, 1, "Trying toggle with 3 functions, attempt 4 yields 1");
488         $div.click();
489         equals( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2");
490         
491         $div.unbind('click',fns[0]);
492         var data = jQuery.data( $div[0], 'events' );
493         ok( !data, "Unbinding one function from toggle unbinds them all");
494 });
495
496 test(".live()/.die()", function() {
497         expect(52);
498
499         var submit = 0, div = 0, livea = 0, liveb = 0;
500
501         jQuery("div").live("submit", function(){ submit++; return false; });
502         jQuery("div").live("click", function(){ div++; });
503         jQuery("div#nothiddendiv").live("click", function(){ livea++; });
504         jQuery("div#nothiddendivchild").live("click", function(){ liveb++; });
505
506         // Nothing should trigger on the body
507         jQuery("body").trigger("click");
508         equals( submit, 0, "Click on body" );
509         equals( div, 0, "Click on body" );
510         equals( livea, 0, "Click on body" );
511         equals( liveb, 0, "Click on body" );
512
513         // This should trigger two events
514         jQuery("div#nothiddendiv").trigger("click");
515         equals( submit, 0, "Click on div" );
516         equals( div, 1, "Click on div" );
517         equals( livea, 1, "Click on div" );
518         equals( liveb, 0, "Click on div" );
519
520         // This should trigger three events (w/ bubbling)
521         jQuery("div#nothiddendivchild").trigger("click");
522         equals( submit, 0, "Click on inner div" );
523         equals( div, 2, "Click on inner div" );
524         equals( livea, 2, "Click on inner div" );
525         equals( liveb, 1, "Click on inner div" );
526
527         // This should trigger one submit
528         jQuery("div#nothiddendivchild").trigger("submit");
529         equals( submit, 1, "Submit on div" );
530         equals( div, 2, "Submit on div" );
531         equals( livea, 2, "Submit on div" );
532         equals( liveb, 1, "Submit on div" );
533
534         // Make sure no other events were removed in the process
535         jQuery("div#nothiddendivchild").trigger("click");
536         equals( submit, 1, "die Click on inner div" );
537         equals( div, 3, "die Click on inner div" );
538         equals( livea, 3, "die Click on inner div" );
539         equals( liveb, 2, "die Click on inner div" );
540
541         // Now make sure that the removal works
542         jQuery("div#nothiddendivchild").die("click");
543         jQuery("div#nothiddendivchild").trigger("click");
544         equals( submit, 1, "die Click on inner div" );
545         equals( div, 4, "die Click on inner div" );
546         equals( livea, 4, "die Click on inner div" );
547         equals( liveb, 2, "die Click on inner div" );
548
549         // Make sure that the click wasn't removed too early
550         jQuery("div#nothiddendiv").trigger("click");
551         equals( submit, 1, "die Click on inner div" );
552         equals( div, 5, "die Click on inner div" );
553         equals( livea, 5, "die Click on inner div" );
554         equals( liveb, 2, "die Click on inner div" );
555
556         // Make sure that stopPropgation doesn't stop live events
557         jQuery("div#nothiddendivchild").live("click", function(e){ liveb++; e.stopPropagation(); });
558         jQuery("div#nothiddendivchild").trigger("click");
559         equals( submit, 1, "stopPropagation Click on inner div" );
560         equals( div, 6, "stopPropagation Click on inner div" );
561         equals( livea, 6, "stopPropagation Click on inner div" );
562         equals( liveb, 3, "stopPropagation Click on inner div" );
563
564         jQuery("div#nothiddendivchild").die("click");
565         jQuery("div#nothiddendiv").die("click");
566         jQuery("div").die("click");
567         jQuery("div").die("submit");
568
569         // Test binding with a different context
570         var clicked = 0, container = jQuery('#main')[0];
571         jQuery("#foo", container).live("click", function(e){ clicked++; });
572         jQuery("div").trigger('click');
573         jQuery("#foo").trigger('click');
574         jQuery("#main").trigger('click');
575         jQuery("body").trigger('click');
576         equals( clicked, 2, "live with a context" );
577
578         // Make sure the event is actually stored on the context
579         ok( jQuery.data(container, "events").live, "live with a context" );
580
581         // Test unbinding with a different context
582         jQuery("#foo", container).die("click");
583         jQuery("#foo").trigger('click');
584         equals( clicked, 2, "die with a context");
585
586
587         // Verify that return false prevents default action
588         jQuery("#anchor2").live("click", function(){ return false; });
589         var hash = window.location.hash;
590         jQuery("#anchor2").trigger("click");
591         equals( window.location.hash, hash, "return false worked" );
592         jQuery("#anchor2").die("click");
593
594         // Verify that .preventDefault() prevents default action
595         jQuery("#anchor2").live("click", function(e){ e.preventDefault(); });
596         var hash = window.location.hash;
597         jQuery("#anchor2").trigger("click");
598         equals( window.location.hash, hash, "e.preventDefault() worked" );
599         jQuery("#anchor2").die("click");
600
601         // Test binding the same handler to multiple points
602         var called = 0;
603         function callback(){ called++; return false; }
604
605         jQuery("#nothiddendiv").live("click", callback);
606         jQuery("#anchor2").live("click", callback);
607
608         jQuery("#nothiddendiv").trigger("click");
609         equals( called, 1, "Verify that only one click occurred." );
610
611         jQuery("#anchor2").trigger("click");
612         equals( called, 2, "Verify that only one click occurred." );
613
614         // Make sure that only one callback is removed
615         jQuery("#anchor2").die("click", callback);
616
617         jQuery("#nothiddendiv").trigger("click");
618         equals( called, 3, "Verify that only one click occurred." );
619
620         jQuery("#anchor2").trigger("click");
621         equals( called, 3, "Verify that no click occurred." );
622
623         // Make sure that it still works if the selector is the same,
624         // but the event type is different
625         jQuery("#nothiddendiv").live("foo", callback);
626
627         // Cleanup
628         jQuery("#nothiddendiv").die("click", callback);
629
630         jQuery("#nothiddendiv").trigger("click");
631         equals( called, 3, "Verify that no click occurred." );
632
633         jQuery("#nothiddendiv").trigger("foo");
634         equals( called, 4, "Verify that one foo occurred." );
635
636         // Cleanup
637         jQuery("#nothiddendiv").die("foo", callback);
638         
639         // Make sure we don't loose the target by DOM modifications
640         // after the bubble already reached the liveHandler
641         var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('<span></span>').get(0);
642         
643         jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(''); });
644         jQuery("#nothiddendivchild").live("click", function(e){ if(e.target) {livec++;} });
645         
646         jQuery("#nothiddendiv span").click();
647         equals( jQuery("#nothiddendiv span").length, 0, "Verify that first handler occurred and modified the DOM." );
648         equals( livec, 1, "Verify that second handler occurred even with nuked target." );
649         
650         // Cleanup
651         jQuery("#nothiddendivchild").die("click");
652
653         // Verify that .live() ocurs and cancel buble in the same order as
654         // we would expect .bind() and .click() without delegation
655         var lived = 0, livee = 0;
656         
657         // bind one pair in one order
658         jQuery('span#liveSpan1 a').live('click', function(){ lived++; return false; });
659         jQuery('span#liveSpan1').live('click', function(){ livee++; });
660
661         jQuery('span#liveSpan1 a').click();
662         equals( lived, 1, "Verify that only one first handler occurred." );
663         equals( livee, 0, "Verify that second handler don't." );
664
665         // and one pair in inverse
666         jQuery('#liveHandlerOrder span#liveSpan2').live('click', function(){ livee++; });
667         jQuery('#liveHandlerOrder span#liveSpan2 a').live('click', function(){ lived++; return false; });
668
669         jQuery('span#liveSpan2 a').click();
670         equals( lived, 2, "Verify that only one first handler occurred." );
671         equals( livee, 0, "Verify that second handler don't." );
672         
673         // Cleanup
674         jQuery("span#liveSpan1 a, span#liveSpan1, span#liveSpan2 a, span#liveSpan2").die("click");
675         
676         // Test this, target and currentTarget are correct
677         jQuery('span#liveSpan1').live('click', function(e){ 
678                 equals( this.id, 'liveSpan1', 'Check the this within a live handler' );
679                 equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a live handler' );
680                 equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a live handler' );
681         });
682         
683         jQuery('span#liveSpan1 a').click();
684         
685         jQuery('span#liveSpan1').die('click');
686 });
687
688 /*
689 test("jQuery(function($) {})", function() {
690         stop();
691         jQuery(function($) {
692                 equals(jQuery, $, "ready doesn't provide an event object, instead it provides a reference to the jQuery function, see http://docs.jquery.com/Events/ready#fn");
693                 start();
694         });
695 });
696
697 test("event properties", function() {
698         stop();
699         jQuery("#simon1").click(function(event) {
700                 ok( event.timeStamp, "assert event.timeStamp is present" );
701                 start();
702         }).click();
703 });
704 */