diff --git a/test/unit/event.js b/test/unit/event.js
index 0b4b364b..6ad112c0 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -726,7 +726,7 @@ test("hover()", function() {
test("mouseover triggers mouseenter", function() {
expect(1);
-
+
var count = 0,
elem = jQuery("");
elem.mouseenter(function () {
@@ -734,7 +734,7 @@ test("mouseover triggers mouseenter", function() {
});
elem.trigger('mouseover');
equals(count, 1, "make sure mouseover triggers a mouseenter" );
-
+
elem.remove();
});
@@ -2023,8 +2023,8 @@ test("window resize", function() {
test("focusin bubbles", function() {
expect(5);
-
- var input = jQuery( '' ).prependTo( "body" ),
+
+ var input = jQuery( '' ).prependTo( "body" ),
order = 0;
jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){
@@ -2037,12 +2037,12 @@ test("focusin bubbles", function() {
// DOM focus method
input[0].focus();
-
+
// To make the next focus test work, we need to take focus off the input.
// This will fire another focusin event, so set order to reflect that.
order = 1;
jQuery("#text1")[0].focus();
-
+
// jQuery trigger, which calls DOM focus
order = 0;
input.trigger( "focus" );
@@ -2051,15 +2051,81 @@ test("focusin bubbles", function() {
jQuery( "body" ).unbind( "focusin.focusinBubblesTest" );
});
-/*
-test("jQuery(function($) {})", function() {
- stop();
- jQuery(function($) {
- 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");
- start();
- });
-});
+(function(){
+ // This code must be run before DOM ready!
+ var notYetReady, noEarlyExecution,
+ order = [],
+ args = {};
+
+ notYetReady = !jQuery.isReady;
+
+ test("jQuery.isReady", function() {
+ expect(2);
+
+ equals(notYetReady, true, "jQuery.isReady should not be true before DOM ready");
+ equals(jQuery.isReady, true, "jQuery.isReady should be true once DOM is ready");
+ });
+
+ // Create an event handler.
+ function makeHandler( testId ) {
+ // When returned function is executed, push testId onto `order` array
+ // to ensure execution order. Also, store event handler arg to ensure
+ // the correct arg is being passed into the event handler.
+ return function( arg ) {
+ order.push(testId);
+ args[testId] = arg;
+ };
+ }
+
+ // Bind to the ready event in every possible way.
+ jQuery(makeHandler("a"));
+ jQuery(document).ready(makeHandler("b"));
+ jQuery(document).bind("ready.readytest", makeHandler("c"));
+
+ // Do it twice, just to be sure.
+ jQuery(makeHandler("d"));
+ jQuery(document).ready(makeHandler("e"));
+ jQuery(document).bind("ready.readytest", makeHandler("f"));
+
+ noEarlyExecution = order.length == 0;
+
+ // This assumes that QUnit tests are run on DOM ready!
+ test("jQuery ready", function() {
+ expect(10);
+
+ ok(noEarlyExecution, "Handlers bound to DOM ready should not execute before DOM ready");
+
+ // Ensure execution order.
+ same(order, ["a", "b", "d", "e", "c", "f"], "Bound DOM ready handlers should execute in bind-order, but those bound with jQuery(document).bind( 'ready', fn ) will always execute last");
+
+ // Ensure handler argument is correct.
+ equals(args.a, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery");
+ equals(args.b, jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery");
+ ok(args.c instanceof jQuery.Event, "Argument passed to fn in jQuery(document).bind( 'ready', fn ) should be an event object");
+
+ order = [];
+
+ // Now that the ready event has fired, again bind to the ready event
+ // in every possible way. These event handlers should execute immediately.
+ jQuery(makeHandler("g"));
+ equals(order.pop(), "g", "Event handler should execute immediately");
+ equals(args.g, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery");
+
+ jQuery(document).ready(makeHandler("h"));
+ equals(order.pop(), "h", "Event handler should execute immediately");
+ equals(args.h, jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery");
+
+ jQuery(document).bind("ready.readytest", makeHandler("never"));
+ equals(order.length, 0, "Event handler should never execute since DOM ready has already passed");
+
+ // Cleanup.
+ jQuery(document).unbind("ready.readytest");
+ });
+
+})();
+
+/*
test("event properties", function() {
stop();
jQuery("#simon1").click(function(event) {