+test("live with submit", function() {
+ var count = 0;
+
+ jQuery("#testForm").live("submit", function() {
+ count++;
+ return false;
+ });
+
+ jQuery("#testForm input[name=sub1]")[0].click();
+ jQuery("#testForm input[name=T1]").trigger({type: "keypress", keyCode: 13});
+
+ equals(2, count);
+
+ jQuery("#testForm").die("submit");
+});
+
+test("live with focus/blur", function(){
+ expect(2);
+
+ // Setup
+ jQuery("<input type='text' id='livefb' />").appendTo("body");
+
+ var $child = jQuery("#livefb"),
+ child = $child[0],
+ pass = {};
+
+ function worked(e){
+ pass[e.type] = true;
+ }
+
+ $child.live("focus", worked);
+ $child.live("blur", worked);
+
+ // Test
+ child.focus();
+ if (pass.focus)
+ ok(true, "Test live() with focus event");
+ else
+ ok(true, "Cannot test focus because the window isn't focused");
+
+ child.blur();
+ if (pass.blur)
+ ok( true, "Test live() with blur event");
+ else
+ ok(true, "Cannot test blur because the window isn't focused");
+
+ // Teardown
+ $child.die("focus", worked);
+ $child.die("blur", worked);
+ $child.remove();
+ window.scrollTo(0,0);
+});
+
+test("Non DOM element events", function() {
+ expect(3);
+
+ jQuery({})
+ .bind('nonelementglobal', function(e) {
+ ok( true, "Global event on non-DOM annonymos object triggered" );
+ });
+
+ var o = {};
+
+ jQuery(o)
+ .bind('nonelementobj', function(e) {
+ ok( true, "Event on non-DOM object triggered" );
+ }).bind('nonelementglobal', function() {
+ ok( true, "Global event on non-DOM object triggered" );
+ });
+
+ jQuery(o).trigger('nonelementobj');
+ jQuery.event.trigger('nonelementglobal');
+});
+